diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/InventoryAndWarehousingController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/InventoryAndWarehousingController.java index 590f0df9..b33d62f4 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/InventoryAndWarehousingController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/InventoryAndWarehousingController.java @@ -8,6 +8,7 @@ import com.bonus.sgzb.material.domain.SavePutInfoDto; import com.bonus.sgzb.material.service.InventoryAndWarehousingService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -21,6 +22,7 @@ import java.util.List; @Api(tags = " 入库盘点") @RestController @RequestMapping("/inventoryAndWarehousing") +@Slf4j public class InventoryAndWarehousingController extends BaseController { @Autowired private InventoryAndWarehousingService inventoryAndWarehousingService; @@ -31,6 +33,7 @@ public class InventoryAndWarehousingController extends BaseController { @ApiOperation(value = "获取入库盘点列表") @GetMapping("/getList") public TableDataInfo getList(PutInStorageBean bean) { + log.info("获取入库盘点列表传参:{}", bean); startPage(); List list = inventoryAndWarehousingService.getList(bean); return getDataTable(list); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java index 321d8250..f186ca3b 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java @@ -79,7 +79,7 @@ public class MachIneDto { * 创建者 */ @ApiModelProperty(value = "创建者") - private String creator; + private Long creator; /** * 入库形式 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PutInStorageBean.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PutInStorageBean.java index b240ee45..e9f5ac41 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PutInStorageBean.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PutInStorageBean.java @@ -24,6 +24,10 @@ public class PutInStorageBean extends BaseEntity { @ApiModelProperty(value = "入库形式") private String putInType; + /** 关键字 */ + @ApiModelProperty(value = "关键字") + private String keyWord; + /** 入库数量 */ @ApiModelProperty(value = "入库数量") private BigDecimal num; @@ -34,11 +38,11 @@ public class PutInStorageBean extends BaseEntity { /** 入库人 */ @ApiModelProperty(value = "入库人") - private String userName; + private String modelName; /** 盘点入库单号 */ @ApiModelProperty(value = "盘点入库单号") - private String code; + private String kindName; /** 单位ID */ @ApiModelProperty(value = "单位ID") @@ -62,7 +66,7 @@ public class PutInStorageBean extends BaseEntity { /** 备注 */ @ApiModelProperty(value = "备注") - private String remarks; + private String remark; /** 主信息 */ diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java index f0b339da..c3864724 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java @@ -96,7 +96,7 @@ public class SavePutInfoDto extends BaseEntity { * 创建者 */ @ApiModelProperty(value = "创建者") - private String creator; + private Long creator; /** * 创建时间 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java index 96ab1e98..63350019 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java @@ -5,6 +5,7 @@ import com.bonus.sgzb.material.domain.PutInStorageBean; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.Date; import java.util.List; /** @@ -72,4 +73,10 @@ public interface InventoryAndWarehousingMapper { */ int selectByCode(String code); + /** + * 查询 + * @param nowDate + * @return + */ + int selectTaskNumByMonth(@Param("date") Date nowDate); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java index 84437f2b..70715454 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java @@ -1,5 +1,6 @@ package com.bonus.sgzb.material.service.impl; +import com.bonus.sgzb.common.core.utils.DateUtils; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.security.utils.SecurityUtils; import com.bonus.sgzb.material.config.ExceptionEnum; @@ -8,13 +9,14 @@ import com.bonus.sgzb.material.domain.PutInStorageBean; import com.bonus.sgzb.material.domain.SavePutInfoDto; import com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper; import com.bonus.sgzb.material.service.InventoryAndWarehousingService; -import com.bonus.sgzb.material.config.FieldGenerator; +import com.bonus.sgzb.material.vo.GlobalContants; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -39,6 +41,26 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi return inventoryAndWarehousingMapper.getList(bean); } + /** + * 生成code编码 + * @return + */ + public String genderBackCode() { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + Date nowDate = DateUtils.getNowDate(); + String format = dateFormat.format(nowDate); + int taskNum = inventoryAndWarehousingMapper.selectTaskNumByMonth(nowDate) + 1; + String code = ""; + if (taskNum > GlobalContants.NUM1 && taskNum < GlobalContants.NUM2) { + code = "PD" + format + "-00" + taskNum; + } else if (taskNum > GlobalContants.NUM3 && taskNum < GlobalContants.NUM4) { + code = "PD" + format + "-0" + taskNum; + } else { + code = "PD" + format + "-000" + taskNum; + } + return code; + } + /** * 新增入库盘点 * @param dto @@ -49,23 +71,14 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi public AjaxResult savePutInfo(SavePutInfoDto dto) { log.info("新增入库盘点入参dto:{}", dto); Long userId = SecurityUtils.getLoginUser().getUserid(); - dto.setCreator(userId.toString()); - List codeList = new ArrayList<>(); - if (dto.getNum() != null) { - while (codeList.size() < dto.getNum()) { - String code = FieldGenerator.generateField(); - int count = selectByCode(code); - if (count == 0 && !codeList.contains(code)) { - codeList.add(code); - } - } - } + dto.setCreator(userId); + String code = genderBackCode(); int res; try { //1. 判断是数量还是编号入库,保存到不同表 //1.1 如果是编号入库 if (dto.getIsCode()) { - res = insertMaMachineInfo(dto, codeList); + res = insertMaMachineInfo(dto, code); if (res == 0) { log.error("insertMaMachineInfo方法插入异常"); throw new RuntimeException("insertMaMachineInfo方法插入异常"); @@ -78,7 +91,7 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi } } else { //2.插入ma_type_put_in_storage_info表和ma_type_put_in_storage_details表 - res = insertPutInfo(dto); + res = insertPutInfo(dto, code); if (res == 0) { log.error("insertPutInfo方法插入异常"); throw new RuntimeException("insertPutInfo方法插入异常"); @@ -105,14 +118,13 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi /** * 编号新增,插入ma_machine、ma_machine_label和ma_label_bind * @param dto - * @param codeList + * @param code * @return */ - private int insertMaMachineInfo(SavePutInfoDto dto, List codeList) { + private int insertMaMachineInfo(SavePutInfoDto dto, String code) { int res = 0; for (int i = 0; i < dto.getMachIneDtoList().size(); i++) { MachIneDto machIneDto = dto.getMachIneDtoList().get(i); - String code = codeList.get(i); machIneDto.setCode(code); machIneDto.setIsCode(dto.getIsCode()); machIneDto.setTypeId(dto.getTypeId()); @@ -171,7 +183,7 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi * @param dto * @return */ - private int insertPutInfo(SavePutInfoDto dto) { + private int insertPutInfo(SavePutInfoDto dto, String code) { int res = 0; for (int i = 0; i < dto.getMachIneDtoList().size(); i++) { MachIneDto machIneDto = dto.getMachIneDtoList().get(i); @@ -180,6 +192,7 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi machIneDto.setRemarks(dto.getRemarks()); machIneDto.setUnitId(dto.getUnitId()); machIneDto.setProId(dto.getProId()); + machIneDto.setCode(code); res += insertTypePutInStorageInfo(machIneDto); //根据类型追加ma_type表里面的num res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum()); diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/InventoryAndWarehousingMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/InventoryAndWarehousingMapper.xml index d61cd0b3..adb1fef1 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/InventoryAndWarehousingMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/InventoryAndWarehousingMapper.xml @@ -60,6 +60,7 @@ CREATOR, UNIT_ID, PROJECT_ID, + CODE, CREATE_DATE, @@ -88,6 +89,7 @@ #{creator}, #{unitId}, #{proId}, + #{code}, sysdate(), @@ -151,6 +153,7 @@ ma_id, label_code, type_id, + binder, label_type, bind_time, status @@ -159,6 +162,7 @@ #{maId}, #{code}, #{typeId}, + #{creator}, 9, now(), 1 @@ -177,10 +181,11 @@ SELECT pisi.PUT_IN_TYPE as putInType, lot.lot_name as projectName, bui.unit_name as unitName, - pisi.`CODE` as code, + pisi.`CODE` as kindName, mt2.type_name as typeName, - su.user_name as userName, - pisi.CREATE_DATE as createDate + su.user_name as modelName, + pisi.CREATE_DATE as createDate, + pisi.REMARKS as remark FROM ma_type_put_in_storage_info pisi LEFT JOIN ma_type_put_in_storage_details pisd on pisi.id = pisd.INFO LEFT JOIN bm_project_lot lot on lot.lot_id = pisi.PROJECT_ID @@ -188,12 +193,28 @@ LEFT JOIN ma_type mt on mt.type_id = pisd.TYPE LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id LEFT JOIN sys_user su on su.user_id = pisi.CREATOR + where + 1 = 1 + + and (pisi.PUT_IN_TYPE like concat('%',#{keyWord},'%') or + lot.lot_name like concat('%',#{keyWord},'%') or + bui.unit_name like concat('%',#{keyWord},'%') or + mt2.type_name like concat('%',#{keyWord},'%') or + su.user_name like concat('%',#{keyWord},'%') or + pisd.REMARKS like concat('%',#{keyWord},'%') + ) + + order by pisi.CREATE_DATE desc + \ No newline at end of file