-5楼自检工序:根据原材料条码生成成品条码
master
xins 2 months ago
parent 94a809eebb
commit 563f076ae2

@ -156,4 +156,14 @@ public interface RemoteMesService {
@GetMapping("/barcode/selectMesBaseBindBarcodeList/{barcodeId}") @GetMapping("/barcode/selectMesBaseBindBarcodeList/{barcodeId}")
public R<List<MesBaseBindBarcode>> selectMesBaseBindBarcodeList(@PathVariable("barcodeId") Long barcodeId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); public R<List<MesBaseBindBarcode>> selectMesBaseBindBarcodeList(@PathVariable("barcodeId") Long barcodeId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
*
* @param barcodeInfo
* @param source
* @return
*/
@GetMapping("/barcode/selectBindBarcodeListByBarcodeInfo/{barcodeId}")
public R<List<MesBaseBindBarcode>> selectBindBarcodeListByBarcodeInfo(@PathVariable("barcodeInfo") String barcodeInfo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
} }

@ -26,6 +26,10 @@ public class MesBaseBindBarcode extends BaseEntity
private Long saleOrderId; private Long saleOrderId;
private Long materialId;
private Long productId;
/** 绑定的条码内容 */ /** 绑定的条码内容 */
@Excel(name = "绑定的条码内容") @Excel(name = "绑定的条码内容")
private String bindBarcode; private String bindBarcode;
@ -65,6 +69,22 @@ public class MesBaseBindBarcode extends BaseEntity
this.saleOrderId = saleOrderId; this.saleOrderId = saleOrderId;
} }
public Long getMaterialId() {
return materialId;
}
public void setMaterialId(Long materialId) {
this.materialId = materialId;
}
public Long getProductId() {
return productId;
}
public void setProductId(Long productId) {
this.productId = productId;
}
public void setBindBarcode(String bindBarcode) public void setBindBarcode(String bindBarcode)
{ {
this.bindBarcode = bindBarcode; this.bindBarcode = bindBarcode;

@ -88,6 +88,11 @@ public class RemoteMesFallbackFactory implements FallbackFactory<RemoteMesServic
@Override @Override
public R<List<MesBaseBindBarcode>> selectMesBaseBindBarcodeList(Long barcodeId, String source) { public R<List<MesBaseBindBarcode>> selectMesBaseBindBarcodeList(Long barcodeId, String source) {
return R.fail("根据原材料条码ID获取成品条码信息失败:" + throwable.getMessage());
}
@Override
public R<List<MesBaseBindBarcode>> selectBindBarcodeListByBarcodeInfo(String barcodeInfo, String source) {
return R.fail("根据原材料条码获取成品条码信息失败:" + throwable.getMessage()); return R.fail("根据原材料条码获取成品条码信息失败:" + throwable.getMessage());
} }
}; };

@ -310,6 +310,50 @@ public class Seq {
// 采购申请任务编号的记录标识 // 采购申请任务编号的记录标识
public static final String mesPurchaseApplyProcessCode = "CG"; public static final String mesPurchaseApplyProcessCode = "CG";
// 采购合并虚拟原材料条码内容记录标识
public static final String mesPurchaseVirtualBarcodeSeqType = "VIRTUAL_BAR_CODE";
// 采购合并虚拟原材料条码内容序列数
private static AtomicInteger mesPurchaseVirtualBarcodeSeq = new AtomicInteger(1);
// 采购合并虚拟原材料条码内容标识
public static final String mesPurchaseVirtualBarcodeCode = "VR";
// 内部生产合并虚拟原材料条码内容记录标识
public static final String mesInternalVirtualBarcodeSeqType = "INTERNAL_VIRTUAL_BAR_CODE";
// 内部生产虚拟原材料条码内容序列数
private static AtomicInteger mesInternalVirtualBarcodeSeq = new AtomicInteger(1);
// 内部生产虚拟原材料条码内容标识
public static final String mesInternalVirtualBarcodeCode = "VI";
// 采购合并虚拟成品条码内容记录标识
public static final String mesPurchaseVirtualProductBarcodeSeqType = "VIRTUAL_PRODUCT_BAR_CODE";
// 采购合并虚拟成品条码内容序列数
private static AtomicInteger mesPurchaseVirtualProductBarcodeSeq = new AtomicInteger(1);
// 采购合并虚拟成品条码内容标识
public static final String mesPurchaseVirtualProductBarcodeCode = "VP";
// 内部生产合并虚拟成品条码内容记录标识
public static final String mesInternalVirtualProductBarcodeSeqType = "INTERNAL_VIRTUAL_PRODUCT_BAR_CODE";
// 内部生产虚拟成品条码内容序列数
private static AtomicInteger mesInternalVirtualProductBarcodeSeq = new AtomicInteger(1);
// 内部生产虚拟成品条码内容标识
public static final String mesInternalVirtualProductBarcodeCode = "VT";
/** /**
* *
* *
@ -424,6 +468,14 @@ public class Seq {
atomicInt = mesVirtualPurchasaeOrderSeq; atomicInt = mesVirtualPurchasaeOrderSeq;
}else if (mesPurchaseApplyProcessSeqType.equals(type)) { }else if (mesPurchaseApplyProcessSeqType.equals(type)) {
atomicInt = mesPurchaseApplyProcessSeq; atomicInt = mesPurchaseApplyProcessSeq;
}else if (mesPurchaseVirtualBarcodeSeqType.equals(type)) {
atomicInt = mesPurchaseVirtualBarcodeSeq;
}else if (mesPurchaseVirtualProductBarcodeSeqType.equals(type)) {
atomicInt = mesPurchaseVirtualProductBarcodeSeq;
}else if (mesInternalVirtualBarcodeSeqType.equals(type)) {
atomicInt = mesInternalVirtualBarcodeSeq;
}else if (mesInternalVirtualProductBarcodeSeqType.equals(type)) {
atomicInt = mesInternalVirtualProductBarcodeSeq;
} }
return getId(atomicInt, 3, code); return getId(atomicInt, 3, code);
} }

@ -398,5 +398,15 @@ public class MesBaseBarcodeInfoController extends BaseController
return R.ok(mesBaseBarcodeInfoService.selectMesBaseBindBarcodeList(queryBindBarcode)); return R.ok(mesBaseBarcodeInfoService.selectMesBaseBindBarcodeList(queryBindBarcode));
} }
/**
*
*/
@InnerAuth
@GetMapping(value="/selectBindBarcodeListByBarcodeInfo/{barcodeInfo}")
public R<List<MesBaseBindBarcode>> selectBindBarcodeListByBarcodeInfo(@PathVariable("barcodeInfo") String barcodeInfo)
{
MesBaseBindBarcode queryBindBarcode = new MesBaseBindBarcode();
queryBindBarcode.setBarcodeInfo(barcodeInfo);
return R.ok(mesBaseBarcodeInfoService.selectMesBaseBindBarcodeList(queryBindBarcode));
}
} }

@ -17,6 +17,7 @@ import com.hw.mes.domain.vo.MesBindBarcodeVo;
import com.hw.mes.mapper.*; import com.hw.mes.mapper.*;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.stream.Collectors;
import com.hw.printer.api.RemotePrinterService; import com.hw.printer.api.RemotePrinterService;
import com.hw.printer.api.domain.vo.PrintContentVo; import com.hw.printer.api.domain.vo.PrintContentVo;
@ -331,6 +332,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
throw new ServiceException("此生产明细已经生成条码,不能重复生成"); throw new ServiceException("此生产明细已经生成条码,不能重复生成");
} }
//根据生产明细代码获取生产明细
MesProductPlanDetail mesProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailCode(planDetailCode); MesProductPlanDetail mesProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailCode(planDetailCode);
if (mesProductPlanDetail == null) { if (mesProductPlanDetail == null) {
throw new ServiceException("此生产明细不存在"); throw new ServiceException("此生产明细不存在");
@ -348,13 +350,14 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
Long saleOrderId = productPlan.getSaleOrderId(); Long saleOrderId = productPlan.getSaleOrderId();
String saleOrderCode = productPlan.getSaleorderCode(); String saleOrderCode = productPlan.getSaleorderCode();
Long materialId = productPlan.getMaterialId();//在生产计划的materialid是根据saletype保存如果是外部销售则保存productorder中的materialid如果是内部生产则保存prpductorder中的producematerialid Long materialId = null;//在生产计划的materialid是根据saletype保存如果是外部销售则保存productorder中的materialid如果是内部生产则保存prpductorder中的producematerialid
//五楼根据原材料条码单独生成成品条码 //五楼自检工序根据原材料条码生成成品条码
if (StringUtils.isNotEmpty(mesBaseBarcodeInfo.getSingleFlag()) && if (StringUtils.isNotEmpty(mesBaseBarcodeInfo.getSingleFlag()) &&
mesBaseBarcodeInfo.getSingleFlag().equals(MesConstants.MES_BARCODE_SINGLE_FLAG_YES)) { mesBaseBarcodeInfo.getSingleFlag().equals(MesConstants.MES_BARCODE_SINGLE_FLAG_YES)) {
String rawMaterialBarcode = mesBaseBarcodeInfo.getProductBarcode(); String rawMaterialBarcode = mesBaseBarcodeInfo.getProductBarcode();
MesBaseBarcodeInfo rawBarcode = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(rawMaterialBarcode); MesBaseBarcodeInfo rawBarcode = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(rawMaterialBarcode);
if (rawBarcode == null) { if (rawBarcode == null) {
throw new ServiceException("原材料条码有误"); throw new ServiceException("原材料条码有误");
@ -364,6 +367,12 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
throw new ServiceException("此条码为非原材料条码,不能生成成品条码"); throw new ServiceException("此条码为非原材料条码,不能生成成品条码");
} }
if (rawMaterialBarcode.indexOf(Seq.mesPurchaseVirtualBarcodeCode) >= 0) {
barcode = Seq.getId(Seq.mesPurchaseVirtualProductBarcodeSeqType, Seq.mesPurchaseVirtualProductBarcodeCode);
} else if (rawMaterialBarcode.indexOf(Seq.mesInternalVirtualBarcodeCode) >= 0) {
barcode = Seq.getId(Seq.mesInternalVirtualProductBarcodeSeqType, Seq.mesInternalVirtualProductBarcodeCode);
}
MesBaseBarcodeInfo productBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByProductBarcode(rawMaterialBarcode); MesBaseBarcodeInfo productBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByProductBarcode(rawMaterialBarcode);
if (productBarcodeInfo != null) { if (productBarcodeInfo != null) {
throw new ServiceException("此原材料条码已经生成过成品条码,不能重复生成"); throw new ServiceException("此原材料条码已经生成过成品条码,不能重复生成");
@ -395,6 +404,13 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
throw new ServiceException("原材料条码的生产派工不存在"); throw new ServiceException("原材料条码的生产派工不存在");
} }
if (!rawBarcodeProductPlan.getDispatchCode().equals(productPlan.getDispatchCode())) {
throw new ServiceException("派工单号不一致,当前派工单号:" + productPlan.getDispatchCode()
+ ",原材料条码派工单号:" + rawBarcodeProductPlan.getDispatchCode());
}
materialId = rawBarcode.getMaterialId();
mesBaseBarcodeInfo.setPalletInfoCode(rawBarcode.getPalletInfoCode());//重新绑定托盘号 mesBaseBarcodeInfo.setPalletInfoCode(rawBarcode.getPalletInfoCode());//重新绑定托盘号
mesBaseBarcodeInfo.setBindStatus(MesConstants.MES_BARCODE_BIND_STATUS_BINDING); mesBaseBarcodeInfo.setBindStatus(MesConstants.MES_BARCODE_BIND_STATUS_BINDING);
@ -421,12 +437,14 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail); mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail);
} else { } else {
materialId = mesBaseBarcodeInfo.getMaterialId();
MesProductOrder mesProductOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(productPlan.getProductOrderId()); MesProductOrder mesProductOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(productPlan.getProductOrderId());
mesBaseBarcodeInfo.setCompleteFlag(mesProductOrder.getSaleType().equals(MesConstants.MES_PRODUCT_ORDER_SALE) mesBaseBarcodeInfo.setCompleteFlag(mesProductOrder.getSaleType().equals(MesConstants.MES_PRODUCT_ORDER_SALE)
? MesConstants.MES_BASE_BARCODE_COMPLETE_FLAG_YES : MesConstants.MES_BASE_BARCODE_COMPLETE_FLAG_NO); ? MesConstants.MES_BASE_BARCODE_COMPLETE_FLAG_YES : MesConstants.MES_BASE_BARCODE_COMPLETE_FLAG_NO);
} }
mesBaseBarcodeInfo.setBatchCode(barcode);// 成品的批次代码 == 条码内容 mesBaseBarcodeInfo.setBatchCode(barcode);// 成品的批次代码 == 条码内容
mesBaseBarcodeInfo.setBarcodeInfo(barcode); mesBaseBarcodeInfo.setBarcodeInfo(barcode);
mesBaseBarcodeInfo.setAmount(new BigDecimal(1)); mesBaseBarcodeInfo.setAmount(new BigDecimal(1));
@ -916,6 +934,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
StringBuilder palletBindErrorMsg = new StringBuilder(); StringBuilder palletBindErrorMsg = new StringBuilder();
boolean palletInfoCodeRepeat = false; boolean palletInfoCodeRepeat = false;
String palletInfoCode = ""; String palletInfoCode = "";
String barcodeInfo = "";
if (productBarcodesArr != null) { if (productBarcodesArr != null) {
for (String productBarcode : productBarcodesArr) { for (String productBarcode : productBarcodesArr) {
//先根据之前的成品条码信息获取托盘信息 //先根据之前的成品条码信息获取托盘信息
@ -945,6 +964,8 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
allErrorMsgBuilder.append(this.checkInternalMesBaseBarcode(productBarcode, productBarcodeInfo, mesBaseBarcodeInfo)); allErrorMsgBuilder.append(this.checkInternalMesBaseBarcode(productBarcode, productBarcodeInfo, mesBaseBarcodeInfo));
} }
barcodeInfo = Seq.getId(Seq.mesInternalVirtualBarcodeSeqType, Seq.mesInternalVirtualBarcodeCode);
} else { } else {
MesBasePalletInfo basePalletInfo = mesBasePalletInfoMapper.selectMesBasePalletInfoByBarcode(productBarcodes); MesBasePalletInfo basePalletInfo = mesBasePalletInfoMapper.selectMesBasePalletInfoByBarcode(productBarcodes);
if (basePalletInfo == null) { if (basePalletInfo == null) {
@ -964,6 +985,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
basePalletInfoList.add(basePalletInfo); basePalletInfoList.add(basePalletInfo);
materialId = productBarcodeInfo.getMaterialId(); materialId = productBarcodeInfo.getMaterialId();
barcodeInfo = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode);
} }
@ -975,7 +997,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
throw new ServiceException(allErrorMsgBuilder.toString()); throw new ServiceException(allErrorMsgBuilder.toString());
} }
String barcodeInfo = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode);
String userName = SecurityUtils.getUsername(); String userName = SecurityUtils.getUsername();
Date currentDate = DateUtils.getNowDate(); Date currentDate = DateUtils.getNowDate();
//修改托盘信息的绑定关系为当前原材料的 //修改托盘信息的绑定关系为当前原材料的
@ -989,7 +1011,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
mesBasePalletInfoMapper.updateMesBasePalletInfo(toUpdatePalletInfo); mesBasePalletInfoMapper.updateMesBasePalletInfo(toUpdatePalletInfo);
} }
mesBaseBarcodeInfo.setBarcodeInfo(barcodeInfo); mesBaseBarcodeInfo.setBarcodeInfo(barcodeInfo);
mesBaseBarcodeInfo.setBatchCode(barcodeInfo); mesBaseBarcodeInfo.setBatchCode(barcodeInfo);
mesBaseBarcodeInfo.setMaterialId(materialId); mesBaseBarcodeInfo.setMaterialId(materialId);
@ -1025,15 +1046,46 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(productBarcodeInfo); mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(productBarcodeInfo);
} }
Long bindMaterialId = productBarcodeInfo.getMaterialId();
MesMaterialBom queryMaterialBom = new MesMaterialBom();
queryMaterialBom.setMaterialId(bindMaterialId);
queryMaterialBom.setActiveFlag(MesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_NORMAL);
List<MesMaterialBom> mesMaterialBomList = mesMaterialBomMapper.selectMesMaterialBomList(queryMaterialBom);
if (mesMaterialBomList == null || mesMaterialBomList.isEmpty()) {
allErrorMsgBuilder.append("成品条码[").append(productBarcodeInfo.getBarcodeInfo()).append("]没有维护生产bom信息;");
}
List<MesMaterialBom> childMaterialBomList = mesMaterialBomList.stream().
filter(materialBom -> materialBom.getParentId() != null && !materialBom.getParentId().equals(0L))
.collect(Collectors.toList());
if (childMaterialBomList == null || childMaterialBomList.isEmpty()) {
allErrorMsgBuilder.append("成品条码[").append(productBarcodeInfo.getBarcodeInfo()).append("]没有维护在五楼成品的生产bom信息中;");
} else if (childMaterialBomList.size() > 1) {
allErrorMsgBuilder.append("成品条码[").append(productBarcodeInfo.getBarcodeInfo())
.append("]五楼成品的生产bom信息多于1个").append(mesMaterialBomList.size()).append(";");
} else {
MesMaterialBom childMaterialBom = childMaterialBomList.get(0);
MesMaterialBom parentBom = mesMaterialBomMapper.selectMesMaterialBomByMaterialBomId(childMaterialBom.getParentId());
MesBaseBindBarcode baseBindBarcode = new MesBaseBindBarcode(); MesBaseBindBarcode baseBindBarcode = new MesBaseBindBarcode();
baseBindBarcode.setBindBarcode(productBarcodeInfo.getBarcodeInfo()); baseBindBarcode.setBindBarcode(productBarcodeInfo.getBarcodeInfo());
baseBindBarcode.setBarcodeId(mesBaseBarcodeInfo.getBarcodeId()); baseBindBarcode.setBarcodeId(mesBaseBarcodeInfo.getBarcodeId());
baseBindBarcode.setBarcodeInfo(barcodeInfo); baseBindBarcode.setBarcodeInfo(barcodeInfo);
baseBindBarcode.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId()); baseBindBarcode.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId());
baseBindBarcode.setMaterialId(bindMaterialId);//四楼成品条码的物料id作为五楼原材料的物料id
baseBindBarcode.setProductId(parentBom.getMaterialId());
baseBindBarcode.setCreateBy(userName); baseBindBarcode.setCreateBy(userName);
baseBindBarcode.setCreateTime(new Date()); baseBindBarcode.setCreateTime(new Date());
toInsertedBaseBindBarcodeList.add(baseBindBarcode); toInsertedBaseBindBarcodeList.add(baseBindBarcode);
} }
}
if (allErrorMsgBuilder.length() > 0) {
throw new ServiceException(allErrorMsgBuilder.toString());
}
return mesBaseBindBarcodeMapper.batchMesBaseBindBarcode(toInsertedBaseBindBarcodeList); return mesBaseBindBarcodeMapper.batchMesBaseBindBarcode(toInsertedBaseBindBarcodeList);
} }
@ -1357,8 +1409,10 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
throw new ServiceException(errorMsgBuilder.toString()); throw new ServiceException(errorMsgBuilder.toString());
} }
String barcodeInfo = Seq.getId(Seq.mesPurchaseVirtualBarcodeSeqType, Seq.mesPurchaseVirtualBarcodeCode);
//新建虚拟物料 //新建虚拟物料
String barcodeInfo = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode);
Long materialId = this.insertNewVirtualMaterial(barcodeInfo, userName, currentDate); Long materialId = this.insertNewVirtualMaterial(barcodeInfo, userName, currentDate);
//创建虚拟销售订单,保存对应的销售订单列表 //创建虚拟销售订单,保存对应的销售订单列表
@ -1506,7 +1560,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
} }
/** /**
* *
* *

@ -8,20 +8,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="bindBarcodeId" column="bind_barcode_id" /> <result property="bindBarcodeId" column="bind_barcode_id" />
<result property="barcodeId" column="barcode_id" /> <result property="barcodeId" column="barcode_id" />
<result property="barcodeInfo" column="barcode_info" /> <result property="barcodeInfo" column="barcode_info" />
<result property="saleOrderId" column="sale_order_id" />
<result property="bindBarcode" column="bind_barcode" /> <result property="bindBarcode" column="bind_barcode" />
<result property="saleOrderId" column="sale_order_id" />
<result property="materialId" column="material_id" />
<result property="productId" column="product_id" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
</resultMap> </resultMap>
<sql id="selectMesBaseBindBarcodeVo"> <sql id="selectMesBaseBindBarcodeVo">
select bind_barcode_id, barcode_id,barcode_info, sale_order_id,bind_barcode, create_by, create_time from mes_base_bind_barcode select bind_barcode_id, barcode_id,barcode_info, sale_order_id,material_id,product_id,bind_barcode, create_by, create_time from mes_base_bind_barcode
</sql> </sql>
<select id="selectMesBaseBindBarcodeList" parameterType="MesBaseBindBarcode" resultMap="MesBaseBindBarcodeResult"> <select id="selectMesBaseBindBarcodeList" parameterType="MesBaseBindBarcode" resultMap="MesBaseBindBarcodeResult">
<include refid="selectMesBaseBindBarcodeVo"/> <include refid="selectMesBaseBindBarcodeVo"/>
<where> <where>
<if test="barcodeId != null "> and barcode_id = #{barcodeId}</if> <if test="barcodeId != null "> and barcode_id = #{barcodeId}</if>
<if test="barcodeInfo != null and barcodeInfo != ''"> and barcode_info = #{barcodeInfo}</if>
<if test="bindBarcode != null and bindBarcode != ''"> and bind_barcode = #{bindBarcode}</if> <if test="bindBarcode != null and bindBarcode != ''"> and bind_barcode = #{bindBarcode}</if>
</where> </where>
</select> </select>
@ -37,6 +40,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="barcodeId != null">barcode_id,</if> <if test="barcodeId != null">barcode_id,</if>
<if test="barcodeInfo != null">barcode_info,</if> <if test="barcodeInfo != null">barcode_info,</if>
<if test="saleOrderId != null">sale_order_id,</if> <if test="saleOrderId != null">sale_order_id,</if>
<if test="materialId != null">material_id,</if>
<if test="productId != null">product_id,</if>
<if test="bindBarcode != null and bindBarcode != ''">bind_barcode,</if> <if test="bindBarcode != null and bindBarcode != ''">bind_barcode,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
@ -45,6 +50,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="barcodeId != null">#{barcodeId},</if> <if test="barcodeId != null">#{barcodeId},</if>
<if test="barcodeInfo != null">#{barcodeInfo},</if> <if test="barcodeInfo != null">#{barcodeInfo},</if>
<if test="saleOrderId != null">#{saleOrderId},</if> <if test="saleOrderId != null">#{saleOrderId},</if>
<if test="materialId != null">#{materialId},</if>
<if test="productId != null">#{productId},</if>
<if test="bindBarcode != null and bindBarcode != ''">#{bindBarcode},</if> <if test="bindBarcode != null and bindBarcode != ''">#{bindBarcode},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
@ -75,9 +82,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchMesBaseBindBarcode"> <insert id="batchMesBaseBindBarcode">
insert into mes_base_bind_barcode( bind_barcode_id, barcode_id, barcode_info, sale_order_id,bind_barcode, create_by, create_time) values insert into mes_base_bind_barcode( bind_barcode_id, barcode_id, barcode_info, sale_order_id,material_id,product_id,bind_barcode, create_by, create_time) values
<foreach item="item" index="index" collection="list" separator=","> <foreach item="item" index="index" collection="list" separator=",">
( #{item.bindBarcodeId}, #{item.barcodeId},#{item.barcodeInfo}, #{item.saleOrderId}, #{item.bindBarcode}, #{item.createBy}, #{item.createTime}) ( #{item.bindBarcodeId}, #{item.barcodeId},#{item.barcodeInfo}, #{item.saleOrderId}, #{item.materialId}, #{item.productId}, #{item.bindBarcode}, #{item.createBy}, #{item.createTime})
</foreach> </foreach>
</insert> </insert>

@ -164,7 +164,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
/** /**
* (5) * (5)
* *
* @param wmsProductInstockVo * @param wmsProductInstockVo
* @return * @return
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -174,7 +174,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER); R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData(); MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
if (baseBarcodeInfo == null) { if (baseBarcodeInfo == null) {
throw new ServiceException("物料码有误"); throw new ServiceException("物料码有误");
} }
Long productId = baseBarcodeInfo.getMaterialId(); Long productId = baseBarcodeInfo.getMaterialId();
@ -183,18 +183,52 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
if (baseLocation == null) { if (baseLocation == null) {
throw new ServiceException("库位编码有误"); throw new ServiceException("库位编码有误");
} }
//todo 仓库可存储此物料判断是否可以入此库位
Date currentDate = new Date(); Date currentDate = new Date();
String userName = SecurityUtils.getUsername(); String userName = SecurityUtils.getUsername();
if (baseBarcodeInfo.getMaterialId().equals(0L)) {//代表4楼到5楼合并的条码
String rawMaterialBarcode = baseBarcodeInfo.getProductBarcode();
if (StringUtils.isEmpty(rawMaterialBarcode)) {
throw new ServiceException("没有绑定原材料条码");
}
R<List<MesBaseBindBarcode>> baseBindBarcodeListData = remoteMesService.selectBindBarcodeListByBarcodeInfo(rawMaterialBarcode, SecurityConstants.INNER);
if (baseBindBarcodeListData == null) {
throw new RuntimeException("没有绑定的成品条码信息。");
}
List<MesBaseBindBarcode> baseBindBarcodeList = baseBindBarcodeListData.getData();
if (baseBindBarcodeList == null || baseBindBarcodeList.isEmpty()) {
throw new RuntimeException("没有绑定的成品条码信息!");
}
for(MesBaseBindBarcode baseBindBarcode:baseBindBarcodeList){
this.saveWmsProductInstock(baseLocation.getWarehouseId(), locationCode,
baseBarcodeInfo.getPlanCode(), baseBarcodeInfo.getPlanDetailCode(), null,
baseBindBarcode.getProductId(), userName, currentDate);
}
} else {
this.saveWmsProductInstock(baseLocation.getWarehouseId(), locationCode,
baseBarcodeInfo.getPlanCode(), baseBarcodeInfo.getPlanDetailCode(), materialBarcode,
productId, userName, currentDate);
}
//更新库存
updateProductStock(baseBarcodeInfo, locationCode, baseLocation.getWarehouseId(), baseLocation.getWarehouseFloor(), userName, currentDate);
return 1;
}
public void saveWmsProductInstock(Long warehouseId, String locationCode, String planCode, String planDetailCode, String materialBarcode,
Long productId, String userName, Date currentDate) {
WmsProductInstock wmsProductInstock = new WmsProductInstock(); WmsProductInstock wmsProductInstock = new WmsProductInstock();
wmsProductInstock.setWarehouseId(baseLocation.getWarehouseId()); wmsProductInstock.setWarehouseId(warehouseId);
wmsProductInstock.setLocationCode(locationCode); wmsProductInstock.setLocationCode(locationCode);
wmsProductInstock.setProductType(WmsConstants.PRODUCT_INSTOCK_STOCK_TYPE_PRODUCT); wmsProductInstock.setProductType(WmsConstants.PRODUCT_INSTOCK_STOCK_TYPE_PRODUCT);
wmsProductInstock.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL); wmsProductInstock.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL);
wmsProductInstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); wmsProductInstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
wmsProductInstock.setPlanCode(baseBarcodeInfo.getPlanCode()); wmsProductInstock.setPlanCode(planCode);
wmsProductInstock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode()); wmsProductInstock.setPlanDetailCode(planDetailCode);
wmsProductInstock.setProductBatch(materialBarcode); wmsProductInstock.setProductBatch(materialBarcode);
wmsProductInstock.setProductId(productId); wmsProductInstock.setProductId(productId);
wmsProductInstock.setInstockType(WmsConstants.PRODUCT_INSTOCK_INSTOCK_TYPE_PRODUCT); wmsProductInstock.setInstockType(WmsConstants.PRODUCT_INSTOCK_INSTOCK_TYPE_PRODUCT);
@ -204,15 +238,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService {
wmsProductInstock.setApplyDate(currentDate); wmsProductInstock.setApplyDate(currentDate);
//插入记录 //插入记录
int rows = wmsProductInstockMapper.insertWmsProductInstock(wmsProductInstock); wmsProductInstockMapper.insertWmsProductInstock(wmsProductInstock);
//插入明细
// insertWmsProductInstockDetail(wmsProductInstock, materialBarcode, productId, wmsProductInstockVo);
//更新库存
updateProductStock(baseBarcodeInfo, locationCode, baseLocation.getWarehouseId(), baseLocation.getWarehouseFloor(), userName, currentDate);
return rows;
} }

Loading…
Cancel
Save