From 5a5bce2767c3dd615f58d83ec7b2eb00c128aa3b Mon Sep 17 00:00:00 2001 From: jun Date: Tue, 6 Aug 2024 05:53:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=A8=A1=E6=9D=BF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=89=93=E5=8D=B0=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/groovy/MesProductionRecordToPisces.groovy | 17 +++++++-- .../src/groovy/MesUpdateSrcData.groovy | 44 ++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 modules/i3plus-ext-mes-apiservice/src/groovy/MesUpdateSrcData.groovy diff --git a/modules/i3plus-ext-mes-apiservice/src/groovy/MesProductionRecordToPisces.groovy b/modules/i3plus-ext-mes-apiservice/src/groovy/MesProductionRecordToPisces.groovy index aa7e57c..f116c5c 100644 --- a/modules/i3plus-ext-mes-apiservice/src/groovy/MesProductionRecordToPisces.groovy +++ b/modules/i3plus-ext-mes-apiservice/src/groovy/MesProductionRecordToPisces.groovy @@ -1,3 +1,4 @@ +import cn.estsh.i3plus.platform.common.tool.TimeTool import cn.estsh.i3plus.platform.plugin.datasource.DynamicDataSourceProxy import cn.estsh.i3plus.pojo.base.bean.DdlPackBean import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack @@ -12,6 +13,7 @@ import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate import org.springframework.util.CollectionUtils +import org.springframework.util.StringUtils import javax.annotation.Resource import java.sql.Connection @@ -65,7 +67,7 @@ class MesProductionRecordToPisces { Map mesWorkCenterMap = new HashMap<>(); Map mesWorkCellMap = new HashMap<>(); Map mesProcessMap = new HashMap<>(); - List updateList = new ArrayList<>(); + List idList = new ArrayList<>(); List> destData = new ArrayList<>(); for (Map rowMap : srcData) { @@ -77,8 +79,9 @@ class MesProductionRecordToPisces { if (!CollectionUtils.isEmpty(dataMap) && dataMap.size() > 0) { rowMap.put("BARCODE_ID", dataMap.iterator().next().get("ID")) - updateList.add("update mes_production_record set system_sync_status = 1 where id= " + rowMap.get("id") + " ;") + idList.add(rowMap.get("id").toString()); } else { + LOGGER.info("条码{}物料{}条码信息未同步,信息不存在", rowMap.get("product_sn"),rowMap.get("part_no")) continue } String workCenterCode = String.valueOf(rowMap.get("work_center_code")); @@ -145,7 +148,9 @@ class MesProductionRecordToPisces { } //更新同步标识 - if (!CollectionUtils.isEmpty(updateList) && updateList.size() > 0) { + if (!CollectionUtils.isEmpty(idList) && idList.size() > 0) { + List updateList = new ArrayList<>(); + updateList.add("update mes_production_record set system_sync_date_time='"+ TimeTool.getNowTime(true)+"',system_sync_status = 1 where id in (" + String.join(",",idList) + ") ;") this.mesConn = mesDataSource.getWriteConnectionWithoutPool(); mesDataSource.executeAsBatch(updateList, mesConn) mesDataSource.closeConnectionWithoutPoll(this.mesConn) @@ -202,4 +207,10 @@ class MesProductionRecordToPisces { return mesProcessMap.get(processCode); } + def saveSrcData(MesInterfaceDataMapper mapper, List> srcData) throws Exception { + if (srcData == null || srcData.size() == 0 || StringUtils.isEmpty(mapper.getSrcTableName())) { + return srcData + } + } + } \ No newline at end of file diff --git a/modules/i3plus-ext-mes-apiservice/src/groovy/MesUpdateSrcData.groovy b/modules/i3plus-ext-mes-apiservice/src/groovy/MesUpdateSrcData.groovy new file mode 100644 index 0000000..71237ea --- /dev/null +++ b/modules/i3plus-ext-mes-apiservice/src/groovy/MesUpdateSrcData.groovy @@ -0,0 +1,44 @@ +import cn.estsh.i3plus.platform.common.tool.TimeTool +import cn.estsh.i3plus.platform.plugin.datasource.DynamicDataSourceProxy +import cn.estsh.i3plus.pojo.mes.dbinterface.MesInterfaceDataMapper +import lombok.Getter +import lombok.Setter +import org.springframework.util.StringUtils + +import javax.annotation.Resource +import java.sql.Connection + +/** + * @Description :MES2PISCES-更新同步标识 + * @Reference : + * @Author : junsheng.li + * @CreateDate 2024/8/5 20:19 + * @Modify: + * */ +class MesUpdateSrcData { + + @Resource(name = "mesDataSource") + private DynamicDataSourceProxy mesDataSource; + + @Getter + @Setter + private Connection mesConn; + + def saveSrcData(MesInterfaceDataMapper mapper, List> srcData) throws Exception { + if (srcData == null || srcData.size() == 0 || StringUtils.isEmpty(mapper.getSrcTableName())) { + return srcData + } + List idList = new ArrayList<>(); + for (Map data : srcData) { + idList.add(data.get("id").toString()); + } + + //更新同步标识 + List updateList = new ArrayList<>(); + updateList.add("update " + mapper.getSrcTableName() + " set system_sync_date_time='" + TimeTool.getNowTime(true) + "',system_sync_status='1' where id in (" + String.join(",", idList) + ") ;"); + this.mesConn = mesDataSource.getWriteConnectionWithoutPool(); + mesDataSource.executeAsBatch(updateList, mesConn) + mesDataSource.closeConnectionWithoutPoll(this.mesConn) + + } +} \ No newline at end of file