add:单位
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
|
||||
package org.nl.wms.base_manage.measure.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.wms.base_manage.measure.service.IBmMeasureUnitService;
|
||||
import org.nl.wms.base_manage.measure.service.dao.BmMeasureUnit;
|
||||
import org.nl.wms.base_manage.measure.service.dto.UnitQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author loujf
|
||||
* @date 2021-12-07
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/bmMeasureUnit")
|
||||
@Slf4j
|
||||
public class BmMeasureunitController {
|
||||
|
||||
@Autowired
|
||||
private IBmMeasureUnitService measureUnitService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询单位")
|
||||
public ResponseEntity<Object> query(UnitQuery query, PageQuery page) {
|
||||
return new ResponseEntity<>(measureUnitService.pageQuery(query, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/select")
|
||||
@Log("查询单位下拉列表设备")
|
||||
public ResponseEntity<Object> selectAll() {
|
||||
List<BmMeasureUnit> list = measureUnitService.list();
|
||||
List<Map> result = new ArrayList<>();
|
||||
for (BmMeasureUnit item : list) {
|
||||
result.add(MapOf.of("label", item.getUnit_name(), "value", item.getMeasure_unit_id()));
|
||||
}
|
||||
return new ResponseEntity<>(TableDataInfo.build(result), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@Log("新增计量单位")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject whereJson) {
|
||||
measureUnitService.create(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@Log("修改计量单位")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson) {
|
||||
measureUnitService.update(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@Log("删除计量单位")
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
measureUnitService.removeById(id);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.nl.wms.base_manage.measure.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.wms.base_manage.measure.service.dao.BmMeasureUnit;
|
||||
import org.nl.wms.base_manage.measure.service.dto.UnitQuery;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 计量单位表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-05-05
|
||||
*/
|
||||
public interface IBmMeasureUnitService extends IService<BmMeasureUnit> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param query,page /
|
||||
* @return JSONObject
|
||||
*/
|
||||
Object pageQuery(UnitQuery query, PageQuery page);
|
||||
|
||||
void create(JSONObject jo);
|
||||
|
||||
void update(JSONObject jo);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package org.nl.wms.base_manage.measure.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 计量单位表
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-05-05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("bm_measure_unit")
|
||||
public class BmMeasureUnit implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 计量单位标识
|
||||
*/
|
||||
@TableId
|
||||
private String measure_unit_id;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String unit_code;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String unit_name;
|
||||
|
||||
/**
|
||||
* 数据精度
|
||||
*/
|
||||
private BigDecimal qty_precision;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean is_used;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String create_id;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String create_name;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String update_id;
|
||||
|
||||
/**
|
||||
* 修改人姓名
|
||||
*/
|
||||
private String update_name;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String update_time;
|
||||
|
||||
/**
|
||||
* 外部标识
|
||||
*/
|
||||
private String ext_id;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.wms.base_manage.measure.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.wms.base_manage.measure.service.dao.BmMeasureUnit;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 计量单位表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-05-05
|
||||
*/
|
||||
public interface BmMeasureUnitMapper extends BaseMapper<BmMeasureUnit> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.base_manage.measure.service.dao.mapper.BmMeasureUnitMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.nl.wms.base_manage.measure.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.common.domain.entity.BaseQuery;
|
||||
import org.nl.common.domain.entity.QParam;
|
||||
import org.nl.common.enums.QueryTEnum;
|
||||
import org.nl.wms.base_manage.measure.service.dao.BmMeasureUnit;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/4 19:49
|
||||
*/
|
||||
@Data
|
||||
public class UnitQuery extends BaseQuery<BmMeasureUnit> {
|
||||
|
||||
private String search;
|
||||
@Override
|
||||
public void paramMapping() {
|
||||
super.doP.put("search", QParam.builder().k(new String[]{"unit_name"}).type(QueryTEnum.LK).build());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.nl.wms.base_manage.measure.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.jsonwebtoken.lang.Assert;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.base_manage.measure.service.IBmMeasureUnitService;
|
||||
import org.nl.wms.base_manage.measure.service.dao.BmMeasureUnit;
|
||||
import org.nl.wms.base_manage.measure.service.dao.mapper.BmMeasureUnitMapper;
|
||||
import org.nl.wms.base_manage.measure.service.dto.UnitQuery;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 计量单位表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-05-05
|
||||
*/
|
||||
@Service
|
||||
public class BmMeasureUnitServiceImpl extends ServiceImpl<BmMeasureUnitMapper, BmMeasureUnit> implements IBmMeasureUnitService {
|
||||
|
||||
@Override
|
||||
public Object pageQuery(UnitQuery query, PageQuery page) {
|
||||
Page<BmMeasureUnit> pageQuery = this.page(page.build(), query.build());
|
||||
return TableDataInfo.build(pageQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(JSONObject jo) {
|
||||
String unit_code = jo.getString("unit_code");
|
||||
String unit_name = jo.getString("unit_name");
|
||||
String ext_id = jo.getString("ext_id");
|
||||
BigDecimal qty_precision = jo.getBigDecimal("qty_precision");
|
||||
boolean is_used = jo.getBoolean("is_used");
|
||||
BmMeasureUnit unit = new BmMeasureUnit();
|
||||
unit.setMeasure_unit_id(IdUtil.getStringId());
|
||||
unit.setUnit_code(unit_code);
|
||||
unit.setUnit_name(unit_name);
|
||||
unit.setQty_precision(qty_precision);
|
||||
unit.setExt_id(ext_id);
|
||||
unit.setIs_used(is_used);
|
||||
unit.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
unit.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
unit.setCreate_time(DateUtil.now());
|
||||
this.save(unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(JSONObject jo) {
|
||||
Assert.notNull(new Object[]{jo, jo.get("measure_unit_id")}, "请求参数不能为空");
|
||||
BmMeasureUnit mst = jo.toJavaObject(BmMeasureUnit.class);
|
||||
mst.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
mst.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
mst.setUpdate_time(DateUtil.now());
|
||||
this.updateById(mst);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user