From 1ea8d90839d361f8c16e0ca46cf9c70dfa587e3b Mon Sep 17 00:00:00 2001 From: xins Date: Mon, 22 Apr 2024 17:58:08 +0800 Subject: [PATCH] =?UTF-8?q?2.1.7=20jindie:=E5=90=8C=E6=AD=A5=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=AE=8C=E5=96=84=20tdengine=EF=BC=9A=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0drop=20table=E6=96=B9=E6=B3=95=20mes=EF=BC=9A=E4=BA=94?= =?UTF-8?q?=E6=A5=BC=E4=B8=8B=E5=8F=91=E6=9F=9C=E4=BD=93=E7=BB=99=E5=B7=A5?= =?UTF-8?q?=E4=BD=8D=E6=97=B6=EF=BC=8C=E6=A0=A1=E9=AA=8C=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E5=B7=A5=E4=BD=8D=E7=9A=84=E6=B4=BE=E5=B7=A5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tdengine/api/RemoteTdEngineService.java | 2 ++ .../hw/tdengine/api/domain/TdTableDropVo.java | 27 +++++++++++++++ .../RemoteTdEngineFallbackFactory.java | 5 +++ .../impl/KingdeeErpSyncServiceImpl.java | 18 ++++++---- .../hw/mes/mapper/MesProductPlanMapper.java | 10 ++++++ .../impl/MesProductPlanServiceImpl.java | 33 +++++++++++++++--- .../mapper/mes/MesProductPlanMapper.xml | 34 +++++++++++++++++++ .../controller/TdEngineController.java | 29 ++++++++++++++++ .../hw/tdengine/mapper/TdEngineMapper.java | 8 +++++ .../hw/tdengine/service/ITdEngineService.java | 12 +++++++ .../service/impl/TdEngineServiceImpl.java | 13 +++++++ .../mapper/tdengine/TdEngineMapper.xml | 4 +++ 12 files changed, 183 insertions(+), 12 deletions(-) create mode 100644 hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdTableDropVo.java diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/RemoteTdEngineService.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/RemoteTdEngineService.java index 13a5341..61dc405 100644 --- a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/RemoteTdEngineService.java +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/RemoteTdEngineService.java @@ -71,4 +71,6 @@ public interface RemoteTdEngineService { @PostMapping("/tdengine/alterTableTags") public R alterTableTags(@Validated @RequestBody List alterTagVos, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + @PostMapping("/tdengine/dropTable") + R dropTable(@Validated @RequestBody TdTableDropVo tdTableDropVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); } diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdTableDropVo.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdTableDropVo.java new file mode 100644 index 0000000..b7e7ab6 --- /dev/null +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/domain/TdTableDropVo.java @@ -0,0 +1,27 @@ +package com.hw.tdengine.api.domain; + +import lombok.Data; + +import javax.validation.constraints.NotEmpty; + +/** + * @Description: drop子表实体类 + * @ClassName: TdTableDropVo + * @Author : xins + * @Date :2024-04-20 11:09 + * @Version :1.0 + */ +@Data +public class TdTableDropVo { + + //数据库名称 + @NotEmpty(message="databaseName cannot be empty") + private String databaseName; + + + //子表名称 + @NotEmpty(message="tableName cannot be empty") + private String tableName; + + +} diff --git a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/factory/RemoteTdEngineFallbackFactory.java b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/factory/RemoteTdEngineFallbackFactory.java index efdd6d4..234683e 100644 --- a/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/factory/RemoteTdEngineFallbackFactory.java +++ b/hw-api/hw-api-tdengine/src/main/java/com/hw/tdengine/api/factory/RemoteTdEngineFallbackFactory.java @@ -113,6 +113,11 @@ public class RemoteTdEngineFallbackFactory implements FallbackFactory dropTable(TdTableDropVo tdTableDropVo, String source) { + return R.fail("drop子表失败:" + throwable.getMessage()); + } + }; } } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpSyncServiceImpl.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpSyncServiceImpl.java index 61fb86e..5d6b909 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpSyncServiceImpl.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpSyncServiceImpl.java @@ -44,7 +44,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { String orderString = ""; int topRowCount = 0; int startRow = 0; - int limit = 2000; + int limit = 100; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); queryJson.put("OrderString", orderString); @@ -77,13 +77,13 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { JSONObject queryJson = new JSONObject(); String formId = "BD_Material"; String fieldKeys = "FMaterialId,FNumber,FName,FBaseUnitId,FSpecification,FNETWEIGHT,FGROSSWEIGHT," + - "FCreateDate,FModifyDate,FApproveDate,FCreateOrgId,FUseOrgId"; + "FCreateDate,FModifyDate,FApproveDate,FCreateOrgId,FUseOrgId,FPurchasePriceUnitId"; // String filterString = "FNumber='98010102'"; String filterString = ""; String orderString = ""; int topRowCount = 0; int startRow = 0; - int limit = 23; + int limit = 99; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); queryJson.put("FilterString", filterString); @@ -179,12 +179,15 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { JSONObject queryJson = new JSONObject(); String formId = "SAL_SaleOrder"; - String fieldKeys = "FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialName,FQty,FModifyDate,FMinPlanDeliveryDate"; + String fieldKeys = "FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialName," + + "FQty,FModifyDate,FMinPlanDeliveryDate,FAuxPropId,FStockId,FOwnerId,FSaleDeptId,FPrice,FStockOrgId"; +// String filterString = "FNumber='98010102'"; + filterString = ""; String orderString = ""; int topRowCount = 0; int startRow = 0; - int limit = 2000; + int limit = 10; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); queryJson.put("FilterString", filterString); @@ -246,7 +249,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { JSONObject queryJson = new JSONObject(); String formId = "PUR_PurchaseOrder"; - String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialId.FName,FQty,FDeliveryDate"; + String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialId.FName," + + "FQty,FDeliveryDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FSrcBillNo,FPurchaseOrgId,F_TOND_Base,FSupplierId"; String filterString = ""; String orderString = ""; int topRowCount = 0; @@ -272,7 +276,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { // syncSupplierInfoFromErp(); // syncMaterialInfoFromErp(); // syncSaleOrderFromErp(); -// syncPurchaseOrderFromErp(); + syncPurchaseOrderFromErp(); // syncProjectInfoFromErp(); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanMapper.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanMapper.java index ee5816e..d1d13a5 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanMapper.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanMapper.java @@ -94,4 +94,14 @@ public interface MesProductPlanMapper * @return 生产派工集合 */ public List selectMesProductPlanJoinList(MesProductPlan mesProductPlan); + + + + /** + * 查询生产派工 + * + * @param planCode 生产计划编号(唯一索引) + * @return 生产派工 + */ + public MesProductPlan selectOnlyMesProductPlanByPlanCode(String planCode); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java index afc9ce4..7cc8c72 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java @@ -397,8 +397,30 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { throw new ServiceException("此物料条码已经下发,无需重复下发"); } - + //下发工位判断有没有派工和完成情况 + String planCode = mesBaseBarcodeInfo.getPlanCode(); + MesProductPlan mesProductPlan = mesProductPlanMapper.selectOnlyMesProductPlanByPlanCode(planCode); Long stationId = mesAssignTaskVo.getStationId(); + + MesProductPlan queryProductPlan = new MesProductPlan(); + queryProductPlan.setProductOrderId(mesProductPlan.getProductOrderId()); + queryProductPlan.setStationId(stationId); + List mesProductPlanList = mesProductPlanMapper.selectMesProductPlanList(queryProductPlan); + if (mesProductPlanList == null || mesProductPlanList.isEmpty()) { + throw new ServiceException("此工位没有派工"); + } + + BigDecimal totalPlanAmount = mesProductPlanList.stream().map(MesProductPlan::getPlanAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + + MesMaterialAssignInfo queryMaterialAssignInfo = new MesMaterialAssignInfo(); + queryMaterialAssignInfo.setStationId(stationId); + List mesMaterialAssignInfoList = mesMaterialAssignInfoMapper.selectMesMaterialAssignInfoList(queryMesMaterialAssignInfo); + BigDecimal assignedAmount = mesMaterialAssignInfoList == null ? BigDecimal.ZERO : BigDecimal.valueOf(mesMaterialAssignInfoList.size()); + + if (assignedAmount.add(BigDecimal.ONE).compareTo(totalPlanAmount) > 0) { + throw new ServiceException("此工位已经分配数量" + assignedAmount + ",计划数量" + totalPlanAmount + ",不能再分配"); + } + Date currentDate = new Date(); MesMaterialAssignInfo mesMaterialAssignInfo = new MesMaterialAssignInfo(); mesMaterialAssignInfo.setMaterialBarcode(materialBarcode); @@ -408,13 +430,13 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { mesMaterialAssignInfoMapper.insertMesMaterialAssignInfo(mesMaterialAssignInfo); - Long stationNo = stationId % 10; + Long stationNo = stationId % 10;//第几个工位取个位数 JSONObject assignTaskMessageJson = new JSONObject(); assignTaskMessageJson.put("stationNo", stationNo); assignTaskMessageJson.put("time", currentDate.getTime()); assignTaskMessageJson.put("materialBarcode", materialBarcode); - //2、订阅者读取此条信息后会给出反馈,直接写入redis,如果在10s内返回,则成功,如果10s内失败则失败 + //如果在10s内返回,则成功,如果10s内失败则失败 String returnMsg = SocketUtils. sendAndReceive(mesConfig.getSocketServerHost(), mesConfig.getSocketServerPort(), mesConfig.getSocketServerReadTimeOut(), assignTaskMessageJson.toString()); if (StringUtils.isEmpty(returnMsg)) { @@ -434,17 +456,18 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { /** * 查询物料安装情况 + * * @param hashMap (installType=1已安装,installType=2未安装) * @return */ @Override public List> selectMaterialInstallationCircumstance(Map hashMap) { List> result = new ArrayList<>(); - if (hashMap.containsKey("installType") && hashMap.get("installType").equals("1")){ + if (hashMap.containsKey("installType") && hashMap.get("installType").equals("1")) { result = mesMaterialCheckResultMapper.selectMaterialInstallationCircumstance(hashMap); } if (hashMap.containsKey("installType") && hashMap.get("installType").equals("2") - && hashMap.containsKey("planDetailId") && hashMap.containsKey("materialBomId")){ + && hashMap.containsKey("planDetailId") && hashMap.containsKey("materialBomId")) { result = mesMaterialCheckResultMapper.selectMaterialUnInstallationCircumstance(hashMap); } return result; diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml index 8ed62a3..f15372f 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml @@ -332,4 +332,38 @@ + + + + diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/controller/TdEngineController.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/controller/TdEngineController.java index 966962d..f37ccfe 100644 --- a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/controller/TdEngineController.java +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/controller/TdEngineController.java @@ -538,4 +538,33 @@ public class TdEngineController { } + /** + * @return R + * @param: tableDto + * @description 创建子表 + * @author xins + * @date 2023-08-28 16:17 + */ + @InnerAuth + @PostMapping("/dropTable") + public R dropTable(@Validated @RequestBody TdTableDropVo tdTableDropVo) { + try { + String databaseName = tdTableDropVo.getDatabaseName(); + String tableName = tdTableDropVo.getTableName(); + this.tdEngineService.dropTable(databaseName, tableName); + log.info("successfully droped table " + tableName); + return R.ok("successfully droped table " + tableName); + } catch (Exception e) { + String message = e.getCause().getMessage(); + try { + message = message.substring(message.lastIndexOf("invalid operation")); + } catch (Exception ex) { + log.error(ex.getMessage()); + } + log.error(message); + return R.fail(message); + } + } + + } diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/TdEngineMapper.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/TdEngineMapper.java index 81b5aab..e96b565 100644 --- a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/TdEngineMapper.java +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/mapper/TdEngineMapper.java @@ -166,6 +166,14 @@ public interface TdEngineMapper { int getCountOfSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo); + /** + * drop 子表 + * + * @param databaseName + * @param tableName + */ + void dropTable(@Param("databaseName") String databaseName, + @Param("tableName") String tableName); // /** // * 检查表是否存在 diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/ITdEngineService.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/ITdEngineService.java index 160b5ca..781916c 100644 --- a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/ITdEngineService.java +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/ITdEngineService.java @@ -158,6 +158,18 @@ public interface ITdEngineService { * @param alterTagVos */ public void alterTableTags(List alterTagVos); + + + /** + * @param: databaseName + * @param: tableName + * @description drop子表 + * @author xins + * @date 2024-04-20 11:08 + */ + public void dropTable(String databaseName, String tableName) throws Exception; + + // void initSTableFrame(String msg) throws Exception; // List> getRealtimeData(SelectVisualDto selectVisualDto); diff --git a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/TdEngineServiceImpl.java b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/TdEngineServiceImpl.java index 012080a..f81076f 100644 --- a/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/TdEngineServiceImpl.java +++ b/hw-modules/hw-tdengine/src/main/java/com/hw/tdengine/service/impl/TdEngineServiceImpl.java @@ -282,6 +282,19 @@ public class TdEngineServiceImpl implements ITdEngineService { } + /** + * @param: databaseName + * @param: tableName + * @description drop子表 + * @author xins + * @date 2024-04-20 11:08 + */ + @Override + public void dropTable(String databaseName, String tableName) throws Exception { + this.tdEngineMapper.dropTable(databaseName, tableName); + + } + // // /** // * 检查数据库表是否存在 diff --git a/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml b/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml index e935dac..513c4d7 100644 --- a/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml +++ b/hw-modules/hw-tdengine/src/main/resources/mapper/tdengine/TdEngineMapper.xml @@ -361,6 +361,10 @@ + + drop table #{databaseName}.#{tableName} + +