diff --git a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java index d6353dc1..24e1f45f 100644 --- a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java +++ b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java @@ -45,6 +45,11 @@ public interface RemoteJindieService { @PostMapping("/jindie/syncPurchaseOrderFromErp") R syncPurchaseOrderFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo,@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + /** 同步收料通知单*/ + @PostMapping("/jindie/syncPurchaseReceiveBillFromErp") + R syncPurchaseReceiveBillFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo,@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** 采购申请单excel导入*/ @PostMapping("/jindie/singleSavePurchaseRequisition") R singleSavePurchaseRequisition(@RequestBody String params, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); diff --git a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java index 527ac548..48ce0c6b 100644 --- a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java +++ b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java @@ -46,6 +46,11 @@ public class RemoteJindieFallbackFactory implements FallbackFactory syncPurchaseReceiveBillFromErp(ErpSyncInfoVo erpSyncInfoVo, String source) { + return R.fail("同步收料通知单信息失败:" + throwable.getMessage()); + } + @Override public R singleSavePurchaseRequisition(String params, String source) { return R.fail("采购申请单excel导入失败:" + throwable.getMessage()); diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java index 5e710dd4..f702a154 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java @@ -97,6 +97,9 @@ public class MesBaseBarcodeInfo extends BaseEntity @Excel(name = "打印次数") private Long printNumber; + /**收料通知单ID*/ + private Long receiveBillId; + /**采购订单ID*/ private Long purchaseOrderId; @@ -389,6 +392,14 @@ public class MesBaseBarcodeInfo extends BaseEntity return machineName; } + public Long getReceiveBillId() { + return receiveBillId; + } + + public void setReceiveBillId(Long receiveBillId) { + this.receiveBillId = receiveBillId; + } + public Long getPurchaseOrderId() { return purchaseOrderId; } diff --git a/hw-auth/src/main/java/com/hw/auth/service/SysLoginService.java b/hw-auth/src/main/java/com/hw/auth/service/SysLoginService.java index 9296f03f..67695241 100644 --- a/hw-auth/src/main/java/com/hw/auth/service/SysLoginService.java +++ b/hw-auth/src/main/java/com/hw/auth/service/SysLoginService.java @@ -19,6 +19,11 @@ import com.hw.system.api.RemoteUserService; import com.hw.system.api.domain.SysUser; import com.hw.system.api.model.LoginUser; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + /** * 登录校验方法 * @@ -106,7 +111,14 @@ public class SysLoginService passwordService.validate(user, password); recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); - if (!soloLogin) + List multipleLoginUserList = new ArrayList<>(); + String multipleLoginUserListStr = redisService.getCacheObject(CacheConstants.SYS_LOGIN_MULTI_USER_LOGIN_LIST); + if(StringUtils.isNotEmpty(multipleLoginUserListStr)) { + String[] multipleLoginUserListStrArr = multipleLoginUserListStr.split(","); + multipleLoginUserList = Arrays.stream(multipleLoginUserListStrArr).collect(Collectors.toList()); + } + + if (!soloLogin && !multipleLoginUserList.contains(username)) { // 如果用户不允许多终端同时登录,清除缓存信息 String userIdKey = Constants.LOGIN_USERID_KEY + user.getUserId(); diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/CacheConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/CacheConstants.java index 19b65ebb..39c29bd4 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/CacheConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/CacheConstants.java @@ -56,4 +56,14 @@ public class CacheConstants * 登录IP黑名单 cache key */ public static final String SYS_LOGIN_BLACKIPLIST = SYS_CONFIG_KEY + "sys.login.blackIPList"; + + /** + * 不限制用户多端登录的用户 cache key + */ + public static final String SYS_LOGIN_MULTI_USER_LOGIN_LIST = SYS_CONFIG_KEY + "sys.login.multiList"; + + /** + * 邮箱账户信息 cache key + */ + public static final String SYS_EAMIL_ACCOUNT_INFO = SYS_CONFIG_KEY + "sys.email.account"; } 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 7309bac6..23b9c4f2 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 @@ -32,6 +32,8 @@ public class SystemConstants { public static final String SYS_ROUTER_POINT_TYPE_ALARM = "1";//报警 public static final String SYS_ROUTER_POINT_TYPE_AUDIT = "2";//审核 + public static final String SYS_ROUTER_POINT_TYPE_NOTICE = "3";//通知 + /** * 设备报警记录路由 */ 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 6d5403c0..c9733965 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 @@ -1,5 +1,7 @@ package com.hw.common.core.utils; +import com.hw.common.core.constant.CacheConstants; + import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; @@ -48,7 +50,7 @@ public class MailUtils { // throw new RuntimeException(e); // } - processSendEmail("ericxinstar@163.com","ddd","ddde"); +// processSendEmail("ericxinstar@163.com","ddd","ddde"); } /** @@ -57,14 +59,23 @@ public class MailUtils { * @param subject 标题 * @param text 内容 */ - public static void processSendEmail(String receiverEmail, String subject, String text) { + public static void processSendEmail(String emailAccount,String emailPassword,String receiverEmail, String subject, String text) { // 设置发件人、收件人、SMTP服务器等信息 - String senderEmail = "zhuangbeizhizaozhongxin@jsjyep.com"; +// String senderEmail = "zhuangbeizhizaozhongxin@jsjyep.com"; // String receiverEmail = "chencheng01@jsjyep.com"; - String password = "Dingxl226129"; +// String password = "Dingxl226129"; String host = "smtp.exmail.qq.com"; // SMTP服务器地址 int port = 465; // 端口号,如果是SSL连接常用465,非SSL常用587或25 +// if(StringUtils.isEmpty(emailAccount)){ +// emailAccount = senderEmail; +// } +// if(StringUtils.isNotEmpty(emailPassword)){ +// password = emailPassword; +// } + + String sysEamilAccountInfoCacheKey = CacheConstants.SYS_EAMIL_ACCOUNT_INFO; + // 设置邮件服务器的属性 Properties props = new Properties(); props.put("mail.smtp.auth", "true"); @@ -84,14 +95,14 @@ public class MailUtils { Session session = Session.getInstance(props, new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(senderEmail, password); + return new PasswordAuthentication(emailAccount, emailPassword); } }); try { // 创建邮件消息 Message message = new MimeMessage(session); - message.setFrom(new InternetAddress(senderEmail)); + message.setFrom(new InternetAddress(emailAccount)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(receiverEmail)); message.setSubject(subject); message.setText(text); diff --git a/hw-common/hw-common-security/src/main/java/com/hw/common/security/service/TokenService.java b/hw-common/hw-common-security/src/main/java/com/hw/common/security/service/TokenService.java index 339d0bf5..0b5ac156 100644 --- a/hw-common/hw-common-security/src/main/java/com/hw/common/security/service/TokenService.java +++ b/hw-common/hw-common-security/src/main/java/com/hw/common/security/service/TokenService.java @@ -1,8 +1,8 @@ package com.hw.common.security.service; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -175,7 +175,14 @@ public class TokenService String userKey = getTokenKey(loginUser.getToken()); redisService.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES); - if (!soloLogin) + List multipleLoginUserList = new ArrayList<>(); + String multipleLoginUserListStr = redisService.getCacheObject(CacheConstants.SYS_LOGIN_MULTI_USER_LOGIN_LIST); + if(StringUtils.isNotEmpty(multipleLoginUserListStr)) { + String[] multipleLoginUserListStrArr = multipleLoginUserListStr.split(","); + multipleLoginUserList = Arrays.stream(multipleLoginUserListStrArr).collect(Collectors.toList()); + } + + if (!soloLogin && !multipleLoginUserList.contains(loginUser.getUsername())) { // 缓存用户唯一标识,防止同一帐号,同时登录 String userIdKey = getUserIdKey(loginUser.getSysUser().getUserId()); 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 5249e2d5..a4e1afb4 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 @@ -114,7 +114,7 @@ public class KingdeeErpSyncController { */ @PostMapping("/syncSaleOrderFromErp") @Log(title = "ERP销售订单", businessType = BusinessType.INSERT) - @InnerAuth +// @InnerAuth public AjaxResult syncSaleOrderFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo) { try { return AjaxResult.success(kingdeeErpSyncService.syncSaleOrderFromErp(0, erpSyncInfoVo)); @@ -140,6 +140,21 @@ public class KingdeeErpSyncController { } } + /** + * 从ERP中同步采购订单信息到MES + */ + @PostMapping("/syncPurchaseReceiveBillFromErp") + @Log(title = "ERP采购收料单", businessType = BusinessType.INSERT) + @InnerAuth + public AjaxResult syncPurchaseReceiveBillFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo) { + try { + return AjaxResult.success(kingdeeErpSyncService.syncPurchaseReceiveBillFromErp(0, erpSyncInfoVo)); + } catch (Exception e) { + logger.error("同步采购订单信息错误:" + e.getMessage()); + return AjaxResult.error(); + } + } + /** * 采购申请单多物料->提交->审核 @@ -284,4 +299,7 @@ public class KingdeeErpSyncController { } + + + } 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 new file mode 100644 index 00000000..2dd5327f --- /dev/null +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseReceiveBill.java @@ -0,0 +1,310 @@ +package com.hw.jindie.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.hw.common.core.annotation.Excel; +import com.hw.common.core.web.domain.BaseEntity; + +/** + * 收料通知单对象 mes_purchase_receive_bill + * + * @author xins + * @date 2024-12-16 + */ +public class MesPurchaseReceiveBill extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键标识 */ + private Long receiveBillId; + + /** ERP的主键信息;对应FID */ + @Excel(name = "ERP的主键信息;对应FID") + private Long erpId; + + /** 对应金蝶ERP收料单明细的ID;对应FDetailEntity_FEntryID */ + @Excel(name = "对应金蝶ERP收料单明细的ID;对应FDetailEntity_FEntryID") + private Long fentryId; + + /** 收料单据号;对应FBillNo */ + @Excel(name = "收料单据号;对应FBillNo") + private String billNo; + + /** 采购订单编号;对应FOrderBillNo */ + @Excel(name = "采购订单编号;对应FOrderBillNo") + private String poNo; + + /** 单据状态;FDocumentStatus */ + @Excel(name = "单据状态;FDocumentStatus") + private String documentStatus; + + /** ERP物料ID;FMaterialId */ + @Excel(name = "ERP物料ID;FMaterialId") + private Long materialId; + + /** 物料编码;对应FMaterialId.FNumber */ + @Excel(name = "物料编码;对应FMaterialId.FNumber") + private String materialCode; + + /** 物料名称;对应FMaterialId.FName */ + @Excel(name = "物料名称;对应FMaterialId.FName") + private String materialName; + + /** 源单内码;对应FDetailEntity_Link_FSBillId */ + @Excel(name = "源单内码;对应FDetailEntity_Link_FSBillId") + private String fsBillId; + + /** 源单分录内码;对应FDetailEntity_Link_FSId */ + @Excel(name = "源单分录内码;对应FDetailEntity_Link_FSId") + private String fsId; + + /** 实到数量;对应FActlandQty */ + @Excel(name = "实到数量;对应FActlandQty") + private BigDecimal actLandAmount; + + /** 交货数量;对应FActReceiveQty */ + @Excel(name = "交货数量;对应FActReceiveQty") + private BigDecimal actReceiveAmount; + + /** 审核日期;对应FApproveDate */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "审核日期;对应FApproveDate", width = 30, dateFormat = "yyyy-MM-dd") + private Date approveDate; + + /** ERP最后修改日期;对应FModifyDate */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "ERP最后修改日期;对应FModifyDate", width = 30, dateFormat = "yyyy-MM-dd") + private Date erpModifyDate; + + /** 收料组织;FPurchaseOrgId */ + @Excel(name = "收料组织;FPurchaseOrgId") + private Long purchaseOrgId; + + /** 京源项目;F_TOND_Base */ + @Excel(name = "京源项目;F_TOND_Base") + private String tondBase; + + /** 单价;FPRICE */ + @Excel(name = "单价;FPRICE") + private BigDecimal price; + + /** 供应商ID;FSupplierId */ + @Excel(name = "供应商ID;FSupplierId") + private Long supplierId; + + private String materialSpec; + + + public void setReceiveBillId(Long receiveBillId) + { + this.receiveBillId = receiveBillId; + } + + public Long getReceiveBillId() + { + return receiveBillId; + } + public void setErpId(Long erpId) + { + this.erpId = erpId; + } + + public Long getErpId() + { + return erpId; + } + public void setFentryId(Long fentryId) + { + this.fentryId = fentryId; + } + + public Long getFentryId() + { + return fentryId; + } + public void setBillNo(String billNo) + { + this.billNo = billNo; + } + + public String getBillNo() + { + return billNo; + } + public void setPoNo(String poNo) + { + this.poNo = poNo; + } + + public String getPoNo() + { + return poNo; + } + public void setDocumentStatus(String documentStatus) + { + this.documentStatus = documentStatus; + } + + public String getDocumentStatus() + { + return documentStatus; + } + public void setMaterialId(Long materialId) + { + this.materialId = materialId; + } + + public Long getMaterialId() + { + return materialId; + } + public void setMaterialCode(String materialCode) + { + this.materialCode = materialCode; + } + + public String getMaterialCode() + { + return materialCode; + } + public void setMaterialName(String materialName) + { + this.materialName = materialName; + } + + public String getMaterialName() + { + return materialName; + } + public void setFsBillId(String fsBillId) + { + this.fsBillId = fsBillId; + } + + public String getFsBillId() + { + return fsBillId; + } + public void setFsId(String fsId) + { + this.fsId = fsId; + } + + public String getFsId() + { + return fsId; + } + public void setActLandAmount(BigDecimal actLandAmount) + { + this.actLandAmount = actLandAmount; + } + + public BigDecimal getActLandAmount() + { + return actLandAmount; + } + public void setActReceiveAmount(BigDecimal actReceiveAmount) + { + this.actReceiveAmount = actReceiveAmount; + } + + public BigDecimal getActReceiveAmount() + { + return actReceiveAmount; + } + public void setApproveDate(Date approveDate) + { + this.approveDate = approveDate; + } + + public Date getApproveDate() + { + return approveDate; + } + public void setErpModifyDate(Date erpModifyDate) + { + this.erpModifyDate = erpModifyDate; + } + + public Date getErpModifyDate() + { + return erpModifyDate; + } + public void setPurchaseOrgId(Long purchaseOrgId) + { + this.purchaseOrgId = purchaseOrgId; + } + + public Long getPurchaseOrgId() + { + return purchaseOrgId; + } + public void setTondBase(String tondBase) + { + this.tondBase = tondBase; + } + + public String getTondBase() + { + return tondBase; + } + public void setPrice(BigDecimal price) + { + this.price = price; + } + + public BigDecimal getPrice() + { + return price; + } + public void setSupplierId(Long supplierId) + { + this.supplierId = supplierId; + } + + public Long getSupplierId() + { + return supplierId; + } + + public String getMaterialSpec() { + return materialSpec; + } + + public void setMaterialSpec(String materialSpec) { + this.materialSpec = materialSpec; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("receiveBillId", getReceiveBillId()) + .append("erpId", getErpId()) + .append("fentryId", getFentryId()) + .append("billNo", getBillNo()) + .append("poNo", getPoNo()) + .append("documentStatus", getDocumentStatus()) + .append("materialId", getMaterialId()) + .append("materialCode", getMaterialCode()) + .append("materialName", getMaterialName()) + .append("fsBillId", getFsBillId()) + .append("fsId", getFsId()) + .append("actLandAmount", getActLandAmount()) + .append("actReceiveAmount", getActReceiveAmount()) + .append("approveDate", getApproveDate()) + .append("erpModifyDate", getErpModifyDate()) + .append("purchaseOrgId", getPurchaseOrgId()) + .append("tondBase", getTondBase()) + .append("price", getPrice()) + .append("supplierId", getSupplierId()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesPurchaseReceiveBillMapper.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesPurchaseReceiveBillMapper.java new file mode 100644 index 00000000..fdff314a --- /dev/null +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesPurchaseReceiveBillMapper.java @@ -0,0 +1,94 @@ +package com.hw.jindie.mapper; + +import java.util.List; + +import com.hw.jindie.domain.MesPurchaseOrder; +import com.hw.jindie.domain.MesPurchaseReceiveBill; +import org.apache.ibatis.annotations.Param; + +/** + * 收料通知单Mapper接口 + * + * @author xins + * @date 2024-12-16 + */ +public interface MesPurchaseReceiveBillMapper +{ + /** + * 查询收料通知单 + * + * @param receiveBillId 收料通知单主键 + * @return 收料通知单 + */ + public MesPurchaseReceiveBill selectMesPurchaseReceiveBillByReceiveBillId(Long receiveBillId); + + /** + * 查询收料通知单列表 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 收料通知单集合 + */ + public List selectMesPurchaseReceiveBillList(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 新增收料通知单 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 结果 + */ + public int insertMesPurchaseReceiveBill(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 修改收料通知单 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 结果 + */ + public int updateMesPurchaseReceiveBill(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 删除收料通知单 + * + * @param receiveBillId 收料通知单主键 + * @return 结果 + */ + public int deleteMesPurchaseReceiveBillByReceiveBillId(Long receiveBillId); + + /** + * 批量删除收料通知单 + * + * @param receiveBillIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMesPurchaseReceiveBillByReceiveBillIds(Long[] receiveBillIds); + + + /** + * 获取最大的ERP更新时间 + * + * @return String + */ + public String selectMaxErpModifyDate(); + + + /** + * 查询收料通知单信息 + * + * @param erpId ERP主键 + * @param fentryId ERP销售明细主键 + * @return 收料通知单信息 + */ + public MesPurchaseReceiveBill selectMesPurchaseReceiveBillByUI(@Param("erpId") Long erpId, + @Param("fentryId") Long fentryId); + + /** + * 批量新增收料通知单信息 + * + * @param MesPurchaseReceiveBills 收料通知单信息列表 + * @return 结果 + */ + public int batchMesBasePurchaseReceiveBill(List MesPurchaseReceiveBills); + + + +} diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/IKingdeeErpSyncService.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/IKingdeeErpSyncService.java index ae3c6bde..a0cf1656 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/IKingdeeErpSyncService.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/IKingdeeErpSyncService.java @@ -21,4 +21,10 @@ public interface IKingdeeErpSyncService { public int syncProjectInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception; public int syncSaleOrderFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception; public int syncPurchaseOrderFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception; + + /** + * @throws Exception + * @Descrption:从金蝶ERP同步收料通知单 + */ + public int syncPurchaseReceiveBillFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception; } 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 3df5d648..b45c844b 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 @@ -3,17 +3,25 @@ package com.hw.jindie.service.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hw.common.core.constant.MesConstants; +import com.hw.common.core.constant.SecurityConstants; +import com.hw.common.core.constant.SystemConstants; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.StringUtils; +import com.hw.common.log.enums.BusinessType; import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; import com.hw.jindie.config.KingdeeConfig; import com.hw.jindie.domain.*; import com.hw.jindie.mapper.*; import com.hw.jindie.service.IKingdeeErpSyncService; +import com.hw.system.api.RemoteLogService; +import com.hw.system.api.RemoteSysCommonService; +import com.hw.system.api.domain.SysOperLog; +import com.hw.system.api.domain.common.SysPointRouter; import com.kingdee.bos.webapi.sdk.K3CloudApi; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; @@ -39,10 +47,18 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { @Autowired private MesPurchaseOrderMapper mesPurchaseOrderMapper; @Autowired + private MesPurchaseReceiveBillMapper mesPurchaseReceiveBillMapper; + @Autowired private MesBaseUnitInfoMapper mesBaseUnitInfoMapper; @Autowired private KingdeeConfig kingdeeConfig; + @Resource + private RemoteSysCommonService remoteSysCommonService; + + @Resource + private RemoteLogService remoteLogService; + private static final int limit = 100; /** @@ -164,7 +180,6 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { } - /** * @throws Exception * @Description:从金蝶ERP同步单位信息 @@ -221,8 +236,9 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { List toInsertSupplierInfoList = new ArrayList<>(); List toUpdateSupplierInfoList = new ArrayList<>(); Date currentDate = new Date(); - for (int i = 0; i < resultArray.size(); i++) { - try { + try { + for (int i = 0; i < resultArray.size(); i++) { + JSONObject resultObject = (JSONObject) resultArray.get(i); MesBaseUnitInfo baseUnitInfo = new MesBaseUnitInfo(); //主键 @@ -256,24 +272,24 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { } else { toInsertSupplierInfoList.add(baseUnitInfo); } - } catch (Exception e) { - e.printStackTrace(); } - } - - if (!toInsertSupplierInfoList.isEmpty()) { - for (MesBaseUnitInfo mesBaseUnitInfo : toInsertSupplierInfoList) { - mesBaseUnitInfoMapper.insertMesBaseUnitInfo(mesBaseUnitInfo); + if (!toInsertSupplierInfoList.isEmpty()) { + for (MesBaseUnitInfo mesBaseUnitInfo : toInsertSupplierInfoList) { + mesBaseUnitInfoMapper.insertMesBaseUnitInfo(mesBaseUnitInfo); + } } - } - if (!toUpdateSupplierInfoList.isEmpty()) { - for (MesBaseUnitInfo toUpdatedUnitInfo : toUpdateSupplierInfoList) { - mesBaseUnitInfoMapper.updateMesBaseUnitInfo(toUpdatedUnitInfo); + if (!toUpdateSupplierInfoList.isEmpty()) { + for (MesBaseUnitInfo toUpdatedUnitInfo : toUpdateSupplierInfoList) { + mesBaseUnitInfoMapper.updateMesBaseUnitInfo(toUpdatedUnitInfo); + } } + } catch (Exception e) { + e.printStackTrace(); } + // System.out.println("size:" + resultArray.size()); // System.out.println(resultArray); //如果返回的数组的数量等于分页数量,则继续获取下一页数据 @@ -352,9 +368,11 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { List toInsertSupplierInfoList = new ArrayList<>(); List toUpdateSupplierInfoList = new ArrayList<>(); + List sysOperLogList = new ArrayList<>(); Date currentDate = new Date(); - for (int i = 0; i < resultArray.size(); i++) { - try { + try { + for (int i = 0; i < resultArray.size(); i++) { + JSONObject resultObject = (JSONObject) resultArray.get(i); MesBaseSupplierInfo mesBaseSupplierInfo = new MesBaseSupplierInfo(); //供应商编号 @@ -393,25 +411,38 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { if (existedMesBaseSupplierInfo != null) { mesBaseSupplierInfo.setSupplierId(existedMesBaseSupplierInfo.getSupplierId()); toUpdateSupplierInfoList.add(mesBaseSupplierInfo); + SysOperLog sysOperLog = this.getSysOperLog("供应商信息同步", 2, "com.hw.jindie.controller.KingdeeErpSyncController.syncSupplierInfoFromErp", + "POST", "syncSupplierInfoFromErp", "BD_Supplier(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); } else { toInsertSupplierInfoList.add(mesBaseSupplierInfo); + SysOperLog sysOperLog = this.getSysOperLog("供应商信息同步", 1, "com.hw.jindie.controller.KingdeeErpSyncController.syncSupplierInfoFromErp", + "POST", "syncSupplierInfoFromErp", "BD_Supplier(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); } - } catch (Exception e) { - e.printStackTrace(); + } - } - if (!toInsertSupplierInfoList.isEmpty()) { - mesBaseSupplierInfoMapper.batchMesBaseSupplierInfo(toInsertSupplierInfoList); - } - if (!toUpdateSupplierInfoList.isEmpty()) { - for (MesBaseSupplierInfo toUpdatedSupplierInfo : toUpdateSupplierInfoList) { - mesBaseSupplierInfoMapper.updateMesBaseSupplierInfo(toUpdatedSupplierInfo); + if (!toInsertSupplierInfoList.isEmpty()) { + mesBaseSupplierInfoMapper.batchMesBaseSupplierInfo(toInsertSupplierInfoList); + } + if (!toUpdateSupplierInfoList.isEmpty()) { + for (MesBaseSupplierInfo toUpdatedSupplierInfo : toUpdateSupplierInfoList) { + mesBaseSupplierInfoMapper.updateMesBaseSupplierInfo(toUpdatedSupplierInfo); + } } + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } + } + } catch (Exception e) { + e.printStackTrace(); } + System.out.println("size:" + resultArray.size()); //如果返回的数组的数量等于分页数量,则继续获取下一页数据 if (resultArray.size() == limit) { @@ -491,81 +522,100 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { List toInsertMaterialInfoList = new ArrayList<>(); List toUpdateMaterialInfoList = new ArrayList<>(); + List sysOperLogList = new ArrayList<>(); Date currentDate = new Date(); - for (int i = 0; i < resultArray.size(); i++) { - JSONObject resultObject = (JSONObject) resultArray.get(i); - MesBaseMaterialInfo mesBaseMaterialInfo = new MesBaseMaterialInfo(); - //erp主键 - Long erpId = resultObject.getLong("FMaterialId"); - //物料编码 - String materialCode = resultObject.getString("FNumber"); - //物料名称 - String materialName = resultObject.getString("FName"); - //计量单位ID - Long materialUnitId = resultObject.getLong("FBaseUnitId"); - //物料规格 - String materialSpec = resultObject.getString("FSpecification"); - //净重 - BigDecimal netWeight = resultObject.getBigDecimal("FNETWEIGHT"); - //毛重 - BigDecimal grossWeight = resultObject.getBigDecimal("FGROSSWEIGHT"); - //创建时间 - String createDateStr = resultObject.getString("FCreateDate"); - //erp最后更新日期 - String modifyDateStr = resultObject.getString("FModifyDate"); - //审核日期 - String approveDateStr = resultObject.getString("FApproveDate"); - //创建组织 - Long createOrgId = resultObject.getLong("FCreateOrgId"); - //使用组织 - Long useOrgId = resultObject.getLong("FUseOrgId"); - //采购计量单价 - Long purchasePriceUnitId = resultObject.getLong("FPurchasePriceUnitId"); - - mesBaseMaterialInfo.setErpId(erpId); - mesBaseMaterialInfo.setMaterialCode(materialCode); - mesBaseMaterialInfo.setMaterialName(materialName); - mesBaseMaterialInfo.setMaterialUnitId(materialUnitId); - mesBaseMaterialInfo.setMaterialSpec(materialSpec); - mesBaseMaterialInfo.setNetWeight(netWeight); - mesBaseMaterialInfo.setGrossWeight(grossWeight); - mesBaseMaterialInfo.setCreateOrgId(createOrgId); - mesBaseMaterialInfo.setUseOrgId(useOrgId); - mesBaseMaterialInfo.setUpdateTime(currentDate); - mesBaseMaterialInfo.setPurchasePriceUnitId(purchasePriceUnitId); - - if (StringUtils.isNotEmpty(createDateStr)) { - mesBaseMaterialInfo.setCreateTime(conversionERPTime(createDateStr)); - } + try { + for (int i = 0; i < resultArray.size(); i++) { + JSONObject resultObject = (JSONObject) resultArray.get(i); + MesBaseMaterialInfo mesBaseMaterialInfo = new MesBaseMaterialInfo(); + //erp主键 + Long erpId = resultObject.getLong("FMaterialId"); + //物料编码 + String materialCode = resultObject.getString("FNumber"); + //物料名称 + String materialName = resultObject.getString("FName"); + //计量单位ID + Long materialUnitId = resultObject.getLong("FBaseUnitId"); + //物料规格 + String materialSpec = resultObject.getString("FSpecification"); + //净重 + BigDecimal netWeight = resultObject.getBigDecimal("FNETWEIGHT"); + //毛重 + BigDecimal grossWeight = resultObject.getBigDecimal("FGROSSWEIGHT"); + //创建时间 + String createDateStr = resultObject.getString("FCreateDate"); + //erp最后更新日期 + String modifyDateStr = resultObject.getString("FModifyDate"); + //审核日期 + String approveDateStr = resultObject.getString("FApproveDate"); + //创建组织 + Long createOrgId = resultObject.getLong("FCreateOrgId"); + //使用组织 + Long useOrgId = resultObject.getLong("FUseOrgId"); + //采购计量单价 + Long purchasePriceUnitId = resultObject.getLong("FPurchasePriceUnitId"); + + mesBaseMaterialInfo.setErpId(erpId); + mesBaseMaterialInfo.setMaterialCode(materialCode); + mesBaseMaterialInfo.setMaterialName(materialName); + mesBaseMaterialInfo.setMaterialUnitId(materialUnitId); + mesBaseMaterialInfo.setMaterialSpec(materialSpec); + mesBaseMaterialInfo.setNetWeight(netWeight); + mesBaseMaterialInfo.setGrossWeight(grossWeight); + mesBaseMaterialInfo.setCreateOrgId(createOrgId); + mesBaseMaterialInfo.setUseOrgId(useOrgId); + mesBaseMaterialInfo.setUpdateTime(currentDate); + mesBaseMaterialInfo.setPurchasePriceUnitId(purchasePriceUnitId); + + if (StringUtils.isNotEmpty(createDateStr)) { + mesBaseMaterialInfo.setCreateTime(conversionERPTime(createDateStr)); + } - if (StringUtils.isNotEmpty(modifyDateStr)) { - mesBaseMaterialInfo.setErpModifyDate(conversionERPTime(modifyDateStr)); - } + if (StringUtils.isNotEmpty(modifyDateStr)) { + mesBaseMaterialInfo.setErpModifyDate(conversionERPTime(modifyDateStr)); + } - if (StringUtils.isNotEmpty(approveDateStr)) { - mesBaseMaterialInfo.setApproveDate(conversionERPTime(approveDateStr)); - } + if (StringUtils.isNotEmpty(approveDateStr)) { + mesBaseMaterialInfo.setApproveDate(conversionERPTime(approveDateStr)); + } - MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByErpId(erpId); + MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByErpId(erpId); // MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByMaterialCode(materialCode); - if (existedMesBaseMaterialInfo != null) { - mesBaseMaterialInfo.setMaterialId(existedMesBaseMaterialInfo.getMaterialId()); - toUpdateMaterialInfoList.add(mesBaseMaterialInfo); - } else { - mesBaseMaterialInfo.setActiveFlag(MesConstants.MES_MATERIAL_ACTIVE_FLAG_NORMAL); - toInsertMaterialInfoList.add(mesBaseMaterialInfo); + if (existedMesBaseMaterialInfo != null) { + mesBaseMaterialInfo.setMaterialId(existedMesBaseMaterialInfo.getMaterialId()); + toUpdateMaterialInfoList.add(mesBaseMaterialInfo); + SysOperLog sysOperLog = this.getSysOperLog("物料信息同步", 2, "com.hw.jindie.controller.KingdeeErpSyncController.syncMaterialInfoFromErp", + "POST", "syncMaterialInfoFromErp", "BD_Material(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); + + } else { + mesBaseMaterialInfo.setActiveFlag(MesConstants.MES_MATERIAL_ACTIVE_FLAG_NORMAL); + toInsertMaterialInfoList.add(mesBaseMaterialInfo); + + SysOperLog sysOperLog = this.getSysOperLog("物料信息同步", 1, "com.hw.jindie.controller.KingdeeErpSyncController.syncMaterialInfoFromErp", + "POST", "syncMaterialInfoFromErp", "BD_Material(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); + } } - } - if (!toInsertMaterialInfoList.isEmpty()) { - mesBaseMaterialInfoMapper.batchMesBaseMaterialInfo(toInsertMaterialInfoList); - } - if (!toUpdateMaterialInfoList.isEmpty()) { - for (MesBaseMaterialInfo toUpdatedMaterialInfo : toUpdateMaterialInfoList) { - mesBaseMaterialInfoMapper.updateMesBaseMaterialInfo(toUpdatedMaterialInfo); + if (!toInsertMaterialInfoList.isEmpty()) { + mesBaseMaterialInfoMapper.batchMesBaseMaterialInfo(toInsertMaterialInfoList); + } + if (!toUpdateMaterialInfoList.isEmpty()) { + for (MesBaseMaterialInfo toUpdatedMaterialInfo : toUpdateMaterialInfoList) { + mesBaseMaterialInfoMapper.updateMesBaseMaterialInfo(toUpdatedMaterialInfo); + } + } + + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } } + } catch (Exception e) { + e.printStackTrace(); } System.out.println("size:" + resultArray.size()); @@ -662,9 +712,11 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { List toInsertSaleOrderList = new ArrayList<>(); List toUpdateSaleOrderList = new ArrayList<>(); + List sysOperLogList = new ArrayList<>(); Date currentDate = new Date(); - for (int i = 0; i < resultArray.size(); i++) { - try { + try { + for (int i = 0; i < resultArray.size(); i++) { + JSONObject resultObject = (JSONObject) resultArray.get(i); MesSaleOrder mesSaleOrder = new MesSaleOrder(); //erp主键 @@ -706,7 +758,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { //单据状态 String documentStatus = resultObject.getString("FDocumentStatus"); - if(!documentStatus.equals("C")){ + if (!documentStatus.equals("C")) { System.out.println(documentStatus); } String tondBase = resultObject.getString("F.TOND.Base"); @@ -748,25 +800,38 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { if (existedMesSaleOrder != null) { mesSaleOrder.setSaleOrderId(existedMesSaleOrder.getSaleOrderId()); toUpdateSaleOrderList.add(mesSaleOrder); + + SysOperLog sysOperLog = this.getSysOperLog("销售订单信息同步", 2, "com.hw.jindie.controller.KingdeeErpSyncController.syncSaleOrderFromErp", + "POST", "syncSaleOrderFromErp", "SAL_SaleOrder(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); } else { toInsertSaleOrderList.add(mesSaleOrder); - } - } catch (Exception e) { - e.printStackTrace(); + SysOperLog sysOperLog = this.getSysOperLog("销售订单信息同步", 2, "com.hw.jindie.controller.KingdeeErpSyncController.syncSaleOrderFromErp", + "POST", "syncSaleOrderFromErp", "SAL_SaleOrder(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); + } } - } + if (!toInsertSaleOrderList.isEmpty()) { + mesSaleOrderMapper.batchMesBaseSaleOrder(toInsertSaleOrderList); + } + if (!toUpdateSaleOrderList.isEmpty()) { + for (MesSaleOrder toUpdatedSaleOrder : toUpdateSaleOrderList) { + mesSaleOrderMapper.updateMesSaleOrder(toUpdatedSaleOrder); + } + } - if (!toInsertSaleOrderList.isEmpty()) { - mesSaleOrderMapper.batchMesBaseSaleOrder(toInsertSaleOrderList); - } - if (!toUpdateSaleOrderList.isEmpty()) { - for (MesSaleOrder toUpdatedSaleOrder : toUpdateSaleOrderList) { - mesSaleOrderMapper.updateMesSaleOrder(toUpdatedSaleOrder); + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } } + } catch (Exception e) { + e.printStackTrace(); } + System.out.println("size:" + resultArray.size()); /**分页递归获取所有物料信息*/ @@ -835,9 +900,11 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { List toInsertProjectInfoList = new ArrayList<>(); List toUpdateProjectInfoList = new ArrayList<>(); + List sysOperLogList = new ArrayList<>(); Date currentDate = new Date(); - for (int i = 0; i < resultArray.size(); i++) { - try { + try { + for (int i = 0; i < resultArray.size(); i++) { + JSONObject resultObject = (JSONObject) resultArray.get(i); MesProjectInfo mesProjectInfo = new MesProjectInfo(); Long erpId = resultObject.getLong("FID"); @@ -845,7 +912,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { String FName = resultObject.getString("FName"); String FDocumentStatus = resultObject.getString("FDocumentStatus"); - if(!FDocumentStatus.equals("C")){ + if (!FDocumentStatus.equals("C")) { System.out.println(FDocumentStatus); } @@ -876,23 +943,37 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { if (existedProjectInfo != null) { mesProjectInfo.setProjectId(existedProjectInfo.getProjectId()); toUpdateProjectInfoList.add(mesProjectInfo); + + SysOperLog sysOperLog = this.getSysOperLog("项目信息同步", 2, "com.hw.jindie.controller.KingdeeErpSyncController.syncProjectInfoFromErp", + "POST", "syncProjectInfoFromErp", "TOND_ProjectFile(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); } else { toInsertProjectInfoList.add(mesProjectInfo); + + SysOperLog sysOperLog = this.getSysOperLog("项目信息同步", 1, "com.hw.jindie.controller.KingdeeErpSyncController.syncProjectInfoFromErp", + "POST", "syncProjectInfoFromErp", "TOND_ProjectFile(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); + } + } + if (!toInsertProjectInfoList.isEmpty()) { + mesProjectInfoMapper.batchMesBaseProjectInfo(toInsertProjectInfoList); + } + if (!toUpdateProjectInfoList.isEmpty()) { + for (MesProjectInfo toUpdatedProjectInfo : toUpdateProjectInfoList) { + mesProjectInfoMapper.updateMesProjectInfo(toUpdatedProjectInfo); } - } catch (Exception e) { - e.printStackTrace(); } - } - if (!toInsertProjectInfoList.isEmpty()) { - mesProjectInfoMapper.batchMesBaseProjectInfo(toInsertProjectInfoList); - } - if (!toUpdateProjectInfoList.isEmpty()) { - for (MesProjectInfo toUpdatedProjectInfo : toUpdateProjectInfoList) { - mesProjectInfoMapper.updateMesProjectInfo(toUpdatedProjectInfo); + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } } + } catch (Exception e) { + e.printStackTrace(); } + System.out.println("size:" + resultArray.size()); /**分页递归获取所有物料信息*/ if (resultArray.size() == limit) { @@ -959,7 +1040,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { // System.out.println("maxErpModifyDate=" + maxErpModifyDate); if (StringUtils.isNotEmpty(maxErpModifyDate)) { - filterStringBuilder.append(" FModifyDate >'").append(maxErpModifyDate).append("'"); + filterStringBuilder.append(" and FModifyDate >'").append(maxErpModifyDate).append("'"); } queryJson.put("FilterString", filterStringBuilder.toString()); @@ -972,9 +1053,11 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { List toInsertPurchaseOrderList = new ArrayList<>(); List toUpdatePurchaseOrderList = new ArrayList<>(); + List sysOperLogList = new ArrayList<>(); Date currentDate = new Date(); - for (int i = 0; i < resultArray.size(); i++) { - try { + try { + for (int i = 0; i < resultArray.size(); i++) { + JSONObject resultObject = (JSONObject) resultArray.get(i); MesPurchaseOrder mesPurchaseOrder = new MesPurchaseOrder(); //erpid @@ -985,7 +1068,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { String approveDate = resultObject.getString("FApproveDate"); //单据状态 String documentStatus = resultObject.getString("FDocumentStatus"); - if(!documentStatus.equals("C")){ + if (!documentStatus.equals("C")) { System.out.println(documentStatus); } //订单明细id @@ -1068,31 +1151,249 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { if (existedPurchaseOrder != null) { mesPurchaseOrder.setPurchaseOrderId(existedPurchaseOrder.getPurchaseOrderId()); toUpdatePurchaseOrderList.add(mesPurchaseOrder); + + SysOperLog sysOperLog = this.getSysOperLog("采购订单信息同步", 2, "com.hw.jindie.controller.KingdeeErpSyncController.syncPurchaseOrderFromErp", + "POST", "syncPurchaseOrderFromErp", "PUR_PurchaseOrder(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); } else { mesPurchaseOrder.setOrderStatus(MesConstants.MES_PURCHASE_ORDER_STATUS_TOPURCHASE); toInsertPurchaseOrderList.add(mesPurchaseOrder); + + SysOperLog sysOperLog = this.getSysOperLog("采购订单信息同步", 1, "com.hw.jindie.controller.KingdeeErpSyncController.syncPurchaseOrderFromErp", + "POST", "syncPurchaseOrderFromErp", "PUR_PurchaseOrder(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); } - } catch (Exception e) { - e.printStackTrace(); } + if (!toInsertPurchaseOrderList.isEmpty()) { + mesPurchaseOrderMapper.batchMesBasePurchaseOrder(toInsertPurchaseOrderList); + } + if (!toUpdatePurchaseOrderList.isEmpty()) { + for (MesPurchaseOrder toUpdatePurchaseOrder : toUpdatePurchaseOrderList) { + mesPurchaseOrderMapper.updateMesPurchaseOrder(toUpdatePurchaseOrder); + } + } + + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + + System.out.println("size:" + resultArray.size()); + /**分页递归获取所有物料信息*/ + if (resultArray.size() == limit) { +// System.out.println(startRow); + //通过递归同步所有物料信息,测试先不用 + int i = syncPurchaseOrderFromErp(startRow + resultArray.size(), maxErpModifyDate); +// return i; + return 1; + } else { + //为空时的总行数 + return startRow + resultArray.size(); + } + } + + + /** + * @throws Exception + * @Descrption:从金蝶ERP同步收料通知单 + */ + @Override + public int syncPurchaseReceiveBillFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception { + String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate()) ? + mesPurchaseReceiveBillMapper.selectMaxErpModifyDate() : erpSyncInfoVo.getMaxErpModifyDate(); + return syncPurchaseReceiveBillFromErp(startRow, maxErpModifyDate); + } + + /** + * @throws Exception + * @Descrption:从金蝶ERP同步采购订单 + */ + public int syncPurchaseReceiveBillFromErp(int startRow, String maxErpModifyDate) throws Exception { +// maxErpModifyDate = "2022-03-23 11:30:57"; + K3CloudApi api = new K3CloudApi(); +// 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 filterString = ""; + String orderString = ""; + int topRowCount = 0; +// int startRow = 0; +// int limit = 20; + queryJson.put("FormId", formId); + queryJson.put("FieldKeys", fieldKeys); +// queryJson.put("FilterString", filterString); + queryJson.put("OrderString", orderString); + queryJson.put("TopRowCount", topRowCount); + queryJson.put("StartRow", startRow); + queryJson.put("Limit", limit); + queryJson.put("SubSystemId", ""); +// System.out.println(queryJson.toString()); + + //条件查询 + Long deptId = kingdeeConfig.erpDeptId; + if (deptId == null) { + return 0; } +// System.out.println("maxErpModifyDate=" + maxErpModifyDate); + StringBuilder filterStringBuilder = new StringBuilder(); + filterStringBuilder.append("FReceiveDeptId = ").append(deptId); + + filterStringBuilder.append(" and FDocumentStatus = 'C'"); + +// System.out.println("maxErpModifyDate=" + maxErpModifyDate); + if (StringUtils.isNotEmpty(maxErpModifyDate)) { + filterStringBuilder.append(" and FModifyDate >='").append(maxErpModifyDate).append("'"); - if (!toInsertPurchaseOrderList.isEmpty()) { - mesPurchaseOrderMapper.batchMesBasePurchaseOrder(toInsertPurchaseOrderList); } - if (!toUpdatePurchaseOrderList.isEmpty()) { - for (MesPurchaseOrder toUpdatePurchaseOrder : toUpdatePurchaseOrderList) { - mesPurchaseOrderMapper.updateMesPurchaseOrder(toUpdatePurchaseOrder); + queryJson.put("FilterString", filterStringBuilder.toString()); +// System.out.println(queryJson.toString()); + + String result = api.billQuery(queryJson.toString()); + JSONArray resultArray = JSONArray.parseArray(result); +// System.out.println(resultArray.size()); +// System.out.println("采购订单单据查询接口: " + result); + + List toInsertPurchaseReceiveBillList = new ArrayList<>(); + List toUpdatePurchaseReceiveBillList = new ArrayList<>(); + List sysOperLogList = new ArrayList<>(); + Date currentDate = new Date(); + StringBuilder notifyInfoBuilder = new StringBuilder("收料通知:"); + try { + for (int i = 0; i < resultArray.size(); i++) { + Long beginTimeL = System.currentTimeMillis(); + + JSONObject resultObject = (JSONObject) resultArray.get(i); + MesPurchaseReceiveBill mesPurchaseReceiveBill = new MesPurchaseReceiveBill(); + //erpid + Long erpId = resultObject.getLong("FID"); + //收料单编号 + String billNo = resultObject.getString("FBillNo"); + //采购订单编号 + String poNo = resultObject.getString("FOrderBillNo"); + //审核日期 + String approveDate = resultObject.getString("FApproveDate"); + //单据状态 + String documentStatus = resultObject.getString("FDocumentStatus"); + //订单明细id + Long fentryId = resultObject.getLong("FDetailEntity.FEntryID"); + //erp物料ID + Long fmaterialId = resultObject.getLong("FMaterialId"); + //物料编码 + String materialCode = resultObject.getString("FMaterialId.FNumber"); + //物料名称 + String materialName = resultObject.getString("FMaterialId.Fname"); + + //源单内码 + String fsBillId = resultObject.getString("FDetailEntity.Link.FSBillId"); + //源单分录内码 + 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"); + + //交货数量 + BigDecimal actReceiveAmount = resultObject.getBigDecimal("FActReceiveQty"); + + //实到数量 + BigDecimal actlandAmount = resultObject.getBigDecimal("FActlandQty"); + + + //创建时间 + String FCreateDate = resultObject.getString("FCreateDate"); + //更新时间 + String FModifyDate = resultObject.getString("FModifyDate"); + + mesPurchaseReceiveBill.setErpId(erpId); + mesPurchaseReceiveBill.setBillNo(billNo); + mesPurchaseReceiveBill.setPoNo(poNo); + mesPurchaseReceiveBill.setDocumentStatus(documentStatus); + mesPurchaseReceiveBill.setFentryId(fentryId); + mesPurchaseReceiveBill.setMaterialId(fmaterialId); + mesPurchaseReceiveBill.setMaterialCode(materialCode); + mesPurchaseReceiveBill.setMaterialName(materialName); + mesPurchaseReceiveBill.setFsBillId(fsBillId); + mesPurchaseReceiveBill.setFsId(fsId); + mesPurchaseReceiveBill.setPurchaseOrgId(fStockOrgId); + mesPurchaseReceiveBill.setActReceiveAmount(actReceiveAmount); + mesPurchaseReceiveBill.setActLandAmount(actlandAmount); +// mesPurchaseReceiveBill.setTondBase(tondBase); + mesPurchaseReceiveBill.setSupplierId(supplierId); + mesPurchaseReceiveBill.setUpdateTime(currentDate); + + + if (approveDate != null) { + mesPurchaseReceiveBill.setApproveDate(conversionERPTime(approveDate)); + } +// if (planDeliveryDate != null) { +// mesPurchaseOrder.setPlanDeliveryDate(conversionERPTime(planDeliveryDate)); +// } + if (StringUtils.isNotEmpty(FCreateDate)) { + mesPurchaseReceiveBill.setCreateTime(conversionERPTime(FCreateDate)); + } + if (StringUtils.isNotEmpty(FModifyDate)) { + mesPurchaseReceiveBill.setErpModifyDate(conversionERPTime(FModifyDate)); + } +// if (StringUtils.isNotEmpty(FAuditDate)) { +// mesPurchaseOrder.setAuditDate(conversionERPTime(FAuditDate)); +// } + + MesPurchaseReceiveBill existedPurchaseReceiveBill = mesPurchaseReceiveBillMapper.selectMesPurchaseReceiveBillByUI(erpId, fentryId); + + if (existedPurchaseReceiveBill != null) { + mesPurchaseReceiveBill.setReceiveBillId(existedPurchaseReceiveBill.getReceiveBillId()); + toUpdatePurchaseReceiveBillList.add(mesPurchaseReceiveBill); + } else { + toInsertPurchaseReceiveBillList.add(mesPurchaseReceiveBill); + notifyInfoBuilder.append(materialName).append(";"); + } +// System.out.println("l:"+resultArray.get(i).toString().length()); + + Long costTime = System.currentTimeMillis() - beginTimeL; + SysOperLog sysOperLog = this.getSysOperLog("收料通知单信息同步", 1, "com.hw.jindie.controller.KingdeeErpSyncController.syncPurchaseReceiveBillFromErp", + "POST", "syncPurchaseReceiveBillFromErp", "PUR_ReceiveBill(" + queryJson.toString() + ")", resultArray.get(i).toString(), currentDate, 1L); + sysOperLogList.add(sysOperLog); + + + } + + if (!toUpdatePurchaseReceiveBillList.isEmpty()) { + for (MesPurchaseReceiveBill toUpdatePurchaseReceiveBill : toUpdatePurchaseReceiveBillList) { + mesPurchaseReceiveBillMapper.updateMesPurchaseReceiveBill(toUpdatePurchaseReceiveBill); + } + } + + if (!toInsertPurchaseReceiveBillList.isEmpty()) { + this.insertSysPointRouter(notifyInfoBuilder.toString()); + mesPurchaseReceiveBillMapper.batchMesBasePurchaseReceiveBill(toInsertPurchaseReceiveBillList); } + if (!sysOperLogList.isEmpty()) { + for (SysOperLog sysOperLog : sysOperLogList) { + remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER); + } + } + + } catch (Exception e) { + e.printStackTrace(); } - System.out.println("size:" + resultArray.size()); +// System.out.println(resultArray.get(0).toString().length()+"lll"); +// System.out.println("result:" + resultArray); +// System.out.println("size:" + resultArray.size()); /**分页递归获取所有物料信息*/ if (resultArray.size() == limit) { // System.out.println(startRow); //通过递归同步所有物料信息,测试先不用 - int i = syncPurchaseOrderFromErp(startRow + resultArray.size(), maxErpModifyDate); + int i = syncPurchaseReceiveBillFromErp(startRow + resultArray.size(), maxErpModifyDate); // return i; return 1; } else { @@ -1101,6 +1402,48 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { } } + + private void insertSysPointRouter(String notifyInfo) { + notifyInfo = notifyInfo.length() > 400 ? notifyInfo.substring(0, 400) : notifyInfo; + SysPointRouter sysPointRouter = new SysPointRouter(); + sysPointRouter.setModuleCode("MES"); + sysPointRouter.setPointType(SystemConstants.SYS_ROUTER_POINT_TYPE_NOTICE); + sysPointRouter.setRouterAddress("/mes/plan/purchaseReceiveBill"); + sysPointRouter.setRemark(notifyInfo); + sysPointRouter.setProcessActivityId(SystemConstants.PROCESS_ACTIVITY_ID_STOCK_NOTENOUGH); + sysPointRouter.setCreateBy("定时任务"); + sysPointRouter.setCreateTime(new Date()); + sysPointRouter.setProcessActivityId(7011L); + sysPointRouter.setEmailFlag("1"); + sysPointRouter.setSentEmailFlag("0"); + + List sysPointRouterList = new ArrayList<>(); + sysPointRouterList.add(sysPointRouter); + remoteSysCommonService.insertSysPointRouterPort(sysPointRouterList, SecurityConstants.INNER); + + } + + 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; + } + + public static void main(String[] args) throws Exception { KingdeeErpSyncServiceImpl k = new KingdeeErpSyncServiceImpl(); k.syncProjectInfoFromErp(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 new file mode 100644 index 00000000..6c2d2151 --- /dev/null +++ b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseReceiveBillMapper.xml @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select receive_bill_id, erp_id, fentry_id, bill_no, po_no, document_status, material_id, material_code, material_name, fs_bill_id, fs_id, act_land_amount, act_receive_amount, approve_date, erp_modify_date, purchase_org_id, tond_base, price, supplier_id, remark, create_by, create_time, update_by, update_time from mes_purchase_receive_bill + + + + + + + + insert into mes_purchase_receive_bill + + erp_id, + fentry_id, + bill_no, + po_no, + document_status, + material_id, + material_code, + material_name, + fs_bill_id, + fs_id, + act_land_amount, + act_receive_amount, + approve_date, + erp_modify_date, + purchase_org_id, + tond_base, + price, + supplier_id, + remark, + create_by, + create_time, + update_by, + update_time, + + + #{erpId}, + #{fentryId}, + #{billNo}, + #{poNo}, + #{documentStatus}, + #{materialId}, + #{materialCode}, + #{materialName}, + #{fsBillId}, + #{fsId}, + #{actLandAmount}, + #{actReceiveAmount}, + #{approveDate}, + #{erpModifyDate}, + #{purchaseOrgId}, + #{tondBase}, + #{price}, + #{supplierId}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update mes_purchase_receive_bill + + erp_id = #{erpId}, + fentry_id = #{fentryId}, + bill_no = #{billNo}, + po_no = #{poNo}, + document_status = #{documentStatus}, + material_id = #{materialId}, + material_code = #{materialCode}, + material_name = #{materialName}, + fs_bill_id = #{fsBillId}, + fs_id = #{fsId}, + act_land_amount = #{actLandAmount}, + act_receive_amount = #{actReceiveAmount}, + approve_date = #{approveDate}, + erp_modify_date = #{erpModifyDate}, + purchase_org_id = #{purchaseOrgId}, + tond_base = #{tondBase}, + price = #{price}, + supplier_id = #{supplierId}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where receive_bill_id = #{receiveBillId} + + + + delete from mes_purchase_receive_bill where receive_bill_id = #{receiveBillId} + + + + delete from mes_purchase_receive_bill where receive_bill_id in + + #{receiveBillId} + + + + + + + + + + + + INSERT INTO mes_purchase_receive_bill (erp_id, fentry_id, bill_no,po_no, document_status, material_id, material_code, material_name, approve_date, erp_modify_date, fs_bill_id, fs_id,purchase_org_id, supplier_id, act_land_amount,act_receive_amount, create_time,update_time) VALUES + + (#{item.erpId}, #{item.fentryId}, #{item.billNo},#{item.poNo},#{item.documentStatus}, #{item.materialId}, #{item.materialCode}, #{item.materialName}, #{item.approveDate}, #{item.erpModifyDate},#{item.fsBillId},#{item.fsId}, #{item.purchaseOrgId}, #{item.supplierId}, #{item.actLandAmount}, #{item.actReceiveAmount}, #{item.createTime},#{item.updateTime}) + + + \ No newline at end of file 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 d7b6a2ea..b9d520c9 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 @@ -129,6 +129,14 @@ public class RyTask remoteJindieService.syncPurchaseOrderFromErp(erpSyncInfoVo,SecurityConstants.INNER); } + public void syncPurchaseReceiveBillFromErp(String maxErpModifyDate){ + ErpSyncInfoVo erpSyncInfoVo = new ErpSyncInfoVo(); + erpSyncInfoVo.setMaxErpModifyDate(maxErpModifyDate); + System.out.println("++同步ERP中收料通知单信息++syncPurchaseReceiveBillFromErp"); + remoteJindieService.syncPurchaseReceiveBillFromErp(erpSyncInfoVo,SecurityConstants.INNER); + } + + public void syncInventoryInformationToERP(){ System.out.println(new Date()+"++定时同步原材料入库信息给ERP++syncInventoryInformationToERP"); remoteWmsService.synchronizeInventoryInformationToERP(SecurityConstants.INNER); diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesPurchaseReceiveBillController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesPurchaseReceiveBillController.java new file mode 100644 index 00000000..629ca5e3 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesPurchaseReceiveBillController.java @@ -0,0 +1,105 @@ +package com.hw.mes.controller; + +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.hw.common.log.annotation.Log; +import com.hw.common.log.enums.BusinessType; +import com.hw.common.security.annotation.RequiresPermissions; +import com.hw.mes.domain.MesPurchaseReceiveBill; +import com.hw.mes.service.IMesPurchaseReceiveBillService; +import com.hw.common.core.web.controller.BaseController; +import com.hw.common.core.web.domain.AjaxResult; +import com.hw.common.core.utils.poi.ExcelUtil; +import com.hw.common.core.web.page.TableDataInfo; + +/** + * 收料通知单Controller + * + * @author xins + * @date 2024-12-16 + */ +@RestController +@RequestMapping("/purchaseReceiveBill") +public class MesPurchaseReceiveBillController extends BaseController +{ + @Autowired + private IMesPurchaseReceiveBillService mesPurchaseReceiveBillService; + + /** + * 查询收料通知单列表 + */ + @RequiresPermissions("mes:purchaseReceiveBill:list") + @GetMapping("/list") + public TableDataInfo list(MesPurchaseReceiveBill mesPurchaseReceiveBill) + { + startPage(); + List list = mesPurchaseReceiveBillService.selectMesPurchaseReceiveBillJoinList(mesPurchaseReceiveBill); + return getDataTable(list); + } + + /** + * 导出收料通知单列表 + */ + @RequiresPermissions("mes:purchaseReceiveBill:export") + @Log(title = "收料通知单", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, MesPurchaseReceiveBill mesPurchaseReceiveBill) + { + List list = mesPurchaseReceiveBillService.selectMesPurchaseReceiveBillList(mesPurchaseReceiveBill); + ExcelUtil util = new ExcelUtil(MesPurchaseReceiveBill.class); + util.exportExcel(response, list, "收料通知单数据"); + } + + /** + * 获取收料通知单详细信息 + */ + @RequiresPermissions("mes:purchaseReceiveBill:query") + @GetMapping(value = "/{receiveBillId}") + public AjaxResult getInfo(@PathVariable("receiveBillId") Long receiveBillId) + { + return success(mesPurchaseReceiveBillService.selectMesPurchaseReceiveBillByReceiveBillId(receiveBillId)); + } + + /** + * 新增收料通知单 + */ + @RequiresPermissions("mes:purchaseReceiveBill:add") + @Log(title = "收料通知单", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MesPurchaseReceiveBill mesPurchaseReceiveBill) + { + return toAjax(mesPurchaseReceiveBillService.insertMesPurchaseReceiveBill(mesPurchaseReceiveBill)); + } + + /** + * 修改收料通知单 + */ + @RequiresPermissions("mes:purchaseReceiveBill:edit") + @Log(title = "收料通知单", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MesPurchaseReceiveBill mesPurchaseReceiveBill) + { + return toAjax(mesPurchaseReceiveBillService.updateMesPurchaseReceiveBill(mesPurchaseReceiveBill)); + } + + /** + * 删除收料通知单 + */ + @RequiresPermissions("mes:purchaseReceiveBill:remove") + @Log(title = "收料通知单", businessType = BusinessType.DELETE) + @DeleteMapping("/{receiveBillIds}") + public AjaxResult remove(@PathVariable Long[] receiveBillIds) + { + return toAjax(mesPurchaseReceiveBillService.deleteMesPurchaseReceiveBillByReceiveBillIds(receiveBillIds)); + } +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseReceiveBill.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseReceiveBill.java new file mode 100644 index 00000000..db59dbc3 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseReceiveBill.java @@ -0,0 +1,309 @@ +package com.hw.mes.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.hw.common.core.annotation.Excel; +import com.hw.common.core.web.domain.BaseEntity; + +/** + * 收料通知单对象 mes_purchase_receive_bill + * + * @author xins + * @date 2024-12-16 + */ +public class MesPurchaseReceiveBill extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键标识 */ + private Long receiveBillId; + + /** ERP的主键信息;对应FID */ + @Excel(name = "ERP的主键信息;对应FID") + private Long erpId; + + /** 对应金蝶ERP收料单明细的ID;对应FDetailEntity_FEntryID */ + @Excel(name = "对应金蝶ERP收料单明细的ID;对应FDetailEntity_FEntryID") + private Long fentryId; + + /** 收料单据号;对应FBillNo */ + @Excel(name = "收料单据号;对应FBillNo") + private String billNo; + + /** 采购订单编号;对应FOrderBillNo */ + @Excel(name = "采购订单编号;对应FOrderBillNo") + private String poNo; + + /** 单据状态;FDocumentStatus */ + @Excel(name = "单据状态;FDocumentStatus") + private String documentStatus; + + /** ERP物料ID;FMaterialId */ + @Excel(name = "ERP物料ID;FMaterialId") + private Long materialId; + + /** 物料编码;对应FMaterialId.FNumber */ + @Excel(name = "物料编码;对应FMaterialId.FNumber") + private String materialCode; + + /** 物料名称;对应FMaterialId.FName */ + @Excel(name = "物料名称;对应FMaterialId.FName") + private String materialName; + + /** 源单内码;对应FDetailEntity_Link_FSBillId */ + @Excel(name = "源单内码;对应FDetailEntity_Link_FSBillId") + private String fsBillId; + + /** 源单分录内码;对应FDetailEntity_Link_FSId */ + @Excel(name = "源单分录内码;对应FDetailEntity_Link_FSId") + private String fsId; + + /** 实到数量;对应FActlandQty */ + @Excel(name = "实到数量;对应FActlandQty") + private BigDecimal actLandAmount; + + /** 交货数量;对应FActReceiveQty */ + @Excel(name = "交货数量;对应FActReceiveQty") + private BigDecimal actReceiveAmount; + + /** 审核日期;对应FApproveDate */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "审核日期;对应FApproveDate", width = 30, dateFormat = "yyyy-MM-dd") + private Date approveDate; + + /** ERP最后修改日期;对应FModifyDate */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "ERP最后修改日期;对应FModifyDate", width = 30, dateFormat = "yyyy-MM-dd") + private Date erpModifyDate; + + /** 收料组织;FPurchaseOrgId */ + @Excel(name = "收料组织;FPurchaseOrgId") + private Long purchaseOrgId; + + /** 京源项目;F_TOND_Base */ + @Excel(name = "京源项目;F_TOND_Base") + private String tondBase; + + /** 单价;FPRICE */ + @Excel(name = "单价;FPRICE") + private BigDecimal price; + + /** 供应商ID;FSupplierId */ + @Excel(name = "供应商ID;FSupplierId") + private Long supplierId; + + private String materialSpec; + + public void setReceiveBillId(Long receiveBillId) + { + this.receiveBillId = receiveBillId; + } + + public Long getReceiveBillId() + { + return receiveBillId; + } + public void setErpId(Long erpId) + { + this.erpId = erpId; + } + + public Long getErpId() + { + return erpId; + } + public void setFentryId(Long fentryId) + { + this.fentryId = fentryId; + } + + public Long getFentryId() + { + return fentryId; + } + public void setBillNo(String billNo) + { + this.billNo = billNo; + } + + public String getBillNo() + { + return billNo; + } + public void setPoNo(String poNo) + { + this.poNo = poNo; + } + + public String getPoNo() + { + return poNo; + } + public void setDocumentStatus(String documentStatus) + { + this.documentStatus = documentStatus; + } + + public String getDocumentStatus() + { + return documentStatus; + } + public void setMaterialId(Long materialId) + { + this.materialId = materialId; + } + + public Long getMaterialId() + { + return materialId; + } + public void setMaterialCode(String materialCode) + { + this.materialCode = materialCode; + } + + public String getMaterialCode() + { + return materialCode; + } + public void setMaterialName(String materialName) + { + this.materialName = materialName; + } + + public String getMaterialName() + { + return materialName; + } + public void setFsBillId(String fsBillId) + { + this.fsBillId = fsBillId; + } + + public String getFsBillId() + { + return fsBillId; + } + public void setFsId(String fsId) + { + this.fsId = fsId; + } + + public String getFsId() + { + return fsId; + } + public void setActLandAmount(BigDecimal actLandAmount) + { + this.actLandAmount = actLandAmount; + } + + public BigDecimal getActLandAmount() + { + return actLandAmount; + } + public void setActReceiveAmount(BigDecimal actReceiveAmount) + { + this.actReceiveAmount = actReceiveAmount; + } + + public BigDecimal getActReceiveAmount() + { + return actReceiveAmount; + } + public void setApproveDate(Date approveDate) + { + this.approveDate = approveDate; + } + + public Date getApproveDate() + { + return approveDate; + } + public void setErpModifyDate(Date erpModifyDate) + { + this.erpModifyDate = erpModifyDate; + } + + public Date getErpModifyDate() + { + return erpModifyDate; + } + public void setPurchaseOrgId(Long purchaseOrgId) + { + this.purchaseOrgId = purchaseOrgId; + } + + public Long getPurchaseOrgId() + { + return purchaseOrgId; + } + public void setTondBase(String tondBase) + { + this.tondBase = tondBase; + } + + public String getTondBase() + { + return tondBase; + } + public void setPrice(BigDecimal price) + { + this.price = price; + } + + public BigDecimal getPrice() + { + return price; + } + public void setSupplierId(Long supplierId) + { + this.supplierId = supplierId; + } + + public Long getSupplierId() + { + return supplierId; + } + + public String getMaterialSpec() { + return materialSpec; + } + + public void setMaterialSpec(String materialSpec) { + this.materialSpec = materialSpec; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("receiveBillId", getReceiveBillId()) + .append("erpId", getErpId()) + .append("fentryId", getFentryId()) + .append("billNo", getBillNo()) + .append("poNo", getPoNo()) + .append("documentStatus", getDocumentStatus()) + .append("materialId", getMaterialId()) + .append("materialCode", getMaterialCode()) + .append("materialName", getMaterialName()) + .append("fsBillId", getFsBillId()) + .append("fsId", getFsId()) + .append("actLandAmount", getActLandAmount()) + .append("actReceiveAmount", getActReceiveAmount()) + .append("approveDate", getApproveDate()) + .append("erpModifyDate", getErpModifyDate()) + .append("purchaseOrgId", getPurchaseOrgId()) + .append("tondBase", getTondBase()) + .append("price", getPrice()) + .append("supplierId", getSupplierId()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseReceiveBillMapper.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseReceiveBillMapper.java new file mode 100644 index 00000000..9c644d63 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseReceiveBillMapper.java @@ -0,0 +1,70 @@ +package com.hw.mes.mapper; + +import java.util.List; +import com.hw.mes.domain.MesPurchaseReceiveBill; + +/** + * 收料通知单Mapper接口 + * + * @author xins + * @date 2024-12-16 + */ +public interface MesPurchaseReceiveBillMapper +{ + /** + * 查询收料通知单 + * + * @param receiveBillId 收料通知单主键 + * @return 收料通知单 + */ + public MesPurchaseReceiveBill selectMesPurchaseReceiveBillByReceiveBillId(Long receiveBillId); + + /** + * 查询收料通知单列表 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 收料通知单集合 + */ + public List selectMesPurchaseReceiveBillList(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 新增收料通知单 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 结果 + */ + public int insertMesPurchaseReceiveBill(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 修改收料通知单 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 结果 + */ + public int updateMesPurchaseReceiveBill(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 删除收料通知单 + * + * @param receiveBillId 收料通知单主键 + * @return 结果 + */ + public int deleteMesPurchaseReceiveBillByReceiveBillId(Long receiveBillId); + + /** + * 批量删除收料通知单 + * + * @param receiveBillIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMesPurchaseReceiveBillByReceiveBillIds(Long[] receiveBillIds); + + /** + * 查询收料通知单列表,join material + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 收料通知单集合 + */ + public List selectMesPurchaseReceiveBillJoinList(MesPurchaseReceiveBill mesPurchaseReceiveBill); + +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesPurchaseReceiveBillService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesPurchaseReceiveBillService.java new file mode 100644 index 00000000..bbb20e5e --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesPurchaseReceiveBillService.java @@ -0,0 +1,69 @@ +package com.hw.mes.service; + +import java.util.List; +import com.hw.mes.domain.MesPurchaseReceiveBill; + +/** + * 收料通知单Service接口 + * + * @author xins + * @date 2024-12-16 + */ +public interface IMesPurchaseReceiveBillService +{ + /** + * 查询收料通知单 + * + * @param receiveBillId 收料通知单主键 + * @return 收料通知单 + */ + public MesPurchaseReceiveBill selectMesPurchaseReceiveBillByReceiveBillId(Long receiveBillId); + + /** + * 查询收料通知单列表 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 收料通知单集合 + */ + public List selectMesPurchaseReceiveBillList(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 查询收料通知单列表,Join material + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 收料通知单集合 + */ + public List selectMesPurchaseReceiveBillJoinList(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 新增收料通知单 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 结果 + */ + public int insertMesPurchaseReceiveBill(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 修改收料通知单 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 结果 + */ + public int updateMesPurchaseReceiveBill(MesPurchaseReceiveBill mesPurchaseReceiveBill); + + /** + * 批量删除收料通知单 + * + * @param receiveBillIds 需要删除的收料通知单主键集合 + * @return 结果 + */ + public int deleteMesPurchaseReceiveBillByReceiveBillIds(Long[] receiveBillIds); + + /** + * 删除收料通知单信息 + * + * @param receiveBillId 收料通知单主键 + * @return 结果 + */ + public int deleteMesPurchaseReceiveBillByReceiveBillId(Long receiveBillId); +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java index 7f8b4a3f..5f08ada5 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java @@ -563,6 +563,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService MesBaseBarcodeInfo toInsertedBarcodeInfo = new MesBaseBarcodeInfo(); //同一批次的批次代码相同 toInsertedBarcodeInfo.setBatchCode(batchCode); + toInsertedBarcodeInfo.setReceiveBillId(mesBaseBarcodeInfo.getReceiveBillId()); toInsertedBarcodeInfo.setPurchaseOrderId(mesBaseBarcodeInfo.getPurchaseOrderId()); toInsertedBarcodeInfo.setPoNo(mesBaseBarcodeInfo.getPoNo()); toInsertedBarcodeInfo.setBarcodeType(MesConstants.MES_BARCODE_TYPE_RAW); @@ -698,8 +699,8 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService try { String hostIp = IpUtils.getIpAddr(); - if(hostIp.equals("192.168.2.26")){ - hostIp = "192.168.2.10"; + if(hostIp.equals("192.168.2.10")){ + hostIp = "192.168.2.26"; } String printKey = "print_" + hostIp; redisTemplate.opsForList().rightPush(printKey, printContentJson.toString()); 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 05784537..d867c37f 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 @@ -6,12 +6,14 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import com.hw.common.core.constant.CacheConstants; import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.domain.R; import com.hw.common.core.exception.ServiceException; 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.redis.service.RedisService; import com.hw.mes.domain.MesBaseAttachInfo; import com.hw.mes.service.IMesBaseAttachInfoService; import com.hw.system.api.RemoteUserService; @@ -41,6 +43,9 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { @Autowired private IMesBaseAttachInfoService mesBaseAttachInfoService; + @Autowired + private RedisService redisService; + /** * 查询物料BOM信息 * @@ -258,9 +263,18 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService { } else { sendMsg.append(",SOP已维护成功!"); } + String emailAccountInfo = redisService.getCacheObject(CacheConstants.SYS_EAMIL_ACCOUNT_INFO); + String emailAccount = ""; + String emailPassword = ""; + if(StringUtils.isNotEmpty(emailAccountInfo)){ + int splitIndex = emailAccountInfo.indexOf(","); + emailAccount = emailAccountInfo.substring(0,splitIndex); + emailPassword = emailAccountInfo.substring(splitIndex+1); + } + for (SysUser sysUser : sysUserList) { String email = sysUser.getEmail(); - MailUtils.processSendEmail(email, "通知", sendMsg.toString()); + MailUtils.processSendEmail(emailAccount,emailPassword,email, "上传图纸通知", sendMsg.toString()); } mesMaterialBom.setUpdateTime(DateUtils.getNowDate()); return mesMaterialBomMapper.updateMesMaterialBom(mesMaterialBom); diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseReceiveBillServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseReceiveBillServiceImpl.java new file mode 100644 index 00000000..1722ee73 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseReceiveBillServiceImpl.java @@ -0,0 +1,109 @@ +package com.hw.mes.service.impl; + +import java.util.List; +import com.hw.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.hw.mes.mapper.MesPurchaseReceiveBillMapper; +import com.hw.mes.domain.MesPurchaseReceiveBill; +import com.hw.mes.service.IMesPurchaseReceiveBillService; + +/** + * 收料通知单Service业务层处理 + * + * @author xins + * @date 2024-12-16 + */ +@Service +public class MesPurchaseReceiveBillServiceImpl implements IMesPurchaseReceiveBillService +{ + @Autowired + private MesPurchaseReceiveBillMapper mesPurchaseReceiveBillMapper; + + /** + * 查询收料通知单 + * + * @param receiveBillId 收料通知单主键 + * @return 收料通知单 + */ + @Override + public MesPurchaseReceiveBill selectMesPurchaseReceiveBillByReceiveBillId(Long receiveBillId) + { + return mesPurchaseReceiveBillMapper.selectMesPurchaseReceiveBillByReceiveBillId(receiveBillId); + } + + /** + * 查询收料通知单列表 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 收料通知单 + */ + @Override + public List selectMesPurchaseReceiveBillList(MesPurchaseReceiveBill mesPurchaseReceiveBill) + { + return mesPurchaseReceiveBillMapper.selectMesPurchaseReceiveBillList(mesPurchaseReceiveBill); + } + + /** + * 查询收料通知单列表,Join material + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 收料通知单 + */ + @Override + public List selectMesPurchaseReceiveBillJoinList(MesPurchaseReceiveBill mesPurchaseReceiveBill) + { + return mesPurchaseReceiveBillMapper.selectMesPurchaseReceiveBillJoinList(mesPurchaseReceiveBill); + } + + + /** + * 新增收料通知单 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 结果 + */ + @Override + public int insertMesPurchaseReceiveBill(MesPurchaseReceiveBill mesPurchaseReceiveBill) + { + mesPurchaseReceiveBill.setCreateTime(DateUtils.getNowDate()); + return mesPurchaseReceiveBillMapper.insertMesPurchaseReceiveBill(mesPurchaseReceiveBill); + } + + /** + * 修改收料通知单 + * + * @param mesPurchaseReceiveBill 收料通知单 + * @return 结果 + */ + @Override + public int updateMesPurchaseReceiveBill(MesPurchaseReceiveBill mesPurchaseReceiveBill) + { + mesPurchaseReceiveBill.setUpdateTime(DateUtils.getNowDate()); + return mesPurchaseReceiveBillMapper.updateMesPurchaseReceiveBill(mesPurchaseReceiveBill); + } + + /** + * 批量删除收料通知单 + * + * @param receiveBillIds 需要删除的收料通知单主键 + * @return 结果 + */ + @Override + public int deleteMesPurchaseReceiveBillByReceiveBillIds(Long[] receiveBillIds) + { + return mesPurchaseReceiveBillMapper.deleteMesPurchaseReceiveBillByReceiveBillIds(receiveBillIds); + } + + /** + * 删除收料通知单信息 + * + * @param receiveBillId 收料通知单主键 + * @return 结果 + */ + @Override + public int deleteMesPurchaseReceiveBillByReceiveBillId(Long receiveBillId) + { + return mesPurchaseReceiveBillMapper.deleteMesPurchaseReceiveBillByReceiveBillId(receiveBillId); + } +} diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml index d2c7d7ff..cae7e93c 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml @@ -24,6 +24,7 @@ + @@ -195,6 +196,7 @@ product_barcode, machine_name, print_number, + receive_bill_id, purchase_order_id, po_no, production_date, @@ -234,6 +236,7 @@ #{productBarcode}, #{machineName}, #{printNumber}, + #{receiveBillId}, #{purchaseOrderId}, #{poNo}, #{productionDate}, 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 802b8663..ad32149d 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 @@ -214,7 +214,7 @@ and mmb.project_id = #{projectId} and mmb.active_flag = #{activeFlag} - order by mmb.material_bom_id desc + order by mmb.create_time desc diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseOrderMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseOrderMapper.xml index ef169f51..5a1a67bb 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseOrderMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseOrderMapper.xml @@ -396,7 +396,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from mes_purchase_order mpo left join mes_base_material_info mbmi on mbmi.erp_id = mpo.material_id - and mpo.po_no like concat('%', #{poNo}, '%') + and mpo.po_no = #{poNo} + and mpo.material_id = #{materialId} and mbmi.material_code like concat('%', #{materialCode}, '%') and mbmi.material_name like concat('%', #{materialName}, '%') and mpo.specification_parameter like concat('%', #{specificationParameter}, '%') @@ -476,6 +477,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and pbmi.material_code like concat('%', #{productCode}, '%') and pbmi.material_name like concat('%', #{productName}, '%') and mpo.po_no like concat('%', #{poNo}, '%') + and mpo.material_id = #{materialId} and mbmi.material_code like concat('%', #{materialCode}, '%') and mbmi.material_name like concat('%', #{materialName}, '%') and replace(mbmi.material_spec,' ','') like concat('%', #{materialSpec}, diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseReceiveBillMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseReceiveBillMapper.xml new file mode 100644 index 00000000..287a0824 --- /dev/null +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseReceiveBillMapper.xml @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select receive_bill_id, erp_id, fentry_id, bill_no, po_no, document_status, material_id, material_code, material_name, fs_bill_id, fs_id, act_land_amount, act_receive_amount, approve_date, erp_modify_date, purchase_org_id, tond_base, price, supplier_id, remark, create_by, create_time, update_by, update_time from mes_purchase_receive_bill + + + + + + + + insert into mes_purchase_receive_bill + + erp_id, + fentry_id, + bill_no, + po_no, + document_status, + material_id, + material_code, + material_name, + fs_bill_id, + fs_id, + act_land_amount, + act_receive_amount, + approve_date, + erp_modify_date, + purchase_org_id, + tond_base, + price, + supplier_id, + remark, + create_by, + create_time, + update_by, + update_time, + + + #{erpId}, + #{fentryId}, + #{billNo}, + #{poNo}, + #{documentStatus}, + #{materialId}, + #{materialCode}, + #{materialName}, + #{fsBillId}, + #{fsId}, + #{actLandAmount}, + #{actReceiveAmount}, + #{approveDate}, + #{erpModifyDate}, + #{purchaseOrgId}, + #{tondBase}, + #{price}, + #{supplierId}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update mes_purchase_receive_bill + + erp_id = #{erpId}, + fentry_id = #{fentryId}, + bill_no = #{billNo}, + po_no = #{poNo}, + document_status = #{documentStatus}, + material_id = #{materialId}, + material_code = #{materialCode}, + material_name = #{materialName}, + fs_bill_id = #{fsBillId}, + fs_id = #{fsId}, + act_land_amount = #{actLandAmount}, + act_receive_amount = #{actReceiveAmount}, + approve_date = #{approveDate}, + erp_modify_date = #{erpModifyDate}, + purchase_org_id = #{purchaseOrgId}, + tond_base = #{tondBase}, + price = #{price}, + supplier_id = #{supplierId}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where receive_bill_id = #{receiveBillId} + + + + delete from mes_purchase_receive_bill where receive_bill_id = #{receiveBillId} + + + + delete from mes_purchase_receive_bill where receive_bill_id in + + #{receiveBillId} + + + + + + + + + + + \ No newline at end of file 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 e69a07e7..6b09f101 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 @@ -6,14 +6,17 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import com.hw.common.core.constant.CacheConstants; 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.redis.service.RedisService; 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.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import com.hw.system.common.mapper.SysPointRouterMapper; import com.hw.system.api.domain.common.SysPointRouter; @@ -34,6 +37,9 @@ public class SysPointRouterServiceImpl implements ISysPointRouterService { @Autowired private SysUserMapper sysUserMapper; + @Autowired + public RedisService redisService; + /** * 查询提示路由信息 * @@ -123,11 +129,22 @@ public class SysPointRouterServiceImpl implements ISysPointRouterService { */ @Override public int processActivityEmailNotify() { + String emailAccountInfo = redisService.getCacheObject(CacheConstants.SYS_EAMIL_ACCOUNT_INFO); + String emailAccount = ""; + String emailPassword = ""; + if(StringUtils.isNotEmpty(emailAccountInfo)){ + int splitIndex = emailAccountInfo.indexOf(","); + emailAccount = emailAccountInfo.substring(0,splitIndex); + emailPassword = emailAccountInfo.substring(splitIndex+1); + } + System.out.println(emailAccount+"e:"+emailPassword); + + 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)); + .filter(spo -> spo.getProcessActivityId() != null).collect(Collectors.groupingBy(SysPointRouter::getProcessActivityId)); for (Long processActivityId : sysPointRouterMap.keySet()) { List sysPointRoutersByActivityList = sysPointRouterMap.get(processActivityId); @@ -143,7 +160,7 @@ public class SysPointRouterServiceImpl implements ISysPointRouterService { for (SysUser sysUser : sysUsers) { if (StringUtils.isNotEmpty(sysUser.getEmail())) { - MailUtils.processSendEmail(sysUser.getEmail(), "通知", sendMsg); + MailUtils.processSendEmail(emailAccount,emailPassword,sysUser.getEmail(), "通知", sendMsg); } } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsProductOutstockAuditVo.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsProductOutstockAuditVo.java index 857ebdd6..111cb1f0 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsProductOutstockAuditVo.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsProductOutstockAuditVo.java @@ -29,4 +29,7 @@ public class WmsProductOutstockAuditVo { //审核意见 private String auditReason; + + //人工标识 + private String manualFlag; } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsProductStockMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsProductStockMapper.java index 35c249f0..637ad606 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsProductStockMapper.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsProductStockMapper.java @@ -161,4 +161,6 @@ public interface WmsProductStockMapper BigDecimal monthInstockAmount(); List selectFourthProductStockPercentage(); + + public WmsProductStock selectProductStockByLocationCode(String locationCode); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockDetailServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockDetailServiceImpl.java index 916cd594..d295041c 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockDetailServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockDetailServiceImpl.java @@ -92,30 +92,67 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD //在PDA成品出库,需要选择出库的申请单,然后输入库位码和物料条码 Long productOutstockId = wmsProductOutstockDetail.getProductOutstockId(); - R baseBarcodeInfoR = remoteMesService.getBarcode(productBarcode, SecurityConstants.INNER); - if (baseBarcodeInfoR == null) { - throw new ServiceException("物料条码有误"); - } - MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData(); - if (baseBarcodeInfo == null) { - throw new ServiceException("物料条码有误"); - } - WmsProductOutstock productOutstock = wmsProductOutstockMapper.selectOnlyWmsProductOutstockByOutstockId(productOutstockId); if (productOutstock == null) { throw new ServiceException("没有此成品出库任务信息"); } - if(!productOutstock.getProductId().equals(baseBarcodeInfo.getMaterialId())) { - throw new ServiceException("物料条码有误"); - } + WmsProductStock productStock = null; + String executeStatus = ""; + + String userName = SecurityUtils.getLoginUser()==null ? SecurityUtils.getUsername() :SecurityUtils.getLoginUser().getNickname(); + Date currentDate = new Date(); //一楼成品库和四楼成品库没有库位 if(StringUtils.isEmpty(locationCode) && (wmsConfig.getFirstFloorProductWarehouseId().equals(productOutstock.getWarehouseId()) || wmsConfig.getFourthFloorProductWarehouseId().equals(productOutstock.getWarehouseId()))){ + R baseBarcodeInfoR = remoteMesService.getBarcode(productBarcode, SecurityConstants.INNER); + if (baseBarcodeInfoR == null) { + throw new ServiceException("物料条码有误"); + } + MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData(); + if (baseBarcodeInfo == null) { + throw new ServiceException("物料条码有误"); + } + if(!productOutstock.getProductId().equals(baseBarcodeInfo.getMaterialId())) { + throw new ServiceException("物料条码有误"); + } locationCode = "0"; + executeStatus = WmsConstants.WMS_EXECUTE_STATUS_FINISH; wmsProductOutstockDetail.setLocationCode("0"); + wmsProductOutstockDetail.setOutstockAmount(BigDecimal.ONE); + productStock = wmsProductStockMapper.selectProductStockByBatch(productBarcode); + + wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId()); + + /**判断已出库数量和申请的数量*/ + BigDecimal applyQty = productOutstock.getApplyQty() == null ? BigDecimal.ZERO : productOutstock.getApplyQty(); + BigDecimal outstockQty = productOutstock.getOutstockQty() == null ? BigDecimal.ZERO : productOutstock.getOutstockQty(); + + BigDecimal currentOutstockQty = outstockQty.add(BigDecimal.ONE); + if (applyQty.compareTo(currentOutstockQty) < 0) { + throw new ServiceException(String.format("出库申请数量为%1$s,不能再出库", applyQty)); + } + + + //更新出库记录 + if (applyQty.compareTo(currentOutstockQty) == 0) { + productOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); + productOutstock.setEndTime(currentDate); + } else if (applyQty.compareTo(currentOutstockQty) > 0) { + productOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING); + } + + productOutstock.setOutstockQty(currentOutstockQty); + if (productOutstock.getBeginTime() == null) { + productOutstock.setBeginTime(currentDate); + } + productOutstock.setUpdateDate(currentDate); + productOutstock.setUpdateBy(userName); + wmsProductOutstockMapper.updateWmsProductOutstock(productOutstock); + + }else{ WmsBaseLocation location = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode); if (location == null) { @@ -124,13 +161,25 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD if (!productOutstock.getWarehouseId().equals(location.getWarehouseId())) { throw new ServiceException("没有此仓库出库任务"); } + if(!location.getLocationStatus().equals(WmsConstants.WMS_BASE_LOCATION_STATUS_NORMAL)){ + throw new ServiceException("库位状态非正常"); + } + + if(!productOutstock.getOperationType().equals(WmsConstants.WMS_OPERATION_TYPE_MANUAL)){ + throw new ServiceException("此成品出库申请为非人工出库"); + } + + productStock = wmsProductStockMapper.selectProductStockByLocationCode(locationCode); + executeStatus = WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE; + productBarcode = StringUtils.isEmpty(productStock.getProductBatch()) ? "0":productStock.getProductBatch(); + wmsProductOutstockDetail.setProductBarcode(productBarcode); + wmsProductOutstockDetail.setOutstockAmount(BigDecimal.ZERO); } if (productOutstock.getExecuteStatus().equals(WmsConstants.WMS_EXECUTE_STATUS_FINISH)) { throw new ServiceException("此出库申请已完成,不能再出库"); } - WmsProductStock productStock = wmsProductStockMapper.selectProductStockByBatch(productBarcode); if (productStock == null || !productStock.getSaleOrderId().equals(productOutstock.getSaleOrderId())) { throw new ServiceException("此库位没有对应订单库存"); } @@ -145,47 +194,21 @@ public class WmsProductOutstockDetailServiceImpl implements IWmsProductOutstockD } - /**判断已出库数量和申请的数量*/ - BigDecimal applyQty = productOutstock.getApplyQty() == null ? BigDecimal.ZERO : productOutstock.getApplyQty(); - BigDecimal outstockQty = productOutstock.getOutstockQty() == null ? BigDecimal.ZERO : productOutstock.getOutstockQty(); - BigDecimal currentOutstockQty = outstockQty.add(BigDecimal.ONE); - if (applyQty.compareTo(currentOutstockQty) < 0) { - throw new ServiceException(String.format("出库申请数量为%1$s,不能再出库", applyQty)); - } - - String userName = SecurityUtils.getLoginUser()==null ? SecurityUtils.getUsername() :SecurityUtils.getLoginUser().getNickname(); - Date currentDate = new Date(); - //更新出库记录 - if (applyQty.compareTo(currentOutstockQty) == 0) { - productOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); - productOutstock.setEndTime(currentDate); - } else if (applyQty.compareTo(currentOutstockQty) > 0) { - productOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING); - } - - productOutstock.setOutstockQty(currentOutstockQty); - if (productOutstock.getBeginTime() == null) { - productOutstock.setBeginTime(currentDate); - } - productOutstock.setUpdateDate(currentDate); - productOutstock.setUpdateBy(userName); - wmsProductOutstockMapper.updateWmsProductOutstock(productOutstock); //删除库存(由于一个成品对应一个库存信息,删除即可) // productStock.setTotalAmount(totalAmount.subtract(BigDecimal.ONE)); // productStock.setUpdateBy(userName); // productStock.setUpdateDate(currentDate); // wmsProductStockMapper.updateWmsProductStock(productStock); - wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId()); + //插入出库记录明细 - wmsProductOutstockDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); + wmsProductOutstockDetail.setExecuteStatus(executeStatus); wmsProductOutstockDetail.setBeginTime(currentDate); wmsProductOutstockDetail.setEndTime(currentDate); wmsProductOutstockDetail.setWarehouseId(productStock.getWarehouseId()); wmsProductOutstockDetail.setPlanAmount(BigDecimal.ONE); - wmsProductOutstockDetail.setOutstockAmount(BigDecimal.ONE); wmsProductOutstockDetailMapper.insertWmsProductOutstockDetail(wmsProductOutstockDetail); diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java index 56d6d568..e8329b2f 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductOutstockServiceImpl.java @@ -558,6 +558,7 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService } + wmsProductOutstock.setOperationType(wmsProductOutstockAuditVo.getManualFlag()); wmsProductOutstock.setAuditStatus(auditStatus); wmsProductOutstock.setAuditReason(auditReason); wmsProductOutstock.setAuditBy(userName); diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductStockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductStockMapper.xml index 0b073b24..98393f4e 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductStockMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsProductStockMapper.xml @@ -432,6 +432,12 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 搜索 重置 @@ -138,6 +145,17 @@ @pagination="getList" /> + + + + + + + @@ -150,9 +168,15 @@ import { updatePurchaseOrder } from "@//api/mes/purchaseOrder"; +import selectPurchaseReceiveBill from '@//views/mes/purchaseReceiveBill/selectPurchaseReceiveBill.vue'; + + export default { name: "PurchaseOrder", dicts: ['active_flag', 'order_status', 'document_status'], + components: { + 'select-purchase-receive-bill': selectPurchaseReceiveBill, + }, props: { defineData: { type: Object, @@ -162,7 +186,7 @@ export default { data() { return { // 遮罩层 - loading: true, + loading: false, // 选中数组 ids: [], // 非单个禁用 @@ -187,6 +211,7 @@ export default { pageSize: 10, erpId: null, fentryId: null, + billNo:null, poNo: null, documentStatus: null, materialId: null, @@ -244,12 +269,13 @@ export default { {key: 21, label: `更新人`, visible: false}, {key: 22, label: `更新时间`, visible: false}, ], - selectedRows:[] + selectedRows:[], + purchaseReceiveBillOpen:false }; }, created() { this.getData(); - this.getList(); + // this.getList(); }, methods: { getData() { @@ -263,6 +289,10 @@ export default { /** 查询采购订单信息列表 */ getList() { + if(this.queryParams.billNo==null ||this.queryParams.billNo==='') { + this.$modal.msgWarning("请先选择收料通知单"); + return; + } this.loading = true; selectPurchaseOrderBindList(this.queryParams).then(response => { response.rows.forEach(e => { @@ -390,11 +420,33 @@ export default { handleSelect(row){ this.selectedRow = row; this.selectedRowId = row.purchaseOrderId; + this.selectedRow.receiveBillId = this.queryParams.receiveBillId; // 滚动到选中行 this.$nextTick(() => { this.$refs.purchaseOrderRef.setCurrentRow(row); }); }, + + handlePurchaseReceiveBill() { + this.purchaseReceiveBillOpen = true; + }, + + + submitPurchaseReceiveBillForm() { + let selectedRow = this.$refs.purchaseOrderRef.selectedRow; + this.$set(this.queryParams, "receiveBillId", null); + this.$set(this.queryParams, "billNo", null); + this.$set(this.queryParams, "poNo", null); + this.$set(this.queryParams, "materialId", null); + + this.$set(this.queryParams, "receiveBillId", selectedRow.receiveBillId); + this.$set(this.queryParams, "billNo", selectedRow.billNo); + this.$set(this.queryParams, "poNo", selectedRow.poNo); + this.$set(this.queryParams, "materialId", selectedRow.materialId); + + this.getList(); + this.purchaseReceiveBillOpen = false; + }, } }; diff --git a/hw-ui/src/views/mes/purchaseOrder/selectOrderBind.vue b/hw-ui/src/views/mes/purchaseOrder/selectOrderBind.vue index ef24eaf7..4766f1ee 100644 --- a/hw-ui/src/views/mes/purchaseOrder/selectOrderBind.vue +++ b/hw-ui/src/views/mes/purchaseOrder/selectOrderBind.vue @@ -1,57 +1,65 @@ @@ -143,10 +161,14 @@ import { getPurchaseOrdersWithBind } from "@//api/mes/purchaseOrder"; +import selectPurchaseReceiveBill from '@//views/mes/purchaseReceiveBill/selectPurchaseReceiveBill.vue'; export default { name: "OrderBind", dicts: ['active_flag', 'order_status', 'document_status','mes_material_bind_flag'], + components: { + 'select-purchase-receive-bill': selectPurchaseReceiveBill, + }, props: { defineData: { type: Object, @@ -156,7 +178,7 @@ export default { data() { return { // 遮罩层 - loading: true, + loading: false, // 选中数组 ids: [], // 非单个禁用 @@ -244,6 +266,7 @@ export default { selectedRow:null, selectedRowId:null, isSingleSelect:true, + purchaseReceiveBillOpen:false, ALWAYS_FLAG:{ YES:"1", NO:"0" @@ -252,7 +275,6 @@ export default { }, created() { this.getData(); - this.getList(); }, methods: { getData() { @@ -272,6 +294,10 @@ export default { /** 查询采购订单信息列表 */ getList() { + if(this.queryParams.billNo==null ||this.queryParams.billNo==='') { + this.$modal.msgWarning("请先选择收料通知单"); + return; + } this.loading = true; getPurchaseOrdersWithBind(this.queryParams).then(response => { response.rows.forEach(e => { @@ -338,6 +364,7 @@ export default { }, handleSelect(row){ this.selectedRow = row; + this.selectedRow.receiveBillId = this.queryParams.receiveBillId; this.selectedRowId = row.purchaseOrderId+"-"+row.orderBindId; // 滚动到选中行 this.$nextTick(() => { @@ -353,6 +380,27 @@ export default { this.multiple = !selection.length }, + handlePurchaseReceiveBill() { + this.purchaseReceiveBillOpen = true; + }, + + + submitPurchaseReceiveBillForm() { + let selectedRow = this.$refs.purchaseOrderRef.selectedRow; + this.$set(this.queryParams, "receiveBillId", null); + this.$set(this.queryParams, "billNo", null); + this.$set(this.queryParams, "poNo", null); + this.$set(this.queryParams, "materialId", null); + + this.$set(this.queryParams, "receiveBillId", selectedRow.receiveBillId); + this.$set(this.queryParams, "billNo", selectedRow.billNo); + this.$set(this.queryParams, "poNo", selectedRow.poNo); + this.$set(this.queryParams, "materialId", selectedRow.materialId); + + this.getList(); + this.purchaseReceiveBillOpen = false; + }, + } }; diff --git a/hw-ui/src/views/mes/purchaseReceiveBill/index.vue b/hw-ui/src/views/mes/purchaseReceiveBill/index.vue new file mode 100644 index 00000000..8b465353 --- /dev/null +++ b/hw-ui/src/views/mes/purchaseReceiveBill/index.vue @@ -0,0 +1,276 @@ + + + diff --git a/hw-ui/src/views/mes/purchaseReceiveBill/selectPurchaseReceiveBill.vue b/hw-ui/src/views/mes/purchaseReceiveBill/selectPurchaseReceiveBill.vue new file mode 100644 index 00000000..34923279 --- /dev/null +++ b/hw-ui/src/views/mes/purchaseReceiveBill/selectPurchaseReceiveBill.vue @@ -0,0 +1,231 @@ + + + diff --git a/hw-ui/src/views/wms/productmanagement/productoutstock/productoutstockDetail.vue b/hw-ui/src/views/wms/productmanagement/productoutstock/productoutstockDetail.vue index 65343249..2fe5809b 100644 --- a/hw-ui/src/views/wms/productmanagement/productoutstock/productoutstockDetail.vue +++ b/hw-ui/src/views/wms/productmanagement/productoutstock/productoutstockDetail.vue @@ -1,6 +1,6 @@