diff --git a/hw-api/hw-api-system/src/main/java/com/hw/system/api/RemoteSysCommonService.java b/hw-api/hw-api-system/src/main/java/com/hw/system/api/RemoteSysCommonService.java index f25b31e7..3f44011c 100644 --- a/hw-api/hw-api-system/src/main/java/com/hw/system/api/RemoteSysCommonService.java +++ b/hw-api/hw-api-system/src/main/java/com/hw/system/api/RemoteSysCommonService.java @@ -34,4 +34,7 @@ public interface RemoteSysCommonService { @PostMapping("/wfprocessactivity/processActivityUserInfo") R selectProcessActivityUserInfo(@RequestHeader(SecurityConstants.FROM_SOURCE) String source, Long processActivityId); + + @PostMapping("/pointRouter/processActivityEmailNotify") + R processActivityEmailNotify(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); } diff --git a/hw-api/hw-api-system/src/main/java/com/hw/system/api/domain/common/SysPointRouter.java b/hw-api/hw-api-system/src/main/java/com/hw/system/api/domain/common/SysPointRouter.java index 28e8f6cf..e789214b 100644 --- a/hw-api/hw-api-system/src/main/java/com/hw/system/api/domain/common/SysPointRouter.java +++ b/hw-api/hw-api-system/src/main/java/com/hw/system/api/domain/common/SysPointRouter.java @@ -56,6 +56,12 @@ public class SysPointRouter extends BaseEntity { @Excel(name = "提示信息") private String remark; + private Long processActivityId; + + private String emailFlag; + + private String sentEmailFlag; + @Override public String getRemark() { return remark; @@ -114,6 +120,30 @@ public class SysPointRouter extends BaseEntity { return routerFlag; } + public Long getProcessActivityId() { + return processActivityId; + } + + public void setProcessActivityId(Long processActivityId) { + this.processActivityId = processActivityId; + } + + public String getEmailFlag() { + return emailFlag; + } + + public void setEmailFlag(String emailFlag) { + this.emailFlag = emailFlag; + } + + public String getSentEmailFlag() { + return sentEmailFlag; + } + + public void setSentEmailFlag(String sentEmailFlag) { + this.sentEmailFlag = sentEmailFlag; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-api/hw-api-system/src/main/java/com/hw/system/api/factory/RemoteSysCommonFallbackFactory.java b/hw-api/hw-api-system/src/main/java/com/hw/system/api/factory/RemoteSysCommonFallbackFactory.java index 65bb8c7d..82d32534 100644 --- a/hw-api/hw-api-system/src/main/java/com/hw/system/api/factory/RemoteSysCommonFallbackFactory.java +++ b/hw-api/hw-api-system/src/main/java/com/hw/system/api/factory/RemoteSysCommonFallbackFactory.java @@ -57,6 +57,11 @@ public class RemoteSysCommonFallbackFactory implements FallbackFactory processActivityEmailNotify(String source) { + return R.fail("发送工单流程节点权限用户邮件失败:" + throwable.getMessage()); + } + }; } 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 b6edc6f8..a53f7129 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 @@ -38,4 +38,16 @@ public class SystemConstants { public static final String SYS_ROUTER_DMS_ALARM_URL = "/dms/deviceAlarm/dmsRecordAlarmInfo"; + /** + * 工单流程节点ID + */ + public static final Long PROCESS_ACTIVITY_ID_QUALITY_CHECK_ABNORMAL = 3012L;//质检异常处理 + public static final Long PROCESS_ACTIVITY_ID_PRODUCT_ORDER_OVERTIME = 2021L;//生产工单超时 + public static final Long PROCESS_ACTIVITY_ID_PURCHASEORDER_OVERTIME = 2031L;//采购订单交货超时 + + public static final Long PROCESS_ACTIVITY_ID_SALE_ORDER_OVERTIME = 2041L;//销售订单交货超时 + + public static final Long PROCESS_ACTIVITY_ID_DEVICE_ALARM = 1071L;//设备报警处理 + + public static final Long PROCESS_ACTIVITY_ID_STOCK_NOTENOUGH = 5011L;//物料库存告警 } diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/MailUtils.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/MailUtils.java index 37e831f4..6d5403c0 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/MailUtils.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/MailUtils.java @@ -9,44 +9,46 @@ public class MailUtils { public static void main(String[] args) { // 设置发件人、收件人、SMTP服务器等信息 - String senderEmail = "chencheng01@jsjyep.com"; - String receiverEmail = "chencheng01@jsjyep.com"; - String password = "QH6faJaWw5rgvM4u"; - String host = "smtp.exmail.qq.com"; // SMTP服务器地址 - int port = 465; // 端口号,如果是SSL连接常用465,非SSL常用587或25 - - // 设置邮件服务器的属性 - Properties props = new Properties(); - props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.ssl.enable", "true"); // 启用SSL - props.put("mail.smtp.ssl.protocols", "TLSv1.2"); // 设置SSL/TLS版本 - -// props.put("mail.smtp.starttls.enable", "true"); // 如果是SSL连接,则不需要这行 - props.put("mail.smtp.host", host); - props.put("mail.smtp.port", port); - - // 创建会话 - Session session = Session.getInstance(props, new Authenticator() { - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(senderEmail, password); - } - }); - - try { - // 创建邮件消息 - Message message = new MimeMessage(session); - message.setFrom(new InternetAddress(senderEmail)); - message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(receiverEmail)); - message.setSubject("测试"); - message.setText("测试正文内容"); +// String senderEmail = "chencheng01@jsjyep.com"; +// String receiverEmail = "chencheng01@jsjyep.com"; +// String password = "QH6faJaWw5rgvM4u"; +// String host = "smtp.exmail.qq.com"; // SMTP服务器地址 +// int port = 465; // 端口号,如果是SSL连接常用465,非SSL常用587或25 +// +// // 设置邮件服务器的属性 +// Properties props = new Properties(); +// props.put("mail.smtp.auth", "true"); +// props.put("mail.smtp.ssl.enable", "true"); // 启用SSL +// props.put("mail.smtp.ssl.protocols", "TLSv1.2"); // 设置SSL/TLS版本 +// +//// props.put("mail.smtp.starttls.enable", "true"); // 如果是SSL连接,则不需要这行 +// props.put("mail.smtp.host", host); +// props.put("mail.smtp.port", port); +// +// // 创建会话 +// Session session = Session.getInstance(props, new Authenticator() { +// protected PasswordAuthentication getPasswordAuthentication() { +// return new PasswordAuthentication(senderEmail, password); +// } +// }); +// +// try { +// // 创建邮件消息 +// Message message = new MimeMessage(session); +// message.setFrom(new InternetAddress(senderEmail)); +// message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(receiverEmail)); +// message.setSubject("测试"); +// message.setText("测试正文内容"); +// +// // 发送邮件 +// Transport.send(message); +//// System.out.println("邮件已成功发送!"); +// } catch (MessagingException e) { +// e.printStackTrace(); +// throw new RuntimeException(e); +// } - // 发送邮件 - Transport.send(message); -// System.out.println("邮件已成功发送!"); - } catch (MessagingException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } + processSendEmail("ericxinstar@163.com","ddd","ddde"); } /** @@ -57,9 +59,9 @@ public class MailUtils { */ public static void processSendEmail(String receiverEmail, String subject, String text) { // 设置发件人、收件人、SMTP服务器等信息 - String senderEmail = "chencheng01@jsjyep.com"; + String senderEmail = "zhuangbeizhizaozhongxin@jsjyep.com"; // String receiverEmail = "chencheng01@jsjyep.com"; - String password = "QH6faJaWw5rgvM4u"; + String password = "Dingxl226129"; String host = "smtp.exmail.qq.com"; // SMTP服务器地址 int port = 465; // 端口号,如果是SSL连接常用465,非SSL常用587或25 @@ -74,6 +76,12 @@ public class MailUtils { props.put("mail.smtp.port", port); // 创建会话 +// Session session = Session.getInstance(props, new Authenticator() { +// protected PasswordAuthentication getPasswordAuthentication() { +// return new PasswordAuthentication(senderEmail, password); +// } +// }); + Session session = Session.getInstance(props, new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(senderEmail, password); @@ -97,4 +105,6 @@ public class MailUtils { } } + + } diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsRecordAlarmInfoServiceImpl.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsRecordAlarmInfoServiceImpl.java index 8081ec8d..56fb2af7 100644 --- a/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsRecordAlarmInfoServiceImpl.java +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsRecordAlarmInfoServiceImpl.java @@ -136,19 +136,21 @@ public class DmsRecordAlarmInfoServiceImpl implements IDmsRecordAlarmInfoService List webRouterList = new ArrayList<>(); Gson gson = new Gson(); HashMap map = new HashMap<>(); - for (DmsRecordAlarmInfo alarmInfo : alarmInfoList) { - SysPointRouter pointRouter = new SysPointRouter(); - pointRouter.setModuleCode(SystemConstants.DMS); - pointRouter.setPointType(SystemConstants.SYS_ROUTER_POINT_TYPE_ALARM); - pointRouter.setRouterAddress(SystemConstants.SYS_ROUTER_DMS_ALARM_URL); - map.put("alarmId", alarmInfo.getAlarmId()); - String json = gson.toJson(map); - pointRouter.setRouterAddressDetail(json); - pointRouter.setRemark(alarmInfo.getAlarmReason()); - webRouterList.add(pointRouter); - } - //WEB通知 - remoteSysCommonService.insertSysPointRouterPort(webRouterList, SecurityConstants.INNER); + //trigger写此逻辑 +// for (DmsRecordAlarmInfo alarmInfo : alarmInfoList) { +// SysPointRouter pointRouter = new SysPointRouter(); +// pointRouter.setModuleCode(SystemConstants.DMS); +// pointRouter.setPointType(SystemConstants.SYS_ROUTER_POINT_TYPE_ALARM); +// pointRouter.setRouterAddress(SystemConstants.SYS_ROUTER_DMS_ALARM_URL); +// pointRouter.setProcessActivityId(SystemConstants.PROCESS_ACTIVITY_ID_QUALITY_CHECK_ABNORMAL); +// map.put("alarmId", alarmInfo.getAlarmId()); +// String json = gson.toJson(map); +// pointRouter.setRouterAddressDetail(json); +// pointRouter.setRemark(alarmInfo.getAlarmReason()); +// webRouterList.add(pointRouter); +// } +// //WEB通知 +// remoteSysCommonService.insertSysPointRouterPort(webRouterList, SecurityConstants.INNER); for (DmsRecordAlarmInfo alarmInfo : alarmInfoList) { DmsRecordAlarmInfo recordAlarmInfo = new DmsRecordAlarmInfo(); recordAlarmInfo.setAlarmId(alarmInfo.getAlarmId()); diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java index 4e7e8018..bdd3aa3b 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java @@ -151,6 +151,8 @@ public class MesPurchaseOrder extends BaseEntity { */ private String specificationParameter; + private BigDecimal price; + public String getSpecificationParameter() { return specificationParameter; } @@ -367,6 +369,14 @@ public class MesPurchaseOrder extends BaseEntity { return isFlag; } + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) 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 5adf608b..3df5d648 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 @@ -929,7 +929,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { JSONObject queryJson = new JSONObject(); String formId = "PUR_PurchaseOrder"; String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FRequireDeptId,FMaterialId,FMaterialId.FNumber,FMaterialId.FName," + - "FQty,FDeliveryDate,FCreateDate,FModifyDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FAUXPROPID.FF100001,FSrcBillNo,FPurchaseOrgId,FPurchaseDeptId,F_TOND_Base,FSupplierId"; + "FQty,FDeliveryDate,FCreateDate,FModifyDate,FUnitId,FStockUnitID,FPriceUnitID,FPrice,FAuxPropId,FAUXPROPID.FF100001,FSrcBillNo,FPurchaseOrgId,FPurchaseDeptId,F_TOND_Base,FSupplierId"; // String filterString = ""; String orderString = ""; int topRowCount = 0; @@ -1006,6 +1006,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { Long stockUnitId = resultObject.getLong("FStockUnitID"); //计价单位 Long priceUnitId = resultObject.getLong("FPriceUnitID"); + //单价 + BigDecimal price = resultObject.getBigDecimal("FPrice"); //辅助属性 Long auxPropId = resultObject.getLong("FAuxPropId"); //规格参数 @@ -1035,6 +1037,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { mesPurchaseOrder.setUnitId(unitId); mesPurchaseOrder.setStockUnitId(stockUnitId); mesPurchaseOrder.setPriceUnitId(priceUnitId); + mesPurchaseOrder.setPrice(price); mesPurchaseOrder.setAuxPropId(auxPropId); mesPurchaseOrder.setSpecificationParameter(FF100001); mesPurchaseOrder.setSrcBillNo(srcBillNo); diff --git a/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java b/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java index 9554af02..5eb28fc8 100644 --- a/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java +++ b/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java @@ -7,6 +7,7 @@ import com.hw.ems.api.RemoteEmsService; import com.hw.jindie.api.RemoteJindieService; import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; import com.hw.mes.api.RemoteMesService; +import com.hw.system.api.RemoteSysCommonService; import com.hw.wms.api.RemoteWmsService; import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; @@ -33,6 +34,8 @@ public class RyTask private RemoteWmsService remoteWmsService; @Autowired private RemoteMesService remoteMesService; + @Autowired + private RemoteSysCommonService remoteSysCommonService; public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { @@ -127,28 +130,28 @@ public class RyTask } public void syncInventoryInformationToERP(){ - System.out.println("++定时同步原材料入库信息给ERP++syncInventoryInformationToERP"); + System.out.println(new Date()+"++定时同步原材料入库信息给ERP++syncInventoryInformationToERP"); remoteWmsService.synchronizeInventoryInformationToERP(SecurityConstants.INNER); } public void syncRawMaterialDeliveryInformationToERP(){ - System.out.println("++定时同步原材料出库信息给ERP++syncRawMaterialDeliveryInformationToERP"); + System.out.println(new Date()+"++定时同步原材料出库信息给ERP++syncRawMaterialDeliveryInformationToERP"); remoteWmsService.synchronizeRawMaterialDeliveryInformationToERP(SecurityConstants.INNER); } public void synchronizeRawReturnInformationToERP(){ - System.out.println("++定时同步原材料退库信息给ERP++syncRawMaterialDeliveryInformationToERP"); + System.out.println(new Date()+"++定时同步原材料退库信息给ERP++syncRawMaterialDeliveryInformationToERP"); remoteWmsService.synchronizeRawReturnInformationToERP(SecurityConstants.INNER); } public void synchronizeProductInstockInformationToERP(Integer days){ - System.out.println("++定时同步成品入库信息给ERP++synchronizeProductInstockInformationToERP"); + System.out.println(new Date()+"++定时同步成品入库信息给ERP++synchronizeProductInstockInformationToERP"); remoteWmsService.synchronizeProductInstockInformationToERP(days, SecurityConstants.INNER); } public void synchronizeProductOutstockInformationToERP(Integer days){ - System.out.println("++定时同步成品出库信息给ERP++synchronizeProductOutstockInformationToERP"); + System.out.println(new Date()+"++定时同步成品出库信息给ERP++synchronizeProductOutstockInformationToERP"); remoteWmsService.synchronizeProductOutstockInformationToERP(days, SecurityConstants.INNER); } @@ -176,4 +179,12 @@ public class RyTask public void generateProduceStatisticsDetail(){ remoteMesService.generateProduceStatisticsDetail(SecurityConstants.INNER); } + + + /** + * 根据syspointrouter获取流程节点权限用户,发送邮件 + */ + public void processActivityEmailNotify(){ + remoteSysCommonService.processActivityEmailNotify(SecurityConstants.INNER); + } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseMaterialInfoServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseMaterialInfoServiceImpl.java index 3acc5dee..6831e78a 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseMaterialInfoServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseMaterialInfoServiceImpl.java @@ -239,6 +239,7 @@ public class MesBaseMaterialInfoServiceImpl implements IMesBaseMaterialInfoServi routerAddressDetailJson.put("alarmInfoId", alarmInfoId); sysPointRouter.setRouterAddressDetail(routerAddressDetailJson.toString()); sysPointRouter.setRemark("库存不足报警"); + sysPointRouter.setProcessActivityId(SystemConstants.PROCESS_ACTIVITY_ID_STOCK_NOTENOUGH); sysPointRouter.setCreateBy(nickName); sysPointRouter.setCreateTime(currentDate); return sysPointRouter; diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java index 074208d9..324bb54f 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java @@ -673,6 +673,7 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { sysPointRouter.setModuleCode("MES"); sysPointRouter.setPointType(SystemConstants.SYS_ROUTER_POINT_TYPE_ALARM); sysPointRouter.setRouterAddress("/mes/plan/productOrder"); + sysPointRouter.setProcessActivityId(SystemConstants.PROCESS_ACTIVITY_ID_PRODUCT_ORDER_OVERTIME); if(productOrderId!=null){ JSONObject routerAddressDetailJson = new JSONObject(); routerAddressDetailJson.put("productOrderId", productOrderId); diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseOrderServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseOrderServiceImpl.java index d2f7f19a..d95a6da6 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseOrderServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseOrderServiceImpl.java @@ -656,6 +656,7 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService { sysPointRouter.setModuleCode("MES"); sysPointRouter.setPointType(SystemConstants.SYS_ROUTER_POINT_TYPE_ALARM); sysPointRouter.setRouterAddress("/mes/plan/purchaseOrder"); + sysPointRouter.setProcessActivityId(SystemConstants.PROCESS_ACTIVITY_ID_PURCHASEORDER_OVERTIME); if(purchaseOrderId!=null){ JSONObject routerAddressDetailJson = new JSONObject(); routerAddressDetailJson.put("purchaseOrderId", purchaseOrderId); diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesSaleOrderServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesSaleOrderServiceImpl.java index e0a02931..3e069ab4 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesSaleOrderServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesSaleOrderServiceImpl.java @@ -374,6 +374,7 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService { sysPointRouter.setModuleCode("MES"); sysPointRouter.setPointType(SystemConstants.SYS_ROUTER_POINT_TYPE_ALARM); sysPointRouter.setRouterAddress("/mes/plan/saleOrder"); + sysPointRouter.setProcessActivityId(SystemConstants.PROCESS_ACTIVITY_ID_SALE_ORDER_OVERTIME); if (saleOrderId != null) { JSONObject routerAddressDetailJson = new JSONObject(); routerAddressDetailJson.put("saleOrderId", saleOrderId); diff --git a/hw-modules/hw-system/src/main/java/com/hw/system/common/controller/SysPointRouterController.java b/hw-modules/hw-system/src/main/java/com/hw/system/common/controller/SysPointRouterController.java index c491ac7b..491c5513 100644 --- a/hw-modules/hw-system/src/main/java/com/hw/system/common/controller/SysPointRouterController.java +++ b/hw-modules/hw-system/src/main/java/com/hw/system/common/controller/SysPointRouterController.java @@ -113,4 +113,13 @@ public class SysPointRouterController extends BaseController { } + /** + * 定时发送邮件通知(从syspointrouter获取报警和审核通知信息) + */ + @PostMapping(("/processActivityEmailNotify")) + public AjaxResult processActivityEmailNotify() { + return toAjax(sysPointRouterService.processActivityEmailNotify()); + } + + } diff --git a/hw-modules/hw-system/src/main/java/com/hw/system/common/mapper/SysPointRouterMapper.java b/hw-modules/hw-system/src/main/java/com/hw/system/common/mapper/SysPointRouterMapper.java index 1eb93f18..8ef8ddf4 100644 --- a/hw-modules/hw-system/src/main/java/com/hw/system/common/mapper/SysPointRouterMapper.java +++ b/hw-modules/hw-system/src/main/java/com/hw/system/common/mapper/SysPointRouterMapper.java @@ -58,4 +58,14 @@ public interface SysPointRouterMapper * @return 结果 */ public int deleteSysPointRouterByPointRouterIds(Long[] pointRouterIds); + + /** + * 查询提示路由信息列表,供发送邮件使用 + * + * @param sysPointRouter 提示路由信息 + * @return 提示路由信息集合 + */ + public List selectEmailNotifySysPointRouterList(SysPointRouter sysPointRouter); + + } diff --git a/hw-modules/hw-system/src/main/java/com/hw/system/common/service/ISysPointRouterService.java b/hw-modules/hw-system/src/main/java/com/hw/system/common/service/ISysPointRouterService.java index a7f70326..6e40327d 100644 --- a/hw-modules/hw-system/src/main/java/com/hw/system/common/service/ISysPointRouterService.java +++ b/hw-modules/hw-system/src/main/java/com/hw/system/common/service/ISysPointRouterService.java @@ -65,4 +65,9 @@ public interface ISysPointRouterService * @return */ public int insertSysPointRouterList(List sysPointRouterList); + + /** + * 流程节点Email通知 + */ + public int processActivityEmailNotify(); } diff --git a/hw-modules/hw-system/src/main/java/com/hw/system/common/service/impl/SysPointRouterServiceImpl.java b/hw-modules/hw-system/src/main/java/com/hw/system/common/service/impl/SysPointRouterServiceImpl.java index 31462a71..e69a07e7 100644 --- a/hw-modules/hw-system/src/main/java/com/hw/system/common/service/impl/SysPointRouterServiceImpl.java +++ b/hw-modules/hw-system/src/main/java/com/hw/system/common/service/impl/SysPointRouterServiceImpl.java @@ -1,9 +1,18 @@ package com.hw.system.common.service.impl; import java.rmi.ServerException; +import java.util.Date; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import com.hw.common.core.utils.DateUtils; +import com.hw.common.core.utils.MailUtils; +import com.hw.common.core.utils.StringUtils; +import com.hw.common.security.utils.SecurityUtils; +import com.hw.system.api.domain.SysUser; +import com.hw.system.common.mapper.WfProcessActivityAuthMapper; +import com.hw.system.mapper.SysUserMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hw.system.common.mapper.SysPointRouterMapper; @@ -22,6 +31,9 @@ public class SysPointRouterServiceImpl implements ISysPointRouterService { @Autowired private SysPointRouterMapper sysPointRouterMapper; + @Autowired + private SysUserMapper sysUserMapper; + /** * 查询提示路由信息 * @@ -92,6 +104,7 @@ public class SysPointRouterServiceImpl implements ISysPointRouterService { /** * 通用存入提示路由信息List + * * @param sysPointRouterList * @return */ @@ -104,4 +117,38 @@ public class SysPointRouterServiceImpl implements ISysPointRouterService { return 1; } + + /** + * 流程节点Email通知 + */ + @Override + public int processActivityEmailNotify() { + SysPointRouter queryPointRouter = new SysPointRouter(); + List sysPointRouterList = sysPointRouterMapper.selectEmailNotifySysPointRouterList(queryPointRouter); + //根据流程节点ID group + Map> sysPointRouterMap = sysPointRouterList.stream() + .filter(spo->spo.getProcessActivityId()!=null).collect(Collectors.groupingBy(SysPointRouter::getProcessActivityId)); + + for (Long processActivityId : sysPointRouterMap.keySet()) { + List sysPointRoutersByActivityList = sysPointRouterMap.get(processActivityId); + List sysUsers = sysUserMapper.selectProcessActivityAuthUserList(processActivityId); + String sendMsg = ""; + for (SysPointRouter sysPointRouter : sysPointRoutersByActivityList) { + sendMsg += sysPointRouter.getRemark() + ";"; + sysPointRouter.setSentEmailFlag("1"); + sysPointRouter.setUpdateTime(new Date()); +// sysPointRouter.setUpdateBy(SecurityUtils.getLoginUser().getNickname()); + sysPointRouterMapper.updateSysPointRouter(sysPointRouter); + } + + for (SysUser sysUser : sysUsers) { + if (StringUtils.isNotEmpty(sysUser.getEmail())) { + MailUtils.processSendEmail(sysUser.getEmail(), "通知", sendMsg); + } + } + + } + + return 1; + } } diff --git a/hw-modules/hw-system/src/main/java/com/hw/system/mapper/SysUserMapper.java b/hw-modules/hw-system/src/main/java/com/hw/system/mapper/SysUserMapper.java index ffe3073f..91b6695e 100644 --- a/hw-modules/hw-system/src/main/java/com/hw/system/mapper/SysUserMapper.java +++ b/hw-modules/hw-system/src/main/java/com/hw/system/mapper/SysUserMapper.java @@ -129,4 +129,13 @@ public interface SysUserMapper public List selectnoperList(SysUser user); + + + /** + * 根据流程节点ID获取有权限的用户信息列表 + * @param user + * @return + */ + public List selectProcessActivityAuthUserList(Long processActivityId); + } diff --git a/hw-modules/hw-system/src/main/resources/mapper/system/SysUserMapper.xml b/hw-modules/hw-system/src/main/resources/mapper/system/SysUserMapper.xml index 4377dd7a..79a16c12 100644 --- a/hw-modules/hw-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/hw-modules/hw-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -235,4 +235,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and u.nick_name like concat('%', #{nickName} ,'%') ${params.dataScope} + + + + + diff --git a/hw-modules/hw-system/src/main/resources/mapper/system/common/SysPointRouterMapper.xml b/hw-modules/hw-system/src/main/resources/mapper/system/common/SysPointRouterMapper.xml index b2c52863..a0646a85 100644 --- a/hw-modules/hw-system/src/main/resources/mapper/system/common/SysPointRouterMapper.xml +++ b/hw-modules/hw-system/src/main/resources/mapper/system/common/SysPointRouterMapper.xml @@ -16,6 +16,9 @@ + + + @@ -29,7 +32,8 @@ create_by, create_time, update_by, - update_time + update_time, + process_activity_id from sys_point_router @@ -68,6 +72,7 @@ router_address_detail, router_flag, remark, + process_activity_id, create_by, create_time, update_by, @@ -80,6 +85,7 @@ #{routerAddressDetail}, #{routerFlag}, #{remark}, + #{processActivityId}, #{createBy}, #{createTime}, #{updateBy}, @@ -96,6 +102,8 @@ router_address_detail = #{routerAddressDetail}, router_flag = #{routerFlag}, remark = #{remark}, + email_flag = #{emailFlag}, + sent_email_flag = #{sentEmailFlag}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, @@ -116,4 +124,16 @@ #{pointRouterId} + + + + + + \ No newline at end of file diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java index 20d26f89..438913ef 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java @@ -250,7 +250,7 @@ public class WmsApiController extends BaseController { } /** - * 定时同步原材料出库信息给ERP + * 定时同步原材料出库信息给ERP(从rawoutstockdetail中获取,主要是无采购订单的不同步给ERP) * * @return */ diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawInstock.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawInstock.java index 7830b0cf..16e8aef9 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawInstock.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawInstock.java @@ -125,6 +125,8 @@ public class WmsRawInstock extends BaseEntity private String materialName; + private String materialSpec; + /** 计量单位编号 */ private String unitCode; @@ -401,6 +403,14 @@ public class WmsRawInstock extends BaseEntity this.materialName = materialName; } + public String getMaterialSpec() { + return materialSpec; + } + + public void setMaterialSpec(String materialSpec) { + this.materialSpec = materialSpec; + } + public String getSrcBillNo() { return srcBillNo; } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstockDetail.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstockDetail.java index 4a90e23a..a8e2e608 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstockDetail.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstockDetail.java @@ -90,6 +90,10 @@ public class WmsRawOutstockDetail extends BaseEntity { @Excel(name = "同步ERP状态(0:失败,1成功)") private String erpStatus; + /** 同步给ERP的数量 */ + @Excel(name = "同步给ERP的数量") + private BigDecimal erpAmount; + /** * 出库人 */ @@ -146,6 +150,10 @@ public class WmsRawOutstockDetail extends BaseEntity { private String materialName; + private String materialSpec; + + private String barcodeSpec; + private String applyBy; private Date applyDate; @@ -162,6 +170,17 @@ public class WmsRawOutstockDetail extends BaseEntity { /**仓库总库存信息ID*/ private Long stockTotalId; + private String taskTypeStr; + + /** 单价 */ + private BigDecimal price; + + /** 规格参数 */ + private String specificationParameter; + + /** 计量单位编号 */ + private String unitCode; + public void setRawOutstockDetailId(Long rawOutstockDetailId) { this.rawOutstockDetailId = rawOutstockDetailId; @@ -259,6 +278,14 @@ public class WmsRawOutstockDetail extends BaseEntity { return erpStatus; } + public BigDecimal getErpAmount() { + return erpAmount; + } + + public void setErpAmount(BigDecimal erpAmount) { + this.erpAmount = erpAmount; + } + public void setOutstockPerson(String outstockPerson) { this.outstockPerson = outstockPerson; } @@ -339,6 +366,22 @@ public class WmsRawOutstockDetail extends BaseEntity { this.materialName = materialName; } + public String getMaterialSpec() { + return materialSpec; + } + + public void setMaterialSpec(String materialSpec) { + this.materialSpec = materialSpec; + } + + public String getBarcodeSpec() { + return barcodeSpec; + } + + public void setBarcodeSpec(String barcodeSpec) { + this.barcodeSpec = barcodeSpec; + } + public String getApplyBy() { return applyBy; } @@ -403,6 +446,38 @@ public class WmsRawOutstockDetail extends BaseEntity { this.stockTotalId = stockTotalId; } + public String getTaskTypeStr() { + return taskTypeStr; + } + + public void setTaskTypeStr(String taskTypeStr) { + this.taskTypeStr = taskTypeStr; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public String getSpecificationParameter() { + return specificationParameter; + } + + public void setSpecificationParameter(String specificationParameter) { + this.specificationParameter = specificationParameter; + } + + public String getUnitCode() { + return unitCode; + } + + public void setUnitCode(String unitCode) { + this.unitCode = unitCode; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawReturnDetail.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawReturnDetail.java index c95606d9..d8e86eb8 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawReturnDetail.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawReturnDetail.java @@ -105,6 +105,8 @@ public class WmsRawReturnDetail extends BaseEntity private String materialSpec; + private String barcodeSpec; + private String applyBy; private String taskType; @@ -321,6 +323,14 @@ public class WmsRawReturnDetail extends BaseEntity this.materialSpec = materialSpec; } + public String getBarcodeSpec() { + return barcodeSpec; + } + + public void setBarcodeSpec(String barcodeSpec) { + this.barcodeSpec = barcodeSpec; + } + public String getApplyBy() { return applyBy; } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockDetailMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockDetailMapper.java index 04a8c7e0..47ddbb60 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockDetailMapper.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockDetailMapper.java @@ -92,4 +92,12 @@ public interface WmsRawOutstockDetailMapper { public int selectCountOfWmsRawOutstockDetail(WmsRawOutstockDetail wmsRawOutstockDetail); + /** + * 执行完成且未同步ERP的原材料出库detailList + * + * @param wmsRawOutstockDetail 原材料出库记录明细 + * @return 原材料出库记录明细集合 + */ + public List selectWmsRawOutstockDetailERPNotSynchronized(WmsRawOutstockDetail wmsRawOutstockDetail); + } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsErpScheduledTaskServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsErpScheduledTaskServiceImpl.java index 9dea0ff6..d803b63b 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsErpScheduledTaskServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsErpScheduledTaskServiceImpl.java @@ -44,6 +44,9 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi @Autowired private WmsRawOutstockMapper wmsRawOutstockMapper; + @Autowired + private WmsRawOutstockDetailMapper wmsRawOutstockDetailMapper; + @Autowired private WmsProductInstockMapper wmsProductInstockMapper; @@ -71,7 +74,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi * @return */ @Override -// @Transactional + @Transactional public int synchronizeInventoryInformationToERP() { WmsRawInstock wmsRawInstock = new WmsRawInstock(); int result = 0; @@ -105,9 +108,24 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi rawInstock.setUpdateDate(DateUtils.getNowDate()); wmsRawInstockMapper.updateWmsRawInstock(rawInstock); } - data.put("FDate", DateUtils.getTime()); + + String fdate = DateUtils.getTime(); + if (instock.getApplyDate() != null) { + fdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, instock.getApplyDate()); + } + + String specificationParameter = instock.getSpecificationParameter(); + if(StringUtils.isEmpty(specificationParameter)){ + specificationParameter = instock.getMaterialSpec(); + } + + if(StringUtils.isEmpty(specificationParameter)){ + specificationParameter = "无"; + } + + data.put("FDate", fdate); data.put("FMaterialId", instock.getMaterialCode()); - data.put("FAuxPropId", instock.getSpecificationParameter()); + data.put("FAuxPropId", specificationParameter); data.put("FSrcBillNo", instock.getSrcBillNo()); data.put("FUnitID", instock.getUnitCode()); data.put("FRealQty", FRealQty); @@ -115,17 +133,23 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi data.put("FSupplierCode", supplierCode); data.put("FTondBase", projectNo); String params = data.toJSONString(); - R paramsResult = remoteJindieService.savePurchaseStorage(params, SecurityConstants.INNER); - String paramsResultData = paramsResult.getMsg(); - JSONObject jsonObject = JSONObject.parseObject(paramsResultData); - Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); - if (isSuccess) { - result++; - log.info("synchronizeInventoryInformationToERP同步原材料入库成功:" + paramsResult.toString()); - } else { - log.error("synchronizeInventoryInformationToERP同步原材料入库失败:" + paramsResult.toString()); - throw new ServiceException("同步原材料入库失败" + paramsResult.toString()); + try { + R paramsResult = remoteJindieService.savePurchaseStorage(params, SecurityConstants.INNER); + String paramsResultData = paramsResult.getMsg(); + JSONObject jsonObject = JSONObject.parseObject(paramsResultData); + Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); + if (isSuccess) { + result++; + log.info("synchronizeInventoryInformationToERP同步原材料入库成功:" + paramsResult.toString()); + } else { + log.error("synchronizeInventoryInformationToERP同步原材料入库失败:" + paramsResult.toString()); + throw new RuntimeException("同步原材料入库失败" + paramsResult.toString()); + } + } catch (Exception e) { + log.error("同步原材料入库失败" + e.getMessage()); + throw new RuntimeException("同步原材料入库失败" + e.getMessage()); } + } /** @@ -134,21 +158,24 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi * @return */ @Override + @Transactional public int synchronizeRawMaterialDeliveryInformationToERP() { int result = 0; - WmsRawOutstock otherRawOutstock = new WmsRawOutstock(); - otherRawOutstock.setTaskTypeStr(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_PICKING + "," + WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_INSTALL - + "," + WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_OTHER); - List otherRawOutstockList = wmsRawOutstockMapper.selectWmsRawOutstockERPNotSynchronized(otherRawOutstock); - Map> otherMaterialIdMap = otherRawOutstockList.stream().collect(Collectors.groupingBy(WmsRawOutstock::getMaterialId)); + //领料 + WmsRawOutstockDetail otherRawOutstockDetail = new WmsRawOutstockDetail(); + otherRawOutstockDetail.setTaskTypeStr(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_PICKING + "," + WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_INSTALL + + "," + WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_AUTO_OUTSTOCK + "," + WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_OTHER); + List otherRawOutstockDetailList = wmsRawOutstockDetailMapper.selectWmsRawOutstockDetailERPNotSynchronized(otherRawOutstockDetail); + Map> otherMaterialIdMap = otherRawOutstockDetailList.stream().collect(Collectors.groupingBy(WmsRawOutstockDetail::getMaterialId)); for (Long materialId : otherMaterialIdMap.keySet()) { result += syncOutstockInformation(otherMaterialIdMap, materialId, ""); } - WmsRawOutstock returnRawOutstock = new WmsRawOutstock(); - returnRawOutstock.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK); - List returnOutstockList = wmsRawOutstockMapper.selectWmsRawOutstockERPNotSynchronized(returnRawOutstock); - Map> returnMaterialIdMap = returnOutstockList.stream().collect(Collectors.groupingBy(WmsRawOutstock::getMaterialId)); + //退货出库 + WmsRawOutstockDetail returnRawOutstockDetail = new WmsRawOutstockDetail(); + returnRawOutstockDetail.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK); + List returnRawOutstockDetailList = wmsRawOutstockDetailMapper.selectWmsRawOutstockDetailERPNotSynchronized(returnRawOutstockDetail); + Map> returnMaterialIdMap = returnRawOutstockDetailList.stream().collect(Collectors.groupingBy(WmsRawOutstockDetail::getMaterialId)); for (Long materialId : returnMaterialIdMap.keySet()) { result += syncOutstockInformation(returnMaterialIdMap, materialId, WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK); } @@ -162,7 +189,7 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi * @return */ @Override -// @Transactional + @Transactional public int synchronizeRawReturnInformationToERP() { WmsRawReturnDetail wmsRawReturnDetail = new WmsRawReturnDetail(); int result = 0; @@ -191,25 +218,35 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi JSONObject data = new JSONObject(); double FRealQty = wmsRawReturnDetaiList.stream().mapToDouble(item -> item.getReturnAmount().subtract(item.getErpAmount()).doubleValue()).sum(); WmsRawReturnDetail rawReturnDetail = wmsRawReturnDetaiList.get(0); - String specificationParameter = StringUtils.isNotEmpty(mesPurchaseOrder.getSpecificationParameter()) ? mesPurchaseOrder.getSpecificationParameter() : rawReturnDetail.getMaterialSpec(); - if (StringUtils.isNotEmpty(specificationParameter)) { - - for (WmsRawReturnDetail wmsRawReturnDetail : wmsRawReturnDetaiList) { - wmsRawReturnDetail.setErpStatus("1");//同步ERP状态(0:失败,1成功) - wmsRawReturnDetail.setErpAmount(wmsRawReturnDetail.getReturnAmount()); - wmsRawReturnDetail.setUpdateDate(DateUtils.getNowDate()); - wmsRawReturnDetailMapper.updateWmsRawReturnDetail(wmsRawReturnDetail); - } - data.put("FDate", DateUtils.getTime()); - data.put("FMaterialId", rawReturnDetail.getMaterialCode()); - data.put("FAuxPropId", specificationParameter); - data.put("FSrcBillNo", srcBillNo); - data.put("FUnitID", rawReturnDetail.getUnitCode()); - data.put("FRealQty", FRealQty); - data.put("FStockId", wmsConfig.getfStockId()); - data.put("FSupplierCode", supplierCode); - data.put("FTondBase", projectNo); - String params = data.toJSONString(); + String specificationParameter = StringUtils.isNotEmpty(mesPurchaseOrder.getSpecificationParameter()) ? + mesPurchaseOrder.getSpecificationParameter() : rawReturnDetail.getMaterialSpec(); + if (StringUtils.isEmpty(specificationParameter)) { + specificationParameter = "无"; + } + + for (WmsRawReturnDetail wmsRawReturnDetail : wmsRawReturnDetaiList) { + wmsRawReturnDetail.setErpStatus("1");//同步ERP状态(0:失败,1成功) + wmsRawReturnDetail.setErpAmount(wmsRawReturnDetail.getReturnAmount()); + wmsRawReturnDetail.setUpdateDate(DateUtils.getNowDate()); + wmsRawReturnDetailMapper.updateWmsRawReturnDetail(wmsRawReturnDetail); + } + + String fdate = DateUtils.getTime(); + if (rawReturnDetail.getReturnTime() != null) { + fdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, rawReturnDetail.getReturnTime()); + } + + data.put("FDate", fdate); + data.put("FMaterialId", rawReturnDetail.getMaterialCode()); + data.put("FAuxPropId", specificationParameter); + data.put("FSrcBillNo", srcBillNo); + data.put("FUnitID", rawReturnDetail.getUnitCode()); + data.put("FRealQty", FRealQty); + data.put("FStockId", wmsConfig.getfStockId()); + data.put("FSupplierCode", supplierCode); + data.put("FTondBase", projectNo); + String params = data.toJSONString(); + try { R paramsResult = remoteJindieService.savePurchaseStorage(params, SecurityConstants.INNER); String paramsResultData = paramsResult.getMsg(); JSONObject jsonObject = JSONObject.parseObject(paramsResultData); @@ -221,27 +258,31 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi log.error("synchronizeInventoryInformationToERP同步原材料退库失败:" + paramsResult.toString()); throw new ServiceException("同步原材料入库失败" + paramsResult.toString()); } + } catch (Exception e) { + log.error("synchronizeInventoryInformationToERP同步原材料退库失败:" + e.getMessage()); + throw new ServiceException("同步原材料入库失败" + e.getMessage()); } + } } @Transactional(propagation = Propagation.REQUIRES_NEW) - public int syncOutstockInformation(Map> materialIdMap, Long materialId, String taskType) { + public int syncOutstockInformation(Map> materialIdMap, Long materialId, String taskType) { int result = 0; - List wmsRawOutstockList = materialIdMap.get(materialId); + List wmsRawOutstockDetailList = materialIdMap.get(materialId); JSONObject data = new JSONObject(); - double FRealQty = wmsRawOutstockList.stream().mapToDouble(item -> item.getRealOutstockAmount().subtract(item.getErpAmount()).doubleValue()).sum(); - WmsRawOutstock outstock = wmsRawOutstockList.get(0); - for (WmsRawOutstock wmsRawOutstock : wmsRawOutstockList) { - if (wmsRawOutstock.getRealOutstockAmount().equals(wmsRawOutstock.getOutstockAmount())) { - wmsRawOutstock.setErpStatus("1");//同步ERP状态(0:失败,1成功,2同步中) + double FRealQty = wmsRawOutstockDetailList.stream().mapToDouble(item -> item.getOutstockAmount().subtract(item.getErpAmount()).doubleValue()).sum(); + WmsRawOutstockDetail outstockDetail = wmsRawOutstockDetailList.get(0); + for (WmsRawOutstockDetail wmsRawOutstockDetail : wmsRawOutstockDetailList) { + if (wmsRawOutstockDetail.getPlanAmount().equals(wmsRawOutstockDetail.getOutstockAmount())) { + wmsRawOutstockDetail.setErpStatus("1");//同步ERP状态(0:失败,1成功,2同步中) } else { - wmsRawOutstock.setErpStatus("2");//同步ERP状态(0:失败,1成功,2同步中) + wmsRawOutstockDetail.setErpStatus("2");//同步ERP状态(0:失败,1成功,2同步中) } - wmsRawOutstock.setErpAmount(wmsRawOutstock.getRealOutstockAmount()); - wmsRawOutstock.setUpdateDate(DateUtils.getNowDate()); - wmsRawOutstockMapper.updateWmsRawOutstock(wmsRawOutstock); + wmsRawOutstockDetail.setErpAmount(wmsRawOutstockDetail.getOutstockAmount()); + wmsRawOutstockDetail.setUpdateDate(DateUtils.getNowDate()); + wmsRawOutstockDetailMapper.updateWmsRawOutstockDetail(wmsRawOutstockDetail); } if (StringUtils.isNotEmpty(taskType) && taskType.equals(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK)) { @@ -251,27 +292,48 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi } // model.put("F_TOND_Combo", "一般领料"); //领料类型(必填项) - data.put("FDate", DateUtils.getTime()); - data.put("FMaterialId", outstock.getMaterialCode()); - data.put("FAuxPropId", outstock.getSpecificationParameter() == null ? "" : outstock.getSpecificationParameter()); - data.put("FUnitID", outstock.getUnitCode()); + String fdate = DateUtils.getTime(); + if (outstockDetail.getOutstockTime() != null) { + fdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, outstockDetail.getOutstockTime()); + } + + String barcodeSpec = outstockDetail.getBarcodeSpec(); + String materialSpec = outstockDetail.getMaterialSpec(); + if(StringUtils.isEmpty(barcodeSpec)){ + if(StringUtils.isNotEmpty(materialSpec)){ + barcodeSpec = materialSpec; + }else{ + barcodeSpec = "无"; + } + } + + data.put("FDate", fdate); + data.put("FMaterialId", outstockDetail.getMaterialCode()); + data.put("FAuxPropId", barcodeSpec); + data.put("FUnitID", outstockDetail.getUnitCode()); data.put("FQty", FRealQty); - data.put("FPrice", outstock.getPrice()); + data.put("FPrice", outstockDetail.getPrice()); data.put("FStockId", wmsConfig.getfStockId()); String params = data.toJSONString(); - R paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER); - String paramsResultData = paramsResult.getMsg(); - JSONObject jsonObject = JSONObject.parseObject(paramsResultData); - Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); - if (isSuccess) { - result++; - log.info("synchronizeRawMaterialDeliveryInformationToERP成功:" + paramsResult.toString()); - } else { - log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString()); - throw new RuntimeException("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString()); + try { + R paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER); + String paramsResultData = paramsResult.getMsg(); + JSONObject jsonObject = JSONObject.parseObject(paramsResultData); + Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); + if (isSuccess) { + result++; + log.info("synchronizeRawMaterialDeliveryInformationToERP成功:" + paramsResult.toString()); + } else { + log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString()); + throw new RuntimeException("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString()); + } + return result; + } catch (Exception e) { + log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + e.getMessage()); + throw new RuntimeException("synchronizeRawMaterialDeliveryInformationToERP失败:" + e.getMessage()); } - return result; + } /** @@ -311,24 +373,41 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi wmsProductInstockMapper.updateWmsProductInstock(wmsProductInstock); } - data.put("FDate", DateUtils.getTime()); + String fdate = DateUtils.getTime(); + if (instock.getApplyDate() != null) { + fdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, instock.getApplyDate()); + } + + String specificationParameter = StringUtils.isNotEmpty(instock.getSpecificationParameter()) ? + instock.getSpecificationParameter() : instock.getMaterialSpec(); + if (StringUtils.isEmpty(specificationParameter)) { + specificationParameter = "无"; + } + + data.put("FDate", fdate); data.put("FMaterialId", instock.getMaterialCode()); - data.put("FAuxPropId", instock.getSpecificationParameter() == null ? "B" : instock.getSpecificationParameter()); + data.put("FAuxPropId", specificationParameter); data.put("FUnitID", instock.getUnitCode()); data.put("FQty", FRealQty); data.put("FPrice", instock.getPrice()); data.put("FStockId", wmsConfig.getfStockId()); String params = data.toJSONString(); - R paramsResult = remoteJindieService.saveOtherInStorage(params, SecurityConstants.INNER); - String paramsResultData = paramsResult.getMsg(); - JSONObject jsonObject = JSONObject.parseObject(paramsResultData); - Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); - if (isSuccess) { - result++; - log.info("synchronizeProductInstockInformationToERP成功:" + paramsResult.toString()); - } else { - log.error("synchronizeProductInstockInformationToERP失败:" + paramsResult.toString()); - throw new RuntimeException("synchronizeProductInstockInformationToERP失败:" + paramsResult.toString()); + try { + R paramsResult = remoteJindieService.saveOtherInStorage(params, SecurityConstants.INNER); + String paramsResultData = paramsResult.getMsg(); + JSONObject jsonObject = JSONObject.parseObject(paramsResultData); + Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); + if (isSuccess) { + result++; + log.info("synchronizeProductInstockInformationToERP成功:" + paramsResult.toString()); + } else { + log.error("synchronizeProductInstockInformationToERP失败:" + paramsResult.toString()); + throw new RuntimeException("synchronizeProductInstockInformationToERP失败:" + paramsResult.toString()); + } + + } catch (Exception e) { + log.error("synchronizeProductInstockInformationToERP失败:" + e.getMessage()); + throw new RuntimeException("synchronizeProductInstockInformationToERP失败:" + e.getMessage()); } } @@ -368,26 +447,44 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi wmsProductOutstock.setUpdateDate(DateUtils.getNowDate()); wmsProductOutstockMapper.updateWmsProductOutstock(wmsProductOutstock); } - data.put("FDate", DateUtils.getTime()); + + String fdate = DateUtils.getTime(); + if (outstock.getApplyDate() != null) { + fdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, outstock.getApplyDate()); + } + + String specificationParameter = StringUtils.isNotEmpty(outstock.getSpecificationParameter()) ? + outstock.getSpecificationParameter() : outstock.getMaterialSpec(); + if (StringUtils.isEmpty(specificationParameter)) { + specificationParameter = "无"; + } + + data.put("FDate", fdate); data.put("FMaterialId", outstock.getMaterialCode()); - data.put("FAuxPropId", outstock.getSpecificationParameter() == null ? "无" : outstock.getSpecificationParameter()); + data.put("FAuxPropId", specificationParameter); data.put("FUnitID", outstock.getUnitCode()); data.put("FQty", FRealQty); data.put("FPrice", outstock.getPrice()); data.put("FStockId", wmsConfig.getfStockId()); data.put("FTONDCombo", "一般领料"); String params = data.toJSONString(); - R paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER); - String paramsResultData = paramsResult.getMsg(); - JSONObject jsonObject = JSONObject.parseObject(paramsResultData); - Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); - if (isSuccess) { - result++; - - log.info("synchronizeProductOutstockInformationToERP成功:" + paramsResult.toString()); - } else { - log.error("synchronizeProductOutstockInformationToERP失败:" + paramsResult.toString()); - throw new RuntimeException("synchronizeProductOutstockInformationToERP失败:" + paramsResult.toString()); + try { + R paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER); + String paramsResultData = paramsResult.getMsg(); + JSONObject jsonObject = JSONObject.parseObject(paramsResultData); + Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); + if (isSuccess) { + result++; + + log.info("synchronizeProductOutstockInformationToERP成功:" + paramsResult.toString()); + } else { + log.error("synchronizeProductOutstockInformationToERP失败:" + paramsResult.toString()); + throw new RuntimeException("synchronizeProductOutstockInformationToERP失败:" + paramsResult.toString()); + } + + } catch (Exception e) { + log.error("synchronizeProductOutstockInformationToERP失败:" + e.getMessage()); + throw new RuntimeException("synchronizeProductOutstockInformationToERP失败:" + e.getMessage()); } } diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductInstockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductInstockMapper.xml index 36a16558..3fbea6b5 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductInstockMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductInstockMapper.xml @@ -239,11 +239,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" wpi.plan_code, wpi.instock_type, wpi.product_id, + wpi.apply_date, wpi.instock_amount, wpi.execute_status, wpi.erp_status, if(wpi.erp_amount is null, 0, wpi.erp_amount) erp_amount, mbmi.material_code, + mbmi.material_spec, mbui.unit_code, mso.price, mso.specification_parameter diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductOutstockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductOutstockMapper.xml index 0630c8db..bfcbeb7c 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductOutstockMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductOutstockMapper.xml @@ -322,6 +322,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" wpo.erp_status, if(wpo.erp_amount is null, 0, wpo.erp_amount) erp_amount, mbmi.material_code, + mbmi.material_spec, mbui.unit_code, mso.price, mso.specification_parameter diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawInstockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawInstockMapper.xml index 0d441300..08b60dc2 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawInstockMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawInstockMapper.xml @@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -214,7 +215,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" wri.material_id, wri.po_no, wri.purchase_order_id, + wri.apply_date, mpo.specification_parameter, + mbmi.material_spec, mpo.src_bill_no, mbmi.material_code, mbui.unit_code, diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockDetailMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockDetailMapper.xml index e4c57b54..041df879 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockDetailMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockDetailMapper.xml @@ -33,6 +33,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -130,6 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" outstock_amount = #{outstockAmount}, execute_status = #{executeStatus}, erp_status = #{erpStatus}, + erp_amount = #{erpAmount}, outstock_person = #{outstockPerson}, outstock_time = #{outstockTime}, outstock_way = #{outstockWay}, @@ -208,4 +211,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml index 11d8b631..b326d80f 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml @@ -264,7 +264,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select wro.raw_outstock_id, wro.task_code, wro.warehouse_id, wro.location_code, wro.order_id, wro.plan_code, wro.plan_detail_code, wro.station_id,wro.material_batch, wro.material_id, wro.operation_type, wro.task_type, wro.apply_reason, wro.audit_reason, wro.audit_status, wro.execute_status, wro.apply_by, wro.apply_date, wro.audit_by, wro.audit_date, wro.update_by, wro.update_date, wro.begin_time, wro.end_time,wro.outstock_amount,wro.real_outstock_amount,wbw.warehouse_name + ,mbmi.material_code,mbmi.material_name,mbmi.material_spec from wms_raw_outstock wro left join wms_base_warehouse wbw on wro.warehouse_id = wbw.warehouse_id + left join mes_base_material_info mbmi on wro.material_id=mbmi.material_id and wro.task_code like concat('%', #{taskCode}, '%') and wro.warehouse_id = #{warehouseId} @@ -275,6 +277,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and wro.execute_status = #{executeStatus} and wro.task_type = #{taskType} and wro.apply_by like concat('%', #{applyBy}, '%') + and mbmi.material_code like concat('%', #{materialCode}, '%') + and mbmi.material_name like concat('%', #{materialName}, '%') + and mbmi.material_spec like concat('%', #{materialSpec}, '%') order by wro.apply_date desc @@ -366,6 +371,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" wro.warehouse_id, wro.operation_type, wro.material_id, + wro.apply_date, mbmi.material_code, mbui.unit_code, wro.outstock_amount, diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawReturnDetailMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawReturnDetailMapper.xml index b1350f11..9efb058b 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawReturnDetailMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawReturnDetailMapper.xml @@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -131,6 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" return_amount = #{returnAmount}, execute_status = #{executeStatus}, erp_status = #{erpStatus}, + erp_amount = #{erpAmount}, return_person = #{returnPerson}, return_time = #{returnTime}, return_way = #{returnWay}, @@ -218,11 +220,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"