盘点入库详情
This commit is contained in:
parent
a790ba40e8
commit
a5e306a0f9
|
|
@ -17,8 +17,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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,4 +50,18 @@ public class InventoryAndWarehousingController extends BaseController {
|
|||
return inventoryAndWarehousingService.savePutInfo(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据入库单号查看详情
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "根据入库单号查看详情")
|
||||
@GetMapping("/getDetail")
|
||||
public TableDataInfo getDetail(PutInStorageBean bean) {
|
||||
startPage();
|
||||
List<PutInStorageBean> list = inventoryAndWarehousingService.getDetails(bean);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ public class MachIneDto {
|
|||
@ApiModelProperty(value = "设备编号")
|
||||
private String maCode;
|
||||
|
||||
/** 二维码 */
|
||||
@ApiModelProperty(value = "二维码")
|
||||
private String qrCode;
|
||||
|
||||
/**
|
||||
* 类型id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -72,4 +72,13 @@ public interface InventoryAndWarehousingMapper {
|
|||
* @return
|
||||
*/
|
||||
int selectTaskNumByMonth(@Param("date") Date nowDate);
|
||||
|
||||
int selectByCode(String code);
|
||||
|
||||
/**
|
||||
* 根据入库单号查看详情
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<PutInStorageBean> getDetails(PutInStorageBean bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,11 @@ public interface InventoryAndWarehousingService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult savePutInfo(SavePutInfoDto dto);
|
||||
|
||||
/**
|
||||
* 根据入库单号查看详情
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<PutInStorageBean> getDetails(PutInStorageBean bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,32 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
|||
return AjaxResult.success(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据入库单号查看详情
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PutInStorageBean> getDetails(PutInStorageBean bean) {
|
||||
return inventoryAndWarehousingMapper.getDetails(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据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 +159,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,
|
||||
|
|
@ -198,37 +198,92 @@
|
|||
</update>
|
||||
|
||||
<select id="getList" resultType="com.bonus.sgzb.material.domain.PutInStorageBean">
|
||||
SELECT pisi.PUT_IN_TYPE as putInType,
|
||||
lot.lot_name as projectName,
|
||||
bui.unit_name as unitName,
|
||||
pisi.`CODE` as kindName,
|
||||
mt2.type_name as typeName,
|
||||
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
|
||||
LEFT JOIN bm_unit_info bui on bui.unit_id = pisi.UNIT_ID
|
||||
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
|
||||
SELECT
|
||||
sub.putInType,
|
||||
sub.projectName,
|
||||
sub.unitName,
|
||||
sub.kindName,
|
||||
sub.typeName,
|
||||
sub.modelName,
|
||||
sub.createDate,
|
||||
sub.remark
|
||||
FROM (
|
||||
SELECT
|
||||
pisi.PUT_IN_TYPE AS putInType,
|
||||
lot.lot_name AS projectName,
|
||||
bui.unit_name AS unitName,
|
||||
pisi.`CODE` AS kindName,
|
||||
mt2.type_name AS typeName,
|
||||
su.user_name AS modelName,
|
||||
pisi.CREATE_DATE AS createDate,
|
||||
pisi.REMARKS AS remark,
|
||||
ROW_NUMBER() OVER (PARTITION BY pisi.`CODE` ORDER BY pisi.CREATE_DATE DESC) AS row_num
|
||||
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
|
||||
LEFT JOIN bm_unit_info bui ON bui.unit_id = pisi.UNIT_ID
|
||||
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.`CODE` like concat('%',#{keyWord},'%') or
|
||||
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
|
||||
pisi.REMARKS like concat('%',#{keyWord},'%')
|
||||
)
|
||||
AND (
|
||||
pisi.`CODE` LIKE CONCAT('%',#{keyWord},'%') OR
|
||||
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
|
||||
pisi.REMARKS LIKE CONCAT('%',#{keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
order by pisi.CREATE_DATE desc
|
||||
) AS sub
|
||||
WHERE sub.row_num = 1
|
||||
ORDER BY createDate DESC
|
||||
</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>
|
||||
<select id="selectByCode" resultType="java.lang.Integer">
|
||||
select count(*)
|
||||
from ma_machine
|
||||
<where>
|
||||
<if test="code != null ">and qr_code = #{code}</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getDetails" resultType="com.bonus.sgzb.material.domain.PutInStorageBean">
|
||||
SELECT
|
||||
pisi.`CODE` as kindName,
|
||||
pisi.PUT_IN_TYPE as putInType,
|
||||
pisd.MACODE as maCode,
|
||||
pisd.NUM as num,
|
||||
mt2.type_name as typeName,
|
||||
mt.type_name as typeModelName,
|
||||
su.user_name as modelName,
|
||||
pisi.CREATE_DATE as createDate
|
||||
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
|
||||
LEFT JOIN bm_unit_info bui on bui.unit_id = pisi.UNIT_ID
|
||||
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="kindName != null and kindName != ''">
|
||||
and pisi.`CODE` = #{kindName}
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (
|
||||
pisi.PUT_IN_TYPE like concat('%',#{keyWord},'%') or
|
||||
mt2.type_name like concat('%',#{keyWord},'%') or
|
||||
su.user_name like concat('%',#{keyWord},'%') or
|
||||
mt.type_name like concat('%',#{keyWord},'%') or
|
||||
pisd.MACODE like concat('%',#{keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
order by pisi.CREATE_DATE desc
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue