|
|
|
@ -23,9 +23,12 @@ import com.hw.mes.domain.MesOrderBind;
|
|
|
|
|
import com.hw.mes.domain.MesProductOrder;
|
|
|
|
|
import com.hw.mes.domain.vo.MesBindBarcodeVo;
|
|
|
|
|
import com.hw.mes.mapper.*;
|
|
|
|
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
|
|
|
|
|
import com.hw.printer.api.RemotePrinterService;
|
|
|
|
|
import com.hw.printer.api.domain.vo.PrintContentVo;
|
|
|
|
|
import com.hw.printer.api.domain.vo.PrinterVo;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.hw.mes.service.IMesBaseBarcodeInfoService;
|
|
|
|
@ -113,19 +116,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
|
|
|
|
|
// 生成成品条码
|
|
|
|
|
else if (mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_PRODUCT)) {
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
// 批次代码 == 条码内容
|
|
|
|
|
int frequency = mesBaseBarcodeInfo.getAmount().intValue();
|
|
|
|
|
for (int i = 0; i < frequency; i++) {
|
|
|
|
|
String code = Seq.getId(Seq.mesCompBarcodeSeqType, Seq.mesCompBarcodeCode);
|
|
|
|
|
mesBaseBarcodeInfo.setBatchCode(code);
|
|
|
|
|
mesBaseBarcodeInfo.setBarcodeInfo(code);
|
|
|
|
|
mesBaseBarcodeInfo.setAmount(new BigDecimal(1));
|
|
|
|
|
mesBaseBarcodeInfo.setCreateTime(currentDate);
|
|
|
|
|
mesBaseBarcodeInfo.setCreateBy(userName);
|
|
|
|
|
mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo);
|
|
|
|
|
}
|
|
|
|
|
generateProductBarcode(mesBaseBarcodeInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
@ -195,6 +186,35 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void generateProductBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) {
|
|
|
|
|
int dispatchAmount = mesBaseBarcodeInfo.getDispatchAmount().intValue();
|
|
|
|
|
int generateAmount = mesBaseBarcodeInfo.getAmount().intValue();//获取要生成的条码数量,目前也是派工的数量
|
|
|
|
|
|
|
|
|
|
String planCode = mesBaseBarcodeInfo.getPlanCode();
|
|
|
|
|
MesBaseBarcodeInfo queryBarcodeInfo = new MesBaseBarcodeInfo();
|
|
|
|
|
queryBarcodeInfo.setPlanCode(planCode);
|
|
|
|
|
List<MesBaseBarcodeInfo> mesBaseBarcodeInfos = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoList(queryBarcodeInfo);
|
|
|
|
|
int hadGeneratedLabelCount = mesBaseBarcodeInfos == null ? 0 : mesBaseBarcodeInfos.size();//获取已经生成条码的数量
|
|
|
|
|
|
|
|
|
|
if (generateAmount + hadGeneratedLabelCount > dispatchAmount) {
|
|
|
|
|
throw new ServiceException("新增条码数量总数不能大于" + dispatchAmount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
for (int i = 0; i < generateAmount; i++) {
|
|
|
|
|
String barcode = Seq.getId(Seq.mesCompBarcodeSeqType, Seq.mesCompBarcodeCode);
|
|
|
|
|
mesBaseBarcodeInfo.setBatchCode(barcode);// 成品的批次代码 == 条码内容
|
|
|
|
|
mesBaseBarcodeInfo.setBarcodeInfo(barcode);
|
|
|
|
|
mesBaseBarcodeInfo.setAmount(new BigDecimal(1));
|
|
|
|
|
mesBaseBarcodeInfo.setCreateTime(currentDate);
|
|
|
|
|
mesBaseBarcodeInfo.setBatchFlag(MesConstants.NOT_IS_BATCH);
|
|
|
|
|
mesBaseBarcodeInfo.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_YES);
|
|
|
|
|
mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MesBaseBarcodeInfo getInsertedBarcodeInfo(MesBaseBarcodeInfo mesBaseBarcodeInfo, String batchCode, String userName, Date currentDate) {
|
|
|
|
|
MesBaseBarcodeInfo toInsertedBarcodeInfo = new MesBaseBarcodeInfo();
|
|
|
|
|
//同一批次的批次代码相同
|
|
|
|
@ -259,14 +279,15 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 打印条码
|
|
|
|
|
* 打印物料条码
|
|
|
|
|
*
|
|
|
|
|
* @param barcodeIds
|
|
|
|
|
* @param printType 打印类型(1原材料 3成品)
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public int printBarcodes(Long[] barcodeIds) {
|
|
|
|
|
public int printBarcodes(Long[] barcodeIds, String printType) {
|
|
|
|
|
//获取条码List
|
|
|
|
|
List<List<PrintContentVo>> printContents = new ArrayList<>();
|
|
|
|
|
List<MesBaseBarcodeInfo> toUpdatedBaseBarcodeInfos = new ArrayList<>();
|
|
|
|
@ -278,27 +299,47 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
throw new ServiceException("此物料条码[" + mesBaseBarcodeInfo.getBarcodeInfo() + "]已经打印过,不能重复打印");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String materialName = mesBaseBarcodeInfo.getMaterialName();
|
|
|
|
|
List<PrintContentVo> printContentVos = new ArrayList<>();
|
|
|
|
|
PrintContentVo printMaterialName = new PrintContentVo();
|
|
|
|
|
printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME);
|
|
|
|
|
printMaterialName.setValue(mesBaseBarcodeInfo.getMaterialName());
|
|
|
|
|
printMaterialName.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printMaterialCode = new PrintContentVo();
|
|
|
|
|
printMaterialCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_CODE);
|
|
|
|
|
printMaterialCode.setValue(mesBaseBarcodeInfo.getMaterialCode());
|
|
|
|
|
printMaterialCode.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printPoNo = new PrintContentVo();
|
|
|
|
|
printPoNo.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_PO_NO);
|
|
|
|
|
printPoNo.setValue(mesBaseBarcodeInfo.getPoNo());
|
|
|
|
|
printPoNo.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printPreMaterial = new PrintContentVo();
|
|
|
|
|
// if (mesBaseBarcodeInfo.getBindFlag() == null) {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
PrintContentVo printSaleOrderCode = new PrintContentVo();
|
|
|
|
|
printSaleOrderCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_SALE_ORDER_CODE);
|
|
|
|
|
printSaleOrderCode.setValue(mesBaseBarcodeInfo.getSaleorderCode());
|
|
|
|
|
printSaleOrderCode.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PrintContentVo printBarCode = new PrintContentVo();
|
|
|
|
|
printBarCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QRCODE);
|
|
|
|
|
printBarCode.setValue(mesBaseBarcodeInfo.getBarcodeInfo());
|
|
|
|
|
printBarCode.setType(PrintContentVo.TYPE_QRCODE);
|
|
|
|
|
|
|
|
|
|
if (printType.equals(PrinterVo.PRINT_TYPE_RAW_LABEL)) {
|
|
|
|
|
PrintContentVo printMaterialName = new PrintContentVo();
|
|
|
|
|
printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME);
|
|
|
|
|
materialName = materialName.length() <= 10 ? "\n" + materialName : materialName;
|
|
|
|
|
printMaterialName.setValue(materialName);
|
|
|
|
|
printMaterialName.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printBatchCode = new PrintContentVo();
|
|
|
|
|
printBatchCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_BATCH_CODE);
|
|
|
|
|
printBatchCode.setValue(mesBaseBarcodeInfo.getBatchCode());
|
|
|
|
|
printBatchCode.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printPoNo = new PrintContentVo();
|
|
|
|
|
printPoNo.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_PO_NO);
|
|
|
|
|
printPoNo.setValue(mesBaseBarcodeInfo.getPoNo());
|
|
|
|
|
printPoNo.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
String printPreMaterialKey = mesBaseBarcodeInfo.getBindFlag() != null && mesBaseBarcodeInfo.getBindFlag().equals(MesConstants.MES_MATERIAL_BIND_FLAG_YES)
|
|
|
|
|
? PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_YES : PrintContentVo.RAW_MATERIAL_LABEL_KEY_PRE_MATERIAL_NO;
|
|
|
|
|
printPreMaterial.setKey(printPreMaterialKey);
|
|
|
|
@ -309,11 +350,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
printMaterialSpec.setValue(mesBaseBarcodeInfo.getMaterialSpec());
|
|
|
|
|
printMaterialSpec.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printSaleOrderCode = new PrintContentVo();
|
|
|
|
|
printSaleOrderCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_SALE_ORDER_CODE);
|
|
|
|
|
printSaleOrderCode.setValue(mesBaseBarcodeInfo.getSaleorderCode());
|
|
|
|
|
printSaleOrderCode.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printQty = new PrintContentVo();
|
|
|
|
|
printQty.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QTY);
|
|
|
|
|
DecimalFormat df = new DecimalFormat("#.##");
|
|
|
|
@ -321,24 +357,36 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
printQty.setValue(formattedNumber);
|
|
|
|
|
printQty.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printBatchCode = new PrintContentVo();
|
|
|
|
|
printBatchCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_BATCH_CODE);
|
|
|
|
|
printBatchCode.setValue(mesBaseBarcodeInfo.getBatchCode());
|
|
|
|
|
printBatchCode.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
printContentVos.add(printMaterialName);
|
|
|
|
|
printContentVos.add(printBatchCode);
|
|
|
|
|
printContentVos.add(printPoNo);
|
|
|
|
|
printContentVos.add(printMaterialSpec);
|
|
|
|
|
printContentVos.add(printQty);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printBarCode = new PrintContentVo();
|
|
|
|
|
printBarCode.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QRCODE);
|
|
|
|
|
printBarCode.setValue(mesBaseBarcodeInfo.getBarcodeInfo());
|
|
|
|
|
printBarCode.setType(PrintContentVo.TYPE_QRCODE);
|
|
|
|
|
} else if (printType.equals(PrinterVo.PRINT_TYPE_PRODUCT_LABEL)) {
|
|
|
|
|
PrintContentVo printMaterialName = new PrintContentVo();
|
|
|
|
|
materialName = materialName.length() <= 8 ? "\n" + materialName : materialName;
|
|
|
|
|
printMaterialName.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_MATERIAL_NAME);
|
|
|
|
|
printMaterialName.setValue(materialName);
|
|
|
|
|
printMaterialName.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printQty = new PrintContentVo();
|
|
|
|
|
printQty.setKey(PrintContentVo.RAW_MATERIAL_LABEL_KEY_QTY);
|
|
|
|
|
printQty.setValue("1");
|
|
|
|
|
printQty.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
|
|
|
|
|
PrintContentVo printPlanCode = new PrintContentVo();
|
|
|
|
|
printPlanCode.setKey(PrintContentVo.PRODUCT_PLAN_CODE);
|
|
|
|
|
printPlanCode.setValue(mesBaseBarcodeInfo.getPlanCode());
|
|
|
|
|
printPlanCode.setType(PrintContentVo.TYPE_TEXT);
|
|
|
|
|
printContentVos.add(printMaterialName);
|
|
|
|
|
printContentVos.add(printQty);
|
|
|
|
|
printContentVos.add(printPlanCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printContentVos.add(printMaterialCode);
|
|
|
|
|
printContentVos.add(printPoNo);
|
|
|
|
|
printContentVos.add(printPreMaterial);
|
|
|
|
|
printContentVos.add(printMaterialSpec);
|
|
|
|
|
printContentVos.add(printSaleOrderCode);
|
|
|
|
|
printContentVos.add(printQty);
|
|
|
|
|
printContentVos.add(printBatchCode);
|
|
|
|
|
printContentVos.add(printBarCode);
|
|
|
|
|
|
|
|
|
|
String checkStatus = mesBaseBarcodeInfo.getCheckStatus() == null ? "" : mesBaseBarcodeInfo.getCheckStatus();
|
|
|
|
@ -367,8 +415,12 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
this.updateMesBaseBarcodeInfo(toUpdateMesBaseBarcodeInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PrinterVo printerVo = new PrinterVo();
|
|
|
|
|
printerVo.setPrintType(printType);
|
|
|
|
|
printerVo.setPrintContents(printContents);
|
|
|
|
|
|
|
|
|
|
//调用的打印接口
|
|
|
|
|
R<?> printResultR = remotePrinterService.printBarcodes(printContents, SecurityConstants.INNER);
|
|
|
|
|
R<?> printResultR = remotePrinterService.printBarcodes(printerVo, SecurityConstants.INNER);
|
|
|
|
|
if (printResultR.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
|
|
|
|
|
throw new RuntimeException(printResultR.getMsg());
|
|
|
|
|
}
|
|
|
|
@ -532,14 +584,21 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重新生成条码信息,之前的作废
|
|
|
|
|
*
|
|
|
|
|
* @param mesBaseBarcodeInfo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public int regenerateBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) {
|
|
|
|
|
String barcodeType = mesBaseBarcodeInfo.getBarcodeType();
|
|
|
|
|
String oldBarcode = mesBaseBarcodeInfo.getBarcodeInfo();
|
|
|
|
|
String newBarcode = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode);
|
|
|
|
|
String newBarcode = "";
|
|
|
|
|
if (barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)) {
|
|
|
|
|
newBarcode = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode);
|
|
|
|
|
} else {
|
|
|
|
|
newBarcode = Seq.getId(Seq.mesCompBarcodeSeqType, Seq.mesCompBarcodeCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
@ -557,7 +616,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
|
|
|
|
|
mesBaseBarcodeInfo.setUpdateTime(currentDate);
|
|
|
|
|
return mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|