This commit is contained in:
xd 2024-05-07 08:55:48 +08:00
parent 33bcaec535
commit 15cf265262
10 changed files with 114 additions and 7 deletions

View File

@ -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<String> userIds = noticeService.getSendEmp(WebsocketConst.MSG_SEND_EMP);
NoticeUtil.sendNoticesBusiness(loginUser,"有客户信息待审核","客户:"+customer.getCusName(),userIds);
}
/**

View File

@ -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("系统异常");
}

View File

@ -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<String> userIds) throws IOException {
public static void sendNotices(LoginUser loginUser, SysNotice notice, List<String> 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<String> 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<String> userIds){
List<SysNoticeUser> sysNoticeUsers = new ArrayList<SysNoticeUser>();
//发送日期

View File

@ -14,4 +14,7 @@ public class WebsocketConst {
/** 消息CONTENT */
public static final String MSG_CONTENT = "noticeContent";
/** 消息发送对象 */
public static final String MSG_SEND_EMP = "KH";
}

View File

@ -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;

View File

@ -112,4 +112,10 @@ public interface SysNoticeMapper
*/
void deleteNoticeEventUser(NoticeUserSelect noticeUserSelect);
/**
* 获取发送人-数据组
* @param msgSendEmp
* @return
*/
List<String> getSendEmp(String msgSendEmp);
}

View File

@ -110,4 +110,11 @@ public interface ISysNoticeService
* @param noticeUserSelect
*/
void deleteNoticeEventUser(NoticeUserSelect noticeUserSelect);
/**
* 获取发送人-数据组
* @param msgSendEmp
* @return
*/
List<String> getSendEmp(String msgSendEmp);
}

View File

@ -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<SysNoticeUser> 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<NoticeUserSelect> 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<String> getSendEmp(String msgSendEmp) {
return noticeMapper.getSendEmp(msgSendEmp);
}
}

View File

@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="cusName" column="cus_name" />
<result property="cusSapCode" column="cus_sap_code" />
<result property="cusStreet" column="cus_street" />
<result property="cusQccStreet" column="cus_qcc_street" />
<result property="cusPaymentTerms" column="cus_payment_terms" />
<result property="cusPhoneNumber" column="cus_phone_number" />
<result property="cusIndustryCode" column="cus_industry_code" />
@ -60,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<sql id="selectCustomerVo">
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>
<select id="selectCustomerByCusId" parameterType="java.lang.String" resultMap="CustomerBankResult">
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, a.cus_industry_code,
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.cus_sales_organization,a.cus_distribution_channel,a.cus_sales_territory,a.cus_sale_office,
@ -105,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="cusName != null and cusName != ''">cus_name,</if>
<if test="cusSapCode != null">cus_sap_code,</if>
<if test="cusStreet != null and cusStreet != ''">cus_street,</if>
<if test="cusQccStreet != null and cusQccStreet != ''">cus_qcc_street,</if>
<if test="cusPaymentTerms != null and cusPaymentTerms != ''">cus_payment_terms,</if>
<if test="cusPhoneNumber != null and cusPhoneNumber != ''">cus_phone_number,</if>
<if test="cusIndustryCode != null and cusIndustryCode != ''">cus_industry_code,</if>
@ -137,6 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="cusName != null and cusName != ''">#{cusName},</if>
<if test="cusSapCode != null">#{cusSapCode},</if>
<if test="cusStreet != null and cusStreet != ''">#{cusStreet},</if>
<if test="cusQccStreet != null and cusQccStreet != ''">#{cusQccStreet},</if>
<if test="cusPaymentTerms != null and cusPaymentTerms != ''">#{cusPaymentTerms},</if>
<if test="cusPhoneNumber != null and cusPhoneNumber != ''">#{cusPhoneNumber},</if>
<if test="cusIndustryCode != null and cusIndustryCode != ''">#{cusIndustryCode},</if>
@ -172,6 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="cusName != null and cusName != ''">cus_name = #{cusName},</if>
<if test="cusSapCode != null">cus_sap_code = #{cusSapCode},</if>
<if test="cusStreet != null and cusStreet != ''">cus_street = #{cusStreet},</if>
<if test="cusQccStreet != null and cusQccStreet != ''">cus_qcc_street = #{cusQccStreet},</if>
<if test="cusPaymentTerms != null and cusPaymentTerms != ''">cus_payment_terms = #{cusPaymentTerms},</if>
<if test="cusPhoneNumber != null and cusPhoneNumber != ''">cus_phone_number = #{cusPhoneNumber},</if>
<if test="cusIndustryCode != null and cusIndustryCode != ''">cus_industry_code = #{cusIndustryCode},</if>

View File

@ -162,4 +162,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from sys_event_user where notice_event_type = #{noticeEventType} and notice_event_user_id = #{userName}
</delete>
<select id="getSendEmp" resultType="String">
select notice_event_user_id from sys_event_user where notice_event_type = #{msgSendEmp}
</select>
</mapper>