forked from I3-YF/i3plus-mes-pcn-yfai
Merge remote-tracking branch 'origin/dev' into dev
commit
efc977e0b9
@ -0,0 +1,23 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.api.busi.ford;
|
||||
|
||||
import cn.estsh.i3plus.pojo.mes.bean.ford.MesFordFetchParameter;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.ford.MesFordJsaSortInfoWithFetchWeb;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IFordFetchWebService {
|
||||
|
||||
void insertParams(MesFordFetchParameter parameter);
|
||||
|
||||
|
||||
void updateParams(MesFordFetchParameter parameter);
|
||||
|
||||
|
||||
void deleteParams(Long id,String UserName);
|
||||
|
||||
MesFordFetchParameter queryParams(Long id);
|
||||
|
||||
List<MesFordFetchParameter> queryParams(String organizeCode);
|
||||
|
||||
List<MesFordJsaSortInfoWithFetchWeb> doFetchData(Long id, String organizeCode);
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi.ford;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.ford.IFordFetchWebService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.ford.MesFordFetchParameter;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.ford.MesFordJsaSortInfoWithFetchWeb;
|
||||
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||
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.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "福特web抓单")
|
||||
@RequestMapping(MesCommonConstant.MES_YANFEN + "/fetch-web")
|
||||
@Slf4j
|
||||
public class MesFordFetchWebController {
|
||||
|
||||
@Autowired
|
||||
private IFordFetchWebService fordFetchWebService;
|
||||
|
||||
@PostMapping(value = "/param/save")
|
||||
@ApiOperation(value = "保存抓单参数")
|
||||
public ResultBean saveParams(@RequestBody MesFordFetchParameter params) {
|
||||
try {
|
||||
fordFetchWebService.insertParams(params);
|
||||
} catch (Exception e) {
|
||||
return ResultBean.fail(e.getMessage());
|
||||
}
|
||||
return ResultBean.success("保存成功!");
|
||||
}
|
||||
|
||||
@PostMapping(value = "/param/update")
|
||||
@ApiOperation(value = "更新抓单参数")
|
||||
public ResultBean updateParams(@RequestBody MesFordFetchParameter params) {
|
||||
try {
|
||||
fordFetchWebService.updateParams(params);
|
||||
} catch (Exception e) {
|
||||
return ResultBean.fail(e.getMessage());
|
||||
}
|
||||
return ResultBean.success("更新成功!");
|
||||
}
|
||||
|
||||
@GetMapping(value = "/param/del/{id}/{userName}")
|
||||
@ApiOperation(value = "删除抓单参数")
|
||||
public ResultBean updateParams(@PathVariable Long id, @PathVariable String userName) {
|
||||
try {
|
||||
fordFetchWebService.deleteParams(id, userName);
|
||||
} catch (Exception e) {
|
||||
return ResultBean.fail(e.getMessage());
|
||||
}
|
||||
return ResultBean.success("删除成功!");
|
||||
}
|
||||
|
||||
@GetMapping(value = "/param/query/{id}")
|
||||
@ApiOperation(value = "查询抓单参数")
|
||||
public ResultBean queryParams(@PathVariable Long id) {
|
||||
MesFordFetchParameter parameter;
|
||||
try {
|
||||
parameter = fordFetchWebService.queryParams(id);
|
||||
} catch (Exception e) {
|
||||
return ResultBean.fail(e.getMessage());
|
||||
}
|
||||
return ResultBean.success("查询成功!").setResultObject(parameter);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/param/query/list/{organizeCode}")
|
||||
@ApiOperation(value = "查询抓单参数")
|
||||
public ResultBean queryParamList(@PathVariable String organizeCode) {
|
||||
List<MesFordFetchParameter> mesFordFetchParameters;
|
||||
try {
|
||||
mesFordFetchParameters = fordFetchWebService.queryParams(organizeCode);
|
||||
} catch (Exception e) {
|
||||
return ResultBean.fail(e.getMessage());
|
||||
}
|
||||
return ResultBean.success("查询成功!").setResultList(mesFordFetchParameters);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/param/data/{id}/{organizeCode}")
|
||||
@ApiOperation(value = "定时抓单")
|
||||
public ResultBean queryData(@PathVariable Long id,@PathVariable String organizeCode) {
|
||||
List<MesFordJsaSortInfoWithFetchWeb> mesFordJsaSortInfoWithFetchWebs;
|
||||
try {
|
||||
mesFordJsaSortInfoWithFetchWebs = fordFetchWebService.doFetchData(id, organizeCode);
|
||||
} catch (Exception e) {
|
||||
return ResultBean.fail(e.getMessage());
|
||||
}
|
||||
return ResultBean.success("查询成功").setResultList(mesFordJsaSortInfoWithFetchWebs);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.ford;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.ford.IFordFetchWebService;
|
||||
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.ford.MesFordFetchParameter;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.ford.MesFordJsaSortInfoWithFetchWeb;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.ford.MesFordFetchParameterRepository;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.ford.MesFordJsaSortInfoWithFetchWebRepository;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.HttpCookie;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MesFordFetchWebServiceImpl implements IFordFetchWebService {
|
||||
@Autowired
|
||||
private MesFordFetchParameterRepository paramRao;
|
||||
|
||||
@Autowired
|
||||
private MesFordJsaSortInfoWithFetchWebRepository fetchWebRao;
|
||||
|
||||
@Override
|
||||
public void insertParams(MesFordFetchParameter parameter) {
|
||||
ConvertBean.saveOrUpdate(parameter, parameter.getCreateUser());
|
||||
paramRao.insert(parameter);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateParams(MesFordFetchParameter parameter) {
|
||||
ConvertBean.saveOrUpdate(parameter, parameter.getCreateUser());
|
||||
paramRao.update(parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteParams(Long id,String userName) {
|
||||
paramRao.deleteWeaklyById(id,userName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MesFordFetchParameter queryParams(Long id) {
|
||||
Optional<MesFordFetchParameter> params = paramRao.findById(id);
|
||||
return params.orElseGet(MesFordFetchParameter::new);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MesFordFetchParameter> queryParams(String organizeCode) {
|
||||
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
||||
return paramRao.findByHqlWhere(ddlPackBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MesFordJsaSortInfoWithFetchWeb> doFetchData(Long id, String organizeCode) {
|
||||
List<MesFordJsaSortInfoWithFetchWeb> infoList = new ArrayList<>();
|
||||
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
||||
DdlPreparedPack.getNumEqualPack(id,"id",ddlPackBean);
|
||||
List<MesFordFetchParameter> list = paramRao.findByHqlWhere(ddlPackBean);
|
||||
if (list.isEmpty()) {
|
||||
throw ImppExceptionBuilder.newInstance().setErrorDetail("未查询出当前配置,请检查数据!").build();
|
||||
}
|
||||
MesFordFetchParameter parameter = list.get(0);
|
||||
//尝试登录
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("username", parameter.getUid());
|
||||
paramMap.put("password", parameter.getPwd());
|
||||
paramMap.put("t", String.valueOf(System.currentTimeMillis()));
|
||||
String body = "username="+parameter.getUid()+"&password="+parameter.getPwd()+"&t="+ System.currentTimeMillis();
|
||||
String loginUrl = parameter.getLoginUrl();
|
||||
HttpResponse loginResponse = HttpRequest.post(loginUrl).body(body)
|
||||
.header("Content-Type","application/x-www-form-urlencoded").timeout(60000).execute();
|
||||
log.info("doFetchData-打印的返回值是:{}",loginResponse.body());
|
||||
if (loginResponse.getStatus() != 200){
|
||||
log.info("doFetchData-登录失败,需要重新登录!返回内容为:{}",loginResponse.body());
|
||||
}
|
||||
List<HttpCookie> cookies = loginResponse.getCookies();
|
||||
//拼接请求参数
|
||||
//time=0.9656002469020775&maxpage=5&trigger=B100VR12&st=2023-05-12%2005:00:00&et=2023-05-12%2023:59:59&catacode=0&itemcode=0
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("maxpage",parameter.getPageSize() != null ? parameter.getPageSize().toString() : "1");
|
||||
map.put("trigger",parameter.getInfoPointCode());
|
||||
map.put("st",parameter.getStartDateTime());
|
||||
map.put("et",parameter.getEndDateTime());
|
||||
map.put("catacode","0");
|
||||
map.put("itemcode","0");
|
||||
HttpResponse response = HttpRequest.get(parameter.getFetchUrl()).cookie(cookies).timeout(60000).form(map).execute();
|
||||
log.info("doFetchData-查询出来的内容为:{}",response.body());
|
||||
Document doc = Jsoup.parse(response.body());
|
||||
Elements trList = doc.select("tr");
|
||||
for (int i = 1; i < trList.size(); i++) {
|
||||
Elements tdList = trList.get(i).select("td");
|
||||
MesFordJsaSortInfoWithFetchWeb webInfo = new MesFordJsaSortInfoWithFetchWeb();
|
||||
if (tdList.get(0).text().equals("无数据") || StringUtils.isBlank(tdList.get(0).text())){
|
||||
break;
|
||||
}
|
||||
webInfo.setSeq(Long.parseLong(tdList.get(0).text()));
|
||||
webInfo.setFetchDate(tdList.get(1).text());
|
||||
webInfo.setFetchTime(tdList.get(2).text());
|
||||
webInfo.setVinCode(tdList.get(3).text());
|
||||
webInfo.setPartNo(tdList.get(4).text());
|
||||
webInfo.setPartName(tdList.get(5).text());
|
||||
webInfo.setColorCode(tdList.get(6).text());
|
||||
webInfo.setInfo0008(tdList.get(7).text());
|
||||
webInfo.setSeqContext(tdList.get(8).text());
|
||||
webInfo.setRemark(tdList.get(9).text());
|
||||
webInfo.setInfoPointDesc(tdList.get(10).text());
|
||||
webInfo.setFetchType(1); //抓取类型
|
||||
webInfo.setDataStatus(200);
|
||||
webInfo.setOrganizeCode(organizeCode);
|
||||
webInfo.setInfoPointCode(parameter.getInfoPointCode());
|
||||
webInfo.setCustOrganizeCode(parameter.getCustOrganizeCode());
|
||||
ConvertBean.saveOrUpdate(webInfo,"doFetchData");
|
||||
//校验是否已经查询过
|
||||
DdlPackBean webInfoPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
||||
DdlPreparedPack.getNumEqualPack(webInfo.getSeq(),"seq",webInfoPackBean);
|
||||
DdlPreparedPack.getStringEqualPack(webInfo.getFetchDate(),"fetchDate",webInfoPackBean);
|
||||
DdlPreparedPack.getStringEqualPack(webInfo.getFetchTime(),"fetchTime",webInfoPackBean);
|
||||
int count = fetchWebRao.findByHqlWhereCount(webInfoPackBean);
|
||||
if (count > 0){
|
||||
continue;
|
||||
}
|
||||
fetchWebRao.insert(webInfo);
|
||||
infoList.add(webInfo);
|
||||
}
|
||||
|
||||
return infoList;
|
||||
}
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
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.api.base.IMesPartService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPrintedSnLogService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
||||
import cn.estsh.i3plus.mes.pcn.util.DateUtil;
|
||||
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||
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 cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description : 装配目视单标签打印
|
||||
* @Reference :
|
||||
* @Author : Castle
|
||||
* @CreateDate : 2024/6/17 16:43
|
||||
* @Modify:
|
||||
**/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ChengDuSplitFixCharPrintStrategy implements IPrintTemplateStrategyService {
|
||||
@Autowired
|
||||
private ISyncFuncService syncFuncService;
|
||||
|
||||
@Autowired
|
||||
private SnowflakeIdMaker snowflakeIdMaker;
|
||||
|
||||
@Autowired
|
||||
private IMesPartService mesPartService;
|
||||
|
||||
@Autowired
|
||||
private IMesPrintedSnLogService mesPrintedSnLogService;
|
||||
|
||||
@Autowired
|
||||
private IMesCustomerPartService mesCustomerPartService;
|
||||
|
||||
@Override
|
||||
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
|
||||
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
|
||||
//物料信息
|
||||
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
|
||||
MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) && !CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName())) ? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(organizeCode,mesProduceSnPrintModel.getPartNo());
|
||||
if (!isStep){
|
||||
if (!Objects.isNull(customerPart)) {
|
||||
genSerialNoModel.setCustPartNo(customerPart.getCustPartNo());
|
||||
}
|
||||
for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
|
||||
//保存条码信息
|
||||
MesProduceSn produceSn = generateMesProduceSn(mesPart, syncFuncService.syncSerialNo(genSerialNoModel.partSnParam(mesPart.getPartSnParam()), mesProduceSnPrintModel.getUserName(), organizeCode, 1).getResultList().get(0).toString(), mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty());
|
||||
//封装打印信息
|
||||
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, customerPart);
|
||||
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear();
|
||||
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
|
||||
Map<String, Object> printTemplateData = new HashMap<>(getPrintContextMap(produceSn, customerPart));
|
||||
mesProduceSnPrintModel.getPrintContextList().add(printTemplateData);
|
||||
//保存打印记录
|
||||
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesCustomPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel, printTemplateData));
|
||||
}
|
||||
}else{
|
||||
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
|
||||
//封装打印信息
|
||||
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, customerPart);
|
||||
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear();
|
||||
Map<String, Object> printTemplateData = new HashMap<>(getPrintContextMap(mesProduceSn, customerPart));
|
||||
List<Map<String, Object>> printDataMapList = new ArrayList<>();
|
||||
printDataMapList.add(printTemplateData);
|
||||
mesProduceSnPrintModel.getPrintContextList().add(packResultMap(mesProduceSnPrintModel, printDataMapList));
|
||||
|
||||
//保存打印记录
|
||||
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesCustomPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel, printTemplateData));
|
||||
}
|
||||
return mesProduceSnPrintModel;
|
||||
}
|
||||
|
||||
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty) {
|
||||
MesProduceSn mesProduceSn = new MesProduceSn();
|
||||
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
|
||||
mesProduceSn.setProductSn(sn);
|
||||
mesProduceSn.setCustSn(sn);
|
||||
mesProduceSn.setPartNo(mesPart.getPartNo());
|
||||
mesProduceSn.setPartName(mesPart.getPartName());
|
||||
mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate());
|
||||
mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate());
|
||||
mesProduceSn.setProdLabelTemplate(mesPart.getProductLabelTemplate());
|
||||
mesProduceSn.setQty(qty);
|
||||
mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue());
|
||||
mesProduceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
|
||||
mesProduceSn.setLotNo(TimeTool.getToday());
|
||||
mesProduceSn.setPrintCount(MesPcnExtConstWords.ONE);
|
||||
mesProduceSn.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue());
|
||||
mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode());
|
||||
ConvertBean.serviceModelInitialize(mesProduceSn, userName);
|
||||
return mesProduceSn;
|
||||
}
|
||||
|
||||
private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, MesCustomerPart customerPart) {
|
||||
MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel();
|
||||
mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo());
|
||||
mesProduceSnPrintDataModel.setPartName(produceSn.getPartName());
|
||||
if (!Objects.isNull(customerPart)) {
|
||||
mesProduceSnPrintDataModel.setCustPartNo(customerPart.getCustPartNo());
|
||||
}
|
||||
mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn());
|
||||
mesProduceSnPrintDataModel.setPrintDate(TimeTool.getNowTime(true));
|
||||
mesProduceSnPrintDataModel.setUserName(produceSn.getCreateUser());
|
||||
mesProduceSnPrintDataModel.setProductDate(TimeTool.parseStringFormat(produceSn.getLotNo(), DateUtil.SHORT_FORMAT, "yyyy/MM/dd"));
|
||||
return mesProduceSnPrintDataModel;
|
||||
}
|
||||
|
||||
private Map<String, Object> getPrintContextMap(MesProduceSn produceSn, MesCustomerPart customerPart) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
String[] splitSn = produceSn.getProductSn().split("#");
|
||||
if (splitSn.length < 3) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result.put(MesPcnExtConstWords.PART_NO, produceSn.getPartNo());
|
||||
result.put(MesPcnExtConstWords.PART_NAME, produceSn.getPartName());
|
||||
if (!Objects.isNull(customerPart)) {
|
||||
result.put(MesPcnExtConstWords.CUST_PART_NO, customerPart.getCustPartNo());
|
||||
}
|
||||
if (!StringUtils.isEmpty(splitSn[0])) {
|
||||
result.put("FIX_PART", splitSn[0].substring(0, 1));
|
||||
result.put(MesPcnExtConstWords.CUST_PART_NO, splitSn[0].substring(1));
|
||||
}
|
||||
if (!StringUtils.isEmpty(splitSn[1])) {
|
||||
result.put("FIX_DATE", splitSn[1].substring(0, 1));
|
||||
result.put(MesPcnExtConstWords.PRODUCT_DATE, splitSn[1].substring(1));
|
||||
}
|
||||
if (!StringUtils.isEmpty(splitSn[2])) {
|
||||
result.put("FIX_SUPPLIER", splitSn[2].substring(0, 1));
|
||||
result.put(MesPcnExtConstWords.SUPPLIER_CODE_L, splitSn[2].substring(1));
|
||||
}
|
||||
result.put(MesPcnExtConstWords.PRINT_BAR_CODE, produceSn.getProductSn());
|
||||
result.put(MesPcnExtConstWords.PRINT_DATE, TimeTool.getNowTime(true));
|
||||
result.put(MesPcnExtConstWords.USER_NAME, produceSn.getCreateUser());
|
||||
return result;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
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.api.base.IMesPartService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPrintedSnLogService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
||||
import cn.estsh.i3plus.mes.pcn.util.DateUtil;
|
||||
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||
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 cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||
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.Objects;
|
||||
|
||||
/**
|
||||
* @Description : 装配目视单标签打印
|
||||
* @Reference :
|
||||
* @Author : Castle
|
||||
* @CreateDate : 2024/6/17 16:43
|
||||
* @Modify:
|
||||
**/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ChengDuSplitPrintStrategy implements IPrintTemplateStrategyService {
|
||||
@Autowired
|
||||
private ISyncFuncService syncFuncService;
|
||||
|
||||
@Autowired
|
||||
private SnowflakeIdMaker snowflakeIdMaker;
|
||||
|
||||
@Autowired
|
||||
private IMesPartService mesPartService;
|
||||
|
||||
@Autowired
|
||||
private IMesPrintedSnLogService mesPrintedSnLogService;
|
||||
|
||||
@Autowired
|
||||
private IMesCustomerPartService mesCustomerPartService;
|
||||
|
||||
@Override
|
||||
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
|
||||
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
|
||||
//物料信息
|
||||
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
|
||||
MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) && !CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName())) ? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(organizeCode,mesProduceSnPrintModel.getPartNo());
|
||||
if (!isStep){
|
||||
if (!Objects.isNull(customerPart)) {
|
||||
genSerialNoModel.setCustPartNo(customerPart.getCustPartNo());
|
||||
}
|
||||
for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
|
||||
//保存条码信息
|
||||
MesProduceSn produceSn = generateMesProduceSn(mesPart, syncFuncService.syncSerialNo(genSerialNoModel.partSnParam(mesPart.getPartSnParam()), mesProduceSnPrintModel.getUserName(), organizeCode, 1).getResultList().get(0).toString(), mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty());
|
||||
//封装打印信息
|
||||
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, customerPart);
|
||||
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
|
||||
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
|
||||
//保存打印记录
|
||||
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel));
|
||||
}
|
||||
}else{
|
||||
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
|
||||
//封装打印信息
|
||||
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, customerPart);
|
||||
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(printDataModel);
|
||||
//保存打印记录
|
||||
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel));
|
||||
}
|
||||
return mesProduceSnPrintModel;
|
||||
}
|
||||
|
||||
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty) {
|
||||
MesProduceSn mesProduceSn = new MesProduceSn();
|
||||
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
|
||||
mesProduceSn.setProductSn(sn);
|
||||
mesProduceSn.setCustSn(sn);
|
||||
mesProduceSn.setPartNo(mesPart.getPartNo());
|
||||
mesProduceSn.setPartName(mesPart.getPartName());
|
||||
mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate());
|
||||
mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate());
|
||||
mesProduceSn.setProdLabelTemplate(mesPart.getProductLabelTemplate());
|
||||
mesProduceSn.setQty(qty);
|
||||
mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue());
|
||||
mesProduceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
|
||||
mesProduceSn.setLotNo(TimeTool.getToday());
|
||||
mesProduceSn.setPrintCount(MesPcnExtConstWords.ONE);
|
||||
mesProduceSn.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue());
|
||||
mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode());
|
||||
ConvertBean.serviceModelInitialize(mesProduceSn, userName);
|
||||
return mesProduceSn;
|
||||
}
|
||||
|
||||
private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, MesCustomerPart customerPart) {
|
||||
MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel();
|
||||
String[] splitSn = produceSn.getProductSn().split("#");
|
||||
if (splitSn.length < 3) {
|
||||
return mesProduceSnPrintDataModel;
|
||||
}
|
||||
|
||||
mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo());
|
||||
mesProduceSnPrintDataModel.setPartName(produceSn.getPartName());
|
||||
mesProduceSnPrintDataModel.setCustPartNo(splitSn[0] + "#");
|
||||
mesProduceSnPrintDataModel.setProductDate(splitSn[1] + "#");
|
||||
mesProduceSnPrintDataModel.setSupplierCode(splitSn[2] + "#");
|
||||
mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn());
|
||||
|
||||
mesProduceSnPrintDataModel.setPrintDate(TimeTool.getNowTime(true));
|
||||
mesProduceSnPrintDataModel.setUserName(produceSn.getCreateUser());
|
||||
return mesProduceSnPrintDataModel;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue