入库盘点

This commit is contained in:
mashuai 2024-04-17 15:07:29 +08:00
parent 2dcbb2a6d3
commit 4b39107750
7 changed files with 77 additions and 29 deletions

View File

@ -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<PutInStorageBean> list = inventoryAndWarehousingService.getList(bean);
return getDataTable(list);

View File

@ -79,7 +79,7 @@ public class MachIneDto {
* 创建者
*/
@ApiModelProperty(value = "创建者")
private String creator;
private Long creator;
/**
* 入库形式

View File

@ -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;
/** 主信息 */

View File

@ -96,7 +96,7 @@ public class SavePutInfoDto extends BaseEntity {
* 创建者
*/
@ApiModelProperty(value = "创建者")
private String creator;
private Long creator;
/**
* 创建时间

View File

@ -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);
}

View File

@ -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<String> 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_machinema_machine_label和ma_label_bind
* @param dto
* @param codeList
* @param code
* @return
*/
private int insertMaMachineInfo(SavePutInfoDto dto, List<String> 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());

View File

@ -60,6 +60,7 @@
<if test="creator != null and creator != ''">CREATOR,</if>
<if test="unitId != null and unitId != ''">UNIT_ID,</if>
<if test="proId != null and proId != ''">PROJECT_ID,</if>
<if test="code != null and code != ''">CODE,</if>
CREATE_DATE,
<choose>
<when test="isCode and remarks != null and remarks != ''">
@ -88,6 +89,7 @@
<if test="creator != null and creator != ''">#{creator},</if>
<if test="unitId != null and unitId != ''">#{unitId},</if>
<if test="proId != null and proId != ''">#{proId},</if>
<if test="code != null and code != ''">#{code},</if>
sysdate(),
<choose>
<when test="isCode and remarks != null and remarks != ''">
@ -151,6 +153,7 @@
<if test="maId != null">ma_id,</if>
<if test="code != null">label_code,</if>
<if test="typeId != null">type_id,</if>
<if test="creator != null">binder,</if>
label_type,
bind_time,
status
@ -159,6 +162,7 @@
<if test="maId != null">#{maId},</if>
<if test="code != null">#{code},</if>
<if test="typeId != null">#{typeId},</if>
<if test="creator != null">#{creator},</if>
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
<if test="keyWord != null and keyWord != ''">
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},'%')
)
</if>
order by pisi.CREATE_DATE desc
</select>
<select id="selectByCode" resultType="java.lang.Integer">
select count(*)
from ma_machine
<where>
where
1 = 1
<if test="code != null "> and qr_code = #{code}</if>
</where>
</select>
<select id="selectTaskNumByMonth" resultType="java.lang.Integer">
select count(*) from ma_type_put_in_storage_info where DATE_FORMAT(CREATE_DATE,'%y%m') = DATE_FORMAT(#{date},'%y%m')
</select>
</mapper>