bug
This commit is contained in:
parent
6b4e876aee
commit
3ebb67dd24
|
|
@ -3,7 +3,6 @@ package com.bonus.sgzb.material.config;
|
|||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 后端生产随机编码通用方法(格式:今日年月日日期-随机4位编码 20240328-0001)
|
||||
|
|
@ -17,8 +16,8 @@ public class FieldGenerator {
|
|||
String currentDate = today.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
// 生成UUID并取后4位,转换为纯数字类型
|
||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
String uuidLast4Digits = uuid.substring(uuid.length() - 4);
|
||||
String uuidLast4Digits = uuid.substring(uuid.length() - 7);
|
||||
int uuidLast4DigitsNumeric = Integer.parseInt(uuidLast4Digits, 16);
|
||||
return currentDate + "-" + String.format("%04d", uuidLast4DigitsNumeric % 10000);
|
||||
return currentDate + "-" + String.format("%07d", uuidLast4DigitsNumeric % 10000);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,10 @@ public class MachIneDto {
|
|||
@ApiModelProperty(value = "编码")
|
||||
private String code;
|
||||
|
||||
/** 二维码 */
|
||||
@ApiModelProperty(value = "二维码")
|
||||
private String qrCode;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -72,4 +72,6 @@ public interface InventoryAndWarehousingMapper {
|
|||
* @return
|
||||
*/
|
||||
int selectTaskNumByMonth(@Param("date") Date nowDate);
|
||||
|
||||
int selectByCode(String code);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ 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;
|
||||
import com.bonus.sgzb.material.config.FieldGenerator;
|
||||
import com.bonus.sgzb.material.domain.MachIneDto;
|
||||
import com.bonus.sgzb.material.domain.PutInStorageBean;
|
||||
import com.bonus.sgzb.material.domain.SavePutInfoDto;
|
||||
|
|
@ -74,13 +75,23 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
|||
log.info("新增入库盘点入参dto:{}", dto);
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
dto.setCreator(userId);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
String code = genderBackCode();
|
||||
int res;
|
||||
try {
|
||||
//1. 判断是数量还是编号入库,保存到不同表
|
||||
//1.1 如果是编号入库
|
||||
if (dto.getIsCode()) {
|
||||
res = insertMaMachineInfo(dto, code);
|
||||
res = insertMaMachineInfo(dto, codeList, code);
|
||||
if (res == 0) {
|
||||
log.error("insertMaMachineInfo方法插入异常");
|
||||
throw new RuntimeException("insertMaMachineInfo方法插入异常");
|
||||
|
|
@ -108,13 +119,22 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
|||
return AjaxResult.success(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code从ma_machine表查询是否有数据,去重
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
private int selectByCode(String code) {
|
||||
return inventoryAndWarehousingMapper.selectByCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编号新增,插入ma_machine、ma_machine_label和ma_label_bind
|
||||
* @param dto
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
private int insertMaMachineInfo(SavePutInfoDto dto, String code) {
|
||||
private int insertMaMachineInfo(SavePutInfoDto dto, List<String> codeList, String code) {
|
||||
int res = 0;
|
||||
if (dto.getNum() != null) {
|
||||
MachIneDto machIneDto = dto.getMachIneDtoList().get(0);
|
||||
|
|
@ -129,6 +149,8 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
|||
for (int i = 0; i < dto.getMachIneDtoList().size(); i++) {
|
||||
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
||||
machIneDto.setCode(code);
|
||||
String qrCode = codeList.get(i);
|
||||
machIneDto.setQrCode(qrCode);
|
||||
machIneDto.setIsCode(dto.getIsCode());
|
||||
machIneDto.setTypeId(dto.getTypeId());
|
||||
machIneDto.setCreator(dto.getCreator());
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@
|
|||
<if test="typeId != null and typeId != '' ">type_id,</if>
|
||||
<if test="maCode != null and maCode != '' ">ma_code,</if>
|
||||
ma_status,
|
||||
<if test="code != null and code != ''">qr_code,</if>
|
||||
<if test="qrCode != null and qrCode != ''">qr_code,</if>
|
||||
<if test="buyPrice != null and buyPrice != ''">buy_price,</if>
|
||||
<if test="maVender != null and maVender != ''">ma_vender,</if>
|
||||
<if test="checkMan != null and checkMan != ''">check_man,</if>
|
||||
|
|
@ -140,7 +140,7 @@
|
|||
<if test="typeId != null and typeId != ''">#{typeId},</if>
|
||||
<if test="maCode != null and maCode != ''">#{maCode},</if>
|
||||
15,
|
||||
<if test="code != null and code != ''">#{code},</if>
|
||||
<if test="qrCode != null and qrCode != ''">#{qrCode},</if>
|
||||
<if test="buyPrice != null and buyPrice != ''">#{buyPrice},</if>
|
||||
<if test="maVender != null and maVender != ''">#{maVender},</if>
|
||||
<if test="checkMan != null and checkMan != ''">#{checkMan},</if>
|
||||
|
|
@ -153,14 +153,14 @@
|
|||
<insert id="insertMachineLabel">
|
||||
insert into ma_machine_label
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="code != null">label_code,</if>
|
||||
<if test="qrCode != null">label_code,</if>
|
||||
<if test="maId != null">ma_id,</if>
|
||||
is_bind,
|
||||
label_type,
|
||||
create_time
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="code != null">#{code},</if>
|
||||
<if test="qrCode != null">#{qrCode},</if>
|
||||
<if test="maId != null">#{maId},</if>
|
||||
1,
|
||||
9,
|
||||
|
|
@ -171,7 +171,7 @@
|
|||
insert into ma_label_bind
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="maId != null">ma_id,</if>
|
||||
<if test="code != null">label_code,</if>
|
||||
<if test="qrCode != null">label_code,</if>
|
||||
<if test="typeId != null">type_id,</if>
|
||||
<if test="creator != null">binder,</if>
|
||||
label_type,
|
||||
|
|
@ -180,7 +180,7 @@
|
|||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="maId != null">#{maId},</if>
|
||||
<if test="code != null">#{code},</if>
|
||||
<if test="qrCode != null">#{qrCode},</if>
|
||||
<if test="typeId != null">#{typeId},</if>
|
||||
<if test="creator != null">#{creator},</if>
|
||||
9,
|
||||
|
|
@ -231,4 +231,11 @@
|
|||
<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>
|
||||
<select id="selectByCode" resultType="java.lang.Integer">
|
||||
select count(*)
|
||||
from ma_machine
|
||||
<where>
|
||||
<if test="code != null ">and qr_code = #{code}</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue