|
|
|
@ -17,6 +17,7 @@ import com.hw.mes.domain.vo.MesBindBarcodeVo;
|
|
|
|
|
import com.hw.mes.mapper.*;
|
|
|
|
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.hw.printer.api.RemotePrinterService;
|
|
|
|
|
import com.hw.printer.api.domain.vo.PrintContentVo;
|
|
|
|
@ -331,6 +332,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
throw new ServiceException("此生产明细已经生成条码,不能重复生成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据生产明细代码获取生产明细
|
|
|
|
|
MesProductPlanDetail mesProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailCode(planDetailCode);
|
|
|
|
|
if (mesProductPlanDetail == null) {
|
|
|
|
|
throw new ServiceException("此生产明细不存在");
|
|
|
|
@ -348,13 +350,14 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
|
|
|
|
|
Long saleOrderId = productPlan.getSaleOrderId();
|
|
|
|
|
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()) &&
|
|
|
|
|
mesBaseBarcodeInfo.getSingleFlag().equals(MesConstants.MES_BARCODE_SINGLE_FLAG_YES)) {
|
|
|
|
|
String rawMaterialBarcode = mesBaseBarcodeInfo.getProductBarcode();
|
|
|
|
|
|
|
|
|
|
MesBaseBarcodeInfo rawBarcode = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(rawMaterialBarcode);
|
|
|
|
|
if (rawBarcode == null) {
|
|
|
|
|
throw new ServiceException("原材料条码有误");
|
|
|
|
@ -364,6 +367,12 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
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);
|
|
|
|
|
if (productBarcodeInfo != null) {
|
|
|
|
|
throw new ServiceException("此原材料条码已经生成过成品条码,不能重复生成");
|
|
|
|
@ -395,6 +404,13 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
throw new ServiceException("原材料条码的生产派工不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!rawBarcodeProductPlan.getDispatchCode().equals(productPlan.getDispatchCode())) {
|
|
|
|
|
throw new ServiceException("派工单号不一致,当前派工单号:" + productPlan.getDispatchCode()
|
|
|
|
|
+ ",原材料条码派工单号:" + rawBarcodeProductPlan.getDispatchCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
materialId = rawBarcode.getMaterialId();
|
|
|
|
|
|
|
|
|
|
mesBaseBarcodeInfo.setPalletInfoCode(rawBarcode.getPalletInfoCode());//重新绑定托盘号
|
|
|
|
|
mesBaseBarcodeInfo.setBindStatus(MesConstants.MES_BARCODE_BIND_STATUS_BINDING);
|
|
|
|
@ -421,12 +437,14 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
materialId = mesBaseBarcodeInfo.getMaterialId();
|
|
|
|
|
|
|
|
|
|
MesProductOrder mesProductOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(productPlan.getProductOrderId());
|
|
|
|
|
mesBaseBarcodeInfo.setCompleteFlag(mesProductOrder.getSaleType().equals(MesConstants.MES_PRODUCT_ORDER_SALE)
|
|
|
|
|
? MesConstants.MES_BASE_BARCODE_COMPLETE_FLAG_YES : MesConstants.MES_BASE_BARCODE_COMPLETE_FLAG_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesBaseBarcodeInfo.setBatchCode(barcode);// 成品的批次代码 == 条码内容
|
|
|
|
|
mesBaseBarcodeInfo.setBarcodeInfo(barcode);
|
|
|
|
|
mesBaseBarcodeInfo.setAmount(new BigDecimal(1));
|
|
|
|
@ -916,6 +934,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
StringBuilder palletBindErrorMsg = new StringBuilder();
|
|
|
|
|
boolean palletInfoCodeRepeat = false;
|
|
|
|
|
String palletInfoCode = "";
|
|
|
|
|
String barcodeInfo = "";
|
|
|
|
|
if (productBarcodesArr != null) {
|
|
|
|
|
for (String productBarcode : productBarcodesArr) {
|
|
|
|
|
//先根据之前的成品条码信息获取托盘信息
|
|
|
|
@ -945,6 +964,8 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
allErrorMsgBuilder.append(this.checkInternalMesBaseBarcode(productBarcode, productBarcodeInfo, mesBaseBarcodeInfo));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
barcodeInfo = Seq.getId(Seq.mesInternalVirtualBarcodeSeqType, Seq.mesInternalVirtualBarcodeCode);
|
|
|
|
|
} else {
|
|
|
|
|
MesBasePalletInfo basePalletInfo = mesBasePalletInfoMapper.selectMesBasePalletInfoByBarcode(productBarcodes);
|
|
|
|
|
if (basePalletInfo == null) {
|
|
|
|
@ -964,6 +985,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
basePalletInfoList.add(basePalletInfo);
|
|
|
|
|
|
|
|
|
|
materialId = productBarcodeInfo.getMaterialId();
|
|
|
|
|
barcodeInfo = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -975,7 +997,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
throw new ServiceException(allErrorMsgBuilder.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String barcodeInfo = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode);
|
|
|
|
|
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
Date currentDate = DateUtils.getNowDate();
|
|
|
|
|
//修改托盘信息的绑定关系为当前原材料的
|
|
|
|
@ -989,7 +1011,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
mesBasePalletInfoMapper.updateMesBasePalletInfo(toUpdatePalletInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesBaseBarcodeInfo.setBarcodeInfo(barcodeInfo);
|
|
|
|
|
mesBaseBarcodeInfo.setBatchCode(barcodeInfo);
|
|
|
|
|
mesBaseBarcodeInfo.setMaterialId(materialId);
|
|
|
|
@ -1025,15 +1046,46 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
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();
|
|
|
|
|
baseBindBarcode.setBindBarcode(productBarcodeInfo.getBarcodeInfo());
|
|
|
|
|
baseBindBarcode.setBarcodeId(mesBaseBarcodeInfo.getBarcodeId());
|
|
|
|
|
baseBindBarcode.setBarcodeInfo(barcodeInfo);
|
|
|
|
|
baseBindBarcode.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId());
|
|
|
|
|
baseBindBarcode.setMaterialId(bindMaterialId);//四楼成品条码的物料id作为五楼原材料的物料id
|
|
|
|
|
baseBindBarcode.setProductId(parentBom.getMaterialId());
|
|
|
|
|
baseBindBarcode.setCreateBy(userName);
|
|
|
|
|
baseBindBarcode.setCreateTime(new Date());
|
|
|
|
|
toInsertedBaseBindBarcodeList.add(baseBindBarcode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (allErrorMsgBuilder.length() > 0) {
|
|
|
|
|
throw new ServiceException(allErrorMsgBuilder.toString());
|
|
|
|
|
}
|
|
|
|
|
return mesBaseBindBarcodeMapper.batchMesBaseBindBarcode(toInsertedBaseBindBarcodeList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1357,8 +1409,10 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
//创建虚拟销售订单,保存对应的销售订单列表
|
|
|
|
@ -1506,7 +1560,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询绑定的成品条码信息
|
|
|
|
|
*
|
|
|
|
|