forked from I3-YF/i3plus-mes-pcn-yfai
Merge remote-tracking branch 'origin/uat-temp-wj-chongqingdaqu-prod-lijiabatchreport' into uat-temp-wj-chongqingdaqu-prod-temp-publish0415
commit
5b67c38b3a
@ -0,0 +1,15 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.api.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesPackageRuleContext;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderExtModel;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
public interface IMesFengRenBatchReportService {
|
||||||
|
|
||||||
|
@ApiOperation(value = "缝纫批量汇报获取默认标包")
|
||||||
|
MesPackageRuleContext queryPackSpecQtyFengRenBatchReport(String organizeCode, String partNo);
|
||||||
|
|
||||||
|
@ApiOperation(value = "缝纫批量汇报")
|
||||||
|
MesProduceSnPrintModel doFengRenBatchReport(MesWorkOrderExtModel model);
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesFengRenBatchReportService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.IMesPackageNoGenerateStepService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderExtModel;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.StopWatch;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Api("缝纫批量汇报")
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(MesCommonConstant.MES_YANFEN)
|
||||||
|
public class MesFengRenBatchReportController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesPackageNoGenerateStepService packageNoGenerateStepService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesFengRenBatchReportService fengRenBatchReportService;
|
||||||
|
|
||||||
|
@GetMapping("/feng-ren-batch-report/get-pack-spec-qty")
|
||||||
|
@ApiOperation(value = "缝纫批量汇报获取默认标包")
|
||||||
|
public ResultBean queryPackSpecQtyFengRenBatchReport(String organizeCode, String partNo) {
|
||||||
|
try {
|
||||||
|
ValidatorBean.checkNotNull(organizeCode, "工厂代码不能为空");
|
||||||
|
ValidatorBean.checkNotNull(partNo, "零件编码不能为空");
|
||||||
|
return ResultBean.success("查询成功").setResultObject(fengRenBatchReportService.queryPackSpecQtyFengRenBatchReport(organizeCode, partNo));
|
||||||
|
} catch (ImppBusiException imppException) {
|
||||||
|
return ResultBean.fail(imppException);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/feng-ren-batch-report/do")
|
||||||
|
@ApiOperation(value = "缝纫批量汇报")
|
||||||
|
public ResultBean doFengRenBatchReport(MesWorkOrderExtModel model) {
|
||||||
|
log.info("工厂{}缝纫批量汇报 --- START --- PARAM:{} --- {}", model.getOrganizeCode(), JSONObject.toJSONString(model), Thread.currentThread().getName());
|
||||||
|
StopWatch stopWatch = new StopWatch();
|
||||||
|
stopWatch.start();
|
||||||
|
try {
|
||||||
|
ValidatorBean.checkNotNull(model.getOrganizeCode(), "工厂代码不能为空");
|
||||||
|
ValidatorBean.checkNotNull(model.getModifyUser(), "操作人不能为空");
|
||||||
|
ValidatorBean.checkNotNull(model.getPartNo(), "零件编码不能为空");
|
||||||
|
ValidatorBean.checkNotNull(model.getWorkOrderNo(), "生产工单号不能为空");
|
||||||
|
ValidatorBean.checkNotNull(model.getId(), "生产工单ID不能为空");
|
||||||
|
return ResultBean.success("汇报成功").setResultObject(fengRenBatchReportService.doFengRenBatchReport(model));
|
||||||
|
} catch (ImppBusiException imppException) {
|
||||||
|
log.info("工厂{}缝纫批量汇报 --- ImppBusiException --- {} --- {}", model.getOrganizeCode(), imppException.getErrorMsg(), Thread.currentThread().getName());
|
||||||
|
return ResultBean.fail(imppException);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("工厂{}缝纫批量汇报 --- Exception --- {} --- {}", model.getOrganizeCode(), JSONObject.toJSONString(e), Thread.currentThread().getName());
|
||||||
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||||
|
} finally {
|
||||||
|
stopWatch.stop();
|
||||||
|
log.info("工厂{}缝纫批量汇报 --- FINALLY --- 耗时:{} --- {}", model.getOrganizeCode(), stopWatch.getTotalTimeMillis(), Thread.currentThread().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||||
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPackage;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 包装条码打印
|
||||||
|
* @Reference :
|
||||||
|
* @Author : wangjie
|
||||||
|
* @CreateDate : 2024/9/29 16:43
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class YfaiPackageNoFengRenPrintStrategy implements IPrintTemplateStrategyService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesCustomerPartService mesCustomerPartService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel model,
|
||||||
|
MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean,
|
||||||
|
Boolean isStep) {
|
||||||
|
|
||||||
|
MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) &&
|
||||||
|
!CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName()))
|
||||||
|
? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName())
|
||||||
|
: mesCustomerPartService.getMesCustomerPart(model.getOrganizeCode(), model.getPartNo());
|
||||||
|
|
||||||
|
// 返回的结果集合
|
||||||
|
List<Map<String, Object>> printDataMapList = new ArrayList<>();
|
||||||
|
if (!isStep) {
|
||||||
|
model.getPackageList().forEach(o -> printDataMapList.add(getPrintMap(model, o, customerPart)));
|
||||||
|
model.setPrintContextList(printDataMapList);
|
||||||
|
} else {
|
||||||
|
model.getPackageList().forEach(o -> printDataMapList.add(getPrintMap(model, o, customerPart)));
|
||||||
|
model.getPrintContextList().add(packResultMap(model, printDataMapList));
|
||||||
|
}
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> packResultMap(MesProduceSnPrintModel printModel, List<Map<String, Object>> printTemplateDateList) {
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
resultMap.put(MesPcnExtConstWords.LABEL_TEMPLATE, printModel.getMesLabelTemplate());
|
||||||
|
resultMap.put(MesPcnExtConstWords.TEMPLATE_DATA, printTemplateDateList);
|
||||||
|
resultMap.put(MesPcnExtConstWords.TEMPLATE_CODE, printModel.getMesLabelTemplate().getTemplateCode());
|
||||||
|
resultMap.put(MesPcnExtConstWords.PRINTER, printModel.getPrinter());
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MesPrintedSnLog getMesPrintedSnLog(MesPackage packageDb, String userName, String printData) {
|
||||||
|
MesPrintedSnLog snLog = new MesPrintedSnLog();
|
||||||
|
snLog.setBarcode(packageDb.getPackageNo());
|
||||||
|
snLog.setPartNo(packageDb.getPartNo());
|
||||||
|
snLog.setPartName(packageDb.getPartName());
|
||||||
|
snLog.setPrintData(printData);
|
||||||
|
snLog.setOrganizeCode(packageDb.getOrganizeCode());
|
||||||
|
ConvertBean.serviceModelInitialize(snLog, userName);
|
||||||
|
return snLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> getPrintMap(MesProduceSnPrintModel model, MesPackage packageDb, MesCustomerPart customerPart) {
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
resultMap.put(MesPcnExtConstWords.PART_NO, packageDb.getPartNo());
|
||||||
|
resultMap.put(MesPcnExtConstWords.PART_NAME, packageDb.getPartName());
|
||||||
|
resultMap.put(MesPcnExtConstWords.CUST_PART_NO, null == customerPart ? MesPcnExtConstWords.EMPTY : customerPart.getCustPartNo());
|
||||||
|
resultMap.put(MesPcnExtConstWords.QR_CODE, packageDb.getPackageNo());
|
||||||
|
resultMap.put(MesPcnExtConstWords.QTY, packageDb.getQty().intValue());
|
||||||
|
resultMap.put(MesPcnExtConstWords.UNIT, packageDb.getUnit());
|
||||||
|
resultMap.put(MesPcnExtConstWords.PACK_SPEC_QTY, packageDb.getPackSpecQty().intValue());
|
||||||
|
resultMap.put(MesPcnExtConstWords.LOT_NO, packageDb.getLotNo().replaceAll(MesPcnExtConstWords.SEPARATOR, MesPcnExtConstWords.SLANT_R));
|
||||||
|
resultMap.put(MesPcnExtConstWords.BAR_CODE, packageDb.getPackageOneCode());
|
||||||
|
resultMap.put(MesPcnExtConstWords.MODIFY_DATE_TIME, packageDb.getModifyDatetime().replaceAll(MesPcnExtConstWords.SEPARATOR, MesPcnExtConstWords.SLANT_R));
|
||||||
|
model.getMesPrintedSnLogList().add(getMesPrintedSnLog(packageDb, model.getUserName(), JSONObject.toJSONString(resultMap)));
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue