From 8d7fed8bbc790806ba4e2cb1907984a6a9be4a86 Mon Sep 17 00:00:00 2001 From: "castle.zang" Date: Tue, 4 Mar 2025 14:24:58 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E7=A6=8F=E7=89=B9=E6=8A=93=E5=8F=96?= =?UTF-8?q?=E7=BD=91=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/api/busi/ford/IFordFetchWebService.java | 22 +++++ .../busi/ford/MesFordFetchWebController.java | 94 ++++++++++++++++++++++ .../ford/MesFordFetchWebServiceImpl.java | 91 +++++++++++++++++++++ 3 files changed, 207 insertions(+) create mode 100644 modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ford/IFordFetchWebService.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/ford/MesFordFetchWebController.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ford/IFordFetchWebService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ford/IFordFetchWebService.java new file mode 100644 index 0000000..73e3dcb --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ford/IFordFetchWebService.java @@ -0,0 +1,22 @@ +package cn.estsh.i3plus.ext.mes.pcn.api.busi.ford; + +import cn.estsh.i3plus.pojo.mes.bean.ford.MesFordFetchParameter; + +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 queryParams(String organizeCode); + + void doFetchData(Long id,String organizeCode); +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/ford/MesFordFetchWebController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/ford/MesFordFetchWebController.java new file mode 100644 index 0000000..08f1199 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/ford/MesFordFetchWebController.java @@ -0,0 +1,94 @@ +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.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.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 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) { + + try { + } catch (Exception e) { + return ResultBean.fail(e.getMessage()); + } + return null; + } + + +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java new file mode 100644 index 0000000..fd271e4 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java @@ -0,0 +1,91 @@ +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.repository.ford.MesFordFetchParameterRepository; +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.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.net.HttpCookie; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@Service +@Slf4j +public class MesFordFetchWebServiceImpl implements IFordFetchWebService { + @Autowired + private MesFordFetchParameterRepository paramRao; + + @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 params = paramRao.findById(id); + return params.orElseGet(MesFordFetchParameter::new); + + } + + @Override + public List queryParams(String organizeCode) { + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode); + return paramRao.findByHqlWhere(ddlPackBean); + } + + @Override + public void doFetchData(Long id, String organizeCode) { + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode); + DdlPreparedPack.getNumEqualPack(id,"id",ddlPackBean); + List list = paramRao.findByHqlWhere(ddlPackBean); + if (list.isEmpty()) { + throw ImppExceptionBuilder.newInstance().setErrorDetail("未查询出当前配置,请检查数据!").build(); + } + MesFordFetchParameter parameter = list.get(0); + //尝试登录 + Map paramMap = new HashMap<>(); + paramMap.put("username", parameter.getUid()); + paramMap.put("passwork", parameter.getPwd()); + Map header = new HashMap<>(); + header.put("content-type","application/x-www-form-urlencoded"); + HttpResponse loginResponse = HttpRequest.post(parameter.getLoginUrl()).form(paramMap).execute(); + if (loginResponse.getStatus() != 200){ + log.info("登录失败,需要重新登录!返回内容为:{}",loginResponse.body()); + } + List 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 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("查询出来的内容为:{}",response.body()); + } +} From 0ed0d4e43fd5df62e0d6d03b85feed4603508987 Mon Sep 17 00:00:00 2001 From: "castle.zang" Date: Wed, 5 Mar 2025 16:15:04 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E7=A6=8F=E7=89=B9=E6=8A=93=E5=8F=96?= =?UTF-8?q?=E7=BD=91=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/api/busi/ford/IFordFetchWebService.java | 3 +- modules/i3plus-ext-mes-pcn-apiservice/pom.xml | 4 ++ .../busi/ford/MesFordFetchWebController.java | 7 ++- .../ford/MesFordFetchWebServiceImpl.java | 68 ++++++++++++++++++---- pom.xml | 5 ++ 5 files changed, 73 insertions(+), 14 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ford/IFordFetchWebService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ford/IFordFetchWebService.java index 73e3dcb..862cbff 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ford/IFordFetchWebService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ford/IFordFetchWebService.java @@ -1,6 +1,7 @@ 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; @@ -18,5 +19,5 @@ public interface IFordFetchWebService { List queryParams(String organizeCode); - void doFetchData(Long id,String organizeCode); + List doFetchData(Long id, String organizeCode); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/pom.xml b/modules/i3plus-ext-mes-pcn-apiservice/pom.xml index b7eacef..94b8dff 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/pom.xml +++ b/modules/i3plus-ext-mes-pcn-apiservice/pom.xml @@ -14,6 +14,10 @@ jar + + org.jsoup + jsoup + org.apache.cxf diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/ford/MesFordFetchWebController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/ford/MesFordFetchWebController.java index 08f1199..fcacc59 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/ford/MesFordFetchWebController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/ford/MesFordFetchWebController.java @@ -3,6 +3,7 @@ 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; @@ -10,6 +11,7 @@ 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 @@ -82,12 +84,13 @@ public class MesFordFetchWebController { @GetMapping(value = "/param/data/{id}/{organizeCode}") @ApiOperation(value = "定时抓单") public ResultBean queryData(@PathVariable Long id,@PathVariable String organizeCode) { - + List mesFordJsaSortInfoWithFetchWebs; try { + mesFordJsaSortInfoWithFetchWebs = fordFetchWebService.doFetchData(id, organizeCode); } catch (Exception e) { return ResultBean.fail(e.getMessage()); } - return null; + return ResultBean.success("查询成功").setResultList(mesFordJsaSortInfoWithFetchWebs); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java index fd271e4..1f30dda 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java @@ -5,19 +5,22 @@ 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.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.net.HttpCookie; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; @Service @Slf4j @@ -25,6 +28,9 @@ public class MesFordFetchWebServiceImpl implements IFordFetchWebService { @Autowired private MesFordFetchParameterRepository paramRao; + @Autowired + private MesFordJsaSortInfoWithFetchWebRepository fetchWebRao; + @Override public void insertParams(MesFordFetchParameter parameter) { ConvertBean.saveOrUpdate(parameter, parameter.getCreateUser()); @@ -57,7 +63,8 @@ public class MesFordFetchWebServiceImpl implements IFordFetchWebService { } @Override - public void doFetchData(Long id, String organizeCode) { + public List doFetchData(Long id, String organizeCode) { + List infoList = new ArrayList<>(); DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode); DdlPreparedPack.getNumEqualPack(id,"id",ddlPackBean); List list = paramRao.findByHqlWhere(ddlPackBean); @@ -68,12 +75,15 @@ public class MesFordFetchWebServiceImpl implements IFordFetchWebService { //尝试登录 Map paramMap = new HashMap<>(); paramMap.put("username", parameter.getUid()); - paramMap.put("passwork", parameter.getPwd()); - Map header = new HashMap<>(); - header.put("content-type","application/x-www-form-urlencoded"); - HttpResponse loginResponse = HttpRequest.post(parameter.getLoginUrl()).form(paramMap).execute(); + 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("登录失败,需要重新登录!返回内容为:{}",loginResponse.body()); + log.info("doFetchData-登录失败,需要重新登录!返回内容为:{}",loginResponse.body()); } List cookies = loginResponse.getCookies(); //拼接请求参数 @@ -86,6 +96,42 @@ public class MesFordFetchWebServiceImpl implements IFordFetchWebService { map.put("catacode","0"); map.put("itemcode","0"); HttpResponse response = HttpRequest.get(parameter.getFetchUrl()).cookie(cookies).timeout(60000).form(map).execute(); - log.info("查询出来的内容为:{}",response.body()); + log.info("doFetchData-查询出来的内容为:{}",response.body()); + Document doc = Jsoup.parse(response.body()); + Elements trList = doc.select("tr"); + for (Element tr : trList) { + Elements tdList = tr.select("td"); + MesFordJsaSortInfoWithFetchWeb webInfo = new MesFordJsaSortInfoWithFetchWeb(); + 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.getNumEqualPack(webInfo.getFetchDate(),"fetchDate",webInfoPackBean); + DdlPreparedPack.getNumEqualPack(webInfo.getFetchTime(),"fetchTime",webInfoPackBean); + int count = fetchWebRao.findByHqlWhereCount(webInfoPackBean); + if (count > 0){ + continue; + } + fetchWebRao.insert(webInfo); + infoList.add(webInfo); + } + + return infoList; } } diff --git a/pom.xml b/pom.xml index 77012b8..0517f83 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,11 @@ + + org.jsoup + jsoup + 1.11.3 + org.apache.cxf From 37843777b5c40631ba1a57722a59e0cd5a7f6522 Mon Sep 17 00:00:00 2001 From: "castle.zang" Date: Thu, 6 Mar 2025 11:01:36 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E7=A6=8F=E7=89=B9=E6=8A=93=E5=8F=96?= =?UTF-8?q?=E7=BD=91=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ford/MesFordFetchWebServiceImpl.java | 67 +++++++++++----------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java index 1f30dda..8d81178 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/ford/MesFordFetchWebServiceImpl.java @@ -12,9 +12,9 @@ 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.nodes.Element; import org.jsoup.select.Elements; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -99,38 +99,41 @@ public class MesFordFetchWebServiceImpl implements IFordFetchWebService { log.info("doFetchData-查询出来的内容为:{}",response.body()); Document doc = Jsoup.parse(response.body()); Elements trList = doc.select("tr"); - for (Element tr : trList) { - Elements tdList = tr.select("td"); - MesFordJsaSortInfoWithFetchWeb webInfo = new MesFordJsaSortInfoWithFetchWeb(); - 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.getNumEqualPack(webInfo.getFetchDate(),"fetchDate",webInfoPackBean); - DdlPreparedPack.getNumEqualPack(webInfo.getFetchTime(),"fetchTime",webInfoPackBean); - int count = fetchWebRao.findByHqlWhereCount(webInfoPackBean); - if (count > 0){ - continue; + 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); } - fetchWebRao.insert(webInfo); - infoList.add(webInfo); - } return infoList; } From 325b82d9496adc04c8163f58cb064f0d642a06c8 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 7 Mar 2025 10:13:12 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../strategy/ChengDuSplitFixCharPrintStrategy.java | 167 +++++++++++++++++++++ .../print/strategy/ChengDuSplitPrintStrategy.java | 125 +++++++++++++++ 2 files changed, 292 insertions(+) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuSplitFixCharPrintStrategy.java create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuSplitPrintStrategy.java diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuSplitFixCharPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuSplitFixCharPrintStrategy.java new file mode 100644 index 0000000..8f80caa --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuSplitFixCharPrintStrategy.java @@ -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 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 printTemplateData = new HashMap<>(getPrintContextMap(mesProduceSn, customerPart)); + List> 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 getPrintContextMap(MesProduceSn produceSn, MesCustomerPart customerPart) { + Map 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 packResultMap(MesProduceSnPrintModel printModel, List> printTemplateDateList) { + Map 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; + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuSplitPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuSplitPrintStrategy.java new file mode 100644 index 0000000..5d1a7f4 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuSplitPrintStrategy.java @@ -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; + } +} From a5df54bc98fe875c4d17a865f3ee2b50f2e3fcff Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 10 Mar 2025 10:59:47 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=EF=BC=9A45420?= =?UTF-8?q?=EF=BC=8C=E6=93=8D=E4=BD=9C=E7=9A=84NC=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=8C2=E4=B8=AA=E4=BA=BA=E5=90=8C=E6=97=B6=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=EF=BC=8C=E4=BA=A7=E7=94=9F2=E7=AC=94move=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/busi/MesNcProcessingService.java | 24 ++++++++++++++++++++-- .../ext/mes/pcn/pojo/util/MesPcnExtConstWords.java | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index e754a9f..97ffb2f 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -28,13 +28,16 @@ import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; import cn.estsh.i3plus.pojo.mes.repository.*; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.impp.framework.boot.exception.ImppBusiException; +import cn.estsh.impp.framework.boot.util.ImppRedis; import cn.estsh.impp.framework.boot.util.ResultBean; import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -127,6 +130,9 @@ public class MesNcProcessingService implements IMesNcProcessingService { @Autowired private IMesMoveRuleRepository mesMoveRuleRepository; + @Resource(name = "redisMesPcn") + private ImppRedis redisMesPcn; + @Override public ListPager queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) { @@ -204,8 +210,22 @@ public class MesNcProcessingService implements IMesNcProcessingService { Integer type = model.getType(); MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); - //保存数据 - saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(),isOrder); + final String redisKey = MesPcnExtConstWords.SAP_TRANS_JOB_LOCK_TAG + model.getSn(); + RLock rLock = (RLock) redisMesPcn.getLock(redisKey); + try { + //使用tryLock拿不到锁直接返回 + //rlock的leaseTime为-1,会每隔WatchdogTimeout秒去续约 + if (!rLock.tryLock()){ + throw new ImppBusiException(String.format("【%s】此条码正在处理中,不能并发执行!", model.getSn())); + } + + //保存数据 + saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(),isOrder); + } finally { + if (rLock.isHeldByCurrentThread()) { + rLock.unlock(); + } + } } else { Integer type = model.getType(); diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java index 076b45f..71e556c 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java @@ -806,4 +806,5 @@ public class MesPcnExtConstWords { //螺钉包保存生产版本标记 public static final String SAVE_PRODUCT_VERSION_FLAG = "ZFBT"; + public static final String SAP_TRANS_JOB_LOCK_TAG = "MES:JOB:MES_NC_PROCESSING_LOCK_TAG:"; } From e5d8013c6644e58b78a3e306a260131a91167070 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 11 Mar 2025 16:54:24 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug=EF=BC=9A45556?= =?UTF-8?q?=EF=BC=8CPCN-=E7=94=B5=E5=AD=90=E5=8C=96=E6=A3=80=E9=AA=8C?= =?UTF-8?q?=E3=80=81=E6=9D=A1=E7=A0=81=E6=89=93=E5=8D=B0=E7=9A=84=E9=9B=B6?= =?UTF-8?q?=E4=BB=B6=E6=9F=A5=E8=AF=A2=E5=BC=80=E7=AA=97=EF=BC=8C=E8=A6=81?= =?UTF-8?q?=E7=94=A8unit=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apiservice/controller/busi/MesPartController.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartController.java index 6ca491d..a830739 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPartController.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Iterator; import java.util.List; /** @@ -41,11 +42,18 @@ public class MesPartController { ListPager mesPartListPager = mesPartService.queryMesPart(mesPart, pager); List partList = mesPartListPager.getObjectList(); - for (MesPart part : partList) { - MesPartSap partSap = mesPartService.getMesPartSapByPartNo(part.getPartNo(), part.getOrganizeCode()); - if (partSap != null) { - part.setUnit(partSap.getUnit()); + Iterator iterator = partList.iterator(); + while (iterator.hasNext()) { + MesPart part = iterator.next(); + try { + MesPartSap partSap = mesPartService.getMesPartSapByPartNo(part.getPartNo(), part.getOrganizeCode()); + if (partSap != null) { + part.setUnit(partSap.getUnit()); + } + } catch (ImppBusiException e) { + iterator.remove(); } + } mesPartListPager.setObjectList(partList); return ResultBean.success("查询成功").setListPager(mesPartListPager); From e0244835040d0d0e6248f758c0911c633c2f8c1f Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 11 Mar 2025 20:26:46 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug=EF=BC=9A45420?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=8D=A1=E6=8E=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/busi/MesNcProcessingService.java | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index 97ffb2f..06afe66 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -206,13 +206,14 @@ public class MesNcProcessingService implements IMesNcProcessingService { if(!Objects.isNull(model.getPart())){ model.setPart(mesPartService.getMesPartSapByPartNo(model.getPart().getPartNo(), org)); } - if (model.getPartInspection().getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { - Integer type = model.getType(); - MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); - final String redisKey = MesPcnExtConstWords.SAP_TRANS_JOB_LOCK_TAG + model.getSn(); - RLock rLock = (RLock) redisMesPcn.getLock(redisKey); - try { + final String redisKey = MesPcnExtConstWords.SAP_TRANS_JOB_LOCK_TAG + model.getPartInspection().getId(); + RLock rLock = (RLock) redisMesPcn.getLock(redisKey); + try { + if (model.getPartInspection().getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { + Integer type = model.getType(); + MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); + //使用tryLock拿不到锁直接返回 //rlock的leaseTime为-1,会每隔WatchdogTimeout秒去续约 if (!rLock.tryLock()){ @@ -221,17 +222,16 @@ public class MesNcProcessingService implements IMesNcProcessingService { //保存数据 saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(),isOrder); - } finally { - if (rLock.isHeldByCurrentThread()) { - rLock.unlock(); - } + } else { + Integer type = model.getType(); + MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); + //保存数据 + saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(), isOrder); + } + } finally { + if (rLock.isHeldByCurrentThread()) { + rLock.unlock(); } - } else { - - Integer type = model.getType(); - MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); - //保存数据 - saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(), isOrder); } } From bf93405f1d09e3647d4788b9296892db23769c41 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 11 Mar 2025 20:26:46 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug=EF=BC=9A45420?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=8D=A1=E6=8E=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/busi/MesNcProcessingService.java | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index 97ffb2f..c0a9705 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -206,13 +206,14 @@ public class MesNcProcessingService implements IMesNcProcessingService { if(!Objects.isNull(model.getPart())){ model.setPart(mesPartService.getMesPartSapByPartNo(model.getPart().getPartNo(), org)); } - if (model.getPartInspection().getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { - Integer type = model.getType(); - MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); - final String redisKey = MesPcnExtConstWords.SAP_TRANS_JOB_LOCK_TAG + model.getSn(); - RLock rLock = (RLock) redisMesPcn.getLock(redisKey); - try { + final String redisKey = MesPcnExtConstWords.SAP_TRANS_JOB_LOCK_TAG + model.getPartInspection().getId(); + RLock rLock = (RLock) redisMesPcn.getLock(redisKey); + try { + if (model.getPartInspection().getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { + Integer type = model.getType(); + MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); + //使用tryLock拿不到锁直接返回 //rlock的leaseTime为-1,会每隔WatchdogTimeout秒去续约 if (!rLock.tryLock()){ @@ -221,17 +222,16 @@ public class MesNcProcessingService implements IMesNcProcessingService { //保存数据 saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(),isOrder); - } finally { - if (rLock.isHeldByCurrentThread()) { - rLock.unlock(); - } + } else { + Integer type = model.getType(); + MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); + //保存数据 + saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(), isOrder); + } + } finally { + if (rLock.isHeldByCurrentThread()) { + rLock.unlock(); } - } else { - - Integer type = model.getType(); - MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); - //保存数据 - saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(), isOrder); } } @@ -370,6 +370,9 @@ public class MesNcProcessingService implements IMesNcProcessingService { String workCenterCode = null == model.getPartInspection() ? null : model.getPartInspection().getWorkCenterCode(); assert model.getPartInspection() != null; model.getPartInspection().setQmsSync(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); + if (!Objects.equals(model.getPartInspection().getNcStatus(), MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue())) { + throw new ImppBusiException(String.format("零件【%s】已进行过NC处理,请勿重复操作!", part.getPartNo())); + } MesProduceSn sn = getProduceSn(model.getSn(), org); //武汉 会输入客户条码 todo 更新工单对应qcStatus boolean isWorkOrderQcStatus=false; From 9d601a3b3c1cb1d96035caab8ab1198a9401ca1c Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 12 Mar 2025 18:25:22 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug=EF=BC=9A45420?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=8D=A1=E6=8E=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index c0a9705..ee61972 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -370,7 +370,8 @@ public class MesNcProcessingService implements IMesNcProcessingService { String workCenterCode = null == model.getPartInspection() ? null : model.getPartInspection().getWorkCenterCode(); assert model.getPartInspection() != null; model.getPartInspection().setQmsSync(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); - if (!Objects.equals(model.getPartInspection().getNcStatus(), MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue())) { + MesPartInspection existedInspection = partInspectionRepository.getById(model.getPartInspection().getId()); + if (existedInspection != null && !Objects.equals(existedInspection.getNcStatus(), MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue())) { throw new ImppBusiException(String.format("零件【%s】已进行过NC处理,请勿重复操作!", part.getPartNo())); } MesProduceSn sn = getProduceSn(model.getSn(), org); From 242a3558a7602cabc2e01d32b4b35f08705eefb6 Mon Sep 17 00:00:00 2001 From: "xiangwei.zhang" <752558143@qq.com> Date: Wed, 12 Mar 2025 21:05:41 +0800 Subject: [PATCH 10/12] =?UTF-8?q?45558=20PCN=EF=BC=9A=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8A=A5=E5=B7=A5job=E9=92=88=E5=AF=B9=E9=9D=9E=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=8A=A5=E5=B7=A5=E6=97=B6=E6=9C=89=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=92=8C=E6=97=A0=E5=B7=A5=E5=8D=95=E9=9C=80=E8=A6=81=E5=88=86?= =?UTF-8?q?=E5=BC=80=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apiservice/dao/IMesProductionRecordDao.java | 2 +- .../daoimpl/MesProductionRecordImpl.java | 7 ++++++- .../serviceimpl/busi/MesWorkOrderService.java | 22 +++++++++++++--------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/dao/IMesProductionRecordDao.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/dao/IMesProductionRecordDao.java index 9d4e76b..c338bca 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/dao/IMesProductionRecordDao.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/dao/IMesProductionRecordDao.java @@ -15,5 +15,5 @@ import java.util.List; public interface IMesProductionRecordDao { @ApiOperation("查询汇报的加工记录") - List findMesProductionRecordNoReport(String organizeCode, Integer workOrderType, Integer pageSize, List workCenterList); + List findMesProductionRecordNoReport(String organizeCode, Integer workOrderType, Integer pageSize, List workCenterList, boolean isHasOrder); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/daoimpl/MesProductionRecordImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/daoimpl/MesProductionRecordImpl.java index e8d2775..a8cac44 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/daoimpl/MesProductionRecordImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/daoimpl/MesProductionRecordImpl.java @@ -32,7 +32,7 @@ public class MesProductionRecordImpl implements IMesProductionRecordDao { private EntityManager entityManager; @Override - public List findMesProductionRecordNoReport(String organizeCode, Integer workOrderType, Integer pageSize, List workCenterList) { + public List findMesProductionRecordNoReport(String organizeCode, Integer workOrderType, Integer pageSize, List workCenterList, boolean isHasOrder) { StringBuilder hql = new StringBuilder(); hql.append(" select record from MesProductionRecord record left join MesWorkCenter center on record.workCenterCode = center.workCenterCode where 1=1"); hql.append(" and record.organizeCode = :organizeCode and record.isValid = :isValid and record.isDeleted = :isDeleted "); @@ -44,6 +44,11 @@ public class MesProductionRecordImpl implements IMesProductionRecordDao { if(MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == workOrderType){ hql.append(" order by record.reportStatus asc,record.modifyDatetime asc "); }else{ + if (isHasOrder) { + hql.append(" and record.workOrderNo !='' and record.workOrderNo is not null "); + } else { + hql.append(" and (record.workOrderNo = '' or record.workOrderNo is null) "); + } hql.append(" order by record.modifyDatetime asc "); } Query hqlQuery = entityManager.createQuery(hql.toString(), MesProductionRecord.class); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java index 4522235..abeb417 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java @@ -552,8 +552,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { MesWorkOrder oldMesWorkOrder = getBestWorkOrder(productionRecord, oldMesWorkOrderList, mesWorkCenter); if (oldMesWorkOrder == null) { LOGGER.error(String.format("未找到匹配的加工单, 条码=%s", productionRecord.getCustSn())); - return; - //throw new ImppBusiException(String.format("未找到匹配的加工单")); + throw new ImppBusiException(String.format("未找到匹配的加工单")); } //获取生产版本 @@ -1243,14 +1242,19 @@ public class MesWorkOrderService implements IMesWorkOrderService { @Override public void doMesWorkOrderNoSortReport(String organizeCode, Integer pageSize, String userName) { String workCenterCodes = configService.getCfgValue(organizeCode, "MES_PCN_REPORT_CENTER"); - //查询所有非排序工单 - List recordNoReportList = mesProductionRecordDao.findMesProductionRecordNoReport(organizeCode, MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue(), pageSize, !StringUtils.isEmpty(workCenterCodes) ? Arrays.asList(workCenterCodes.split(",")) : null); - if (CollectionUtils.isEmpty(recordNoReportList)) { - LOGGER.error("非排序加工单加工记录中没有数据,无需处理"); + //查询非排序工单 有工单 + List recordNoReportHasOrderNoList = mesProductionRecordDao.findMesProductionRecordNoReport(organizeCode, MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue(), pageSize, !StringUtils.isEmpty(workCenterCodes) ? Arrays.asList(workCenterCodes.split(",")) : null, true); + if (CollectionUtils.isEmpty(recordNoReportHasOrderNoList)) { + LOGGER.error("非排序有加工单加工记录中没有数据,无需处理"); + return; + } + //查询非排序工单 有工单 + List recordNoReportNotHasOrderNoList = mesProductionRecordDao.findMesProductionRecordNoReport(organizeCode, MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue(), pageSize, !StringUtils.isEmpty(workCenterCodes) ? Arrays.asList(workCenterCodes.split(",")) : null, false); + if (CollectionUtils.isEmpty(recordNoReportNotHasOrderNoList)) { + LOGGER.error("非排序无加工单加工记录中没有数据,无需处理"); return; } - List recordNoReportNotHasOrderNoList = recordNoReportList.stream().filter(item -> StringUtils.isEmpty(item.getWorkOrderNo())).collect(Collectors.toList()); - List recordNoReportHasOrderNoList = recordNoReportList.stream().filter(item -> !StringUtils.isEmpty(item.getWorkOrderNo())).collect(Collectors.toList()); + //处理无工单加工记录 if(!CollectionUtils.isEmpty(recordNoReportNotHasOrderNoList)){ for (MesProductionRecord mesProductionRecord : recordNoReportNotHasOrderNoList) { @@ -1474,7 +1478,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { } public MesWorkOrderSortReportModel initMesWorkOrderSortReportModel(String organizeCode, Integer pageSize, String userName) { - MesWorkOrderSortReportModel model = new MesWorkOrderSortReportModel(organizeCode, userName, mesProductionRecordDao.findMesProductionRecordNoReport(organizeCode, MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue(), pageSize,null)); + MesWorkOrderSortReportModel model = new MesWorkOrderSortReportModel(organizeCode, userName, mesProductionRecordDao.findMesProductionRecordNoReport(organizeCode, MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue(), pageSize,null,true)); model.setMesWorkOrderList(workOrderExtService.getWorkOrderList(organizeCode, model.getWorkOrderList())); model.setMesMoveRuleList(mesMoveRuleService.findMesMoveRuleByPartProdGroupCode(model.getPartProdGroupCodeList(), organizeCode,MesExtEnumUtil.MOVE_RULE_GROUP_TYPE.MOVE_RULE_GROUP_TYPE_20.getValue())); model.setMesWorkOrderPartList(findMesWorkOrderPartByOrderNo(organizeCode, model.getWorkOrderList())); From 57c54e2892c32c5a0ef84fc50395cfd11eea77e1 Mon Sep 17 00:00:00 2001 From: "xiangwei.zhang" <752558143@qq.com> Date: Wed, 12 Mar 2025 21:07:08 +0800 Subject: [PATCH 11/12] =?UTF-8?q?45558=20PCN=EF=BC=9A=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=8A=A5=E5=B7=A5job=E9=92=88=E5=AF=B9=E9=9D=9E=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=8A=A5=E5=B7=A5=E6=97=B6=E6=9C=89=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=92=8C=E6=97=A0=E5=B7=A5=E5=8D=95=E9=9C=80=E8=A6=81=E5=88=86?= =?UTF-8?q?=E5=BC=80=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java index abeb417..154ac3b 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java @@ -1246,13 +1246,11 @@ public class MesWorkOrderService implements IMesWorkOrderService { List recordNoReportHasOrderNoList = mesProductionRecordDao.findMesProductionRecordNoReport(organizeCode, MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue(), pageSize, !StringUtils.isEmpty(workCenterCodes) ? Arrays.asList(workCenterCodes.split(",")) : null, true); if (CollectionUtils.isEmpty(recordNoReportHasOrderNoList)) { LOGGER.error("非排序有加工单加工记录中没有数据,无需处理"); - return; } //查询非排序工单 有工单 List recordNoReportNotHasOrderNoList = mesProductionRecordDao.findMesProductionRecordNoReport(organizeCode, MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue(), pageSize, !StringUtils.isEmpty(workCenterCodes) ? Arrays.asList(workCenterCodes.split(",")) : null, false); if (CollectionUtils.isEmpty(recordNoReportNotHasOrderNoList)) { LOGGER.error("非排序无加工单加工记录中没有数据,无需处理"); - return; } //处理无工单加工记录 From 74fd70db6f97214514d61378950135a49a4628fb Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 13 Mar 2025 11:32:25 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E6=88=90=E9=83=BD=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=E7=94=9F=E6=88=90=E7=AD=96=E7=95=A5=EF=BC=8C?= =?UTF-8?q?=E5=B9=B4=E4=BB=BD=E5=8F=AA=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=B8=A4?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ChengDuSimpleYearNumberRuleStrategyService.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/ChengDuSimpleYearNumberRuleStrategyService.java diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/ChengDuSimpleYearNumberRuleStrategyService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/ChengDuSimpleYearNumberRuleStrategyService.java new file mode 100644 index 0000000..d6fe3b9 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/ChengDuSimpleYearNumberRuleStrategyService.java @@ -0,0 +1,47 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule; + +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; +import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService; +import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart; +import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.Objects; + +/** + * @Description : MES-客户条码(成都) + * @Reference : + * @Author : jason.niu + * @CreateDate 2025/03/13 16:47 + * @Modify: + **/ +@Component +public class ChengDuSimpleYearNumberRuleStrategyService implements INumberRulePackAttributeStrategyService { + + @Autowired + private IMesCustomerPartService mesCustomerPartService; + + @Override + public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) { + Map dataMap = genSerialNoModel.getDataMap(); + MesCustomerPart customerPart = (!CollectionUtils.isEmpty(dataMap) && dataMap.containsKey(MesCustomerPart.class.getSimpleName())) ? + (MesCustomerPart)dataMap.get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(genSerialNoModel.getOrganizeCode(), genSerialNoModel.getPartNo()); + if (Objects.isNull(customerPart)) { + MesPcnException.throwMesBusiException("请检查客户零件信息,零件[%s]客户零件关系未维护", genSerialNoModel.getPartNo()); + } + genSerialNoModel.setCustPartNo(customerPart.getCustPartNo()); + Date date = new Date(); + genSerialNoModel.setYear(getYear(date)); + return genSerialNoModel; + } + + private String getYear(Date date) { + return (new SimpleDateFormat("yy")).format(date); + } +}