Browse Source

feature 微信发起的投诉建议和保修登记 自动保存相应的处理人员

xiahan 3 months ago
parent
commit
1bb6c1fde2

+ 3 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/dao/CommonBusinessDao.java

@@ -2,6 +2,7 @@ package com.rongwei.zhsw.system.dao;
 
 import com.rongwe.zhsw.system.domain.SwEnterpriseConfigInfoDo;
 import com.rongwe.zhsw.system.vo.OwnerVo;
+import com.rongwei.rwadmincommon.system.domain.SysUserDo;
 import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -20,4 +21,6 @@ public interface CommonBusinessDao {
     List<OwnerVo> getOwnerInfoByDsId(@Param("dsId") String dsKey);
 
     List<SwEnterpriseConfigInfoDo> getSecretKey(@Param("dsKeys") List<String> dsKey);
+
+    List<SysUserDo>getHandlerInfoByVolumeNo(@Param("roleCode") String roleCode,@Param("userNum") String userNum);
 }

+ 43 - 7
zhsw-common/src/main/java/com/rongwei/zhsw/system/wechat/impl/RegistrationServiceImpl.java

@@ -5,16 +5,18 @@ import com.rongwe.zhsw.system.domain.SwUserRepairDo;
 import com.rongwe.zhsw.system.vo.WeChatFeedbackReportVo;
 import com.rongwe.zhsw.system.vo.WeChatRepairReportVo;
 import com.rongwe.zhsw.system.vo.WeChatUploadVo;
+import com.rongwei.rwadmincommon.system.domain.SysUserDo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.utils.SecurityUtil;
+import com.rongwei.rwcommon.utils.StringUtils;
 import com.rongwei.rwcommoncomponent.file.dto.ImageScaleDto;
 import com.rongwei.rwcommoncomponent.file.service.impl.SysFileItemServiceImpl;
 import com.rongwei.rwcommoncomponent.file.utils.FileUtil;
 import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
+import com.rongwei.zhsw.system.dao.CommonBusinessDao;
 import com.rongwei.zhsw.system.service.impl.SwFeedBackOpinionServiceImpl;
 import com.rongwei.zhsw.system.service.impl.SwUserRepairServiceImpl;
 import com.rongwei.zhsw.system.wechat.RegistrationService;
-import com.rongwei.zhsw.system.utils.ZHSWCommonUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +25,7 @@ import org.springframework.stereotype.Service;
 import java.util.Base64;
 import java.util.Date;
 import java.util.List;
+import java.util.function.BiConsumer;
 import java.util.stream.Collectors;
 
 import static com.rongwei.zhsw.system.utils.ZHSWCommonUtils.initModelGeneralParameters;
@@ -43,6 +46,8 @@ public class RegistrationServiceImpl implements RegistrationService {
     private SysFileItemServiceImpl sysFileItemService;
     @Autowired
     private SwFeedBackOpinionServiceImpl swFeedBackOpinionService;
+    @Autowired
+    private CommonBusinessDao commonBusinessDao;
 
     /**
      * 用户保修
@@ -62,18 +67,23 @@ public class RegistrationServiceImpl implements RegistrationService {
         swUserRepairDo.setAddress(weChatRepairReportVo.getAddress());
         swUserRepairDo.setContact(weChatRepairReportVo.getContact());
         swUserRepairDo.setRepairtype(weChatRepairReportVo.getRepairType());
+        swUserRepairDo.setAccountname(weChatRepairReportVo.getUserName());
+        swUserRepairDo.setDeclaccnum(weChatRepairReportVo.getUserNum());
 //        ZHSWCommonUtils.replaceSysDictMethod(swUserRepairDo, SwUserRepairDo::getRepairtype, SwUserRepairDo::setRepairtype,
 //                "repair_management_report_type");
         swUserRepairDo.setRepairsource("2");
         swUserRepairDo.setIscompleted("2");
         swUserRepairDo.setFaultdescription(weChatRepairReportVo.getDescription());
         swUserRepairDo.setContactnumber(weChatRepairReportVo.getPhone());
+        getHandlerInfoByVolumeNo("wxry", weChatRepairReportVo.getUserNum(), swUserRepairDo,
+                SwUserRepairDo::setRepairpersonid, SwUserRepairDo::setRepairperson);
+
         //用户上传的附件
         List<WeChatUploadVo> images = weChatRepairReportVo.getImages();
         List<SysFileItemDo> fileItemDos = null;
         if (images != null && !images.isEmpty()) {
             fileItemDos = images.stream().map(data -> {
-                return imgSave(data, swUserRepairDo.getId(),"REPAIR");
+                return imgSave(data, swUserRepairDo.getId(), "REPAIR");
             }).collect(Collectors.toList());
         }
         if (fileItemDos != null && !fileItemDos.isEmpty()) {
@@ -106,17 +116,22 @@ public class RegistrationServiceImpl implements RegistrationService {
         swFeedBackOpinionDo.setCategory(weChatFeedbackReportVo.getCategory());
         swFeedBackOpinionDo.setReplynote(weChatFeedbackReportVo.getDescription());
         swFeedBackOpinionDo.setIscompleted("2");
+        swFeedBackOpinionDo.setDeclaccnum(weChatFeedbackReportVo.getUserNum());
+        swFeedBackOpinionDo.setAccountname(weChatFeedbackReportVo.getUserName());
         //来源
         swFeedBackOpinionDo.setFeedbacksource("2");
         swFeedBackOpinionDo.setFeedbacktime(new Date());
         swFeedBackOpinionDo.setCreateusername("微信用户");
         swFeedBackOpinionDo.setModifyusername("微信用户");
+        getHandlerInfoByVolumeNo("role071", weChatFeedbackReportVo.getUserNum(), swFeedBackOpinionDo,
+                SwFeedBackOpinionDo::setReplypersonid, SwFeedBackOpinionDo::setReplyperson);
+
         //用户上传的附件
         List<WeChatUploadVo> images = weChatFeedbackReportVo.getImages();
         List<SysFileItemDo> fileItemDos = null;
         if (images != null && !images.isEmpty()) {
             fileItemDos = images.stream().map(data -> {
-                return imgSave(data, swFeedBackOpinionDo.getId(),"FEEDBACK");
+                return imgSave(data, swFeedBackOpinionDo.getId(), "FEEDBACK");
             }).collect(Collectors.toList());
         }
         if (fileItemDos != null && !fileItemDos.isEmpty()) {
@@ -131,14 +146,14 @@ public class RegistrationServiceImpl implements RegistrationService {
     }
 
 
-    public SysFileItemDo imgSave(WeChatUploadVo weChatUploadVo, String id,String pathSuffix) {
+    public SysFileItemDo imgSave(WeChatUploadVo weChatUploadVo, String id, String pathSuffix) {
         String base64 = weChatUploadVo.getBase64();
-        String filePath="/upload_files/"+pathSuffix+"/";
+        String filePath = "/upload_files/" + pathSuffix + "/";
         // 微信临时文件的目录
         String tempFilePath = weChatUploadVo.getTempFilePath();
         String fileName = tempFilePath.substring(tempFilePath.lastIndexOf("/") + 4);
         ImageScaleDto scaleDto = ImageScaleDto.builder().scaleFlag(false).build();
-        FileUtil.uploadFile(Base64.getDecoder().decode(base64),filePath , fileName, scaleDto);
+        FileUtil.uploadFile(Base64.getDecoder().decode(base64), filePath, fileName, scaleDto);
 
         SysFileItemDo sysFileItem = new SysFileItemDo();
         sysFileItem.setFilename(fileName);
@@ -146,11 +161,32 @@ public class RegistrationServiceImpl implements RegistrationService {
         sysFileItem.setFiletype(fileName.substring(fileName.lastIndexOf(".") + 1));
         sysFileItem.setStoragetype("1");
         sysFileItem.setFullpath(filePath + fileName);
-        sysFileItem.setUrlpath("/files/"+pathSuffix+"/" + fileName);
+        sysFileItem.setUrlpath("/files/" + pathSuffix + "/" + fileName);
         sysFileItem.setRelationid(id);
         sysFileItem.setId(SecurityUtil.getUUID());
         sysFileItem.setCreatedate(new Date());
         sysFileItem.setModifydate(new Date());
         return sysFileItem;
     }
+
+    /**
+     * 获取保修和投诉相关的处理人员信息
+     *
+     * @param roleCode 角色编号
+     * @param volumeNo 册号
+     * @return
+     */
+    public <T> void getHandlerInfoByVolumeNo(String roleCode, String userNum,
+                                             T pojo,
+                                             BiConsumer<T, String> setIdFunction,
+                                             BiConsumer<T, String> setNameFunction) {
+        List<SysUserDo> handlerInfoByVolumeNo = commonBusinessDao.getHandlerInfoByVolumeNo(roleCode, userNum);
+        if (handlerInfoByVolumeNo.isEmpty()) {
+            return;
+        }
+        String ids = handlerInfoByVolumeNo.stream().map(SysUserDo::getId).filter(StringUtils::isNotBlank).distinct().collect(Collectors.joining(","));
+        setIdFunction.accept(pojo, ids);
+        String names = handlerInfoByVolumeNo.stream().map(SysUserDo::getName).filter(StringUtils::isNotBlank).distinct().collect(Collectors.joining(","));
+        setNameFunction.accept(pojo, names);
+    }
 }

+ 28 - 5
zhsw-common/src/main/resources/mybatis/zhsw/CommonBusinessDao.xml

@@ -5,10 +5,11 @@
 <mapper namespace="com.rongwei.zhsw.system.dao.CommonBusinessDao">
     <select id="getByIds" resultType="com.rongwei.rwcommonentity.commonservers.domain.TenantDo">
         select * from incontrol.sys_tenant where DELETED='0'
+        and TENANTSTATE='0'
         <if test="ids != null and !ids.isEmpty()">
             AND ID in
             <foreach collection="ids" item="id" open="(" close=")" separator=",">
-                         #{id}
+                #{id}
             </foreach>
         </if>
     </select>
@@ -16,7 +17,9 @@
         select * from incontrol.sys_tenant where DELETED='0'
         <if test="id != null and id != ''">
             AND ID = #{id}
+
         </if>
+        and TENANTSTATE='0'
     </select>
     <select id="getByDsKey" resultType="com.rongwei.rwcommonentity.commonservers.domain.TenantDo">
         select * from incontrol.sys_tenant where DELETED='0'
@@ -28,16 +31,36 @@
         </if>
     </select>
     <select id="getOwnerInfoByDsId" resultType="com.rongwe.zhsw.system.vo.OwnerVo">
-        select swm.ID as id ,suw.WECHATSIGN as weChatSign,#{dsId}as dsKey,swm.STATUS as status,ifnull(suw.DEFAULTACCOUNT,0) as defaultAccount
+        select swm.ID                        as id,
+               suw.WECHATSIGN                as weChatSign,
+               #{dsId}as                        dsKey,
+               swm.STATUS                    as status,
+               ifnull(suw.DEFAULTACCOUNT, 0) as defaultAccount
         from ${dsId}.sw_user_management swm
-            left join ${dsId}.sw_user_wechat suw on suw.USERID=swm.ID and suw.DELETED='0'
-            where swm.DELETED='0'
+                 left join ${dsId}.sw_user_wechat suw on suw.USERID = swm.ID and suw.DELETED = '0'
+        where swm.DELETED = '0'
     </select>
     <select id="getSecretKey" resultType="com.rongwe.zhsw.system.domain.SwEnterpriseConfigInfoDo">
         select * from
-        <foreach collection="dsKeys" item="dsKey" open="(" close=") a" separator="union all"  >
+        <foreach collection="dsKeys" item="dsKey" open="(" close=") a" separator="union all">
             select #{dsKey} as tenantid, MERCHANTSECRETKEY from ${dsKey}.sw_enterprise_config_info
         </foreach>
         where MERCHANTSECRETKEY !='' or MERCHANTSECRETKEY is not null
     </select>
+    <select id="getHandlerInfoByVolumeNo" resultType="com.rongwei.rwadmincommon.system.domain.SysUserDo">
+        SELECT su.ID as id, su.NAME as name, sr.CODE as code
+        FROM sys_role sr
+                 LEFT JOIN sys_user_role sur ON sr.ID = sur.ROLEID and sur.DELETED = 0
+                 LEFT JOIN sys_user su ON sur.USERID = su.ID and su.DELETED = 0
+                 LEFT JOIN sys_user_org suo ON suo.USERID = su.ID AND suo.DELETED = 0
+                 LEFT JOIN sys_organization so ON suo.ORGID = so.ID AND so.DELETED = 0
+        WHERE sr.CODE = #{roleCode}
+          and so.CODE in (SELECT CONCAT('area-', b.BELONGTOAREA)
+
+                         FROM sw_user_management a
+                                  LEFT JOIN sw_book_management b on  b.DELETED = '0' AND b.STATUS = 'enable' and a.VOLUMENO = b.BOOKNUMBER
+                         WHERE
+                             a.DELETED = '0'
+                           AND a.USERNUMBER = #{userNum})
+    </select>
 </mapper>

+ 8 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/WeChatFeedbackReportVo.java

@@ -32,4 +32,12 @@ public class WeChatFeedbackReportVo {
      * 故障附件
      */
     private List<WeChatUploadVo> images;
+    /**
+     * 户名
+     */
+    private String userName;
+    /**
+     * 户号
+     */
+    private String userNum;
 }

+ 8 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/WeChatRepairReportVo.java

@@ -36,5 +36,13 @@ public class WeChatRepairReportVo {
      * "水龙头故障"
      */
     private String repairType;
+    /**
+     * 户名
+     */
+    private String userName;
+    /**
+     * 户号
+     */
+    private String userNum;
 
 }