关联关系校验

dev_unify
yewj 5 months ago
parent 2e3df99740
commit f7843f2739

@ -21,6 +21,7 @@ import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
import com.glxp.api.entity.basic.BasicCorpEntity;
import com.glxp.api.entity.basic.UdiEntity;
import com.glxp.api.entity.basic.UdiProductEntity;
import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.inv.InvPreInProductDetailEntity;
import com.glxp.api.entity.inv.InvPreProductDetailEntity;
@ -959,6 +960,7 @@ public class IoCodeTempController extends BaseController {
if (StrUtil.isNotEmpty(addOrderRequest.getSerialNo())) {
udiEntity.setSerialNo(addOrderRequest.getSerialNo());
}
RelCodeDetailResponse codeRelEntity = null;
if (StrUtil.isEmpty(udiEntity.getBatchNo())) {
IoCodeLostEntity codeLostEntity = codeLostService.findByCode(code);
if (codeLostEntity != null) {
@ -966,7 +968,7 @@ public class IoCodeTempController extends BaseController {
udiEntity.setProduceDate(codeLostEntity.getProduceDate());
udiEntity.setExpireDate(codeLostEntity.getExpireDate());
} else {
RelCodeDetailResponse codeRelEntity = relCodeDetailService.findByCode(code);
codeRelEntity = relCodeDetailService.findByCode(code);
if (codeRelEntity != null) {
udiEntity.setBatchNo(codeRelEntity.getBatchNo());
udiEntity.setProduceDate(DateUtil.formatDate(codeRelEntity.getMadeDate(), "yyMMdd"));
@ -1123,6 +1125,14 @@ public class IoCodeTempController extends BaseController {
codeEnttity.setSerialNo(udiEntity.getSerialNo());
codeEnttity.setDeptCode(invWarehouseEntity.getParentId());
codeEnttity.setInvCode(addOrderRequest.getInvCode());
if (codeRelEntity != null) {
codeEnttity.setParentCode(codeRelEntity.getParentCode());
RelCodeDetail relCodeDetail = relCodeDetailService.getOneByCode(codeRelEntity.getParentCode());
if (relCodeDetail != null) {
codeEnttity.setGrantPaCode(relCodeDetail.getParentCode());
}
}
codeEnttity.setCount(1);
codeEnttity.setProductType(2);
String unitFk = null;

@ -185,4 +185,9 @@ public class IoCodeTempEntity {
@TableField(value = "parentCode")
private String parentCode;
/**
*
*/
@TableField(value = "grantPaCode")
private String grantPaCode;
}

@ -118,12 +118,26 @@ public class RelCodeDetailService extends ServiceImpl<RelCodeDetailMapper, RelCo
public RelCodeDetailResponse findByCode(String code) {
RelCodeDetailRequest relCodeDetailRequest = new RelCodeDetailRequest();
relCodeDetailRequest.setCurCode(code);
List<RelCodeDetailResponse> relCodeDetailResponse = filterList(relCodeDetailRequest);
if (CollUtil.isNotEmpty(relCodeDetailResponse)) {
return relCodeDetailResponse.get(0);
List<RelCodeDetailResponse> relCodeDetailResponses = filterList(relCodeDetailRequest);
if (CollUtil.isNotEmpty(relCodeDetailResponses)) {
return relCodeDetailResponses.get(0);
} else {
return null;
relCodeDetailRequest.setCurCode(null);
relCodeDetailRequest.setParentCode(code);
relCodeDetailResponses = filterList(relCodeDetailRequest);
if (CollUtil.isNotEmpty(relCodeDetailResponses)) {
RelCodeDetailResponse relCodeDetailResponse = relCodeDetailResponses.get(0);
relCodeDetailResponse.setCurCode(code);
relCodeDetailResponse.setParentCode(null);
return relCodeDetailResponse;
}
}
return null;
}
public RelCodeDetail getOneByCode(String code) {
RelCodeDetail relCodeDetail = getOne(new LambdaQueryWrapper<RelCodeDetail>().eq(RelCodeDetail::getCurCode, code));
return relCodeDetail;
}

@ -1,6 +1,7 @@
package com.glxp.api.service.inout.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -11,6 +12,7 @@ import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.entity.inout.IoCodeEntity;
import com.glxp.api.entity.inout.IoCodeTempEntity;
import com.glxp.api.req.inout.FilterCodeRequest;
import com.glxp.api.res.collect.RelCodeDetailResponse;
import com.glxp.api.res.inout.IoCodeTempResponse;
import com.glxp.api.service.collect.RelCodeDetailService;
import com.glxp.api.util.BeanCopyUtils;
@ -124,13 +126,23 @@ public class IoCodeTempService {
public boolean ieExitRel(String code, String orderId) {
boolean ret = false;
RelCodeDetail relCodeDetail = relCodeDetailService.getOne(new LambdaQueryWrapper<RelCodeDetail>().eq(RelCodeDetail::getCurCode, code));
RelCodeDetailResponse relCodeDetail = relCodeDetailService.findByCode(code);
if (relCodeDetail != null) {
ret = ioCodeTempDao.exists(new LambdaQueryWrapper<IoCodeTempEntity>().eq(IoCodeTempEntity::getOrderId, orderId).eq(IoCodeTempEntity::getCode, relCodeDetail.getParentCode()));
//判断是否存在关联关系1.先判断当前单号是否存在父码,若存在则表示存在关联关系重复扫码
if (StrUtil.isNotEmpty(relCodeDetail.getParentCode())) {
ret = ioCodeTempDao.exists(new LambdaQueryWrapper<IoCodeTempEntity>().eq(IoCodeTempEntity::getOrderId, orderId).eq(IoCodeTempEntity::getCode, relCodeDetail.getParentCode()));
if (!ret) {
relCodeDetail = relCodeDetailService.findByCode(relCodeDetail.getParentCode());
ret = ioCodeTempDao.exists(new LambdaQueryWrapper<IoCodeTempEntity>().eq(IoCodeTempEntity::getOrderId, orderId).eq(IoCodeTempEntity::getCode, relCodeDetail.getParentCode()));
}
}
if (ret)
return true;
//若父码不存在,判断当前单号是否存在当前码的子码,若存在则表示存在关联关系重复扫码
ret = ioCodeTempDao.exists(new LambdaQueryWrapper<IoCodeTempEntity>().eq(IoCodeTempEntity::getOrderId, orderId).eq(IoCodeTempEntity::getParentCode, code));
if (!ret) {
ret = ioCodeTempDao.exists(new LambdaQueryWrapper<IoCodeTempEntity>().eq(IoCodeTempEntity::getOrderId, orderId).eq(IoCodeTempEntity::getParentCode, code));
ret = ioCodeTempDao.exists(new LambdaQueryWrapper<IoCodeTempEntity>().eq(IoCodeTempEntity::getOrderId, orderId).eq(IoCodeTempEntity::getGrantPaCode, code));
}
}
return ret;
}

@ -1,68 +1,79 @@
<?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="com.glxp.api.dao.collect.RelCodeDetailMapper">
<resultMap id="BaseResultMap" type="com.glxp.api.entity.collect.RelCodeDetail">
<!--@mbg.generated-->
<!--@Table udi_wms_ywj.rel_code_detail-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="curCode" jdbcType="VARCHAR" property="curCode" />
<result column="packLayer" jdbcType="TINYINT" property="packLayer" />
<result column="parentCode" jdbcType="VARCHAR" property="parentCode" />
<result column="flag" jdbcType="TINYINT" property="flag" />
<result column="batchIdFk" jdbcType="INTEGER" property="batchIdFk" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, curCode, packLayer, parentCode, flag, batchIdFk
</sql>
<resultMap id="BaseResultMap" type="com.glxp.api.entity.collect.RelCodeDetail">
<!--@mbg.generated-->
<!--@Table udi_wms_ywj.rel_code_detail-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="curCode" jdbcType="VARCHAR" property="curCode"/>
<result column="packLayer" jdbcType="TINYINT" property="packLayer"/>
<result column="parentCode" jdbcType="VARCHAR" property="parentCode"/>
<result column="flag" jdbcType="TINYINT" property="flag"/>
<result column="batchIdFk" jdbcType="INTEGER" property="batchIdFk"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id,
curCode,
packLayer,
parentCode,
flag,
batchIdFk
</sql>
<select id="filterList" parameterType="com.glxp.api.req.collect.RelCodeDetailRequest" resultType="com.glxp.api.res.collect.RelCodeDetailResponse">
select
rcd.id,
rcd.curCode,
rcd.packLayer,
rcd.parentCode,
rcd.flag,
rcd.batchIdFk,
rcb.productCode,
rcb.subTypeNo,
rcb.cascadeRatio,
rcb.packageSpec,
rcb.comment,
rcb.batchNo,
rcb.madeDate,
rcb.validateDate,
rcb.workShop,
rcb.lineName,
rcb.lineManager,
rcb.createTime,
rcb.createUser,
rcb.updateTime,
rcb.updateUser
from rel_code_detail rcd
left join rel_code_batch rcb on rcb.id = rcd.batchIdFk
<where>
<if test="productCode != '' and productCode != null">
AND rcb.productCode LIKE concat('%', #{productCode}, '%')
</if>
<if test=" batchIdFk != null">
AND rcb.id = #{batchIdFk}
</if>
<if test="batchNo != null and batchNo != ''">
AND rcb.batchNo = #{batchNo}
</if>
<if test="keyWords != '' and keyWords != null">
and (
rcb.productCode LIKE concat('%', #{keyWords}, '%')
or rcb.subTypeNo LIKE concat('%', #{keyWords}, '%')
or rcb.packageSpec LIKE concat('%', #{keyWords}, '%'))
</if>
<if test="lineName != '' and lineName != null">
AND rcb.lineName LIKE concat('%', #{lineName}, '%')
</if>
<if test="lineManager != '' and lineManager != null">
AND rcb.lineManager LIKE concat('%', #{lineManager}, '%')
</if>
</where>
</select>
<select id="filterList" parameterType="com.glxp.api.req.collect.RelCodeDetailRequest"
resultType="com.glxp.api.res.collect.RelCodeDetailResponse">
select rcd.id,
rcd.curCode,
rcd.packLayer,
rcd.parentCode,
rcd.flag,
rcd.batchIdFk,
rcb.productCode,
rcb.subTypeNo,
rcb.cascadeRatio,
rcb.packageSpec,
rcb.comment,
rcb.batchNo,
rcb.madeDate,
rcb.validateDate,
rcb.workShop,
rcb.lineName,
rcb.lineManager,
rcb.createTime,
rcb.createUser,
rcb.updateTime,
rcb.updateUser
from rel_code_detail rcd
left join rel_code_batch rcb on rcb.id = rcd.batchIdFk
<where>
<if test="productCode != '' and productCode != null">
AND rcb.productCode LIKE concat('%', #{productCode}, '%')
</if>
<if test="batchIdFk != null">
AND rcb.id = #{batchIdFk}
</if>
<if test="curCode != null">
AND rcd.curCode = #{curCode}
</if>
<if test="parentCode != null">
AND rcd.parentCode = #{parentCode}
</if>
<if test="batchNo != null and batchNo != ''">
AND rcb.batchNo = #{batchNo}
</if>
<if test="keyWords != '' and keyWords != null">
and (
rcb.productCode LIKE concat('%', #{keyWords}, '%')
or rcb.subTypeNo LIKE concat('%', #{keyWords}, '%')
or rcb.packageSpec LIKE concat('%', #{keyWords}, '%'))
</if>
<if test="lineName != '' and lineName != null">
AND rcb.lineName LIKE concat('%', #{lineName}, '%')
</if>
<if test="lineManager != '' and lineManager != null">
AND rcb.lineManager LIKE concat('%', #{lineManager}, '%')
</if>
</where>
</select>
</mapper>

@ -1095,6 +1095,16 @@ CALL Pro_Temp_ColumnWork('thr_products_add_di', 'majorStatus',
CALL Pro_Temp_ColumnWork('io_code_temp', 'parentCode',
' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''父级编码''',
1);
CALL Pro_Temp_ColumnWork('io_code_temp', 'grantPaCode',
' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''爷级编码''',
1);
CALL Pro_Temp_ColumnWork('io_code', 'parentCode',
' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''父级编码''',
1);
CALL Pro_Temp_ColumnWork('io_code', 'grantPaCode',
' varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''爷级编码''',
1);
CALL Pro_Temp_ColumnWork('rel_code_batch', 'erpId',

Loading…
Cancel
Save