diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/SystemConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/SystemConstants.java index 23b9c4f2..1475650d 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/SystemConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/SystemConstants.java @@ -54,4 +54,6 @@ public class SystemConstants { public static final Long PROCESS_ACTIVITY_ID_STOCK_NOTENOUGH = 5011L;//物料库存告警 public static final Long PROCESS_ACTIVITY_ID_PRODUCE_PAUSE = 7011L;//车间暂停通知 + + public static final Long PROCESS_ACTIVITY_ID_RECEIVE_BILL = 8011L;//收料通知单通知 } diff --git a/hw-common/hw-common-log/src/main/java/com/hw/common/log/enums/BusinessType.java b/hw-common/hw-common-log/src/main/java/com/hw/common/log/enums/BusinessType.java index de64c8e8..d97b77c8 100644 --- a/hw-common/hw-common-log/src/main/java/com/hw/common/log/enums/BusinessType.java +++ b/hw-common/hw-common-log/src/main/java/com/hw/common/log/enums/BusinessType.java @@ -88,7 +88,7 @@ public enum BusinessType ALLOCATE, /** - * 取消分配 + * 取消分配(16) */ UNALLOCATE, @@ -110,7 +110,7 @@ public enum BusinessType /** - * 出库 + * 出库(20) */ OUTSTOCK, @@ -135,7 +135,7 @@ public enum BusinessType PRINT, /** - * 重新生成 + * 重新生成(25) */ REGENERATE, @@ -160,7 +160,7 @@ public enum BusinessType RECALL, /** - * 暂停 + * 暂停(30) */ PAUSE, diff --git a/hw-modules/hw-file/src/main/java/com/hw/file/controller/SysFileController.java b/hw-modules/hw-file/src/main/java/com/hw/file/controller/SysFileController.java index 45de984a..9d41420f 100644 --- a/hw-modules/hw-file/src/main/java/com/hw/file/controller/SysFileController.java +++ b/hw-modules/hw-file/src/main/java/com/hw/file/controller/SysFileController.java @@ -37,6 +37,8 @@ public class SysFileController SysFile sysFile = new SysFile(); sysFile.setName(FileUtils.getName(url)); sysFile.setUrl(url); + log.info("url:"+url); + log.info("name:"+sysFile.getName()); return R.ok(sysFile); } catch (Exception e) diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java index a4e1afb4..a3610bc4 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java @@ -144,8 +144,8 @@ public class KingdeeErpSyncController { * 从ERP中同步采购订单信息到MES */ @PostMapping("/syncPurchaseReceiveBillFromErp") - @Log(title = "ERP采购收料单", businessType = BusinessType.INSERT) - @InnerAuth +// @Log(title = "ERP采购收料单", businessType = BusinessType.INSERT) +// @InnerAuth public AjaxResult syncPurchaseReceiveBillFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo) { try { return AjaxResult.success(kingdeeErpSyncService.syncPurchaseReceiveBillFromErp(0, erpSyncInfoVo)); diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseReceiveBill.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseReceiveBill.java index 2dd5327f..b7de896f 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseReceiveBill.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseReceiveBill.java @@ -87,6 +87,8 @@ public class MesPurchaseReceiveBill extends BaseEntity @Excel(name = "京源项目;F_TOND_Base") private String tondBase; + private Date preDeliveryDate; + /** 单价;FPRICE */ @Excel(name = "单价;FPRICE") private BigDecimal price; @@ -251,7 +253,16 @@ public class MesPurchaseReceiveBill extends BaseEntity { return tondBase; } - public void setPrice(BigDecimal price) + + public Date getPreDeliveryDate() { + return preDeliveryDate; + } + + public void setPreDeliveryDate(Date preDeliveryDate) { + this.preDeliveryDate = preDeliveryDate; + } + + public void setPrice(BigDecimal price) { this.price = price; } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java index a07bbf0b..9d0c0f67 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java @@ -4,8 +4,11 @@ package com.hw.jindie.service.impl; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.alibaba.nacos.shaded.com.google.gson.Gson; +import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.utils.StringUtils; import com.hw.jindie.config.KingdeeConfig; +import com.hw.system.api.RemoteLogService; +import com.hw.system.api.domain.SysOperLog; import com.kingdee.bos.webapi.entity.RepoRet; import com.kingdee.bos.webapi.entity.RepoStatus; import com.kingdee.bos.webapi.sdk.K3CloudApi; @@ -13,8 +16,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Date; +import java.util.List; /** @@ -24,6 +30,8 @@ import java.util.ArrayList; */ @Service public class KingdeeErpService { + @Resource + private RemoteLogService remoteLogService; private static final Logger logger = LoggerFactory.getLogger(KingdeeErpService.class); @@ -115,6 +123,8 @@ public class KingdeeErpService { RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class); logger.info("singleSavePurchaseRequisition接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson); RepoStatus responseStatus = repoRet.getResult().getResponseStatus(); + List sysOperLogList = new ArrayList<>(); + Date currentDate = new Date(); if (responseStatus.isIsSuccess()) { JSONObject json = new JSONObject(); json.put("formId", KingdeeConfig.PUR_Requisition); @@ -125,12 +135,28 @@ public class KingdeeErpService { if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()) { logger.error("singleSavePurchaseRequisitionCommitException|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); } + + SysOperLog sysOperLogCommit = this.getSysOperLog("原材料入库申请单提交", 1, "com.hw.jindie.controller.KingdeeErpSyncController.syncPurchaseReceiveBillFromErp", + "POST", "syncPurchaseReceiveBillFromErp", "PUR_ReceiveBill(" + json.toString() + ")", commitRepoRet.toString(), currentDate, 1L); + sysOperLogList.add(sysOperLogCommit); + //采购申请单审核 String auditResult = this.genericAuditInterface(json); RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class); if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()) { - logger.error("singleSavePurchaseRequisitionAuditException|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); + logger.error("singleSavePurchaseRequisitionAuditException|请求参数:" + json.toJSONString() + "|返回结果:" + auditRepoRet); + } + + SysOperLog sysOperLogAudit = this.getSysOperLog("原材料入库申请单审核", 1, "com.hw.jindie.controller.KingdeeErpSyncController.syncPurchaseReceiveBillFromErp", + "POST", "syncPurchaseReceiveBillFromErp", "PUR_ReceiveBill(" + json.toString() + ")", commitRepoRet.toString(), currentDate, 1L); + sysOperLogList.add(sysOperLogAudit); + + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } } + } return gson.toJson(responseStatus); } catch (Exception e) { @@ -265,27 +291,51 @@ public class KingdeeErpService { String saveParams = data.toJSONString(); String resultJson = client.save(formId, saveParams); + List sysOperLogList = new ArrayList<>(); + Date currentDate = new Date(); //用于记录结果 Gson gson = new Gson(); //对返回结果进行解析和校验 RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class); logger.info("savePurchaseStorage接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson); RepoStatus responseStatus = repoRet.getResult().getResponseStatus(); + if (responseStatus.isIsSuccess()) { + Long beginTimeL = System.currentTimeMillis(); JSONObject json = new JSONObject(); json.put("formId", KingdeeConfig.STK_InStock); json.put("Ids", repoRet.getResult().getId()); //采购入库单提交 String commitResult = this.genericCommitInterface(json); RepoRet commitRepoRet = gson.fromJson(commitResult, RepoRet.class); + String commitResultStr = "成功"; if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()) { + commitResultStr = "失败"; logger.error("savePurchaseStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); } + + SysOperLog sysOperLogCommit = this.getSysOperLog("原材料入库申请单提交", 1, "com.hw.jindie.controller.KingdeeErpSyncController.savePurchaseStorage", + "POST", "syncPurchaseReceiveBillFromErp", formId+"(" + json.toString() + ")", commitResultStr, currentDate, System.currentTimeMillis()-beginTimeL); + sysOperLogList.add(sysOperLogCommit); + + beginTimeL = System.currentTimeMillis(); //采购入库单审核 String auditResult = this.genericAuditInterface(json); RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class); + String auditResultStr = "成功"; if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()) { - logger.error("savePurchaseStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); + auditResultStr = "失败"; + logger.error("savePurchaseStorage|请求参数:" + json.toJSONString() + "|返回结果:" + auditRepoRet); + } + + SysOperLog sysOperLogAudit = this.getSysOperLog("原材料入库申请单审核", 1, "com.hw.jindie.controller.KingdeeErpSyncController.savePurchaseStorage", + "POST", "syncPurchaseReceiveBillFromErp", formId+"(" + json.toString() + ")", auditResultStr, currentDate, System.currentTimeMillis()-beginTimeL); + sysOperLogList.add(sysOperLogAudit); + + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } } } return gson.toJson(responseStatus); @@ -459,6 +509,9 @@ public class KingdeeErpService { String saveParams = data.toJSONString(); String resultJson = client.save(formId, saveParams); + List sysOperLogList = new ArrayList<>(); + Date currentDate = new Date(); + //用于记录结果 Gson gson = new Gson(); //对返回结果进行解析和校验 @@ -466,21 +519,44 @@ public class KingdeeErpService { logger.info("saveOtherOutStorage接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson); RepoStatus responseStatus = repoRet.getResult().getResponseStatus(); if (responseStatus.isIsSuccess()) { + Long beginTimeL = System.currentTimeMillis(); JSONObject json = new JSONObject(); json.put("formId", KingdeeConfig.STK_MisDelivery); json.put("Ids", repoRet.getResult().getId()); //其他出库单提交 String commitResult = this.genericCommitInterface(json); RepoRet commitRepoRet = gson.fromJson(commitResult, RepoRet.class); + String commitResultStr = "成功"; if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()) { + commitResultStr = "失败"; logger.error("saveOtherOutStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); } + + SysOperLog sysOperLogCommit = this.getSysOperLog("其他出库单提交", 1, "com.hw.jindie.controller.KingdeeErpSyncController.saveOtherOutStorage", + "POST", "saveOtherOutStorage", formId+"(" + json.toString() + ")", commitResultStr, currentDate, System.currentTimeMillis()-beginTimeL); + sysOperLogList.add(sysOperLogCommit); + + beginTimeL = System.currentTimeMillis(); //其他出库单审核 String auditResult = this.genericAuditInterface(json); RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class); + String auditResultStr = "成功"; if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()) { + auditResultStr = "失败"; logger.error("saveOtherOutStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); } + + SysOperLog sysOperLogAudit = this.getSysOperLog("其他出库单审核", 1, "com.hw.jindie.controller.KingdeeErpSyncController.saveOtherOutStorage", + "POST", "saveOtherOutStorage", formId+"(" + json.toString() + ")", auditResultStr, currentDate, System.currentTimeMillis()-beginTimeL); + sysOperLogList.add(sysOperLogAudit); + + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } + } + + } return gson.toJson(responseStatus); } catch (Exception e) { @@ -552,6 +628,9 @@ public class KingdeeErpService { String saveParams = data.toJSONString(); String resultJson = client.save(formId, saveParams); + List sysOperLogList = new ArrayList<>(); + Date currentDate = new Date(); + //用于记录结果 Gson gson = new Gson(); //对返回结果进行解析和校验 @@ -559,21 +638,43 @@ public class KingdeeErpService { logger.info("saveOtherInStorage接口调用成功|请求参数:" + saveParams + "|返回结果:" + resultJson); RepoStatus responseStatus = repoRet.getResult().getResponseStatus(); if (responseStatus.isIsSuccess()) { + Long beginTimeL = System.currentTimeMillis(); JSONObject json = new JSONObject(); json.put("formId", KingdeeConfig.STK_MISCELLANEOUS); json.put("Ids", repoRet.getResult().getId()); //其他入库单提交 String commitResult = this.genericCommitInterface(json); RepoRet commitRepoRet = gson.fromJson(commitResult, RepoRet.class); + String commitResultStr = "成功"; if (!commitRepoRet.getResult().getResponseStatus().isIsSuccess()){ + commitResultStr = "失败"; logger.error("saveOtherInStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); } + + SysOperLog sysOperLogCommit = this.getSysOperLog("其他入库单提交", 1, "com.hw.jindie.controller.KingdeeErpSyncController.saveOtherInStorage", + "POST", "saveOtherInStorage", formId+"(" + json.toString() + ")", commitResultStr, currentDate, System.currentTimeMillis()-beginTimeL); + sysOperLogList.add(sysOperLogCommit); + + beginTimeL = System.currentTimeMillis(); //其他入库单审核 String auditResult = this.genericAuditInterface(json); RepoRet auditRepoRet = gson.fromJson(auditResult, RepoRet.class); + String auditResultStr = "成功"; if (!auditRepoRet.getResult().getResponseStatus().isIsSuccess()){ + auditResultStr = "失败"; logger.error("saveOtherInStorage|请求参数:" + json.toJSONString() + "|返回结果:" + commitRepoRet); } + + SysOperLog sysOperLogAudit = this.getSysOperLog("其他入库单审核", 1, "com.hw.jindie.controller.KingdeeErpSyncController.saveOtherInStorage", + "POST", "saveOtherInStorage", formId+"(" + json.toString() + ")", auditResultStr, currentDate, System.currentTimeMillis()-beginTimeL); + sysOperLogList.add(sysOperLogAudit); + + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } + } + } return gson.toJson(responseStatus); } catch (Exception e) { @@ -583,4 +684,24 @@ public class KingdeeErpService { } + private SysOperLog getSysOperLog(String logTitle, Integer businessType, String method, String requestMethod, String operUrl, + String operParam, String jsonResult, Date operTime, Long costTime) throws Exception { + SysOperLog sysOperLog = new SysOperLog(); + sysOperLog.setTitle(logTitle); + sysOperLog.setBusinessType(businessType); + sysOperLog.setMethod(method); + sysOperLog.setRequestMethod(requestMethod); + sysOperLog.setOperatorType(0); + sysOperLog.setOperIp("127.0.0.1"); + sysOperLog.setOperName("定时任务"); + sysOperLog.setOperUrl(operUrl); + sysOperLog.setOperParam(operParam); + sysOperLog.setJsonResult(jsonResult); + sysOperLog.setStatus(0); + sysOperLog.setOperTime(operTime); + sysOperLog.setCostTime(costTime); + + return sysOperLog; + } + } 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 b45c844b..ab39d9be 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 @@ -1219,7 +1219,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { // String FDocumentStatus = "C"; JSONObject queryJson = new JSONObject(); String formId = "PUR_ReceiveBill"; - String fieldKeys = "FID,FBillNo,FDocumentStatus,FSupplierId,FModifyDate,FCreateDate,FStockOrgId,FActlandQty,FActReceiveQty,FDetailEntity_FEntryID,FDetailEntity_Link_FSBillId,FDetailEntity_Link_FSId,FOrderBillNo,FMaterialId,FMaterialId.FNumber,FMaterialId.Fname"; + String fieldKeys = "FID,FBillNo,FDocumentStatus,FSupplierId,FModifyDate,FCreateDate,FStockOrgId,FActlandQty,FActReceiveQty,FDetailEntity_FEntryID,FDetailEntity_Link_FSBillId,FDetailEntity_Link_FSId,FPreDeliveryDate,FOrderBillNo,FMaterialId,FMaterialId.FNumber,FMaterialId.Fname,FMateriaModel,F_TOND_Base"; // String filterString = ""; String orderString = ""; int topRowCount = 0; @@ -1265,6 +1265,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { List sysOperLogList = new ArrayList<>(); Date currentDate = new Date(); StringBuilder notifyInfoBuilder = new StringBuilder("收料通知:"); + Long projectErpId = null; + String projectName = ""; try { for (int i = 0; i < resultArray.size(); i++) { Long beginTimeL = System.currentTimeMillis(); @@ -1296,8 +1298,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { String fsId = resultObject.getString("FDetailEntity.Link.FSId"); Long fStockOrgId = resultObject.getLong("FStockOrgId"); - //京源项目 -// String tondBase = resultObject.getString("F.TOND.Base"); + //供应商id Long supplierId = resultObject.getLong("FSupplierId"); @@ -1313,6 +1314,11 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { //更新时间 String FModifyDate = resultObject.getString("FModifyDate"); + String tondBase = resultObject.getString("F.TOND.Base"); + String materialSpec = resultObject.getString("FMateriaModel"); + //计划交货日期 + String preDeliveryDate = resultObject.getString("FPreDeliveryDate"); + mesPurchaseReceiveBill.setErpId(erpId); mesPurchaseReceiveBill.setBillNo(billNo); mesPurchaseReceiveBill.setPoNo(poNo); @@ -1326,10 +1332,13 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { mesPurchaseReceiveBill.setPurchaseOrgId(fStockOrgId); mesPurchaseReceiveBill.setActReceiveAmount(actReceiveAmount); mesPurchaseReceiveBill.setActLandAmount(actlandAmount); -// mesPurchaseReceiveBill.setTondBase(tondBase); + mesPurchaseReceiveBill.setTondBase(tondBase); mesPurchaseReceiveBill.setSupplierId(supplierId); mesPurchaseReceiveBill.setUpdateTime(currentDate); + if (preDeliveryDate != null) { + mesPurchaseReceiveBill.setPreDeliveryDate(conversionERPTime(preDeliveryDate)); + } if (approveDate != null) { mesPurchaseReceiveBill.setApproveDate(conversionERPTime(approveDate)); @@ -1349,12 +1358,33 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { MesPurchaseReceiveBill existedPurchaseReceiveBill = mesPurchaseReceiveBillMapper.selectMesPurchaseReceiveBillByUI(erpId, fentryId); + + if (StringUtils.isNotEmpty(tondBase)) { + Long tondBaseL = Long.valueOf(tondBase); + if (StringUtils.isEmpty(projectName)) { + projectErpId = tondBaseL; + MesProjectInfo mesProjectInfo = mesProjectInfoMapper.selectMesProjectInfoByErpId(tondBaseL); + projectName = mesProjectInfo == null ? "" : mesProjectInfo.getProjectName(); + }else{ + if(!tondBaseL.equals(projectErpId)){ + projectErpId = tondBaseL; + MesProjectInfo mesProjectInfo = mesProjectInfoMapper.selectMesProjectInfoByErpId(tondBaseL); + projectName = mesProjectInfo == null ? "" : mesProjectInfo.getProjectName(); + } + } + + } + + if (existedPurchaseReceiveBill != null) { mesPurchaseReceiveBill.setReceiveBillId(existedPurchaseReceiveBill.getReceiveBillId()); toUpdatePurchaseReceiveBillList.add(mesPurchaseReceiveBill); } else { toInsertPurchaseReceiveBillList.add(mesPurchaseReceiveBill); - notifyInfoBuilder.append(materialName).append(";"); + notifyInfoBuilder.append("物料名称:").append(materialName).append("|物料规格:").append(materialSpec) + .append("|实到数量:").append(actlandAmount).append("|预计到货日期:") + .append(preDeliveryDate).append("|项目名称:").append(projectName) + .append(";"); } // System.out.println("l:"+resultArray.get(i).toString().length()); @@ -1413,7 +1443,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { sysPointRouter.setProcessActivityId(SystemConstants.PROCESS_ACTIVITY_ID_STOCK_NOTENOUGH); sysPointRouter.setCreateBy("定时任务"); sysPointRouter.setCreateTime(new Date()); - sysPointRouter.setProcessActivityId(7011L); + sysPointRouter.setProcessActivityId(SystemConstants.PROCESS_ACTIVITY_ID_RECEIVE_BILL); sysPointRouter.setEmailFlag("1"); sysPointRouter.setSentEmailFlag("0"); diff --git a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseReceiveBillMapper.xml b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseReceiveBillMapper.xml index 6c2d2151..255435f4 100644 --- a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseReceiveBillMapper.xml +++ b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseReceiveBillMapper.xml @@ -22,6 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -83,6 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" erp_modify_date, purchase_org_id, tond_base, + pre_delivery_date, price, supplier_id, remark, @@ -108,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{erpModifyDate}, #{purchaseOrgId}, #{tondBase}, + #{preDeliveryDate}, #{price}, #{supplierId}, #{remark}, @@ -137,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" erp_modify_date = #{erpModifyDate}, purchase_org_id = #{purchaseOrgId}, tond_base = #{tondBase}, + pre_delivery_date = #{preDeliveryDate}, price = #{price}, supplier_id = #{supplierId}, remark = #{remark}, diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java index bc4eebc5..14448cbf 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java @@ -323,4 +323,40 @@ public class MesProductPlanController extends BaseController { return R.fail(e.getMessage()); } } + + /** + * 获取生产派工附件List列表 + * @param attachType + * @param dispatchCode + * @param processId + * @param userId + * @return + */ + @GetMapping(value = "/attachInfoList/{attachType}/{dispatchCode}/{processId}/{userId}") + public AjaxResult getAttachInfoList(@PathVariable("attachType") String attachType, @PathVariable("dispatchCode") String dispatchCode, + @PathVariable("processId") Long processId, @PathVariable("userId") Long userId) { + return success(mesProductPlanService.getAttachInfoList(dispatchCode, processId, userId, attachType)); + } + + /** + * 校验生产派工是否已绑定附件 + * @param attachType + * @param attachId + * @return + */ + @GetMapping(value = "/checkMesProductPlanAttachInfo/{attachType}/{attachId}") + public AjaxResult checkMesProductPlanAttachInfo(@PathVariable("attachType") String attachType, @PathVariable("attachId") String attachId) { + return success(mesProductPlanService.checkMesProductPlanAttachInfo(attachType, attachId)); + } + + /** + * 根据planId获取生产派工SOP附件List列表 + * @param attachType + * @param planId + * @return + */ + @GetMapping(value = "/getDispatchAttachByPlanIdList/{attachType}/{planId}") + public AjaxResult getDispatchAttachByPlanIdList(@PathVariable("attachType") String attachType, @PathVariable("planId") Long planId) { + return success(mesProductPlanService.getDispatchAttachByPlanIdList(attachType, planId)); + } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java index 4876d50a..8abe359e 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java @@ -5,14 +5,12 @@ import java.util.List; import java.util.Map; import com.hw.mes.domain.MesBaseAttachInfo; -import com.hw.mes.domain.MesMaterialBom; import com.hw.mes.domain.MesProductOrder; import com.hw.mes.domain.MesProductPlan; import com.hw.mes.domain.vo.MesAssignTaskVo; import com.hw.mes.domain.vo.MesMaterialScanVo; import com.hw.mes.domain.vo.MesProductPlanDeleteVo; import com.hw.mes.domain.vo.MesProductPlanEditVo; -import org.springframework.transaction.annotation.Transactional; /** * 生产派工Service接口 @@ -187,4 +185,29 @@ public interface IMesProductPlanService */ public List selectMesProductPlanJoinUserList(MesProductPlan mesProductPlan); + /** + * 获取生产派工附件List列表 + * @param attachType + * @param dispatchCode + * @param processId + * @param userId + * @return + */ + public List getAttachInfoList(String dispatchCode, Long processId, Long userId, String attachType); + + /** + * 校验生产派工是否已绑定附件 + * @param attachType + * @param attachId + * @return + */ + String checkMesProductPlanAttachInfo(String attachType, String attachId); + + /** + * 根据planId获取生产派工SOP附件List列表 + * @param attachType + * @param planId + * @return + */ + public List getDispatchAttachByPlanIdList(String attachType, Long planId); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java index d867c37f..d4b4e08f 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesMaterialBomServiceImpl.java @@ -7,6 +7,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import com.hw.common.core.constant.CacheConstants; +import com.hw.common.core.constant.MesConstants; import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.domain.R; import com.hw.common.core.exception.ServiceException; @@ -15,6 +16,7 @@ import com.hw.common.core.utils.MailUtils; import com.hw.common.core.utils.StringUtils; import com.hw.common.redis.service.RedisService; import com.hw.mes.domain.MesBaseAttachInfo; +import com.hw.mes.mapper.MesProductPlanMapper; import com.hw.mes.service.IMesBaseAttachInfoService; import com.hw.system.api.RemoteUserService; import com.hw.system.api.domain.SysUser; @@ -46,6 +48,9 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { @Autowired private RedisService redisService; + @Autowired + private MesProductPlanMapper mesProductPlanMapper; + /** * 查询物料BOM信息 * @@ -290,23 +295,26 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { public List getBomAttachInfo(String attachType, Long[] materialBomIds) { List attachIdList = new ArrayList<>(); for (Long materialBomId : materialBomIds) { - if (attachType.equals("1")){ - MesMaterialBom materialBom = mesMaterialBomMapper.selectMesMaterialBomByMaterialBomId(materialBomId); - if (StringUtils.isNotEmpty(materialBom.getAttachId())){ - String[] split = materialBom.getAttachId().split(","); - List longList = Arrays.stream(split) - .map(Long::valueOf) // 转换每个字符串为 Long - .collect(Collectors.toList()); - attachIdList.addAll(longList); - } - } else { - MesMaterialBom materialBom = mesMaterialBomMapper.selectMesMaterialBomByMaterialBomId(materialBomId); - if (StringUtils.isNotEmpty(materialBom.getSopId())){ - String[] split = materialBom.getSopId().split(","); - List longList = Arrays.stream(split) - .map(Long::valueOf) // 转换每个字符串为 Long - .collect(Collectors.toList()); - attachIdList.addAll(longList); + MesMaterialBom mesMaterialBom = new MesMaterialBom(); + mesMaterialBom.setAncestors(materialBomId.toString()); + List materialBomList = mesMaterialBomMapper.selectMesMaterialBomList(mesMaterialBom); + for (MesMaterialBom materialBom : materialBomList) { + if (attachType.equals(MesConstants.MES_ATTACH_TYPE_DRAWING)){ + if (StringUtils.isNotEmpty(materialBom.getAttachId())){ + String[] split = materialBom.getAttachId().split(","); + List longList = Arrays.stream(split) + .map(Long::valueOf) // 转换每个字符串为 Long + .collect(Collectors.toList()); + attachIdList.addAll(longList); + } + } else { + if (StringUtils.isNotEmpty(materialBom.getSopId())){ + String[] split = materialBom.getSopId().split(","); + List longList = Arrays.stream(split) + .map(Long::valueOf) // 转换每个字符串为 Long + .collect(Collectors.toList()); + attachIdList.addAll(longList); + } } } } 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 7e622df8..85c01539 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 @@ -9,12 +9,10 @@ import com.hw.common.core.constant.MesConstants; import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.SocketUtils; -import com.hw.common.core.utils.ip.IpUtils; import com.hw.common.core.utils.uuid.Seq; import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.api.domain.MesBaseBarcodeInfo; -import com.hw.mes.api.domain.MesBaseStationInfo; import com.hw.mes.config.MesConfig; import com.hw.mes.domain.*; import com.hw.mes.domain.vo.MesAssignTaskVo; @@ -25,7 +23,6 @@ import com.hw.mes.mapper.*; import com.hw.mes.service.IMesBaseAttachInfoService; import com.hw.mes.service.IMesProductOrderService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import com.hw.common.core.utils.StringUtils; @@ -776,6 +773,123 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { return mesProductPlanMapper.selectMesProductPlanJoinUserList(mesProductPlan); } + /** + * 获取生产派工附件List列表 + * @param attachType + * @param dispatchCode + * @param processId + * @param userId + * @return + */ + @Override + public List getAttachInfoList(String dispatchCode, Long processId, Long userId, String attachType) { + MesProductPlan queryProductPlan = new MesProductPlan(); + queryProductPlan.setProcessId(processId); + queryProductPlan.setDispatchCode(dispatchCode); + queryProductPlan.setUserId(userId); + List mesProductPlans = mesProductPlanMapper.selectOnlyMesProductPlans(queryProductPlan); + if (mesProductPlans != null && !mesProductPlans.isEmpty()) { + MesProductPlan mesProductPlan = mesProductPlans.get(0); + try { + if (attachType.equals(MesConstants.MES_ATTACH_TYPE_DRAWING)) { + if (StringUtils.isEmpty(mesProductPlan.getAttachId())) { + return new ArrayList<>(); + } + Long[] attachIds = Arrays.stream(mesProductPlan.getAttachId().split(",")) + .map(String::trim) + .map(Long::parseLong) + .toArray(Long[]::new); + return mesBaseAttachInfoService.selectMesBaseAttachInfoByAttachIds(attachIds); + } else if (attachType.equals(MesConstants.MES_ATTACH_TYPE_SOP)) { + if (StringUtils.isEmpty(mesProductPlan.getSopId())) { + return new ArrayList<>(); + } + Long[] sopIds = Arrays.stream(mesProductPlan.getSopId().split(",")) + .map(String::trim) + .map(Long::parseLong) + .toArray(Long[]::new); + return mesBaseAttachInfoService.selectMesBaseAttachInfoByAttachIds(sopIds); + } else { + return new ArrayList<>(); + } + } catch (Exception e) { + return new ArrayList<>(); + } + } + return new ArrayList<>(); + } + + /** + * 校验生产派工是否已绑定附件 + * @param attachType + * @param attachId + * @return + */ + @Override + public String checkMesProductPlanAttachInfo(String attachType, String attachId) { + String result = null; + StringBuilder buffer = new StringBuilder(); + buffer.append("生产派工已绑定此"); + List productPlanList = new ArrayList<>(); + MesProductPlan mesProductPlan = new MesProductPlan(); + if (attachType.equals(MesConstants.MES_ATTACH_TYPE_DRAWING)) { + mesProductPlan.setAttachId(attachId); + productPlanList = mesProductPlanMapper.selectMesProductPlanList(mesProductPlan); + buffer.append("图纸!"); + } else if (attachType.equals(MesConstants.MES_ATTACH_TYPE_SOP)){ + mesProductPlan.setSopId(attachId); + productPlanList = mesProductPlanMapper.selectMesProductPlanList(mesProductPlan); + buffer.append("SOP!"); + } + if (productPlanList.size() > 0){ + result = buffer.toString(); + } + //未绑定 + return result; + } + + /** + * 根据planId获取生产派工SOP附件List列表 + * @param attachType + * @param planId + * @return + */ + @Override + public List getDispatchAttachByPlanIdList(String attachType, Long planId) { + MesProductPlan queryProductPlan = new MesProductPlan(); + queryProductPlan.setPlanId(planId); + List mesProductPlans = mesProductPlanMapper.selectOnlyMesProductPlans(queryProductPlan); + if (mesProductPlans != null && !mesProductPlans.isEmpty()) { + MesProductPlan mesProductPlan = mesProductPlans.get(0); + try { + if (attachType.equals(MesConstants.MES_ATTACH_TYPE_DRAWING)) { + if (StringUtils.isEmpty(mesProductPlan.getAttachId())) { + return new ArrayList<>(); + } + Long[] attachIds = Arrays.stream(mesProductPlan.getAttachId().split(",")) + .map(String::trim) + .map(Long::parseLong) + .toArray(Long[]::new); + return mesBaseAttachInfoService.selectMesBaseAttachInfoByAttachIds(attachIds); + } else if (attachType.equals(MesConstants.MES_ATTACH_TYPE_SOP)) { + if (StringUtils.isEmpty(mesProductPlan.getSopId())) { + return new ArrayList<>(); + } + Long[] sopIds = Arrays.stream(mesProductPlan.getSopId().split(",")) + .map(String::trim) + .map(Long::parseLong) + .toArray(Long[]::new); + return mesBaseAttachInfoService.selectMesBaseAttachInfoByAttachIds(sopIds); + } else { + return new ArrayList<>(); + } + } catch (Exception e) { + return new ArrayList<>(); + } + } + return new ArrayList<>(); + } + // public String executeAssignTaskResultTask() { // ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml index ad32149d..c785794a 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml @@ -62,7 +62,7 @@ and parent_id = #{parentId} - and ancestors like concat('%', #{ancestors},'%') + and (material_bom_id = #{ancestors} or ancestors like concat('%', #{ancestors},'%')) and material_id = #{materialId} and erp_material_id = #{erpMaterialId} and material_name like concat('%', #{materialName}, 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 293e5821..6221e7a3 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 @@ -152,7 +152,8 @@ and mpp.plan_end_time = #{planEndTime} and mpp.real_begin_time = #{realBeginTime} and mpp.real_end_time = #{realEndTime} - and mpp.attach_id = #{attachId} + and mpp.attach_id like concat('%', #{attachId},'%') + and mpp.sop_id like concat('%', #{sopId},'%') and mpp.plan_status = #{planStatus} and mpp.is_flag = #{isFlag} @@ -508,8 +509,10 @@ a.is_flag from mes_product_plan a + and a.plan_id = #{planId} and a.dispatch_code = #{dispatchCode} and a.process_id = #{processId} + and a.user_id = #{userId} and a.final_process_flag = #{finalProcessFlag} and a.product_order_id = #{productOrderId} diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProjectInfoMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProjectInfoMapper.xml index 2b1f96c8..bf3912b6 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProjectInfoMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProjectInfoMapper.xml @@ -45,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and complete_date = #{completeDate} and is_flag = #{isFlag} + order by erp_modify_date desc