From 15cf265262c6ee71d48200701815ddb4244357d7 Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Tue, 7 May 2024 08:55:48 +0800 Subject: [PATCH] '123' --- .../customer/CustomerController.java | 21 ++++++++- .../system/SysNoticeController.java | 2 +- .../web/utils/SendNotice/NoticeUtil.java | 47 ++++++++++++++++++- .../ruoyi/common/constant/WebsocketConst.java | 3 ++ .../com/ruoyi/customer/domain/Customer.java | 7 +++ .../ruoyi/system/mapper/SysNoticeMapper.java | 6 +++ .../system/service/ISysNoticeService.java | 7 +++ .../service/impl/SysNoticeServiceImpl.java | 16 +++++++ .../mapper/customer/CustomerMapper.xml | 8 +++- .../mapper/system/SysNoticeMapper.xml | 4 ++ 10 files changed, 114 insertions(+), 7 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java index 194655c..bfd4927 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java @@ -1,14 +1,20 @@ package com.ruoyi.web.controller.customer; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.alibaba.fastjson2.JSON; +import com.ruoyi.common.constant.WebsocketConst; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.uuid.UUID; import com.ruoyi.customer.domain.qcc.FuzzySearch; import com.ruoyi.customer.domain.qcc.QccFuzzySearchJsonResult; +import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.service.ISysNoticeService; import com.ruoyi.web.utils.IdUtils; +import com.ruoyi.web.utils.SendNotice.NoticeUtil; import com.ruoyi.web.utils.qcc.HttpHelper; import com.ruoyi.web.utils.qcc.QiChaChaUtil; import org.apache.http.client.methods.HttpHead; @@ -56,6 +62,9 @@ public class CustomerController extends BaseController @Autowired private ICustomerService customerService; + @Autowired + private ISysNoticeService noticeService; + /** * 查询客户管理列表 */ @@ -123,8 +132,7 @@ public class CustomerController extends BaseController @PreAuthorize("@ss.hasPermi('customer:customer:commit')") @Log(title = "客户信息提交", businessType = BusinessType.OTHER) @PostMapping("/commitCustomer") - public AjaxResult commitCustomer(@RequestBody Customer customer) - { + public AjaxResult commitCustomer(@RequestBody Customer customer) { String cus_id = customer.getCusId(); customer.setUpdateBy(getUsername()); customer.setCusApprovalStatus("1");//客户提交 状态设置为 审核中 @@ -136,9 +144,11 @@ public class CustomerController extends BaseController customer.setCusCode(IdUtils.createNo("KH_",2)); customer.setCreateBy(getUsername()); customerService.insertCustomer(customer); + sendNotice(customer);//发送消息至数据组 return success(); }else{ customerService.updateCustomer(customer); + sendNotice(customer);//发送消息至数据组 return success(); } } @@ -156,7 +166,14 @@ public class CustomerController extends BaseController customerService.updateCustomer(customer); //TODO 提交校验 调用SAP rfc接口 更新客户凭证号 return success(); + } + private void sendNotice(Customer customer){ + //推送消息 + LoginUser loginUser = getLoginUser();//当前登陆者 + //获取发送人-数据组 + List userIds = noticeService.getSendEmp(WebsocketConst.MSG_SEND_EMP); + NoticeUtil.sendNoticesBusiness(loginUser,"有客户信息待审核","客户:"+customer.getCusName(),userIds); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java index 45ae961..1541434 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java @@ -72,7 +72,7 @@ public class SysNoticeController extends BaseController noticeService.insertNotice(notice); //推送消息插入中间表 LoginUser loginUser = getLoginUser();//当前登陆者 - NoticeUtil.sendNotices(loginUser,notice,noticeService,null); + NoticeUtil.sendNotices(loginUser,notice,null); }catch (Exception e){ return error("系统异常"); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SendNotice/NoticeUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SendNotice/NoticeUtil.java index a698c22..1330694 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SendNotice/NoticeUtil.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SendNotice/NoticeUtil.java @@ -26,13 +26,15 @@ public class NoticeUtil { @Autowired private static WebsocketService wbService = SpringUtils.getBean(WebsocketService.class); + @Autowired + private static ISysNoticeService noticeService = SpringUtils.getBean(ISysNoticeService.class); + /** * 推送消息插入中间表 * @param loginUser 发送对象排除自身 * @param notice 发送信息对象 - * @param noticeService 接口 */ - public static void sendNotices(LoginUser loginUser, SysNotice notice, ISysNoticeService noticeService, List userIds) throws IOException { + public static void sendNotices(LoginUser loginUser, SysNotice notice, List userIds) { JSONObject obj = new JSONObject(); obj.put(WebsocketConst.MSG_ID, notice.getNoticeId()); obj.put(WebsocketConst.MSG_TITLE, notice.getNoticeTitle()); @@ -51,6 +53,47 @@ public class NoticeUtil { } } + /** + * 推送消息插入中间表 + * @param loginUser + * @param noticeTitle + * @param noticeContent + * @param userIds + */ + public static void sendNoticesBusiness(LoginUser loginUser,String noticeTitle,String noticeContent,List userIds) { + + SysNotice notice = new SysNotice(); + notice.setNoticeTitle(noticeTitle); + notice.setNoticeContent(noticeContent); + notice.setNoticeType("3"); + notice.setCreateBy(loginUser.getUsername()); + noticeService.insertNotice(notice);// 插入消息表 + + JSONObject obj = new JSONObject(); + obj.put(WebsocketConst.MSG_ID, notice.getNoticeId()); + obj.put(WebsocketConst.MSG_TITLE, notice.getNoticeTitle()); + obj.put(WebsocketConst.MSG_CONTENT, notice.getNoticeContent()); + + if(!"3".equals(notice.getNoticeType())){//系统通知 或 通知公告 + wbService.sendMessageAll("ruoyi",obj.toString()); + insertNoticeUser(loginUser,notice,noticeService,null); + }else{ + if(userIds!=null&&userIds.size()>0){ + for(String userId:userIds){ + wbService.sendMessageById("ruoyi",userId,obj.toString()); + } + insertNoticeUser(loginUser,notice,noticeService,userIds); + } + } + } + + /** + * 插入 消息用户中间表 + * @param loginUser + * @param notice + * @param noticeService + * @param userIds + */ public static void insertNoticeUser(LoginUser loginUser,SysNotice notice,ISysNoticeService noticeService, List userIds){ List sysNoticeUsers = new ArrayList(); //发送日期 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/WebsocketConst.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/WebsocketConst.java index 7649d2c..ce4be9f 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/WebsocketConst.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/WebsocketConst.java @@ -14,4 +14,7 @@ public class WebsocketConst { /** 消息CONTENT */ public static final String MSG_CONTENT = "noticeContent"; + + /** 消息发送对象 */ + public static final String MSG_SEND_EMP = "KH"; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java index 4d1bc39..919ea70 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java +++ b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java @@ -35,6 +35,10 @@ public class Customer extends BaseEntity @Excel(name = "街道/门牌号") private String cusStreet; + /** 街道 */ + @Excel(name = "街道") + private String cusQccStreet; + /** 付款条件 */ @Excel(name = "付款条件",dictType = "cus_payment_terms") private String cusPaymentTerms; @@ -151,6 +155,9 @@ public class Customer extends BaseEntity { return cusStreet; } + public String getCusQccStreet() { return cusQccStreet; } + + public void setCusQccStreet(String cusQccStreet) { this.cusQccStreet = cusQccStreet; } public void setCusPaymentTerms(String cusPaymentTerms) { this.cusPaymentTerms = cusPaymentTerms; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java index b1b06c2..be14f7c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java @@ -112,4 +112,10 @@ public interface SysNoticeMapper */ void deleteNoticeEventUser(NoticeUserSelect noticeUserSelect); + /** + * 获取发送人-数据组 + * @param msgSendEmp + * @return + */ + List getSendEmp(String msgSendEmp); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java index ccba7b7..25521a0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java @@ -110,4 +110,11 @@ public interface ISysNoticeService * @param noticeUserSelect */ void deleteNoticeEventUser(NoticeUserSelect noticeUserSelect); + + /** + * 获取发送人-数据组 + * @param msgSendEmp + * @return + */ + List getSendEmp(String msgSendEmp); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java index 6262aba..6bc7bfd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java @@ -11,6 +11,7 @@ import org.springframework.stereotype.Service; import com.ruoyi.system.domain.SysNotice; import com.ruoyi.system.mapper.SysNoticeMapper; import com.ruoyi.system.service.ISysNoticeService; +import org.springframework.transaction.annotation.Transactional; /** * 公告 服务层实现 @@ -68,6 +69,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @return 结果 */ @Override + @Transactional public int insertNotice(SysNotice notice) { if (StringUtils.isNotBlank(notice.getNoticeContent())){ @@ -83,6 +85,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @return 结果 */ @Override + @Transactional public int updateNotice(SysNotice notice) { if (StringUtils.isNotBlank(notice.getNoticeContent())){ @@ -139,6 +142,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @param sysNoticeUsers */ @Override + @Transactional public void insertNoticeUserBatch(List sysNoticeUsers) { noticeMapper.insertNoticeUserBatch(sysNoticeUsers); } @@ -148,6 +152,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @param sysNoticeUser */ @Override + @Transactional public void updateSysNoticeUser(SysNoticeUser sysNoticeUser) { noticeMapper.updateSysNoticeUser(sysNoticeUser); } @@ -176,6 +181,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService * @param list */ @Override + @Transactional public void insertNoticeEventUserBatch(List list) { noticeMapper.insertNoticeEventUserBatch(list); } @@ -188,4 +194,14 @@ public class SysNoticeServiceImpl implements ISysNoticeService public void deleteNoticeEventUser(NoticeUserSelect noticeUserSelect) { noticeMapper.deleteNoticeEventUser(noticeUserSelect); } + + /** + * 获取发送人-数据组 + * @param msgSendEmp + * @return + */ + @Override + public List getSendEmp(String msgSendEmp) { + return noticeMapper.getSendEmp(msgSendEmp); + } } diff --git a/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml b/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml index a4689bd..ffe34a6 100644 --- a/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml @@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -60,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select a.cus_id, a.cus_code, a.cus_name, a.cus_sap_code, a.cus_street, a.cus_payment_terms, a.cus_phone_number, + select a.cus_id, a.cus_code, a.cus_name, a.cus_sap_code, a.cus_street, a.cus_qcc_street,a.cus_payment_terms, a.cus_phone_number, a.cus_industry_code, a.cus_group, a.cus_vat_no, a.cus_type, a.cus_country, a.cus_language, a.cus_label, a.cus_classification, a.cus_receiving_email, a.cus_recipient, a.cus_recipient_phone, a.cus_remark, a.cus_state, a.cus_approval_status,a.create_time,u.nick_name create_name, @@ -85,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + select notice_event_user_id from sys_event_user where notice_event_type = #{msgSendEmp} + +