Переглянути джерело

init: init project step4: biz code support

shc 1 рік тому
батько
коміт
9fb1907692

+ 1 - 72
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/entity/SysUser.java

@@ -112,44 +112,12 @@ public class SysUser implements Serializable {
      */
     private String qqOpenid;
 
-    /**
-     * 码云唯一标识
-     */
-    private String giteeLogin;
-
-    /**
-     * 开源中国唯一标识
-     */
-    private String oscId;
 
     /**
      * 用户姓名
      */
     private String realname;
-    /**
-     * 省
-     */
-    private String province;
-    /**
-     * 省
-     */
-    private String provinceCode;
-    /**
-     * 市
-     */
-    private String city;
-    /**
-     * 市
-     */
-    private String cityCode;
-    /**
-     * 区
-     */
-    private String area;
-    /**
-     * 地址
-     */
-    private String address;
+
     /**
      * 备用字段1
      */
@@ -186,45 +154,6 @@ public class SysUser implements Serializable {
      */
     private String w1;
 
-    /**
-     * 税邦云认证状态
-     */
-    private Integer certStatus;
-
-    /**
-     * 人力家认证结果描述
-     */
-    private String certRemark;
-
-    /**
-     * 用户认证类型
-     * 0-人力家
-     * 1-税邦云
-     */
-    private String userType;
-
-    private String bankCardNumber;
-
-    /**
-     * 银行预留手机号
-     */
-    private String bankPhone;
-
-    /**
-     * 开户行
-     */
-    private String bankName;
-
-    /**
-     * 人力家认证状态
-     */
-    private Integer rljCertStatus;
-
-    /**
-     * 税邦云协议签署,0->未签署,1->已签署
-     */
-    private Integer taxHelperAgreementSignature;
-
     /**
      * 小程序签署协议信息
      */

+ 13 - 20
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/entity/WmDaAgent.java

@@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
+import com.qunzhixinxi.hnqz.common.core.entity.BaseEntity;
 import lombok.Data;
 
+import javax.validation.constraints.NotEmpty;
 import java.io.Serializable;
 import java.time.LocalDateTime;
-import java.util.Map;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -23,6 +25,7 @@ import java.util.Set;
 public class WmDaAgent implements Serializable {
     private static final long serialVersionUID = 1L;
 
+
     @TableId(type = IdType.AUTO)
     private Integer id;
 
@@ -124,10 +127,12 @@ public class WmDaAgent implements Serializable {
     private String temp1;
 
     private String temp2;
+
     /**
      * 派工权限
      */
     private String pgqx;
+
     /**
      * 企业类型
      */
@@ -137,25 +142,6 @@ public class WmDaAgent implements Serializable {
      */
     private String management;
 
-    /**
-     * 结算主体类型:0->人力家,1->税邦云
-     */
-    private String[] subjectType;
-
-    /**
-     * MAH结算-药企deptId
-     */
-    private Integer mahSettleDeptId;
-
-    /**
-     * 是否允许结算(选择“允许结算”时,相当于打开了MAH支付权限,该CSO结算时可以选择药企,走药企结算。)
-     */
-    @TableField(exist = false)
-    private Boolean mahSettleFlag;
-
-    @TableField(exist = false)
-    private Map<String, Integer> subjectTypeAndChannel;
-
     /**
      * 部门专用权限限制(0.导出)
      */
@@ -179,4 +165,11 @@ public class WmDaAgent implements Serializable {
      */
     @TableField(exist = false)
     private Set<Integer> csmUserIdList;
+
+    /**
+     * 区域
+     */
+    @NotEmpty(message = "区域必填", groups = {BaseEntity.Create.class})
+    @TableField(exist = false)
+    private List<Long> areaCodes;
 }

+ 1 - 36
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/vo/UserVO.java

@@ -101,25 +101,11 @@ public class UserVO implements Serializable {
 	 */
 	private String deptName;
 
-
 	/**
 	 * 用户姓名
 	 */
 	private String realname;
-	/**
-	 * 省
-	 */
-	private String province;
-	private String provinceCode;
-	/**
-	 * 市
-	 */
-	private String city;
-	private String cityCode;
-	/**
-	 * 区
-	 */
-	private String area;
+
 	/**
 	 * 地址
 	 */
@@ -150,7 +136,6 @@ public class UserVO implements Serializable {
 	 */
 	private String platId;
 
-
 	/**
 	 * 备用字段5
 	 */
@@ -166,28 +151,8 @@ public class UserVO implements Serializable {
 	 */
 	private String w1;
 
-	/**
-	 * 人力家认证状态
-	 */
-	private Integer certStatus;
-
-	private String certRemark;
-
 	private String userSign;
 
-	private String userType;
-
-	private String bankCardNumber;
-
-	/**
-	 * 银行预留手机号
-	 */
-	private String bankPhone;
-
-	/**
-	 * 开户行
-	 */
-	private String bankName;
 
 	/**
 	 * 小程序签署协议信息

+ 0 - 6
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/ApiController.java

@@ -795,13 +795,8 @@ public class ApiController {
 			mapOne.put("realname", sysU.getRealname());
 			mapOne.put("phone", sysU.getPhone());
 			mapOne.put("idCardNumber", sysU.getIdCardNumber());
-			mapOne.put("certStatus", sysU.getCertStatus());
 			mapOne.put("userSign", sysU.getUserSign());
-			mapOne.put("certRemark", sysU.getCertRemark());
 			mapOne.put("reSignedAgreement", sysU.getReSignedAgreement());
-			mapOne.put("bankCardNumber", sysU.getBankCardNumber());
-			mapOne.put("bankPhone", sysU.getBankPhone());
-			mapOne.put("bankName", sysU.getBankName());
 
 			// 获取会员已结算信息和和待结算信息
 			List<WmScorePackageStatus> packageStatuses = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
@@ -929,7 +924,6 @@ public class ApiController {
 			mapOne.put("packageList", listMap);
 			mapOne.put("waitApprove", String.valueOf(waitApprove));
 			mapOne.put("onTheWay", String.valueOf(onTheWay));
-			mapOne.put("userType", sysU.getUserType());
 			mapOne.put("jumpFlag", "北京遥领医疗科技有限公司".equals(sysDept.getName()) ? "1" : "0");
 
 			//// 结算渠道

+ 7 - 71
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/SysUserController.java

@@ -637,80 +637,16 @@ public class SysUserController {
             userDto.setRealname(StrUtil.cleanBlank(userDto.getRealname()));
 
             SysUser oldData = userService.getById(userDto.getUserId());
-            //if (!userDto.getRealname().equals(oldData.getRealname())) {
-            //	if (userDto.getRole().contains(6) || userDto.getRole().contains(10)) {
-            //		Map<String, String> params = new HashMap<>();
-            //		params.put("searchKey", sysDept.getName());
-            //		params.put("pageIndex", "1");
-            //		params.put("pageSize", "10");
-            //		EmployeeGetListResponse qccRes = qccService.getList(params);
-            //		if (qccRes.isSuccess()) {
-            //			for (EmployeeGetListDataItem item : qccRes.getResult()) {
-            //				if (userDto.getRealname().equals(item.getName())) {
-            //					if (userDto.getRole().contains(10)) {
-            //						return R.failed(String.format("%s为该公司%s,不能为兼职CRC", item.getName(), item.getJob()));
-            //					} else {
-            //						return R.failed(String.format("%s为该公司%s,不能为兼职学术推广员", item.getName(), item.getJob()));
-            //					}
-            //
-            //				}
-            //			}
-            //			if (null != qccRes.getPaging()) {
-            //				PageInfo qccPage = qccRes.getPaging();
-            //				// 需要分页查询
-            //				if (qccPage.getTotalRecords() > qccPage.getPageIndex() * qccPage.getPageSize()) {
-            //					int totalPage = qccPage.getTotalRecords() / qccPage.getPageSize();
-            //
-            //					for (int i = 2; i < totalPage + 2; i++) {
-            //						params.put("pageIndex", i + "");
-            //						qccRes = qccService.getList(params);
-            //						if (qccRes.isSuccess()) {
-            //							for (EmployeeGetListDataItem item : qccRes.getResult()) {
-            //								if (userDto.getRole().contains(10)) {
-            //									return R.failed(String.format("%s为该公司%s,不能为兼职CRC", item.getName(), item.getJob()));
-            //								} else {
-            //									return R.failed(String.format("%s为该公司%s,不能为兼职学术推广员", item.getName(), item.getJob()));
-            //								}
-            //							}
-            //						} else {
-            //							break;
-            //						}
-            //					}
-            //				}
-            //			}
-            //
-            //		}
-            //	}
-            //}
-
-
-            /**
-             * @Modify: start
-             * @Version: v2021.4.16
-             * @Author: ryz
-             * @Date: 2021/4/29
-             * 去掉修改用户信息时候的认证
-             */
-            boolean updateFlag = true;
-            if (null != oldData.getCertStatus()) {
-                if (oldData.getCertStatus() != 10) {
-                    updateFlag = false;
-                }
 
+
+
+            if (!userDto.getRealname().equals(oldData.getRealname())) {
+                return R.failed("用户认证通过或正在认证,暂不能修改姓名");
             }
-            if (null != oldData.getRljCertStatus()) {
-                if (oldData.getRljCertStatus() == 1 || oldData.getRljCertStatus() == 3) {
-                    updateFlag = false;
-                }
-            }
-            if (!updateFlag) {
-                if (!userDto.getRealname().equals(oldData.getRealname())) {
-                    return R.failed("用户认证通过或正在认证,暂不能修改姓名");
-                }
-                if (!userDto.getIdCardNumber().equals(oldData.getIdCardNumber())) {
-                    return R.failed("用户认证通过或正在认证,暂不能修改身份证号");
-                }
+            if (!userDto.getIdCardNumber().equals(oldData.getIdCardNumber())) {
+                return R.failed("用户认证通过或正在认证,暂不能修改身份证号");
             }
+
         }
 
         if (SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(1)) {

+ 82 - 152
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmDaAgentController.java

@@ -15,7 +15,6 @@ import com.qunzhixinxi.hnqz.admin.api.constant.enums.EnableEnum;
 import com.qunzhixinxi.hnqz.admin.api.entity.WmDaAgent;
 import com.qunzhixinxi.hnqz.admin.api.entity.WmDaDrugEnt;
 import com.qunzhixinxi.hnqz.admin.api.entity.WmRelation;
-import com.qunzhixinxi.hnqz.admin.api.entity.WmScorePackage;
 import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskType;
 import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskTypeEntRef;
 import com.qunzhixinxi.hnqz.admin.mapper.SysDeptCsmMapper;
@@ -30,15 +29,19 @@ import com.qunzhixinxi.hnqz.admin.mapper.WmTaskTypeMapper;
 import com.qunzhixinxi.hnqz.admin.service.SysCsmUserRelationService;
 import com.qunzhixinxi.hnqz.admin.service.SysDeptRelationService;
 import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
+import com.qunzhixinxi.hnqz.admin.service.SysEnterpriseAreaService;
 import com.qunzhixinxi.hnqz.admin.service.WmDaAgentService;
 import com.qunzhixinxi.hnqz.admin.service.WmDaDrugEntService;
 import com.qunzhixinxi.hnqz.admin.service.WmRelationService;
+import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
+import com.qunzhixinxi.hnqz.common.core.entity.BaseEntity;
 import com.qunzhixinxi.hnqz.common.core.util.R;
 import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
 import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -85,6 +88,7 @@ public class WmDaAgentController {
     private final SysDeptRelationService sysDeptRelationService;
     private final SysCsmUserRelationService sysCsmUserRelationService;
     private final SysDeptCsmMapper sysDeptCsmMapper;
+    private final SysEnterpriseAreaService enterpriseAreaService;
 
     /**
      * 分页查询
@@ -94,8 +98,7 @@ public class WmDaAgentController {
      * @return 分页结果
      */
     @GetMapping("/page")
-//    @PreAuthorize("@pms.hasPermission('admin_wmdaagent_view')" )
-    public R getWmDaAgentPage(Page page, WmDaAgent wmDaAgent) {
+    public R<?> getWmDaAgentPage(Page page, WmDaAgent wmDaAgent) {
 //		if(SecurityUtils.getRoles().contains(1) ||SecurityUtils.getRoles().contains(2))
 //		{
 //			//管理员和平台管理员不做处理
@@ -138,18 +141,16 @@ public class WmDaAgentController {
         wmDaAgent.setDeptId(SecurityUtils.getUser().getDeptId());
         WmDaAgent wmDaAgent3 = wmDaAgentMapper.selectDeptId(wmDaAgent);
         if (wmDaAgent3 != null) {
-            wmDaAgent3.setMahSettleFlag(wmDaAgent3.getMahSettleDeptId() != null);
             wmDaAgentList.add(wmDaAgent3);
         }
-        if (wmRelationList.size() > 0) {
-            List<Integer> ids = wmRelationList.stream().map(p -> p.getDownId()).collect(Collectors.toList());
+        if (CollUtil.isNotEmpty(wmRelationList)) {
+            List<Integer> ids = wmRelationList.stream().map(WmRelation::getDownId).collect(Collectors.toList());
 
             for (Integer id : ids) {
                 WmDaAgent wmDaAgent1 = new WmDaAgent();
                 wmDaAgent1.setDeptId(id);
                 WmDaAgent wmDaAgent2 = wmDaAgentMapper.selectDeptId(wmDaAgent1);
                 if (wmDaAgent2 != null) {
-                    wmDaAgent2.setMahSettleFlag(wmDaAgent2.getMahSettleDeptId() != null);
                     wmDaAgentList.add(wmDaAgent2);
                 }
             }
@@ -164,8 +165,8 @@ public class WmDaAgentController {
 
         //每页数据条数
         Page<WmDaAgent> page1 = new Page<>();
-        int current = new Long(page.getCurrent()).intValue();
-        int size = new Long(page.getSize()).intValue();
+        int current = Long.valueOf(page.getCurrent()).intValue();
+        int size = Long.valueOf(page.getSize()).intValue();
 
         int count = wmDaAgentList.size();
         List<WmDaAgent> pageList = new ArrayList<>();
@@ -179,6 +180,17 @@ public class WmDaAgentController {
         page1.setTotal(count);
         //计算分页总页数
         page1.setPages(count % size == 0 ? count / size : count / size + 1);
+
+        if (CollUtil.isNotEmpty(pageList)) {
+            pageList.forEach(p -> {
+
+                List<Long> areas = enterpriseAreaService.listEntAreas(Long.valueOf(p.getDeptId()));
+                p.setAreaCodes(areas);
+
+            });
+        }
+
+
         page1.setRecords(pageList);
         return R.ok(page1);
     }
@@ -198,7 +210,7 @@ public class WmDaAgentController {
 
     @SysLog("派工企业管理-新增")
     @PostMapping("/insert")
-    public R insert(@RequestBody WmDaAgent wmDaAgent) {
+    public R<?> insert(@RequestBody WmDaAgent wmDaAgent) {
         return wmDaAgentService.insert(wmDaAgent);
     }
 
@@ -211,21 +223,24 @@ public class WmDaAgentController {
     @SysLog("CSO管理-新增")
     @PostMapping
     @Transactional(rollbackFor = Exception.class)
-    public R save(@RequestBody WmDaAgent wmDaAgent) {
+    public R<Boolean> save(@Validated(value = BaseEntity.Create.class) @RequestBody WmDaAgent wmDaAgent) {
         Integer deptId = SecurityUtils.getUser().getDeptId();
 
         WmDaAgent query = new WmDaAgent();
         query.setGsmc(wmDaAgent.getGsmc());
         List<WmDaAgent> list1 = wmDaAgentService.list(Wrappers.query(query));
+
         WmDaAgent wmDaAgent4 = new WmDaAgent();
         wmDaAgent4.setZjNumber(wmDaAgent.getZjNumber());
         List<WmDaAgent> list5 = wmDaAgentMapper.selectList(Wrappers.query(wmDaAgent4));
         List<WmDaAgent> list3 = wmDaAgentMapper.selectByGsmcList(query);
         SysDeptRelation sysDeptRelation = new SysDeptRelation();
-        if (list3.size() > 0) {
+
+        if (CollUtil.isNotEmpty(list3)) {
             sysDeptRelation.setAncestor(deptId);
             sysDeptRelation.setDescendant(list3.get(0).getDeptId());
         }
+
         List<SysDeptRelation> list4 = sysDeptRelationMapper.selectDeptRelation(sysDeptRelation);
 
         WmDaDrugEnt wmDaDrugEnt = new WmDaDrugEnt();
@@ -247,9 +262,9 @@ public class WmDaAgentController {
             }
             wmDaAgent.setDeptId(sysDept.getDeptId());
             wmDaAgent.setTenantId(1);
-            wmDaAgent.setQylx(0 + "");
+            wmDaAgent.setQylx("0");
             wmDaAgent.setManagement("1");
-            wmDaAgent.setPgqx(1 + "");
+            wmDaAgent.setPgqx("1");
             if (wmDaDrugEnt1 != null) {
                 wmDaAgent.setTemp1(wmDaDrugEnt1.getEntname());
             }
@@ -264,7 +279,7 @@ public class WmDaAgentController {
                 wmRelation.setDownId(wmDaAgent.getDeptId());
                 wmRelation.setUpId(SecurityUtils.getUser().getDeptId());
                 List<WmRelation> list2 = wmRelationService.list(Wrappers.query(wmRelation));
-                if (list2.size() == 0) {
+                if (CollUtil.isEmpty(list2)) {
                     wmRelationMapper.insert(wmRelation);
                 }
                 if (2 == sysDept.getLevel()) {
@@ -275,20 +290,20 @@ public class WmDaAgentController {
                     WmTaskType wmTaskType = new WmTaskType();
                     wmTaskType.setDurgentId(wmDaDrugEnt1.getId());
                     wmTaskType.setLevel1Id(wmDaAgent.getId());
-                    wmTaskType.setDelFlag("0");
+                    wmTaskType.setDelFlag(CommonConstants.STATUS_NORMAL);
                     List<WmTaskType> list = wmTaskTypeMapper.selectList(Wrappers.query(wmTaskType));
-                    if (list.size() > 0) {
+                    if (CollUtil.isNotEmpty(list)) {
                         return R.failed("一代积分规则已分配");
                     } else {
 //					if (null != wmDaAgent) {
 //						wmTaskTypeEntRef.setDeptId(list3.get(0).getDeptId());
 //					}
-                        int isSave = wmTaskTypeEntRefMapper.insert(wmTaskTypeEntRef);
+                        wmTaskTypeEntRefMapper.insert(wmTaskTypeEntRef);
 
                         WmTaskType wmTaskTypeQ = new WmTaskType();
                         wmTaskTypeQ.setTaskTypeLevel("1");
                         wmTaskTypeQ.setStatus("0");
-                        wmTaskTypeQ.setDelFlag("0");
+                        wmTaskTypeQ.setDelFlag(CommonConstants.STATUS_NORMAL);
 
                         List<WmTaskType> tempList = wmTaskTypeMapper.selectList(Wrappers.query(wmTaskTypeQ));
 
@@ -318,12 +333,12 @@ public class WmDaAgentController {
 //					if (null != wmDaAgent) {
 //						wmTaskTypeEntRef1.setDeptId(list3.get(0).getDeptId());
 //					}
-                    int isSave = wmTaskTypeEntRefMapper.insert(wmTaskTypeEntRef1);
+                    wmTaskTypeEntRefMapper.insert(wmTaskTypeEntRef1);
 
                     WmTaskType wmTaskTypeQ = new WmTaskType();
                     wmTaskTypeQ.setTaskTypeLevel("1");
                     wmTaskTypeQ.setStatus("0");
-                    wmTaskTypeQ.setDelFlag("0");
+                    wmTaskTypeQ.setDelFlag(CommonConstants.STATUS_NORMAL);
 
                     List<WmTaskType> tempList = wmTaskTypeMapper.selectList(Wrappers.query(wmTaskTypeQ));
 
@@ -405,7 +420,7 @@ public class WmDaAgentController {
                 wmDaAgent1.setExtDrugEnt(list1.get(0).getExtDrugEnt() + "," + wmDaDrugEnt1.getId());
                 wmDaAgent1.setTemp1(list1.get(0).getTemp1() + "," + wmDaDrugEnt1.getEntname());
                 wmDaAgentMapper.updateById(wmDaAgent1);
-                int isSave = wmTaskTypeEntRefMapper.insert(wmTaskTypeEntRef);
+                wmTaskTypeEntRefMapper.insert(wmTaskTypeEntRef);
 
                 WmTaskType wmTaskTypeQ = new WmTaskType();
                 wmTaskTypeQ.setTaskTypeLevel("1");
@@ -454,43 +469,41 @@ public class WmDaAgentController {
     /**
      * CSO管理-修改
      *
-     * @param wmDaAgent
+     * @param wmDaAgent 信息
      * @return R
      */
     @SysLog("CSO管理-修改")
     @PutMapping
     @Transactional(rollbackFor = Exception.class)
-    public R updateById(@RequestBody WmDaAgent wmDaAgent) {
-        SysDept sysDept1 = new SysDept();
-        sysDept1.setDeptId(wmDaAgent.getDeptId());
-        SysDept sysDept = sysDeptMapper.selectDept(sysDept1);
+    public R<Boolean> updateById(@RequestBody WmDaAgent wmDaAgent) {
+
+        SysDept sysDept = sysDeptMapper.selectById(wmDaAgent.getDeptId());
         sysDept.setDelFlag(wmDaAgent.getEnableFlag());
         sysDept.setName(wmDaAgent.getGsmc());
         sysDept.setDeptId(wmDaAgent.getDeptId());
-
-        /**
-         * @Modify: start
-         * @Author: ryz
-         * @Date: 2021/4/20
-         * CSO管理 不能修改结算渠道
-         *
-         */
-//		sysDept.setSubjectType(wmDaAgent.getSubjectType());
         sysDept.setTaxCode(wmDaAgent.getZjNumber());
-        /**
-         * @Modify: end
-         */
         sysDeptMapper.updateByPrimaryKeySelective(sysDept);
+
         SysUser sysUser1 = new SysUser();
         sysUser1.setDeptId(wmDaAgent.getDeptId());
+
         List<SysUser> sysUserList = sysUserMapper.selectUserById(sysUser1);
-        List<Integer> id1 = sysUserList.stream().map(p -> p.getUserId()).collect(Collectors.toList());
+        List<Integer> id1 = sysUserList.stream().map(SysUser::getUserId).collect(Collectors.toList());
         for (Integer id : id1) {
             SysUser sysUser = new SysUser();
             sysUser.setUserId(id);
             sysUser.setDelFlag(wmDaAgent.getEnableFlag());
             sysUserMapper.updateByPrimaryKeySelective(sysUser);
         }
+        wmDaAgentService.updateById(wmDaAgent);
+
+        if (CollUtil.isNotEmpty(wmDaAgent.getAreaCodes())) {
+            // 删除历史的
+            enterpriseAreaService.delRelation(Long.valueOf(wmDaAgent.getDeptId()));
+
+            // 添加新的
+            enterpriseAreaService.saveRelation(Long.valueOf(wmDaAgent.getDeptId()), wmDaAgent.getAreaCodes());
+        }
         return R.ok(wmDaAgentService.updateById(wmDaAgent));
     }
 
@@ -502,7 +515,7 @@ public class WmDaAgentController {
      */
     @SysLog("派工企业管理-修改")
     @PutMapping("/update")
-    public R update(@RequestBody WmDaAgent wmDaAgent) {
+    public R<?> update(@RequestBody WmDaAgent wmDaAgent) {
         return R.ok(wmDaAgentService.updateByPrimaryKeySelective(wmDaAgent));
     }
 
@@ -516,18 +529,18 @@ public class WmDaAgentController {
     @SysLog("通过id删除档案-代理商")
     @DeleteMapping("/{id}")
     @PreAuthorize("@pms.hasPermission('admin_wmdaagent_del')")
-    public R removeById(@PathVariable Integer id) {
+    public R<?> removeById(@PathVariable Integer id) {
         return R.ok(wmDaAgentService.removeById(id));
     }
 
     /**
      * 查询服务上级组织列表
      *
-     * @param deptLevel
-     * @return
+     * @param deptLevel 等级
+     * @return 结果
      */
     @GetMapping("/listDrugEntOrAgent")
-    public R listDrugEntOrAgent(String deptLevel) {
+    public R<?> listDrugEntOrAgent(String deptLevel) {
         // 根据deptLevel(对应sys_dept的level字段)查询服务上级组织,deptLevel=4查询一级代理商,deptLevel=3和其他情况查询药企
         final List<Map<String, String>> result = new ArrayList<>();
         if ("4".equals(deptLevel)) {
@@ -565,15 +578,15 @@ public class WmDaAgentController {
      * @return 角色列表
      */
     @GetMapping("/list")
-    public R listDrugEnt(WmDaAgent wmDaAgent, String agentTypeId) {
+    public R<?> listDrugEnt(WmDaAgent wmDaAgent, String agentTypeId) {
         List<String> stringList = new ArrayList<>();
         if (null != agentTypeId && null != SecurityUtils.getUser().getDrugEntId()) {
             SysDept sysDept = new SysDept();
-            if (null != SecurityUtils.getUser().getDrugEntId() && !"".equals(SecurityUtils.getUser().getDrugEntId()) && !"null".equals(SecurityUtils.getUser().getDrugEntId())) {
+            if (null != SecurityUtils.getUser().getDrugEntId()) {
                 sysDept.setLevel1Id(SecurityUtils.getUser().getDrugEntId());
             }
             List<SysDept> sysDeptList = deptMapper.selectList(Wrappers.query(sysDept));
-            if (sysDeptList.size() > 0) {
+            if (CollUtil.isNotEmpty(sysDeptList)) {
                 for (SysDept sys :
                         sysDeptList) {
                     if ("1".equals(agentTypeId)) {
@@ -593,29 +606,23 @@ public class WmDaAgentController {
 
         wmDaAgent.setDelFlag("0");
         wmDaAgent.setEnableFlag("0");
-        List<WmDaAgent> listWmDaAgent = null;
-        String gsmc = null;
+        List<WmDaAgent> listWmDaAgent;
+        String gsmc;
         if (null != wmDaAgent.getGsmc()) {
             gsmc = wmDaAgent.getGsmc();
             wmDaAgent.setGsmc(null);
-            if (stringList.size() > 0) {
+            if (CollUtil.isNotEmpty(stringList)) {
                 listWmDaAgent = wmDaAgentService.selectByScope(Wrappers.query(wmDaAgent).lambda().like(WmDaAgent::getGsmc, gsmc).in(WmDaAgent::getId, stringList));
             } else {
                 listWmDaAgent = wmDaAgentService.selectByScope(Wrappers.query(wmDaAgent).lambda().like(WmDaAgent::getGsmc, gsmc));
             }
         } else {
-            if (stringList.size() > 0) {
+            if (CollUtil.isNotEmpty(stringList)) {
                 listWmDaAgent = wmDaAgentService.selectByScope(Wrappers.query(wmDaAgent).lambda().in(WmDaAgent::getId, stringList));
             } else {
                 listWmDaAgent = wmDaAgentService.selectByScope(Wrappers.query(wmDaAgent));
             }
         }
-//
-//		if(null!=agentTypeId)
-//		{
-//			if()
-//		}
-
 
         return R.ok(listWmDaAgent);
     }
@@ -627,7 +634,7 @@ public class WmDaAgentController {
      * @return 角色列表
      */
     @GetMapping("/listNoScope")
-    public R listNoScope(WmDaAgent wmDaAgent, String agentTypeId) {
+    public R<?> listNoScope(WmDaAgent wmDaAgent, String agentTypeId) {
         List<String> stringList = new ArrayList<>();
         if (null != agentTypeId && null != SecurityUtils.getUser().getDrugEntId()) {
             SysDept sysDept = new SysDept();
@@ -638,16 +645,15 @@ public class WmDaAgentController {
             }
 
             List<SysDept> sysDeptList = deptMapper.selectList(Wrappers.query(sysDept));
-            if (sysDeptList.size() > 0) {
-                for (SysDept sys :
-                        sysDeptList) {
+            if (CollUtil.isNotEmpty(sysDeptList)) {
+                for (SysDept sys : sysDeptList) {
                     if ("1".equals(agentTypeId)) {
                         if (null != sys.getLevel2Id()) {
-                            stringList.add(sys.getLevel2Id() + "");
+                            stringList.add(sys.getLevel2Id().toString());
                         }
                     } else if ("2".equals(agentTypeId)) {
                         if (null != sys.getLevel3Id()) {
-                            stringList.add(sys.getLevel3Id() + "");
+                            stringList.add(sys.getLevel3Id().toString());
                         }
                     }
 
@@ -658,112 +664,36 @@ public class WmDaAgentController {
 
         wmDaAgent.setDelFlag("0");
         wmDaAgent.setEnableFlag("0");
-        List<WmDaAgent> listWmDaAgent = null;
-        String gsmc = null;
+        List<WmDaAgent> listWmDaAgent;
+        String gsmc;
         if (null != wmDaAgent.getGsmc()) {
             gsmc = wmDaAgent.getGsmc();
             wmDaAgent.setGsmc(null);
-            if (stringList.size() > 0) {
+            if (CollUtil.isNotEmpty(stringList)) {
                 listWmDaAgent = wmDaAgentService.list(Wrappers.query(wmDaAgent).lambda().like(WmDaAgent::getGsmc, gsmc).in(WmDaAgent::getId, stringList));
             } else {
                 listWmDaAgent = wmDaAgentService.list(Wrappers.query(wmDaAgent).lambda().like(WmDaAgent::getGsmc, gsmc));
             }
         } else {
-            if (stringList.size() > 0) {
+            if (CollUtil.isNotEmpty(stringList)) {
                 listWmDaAgent = wmDaAgentService.list(Wrappers.query(wmDaAgent).lambda().in(WmDaAgent::getId, stringList));
             } else {
                 listWmDaAgent = wmDaAgentService.list(Wrappers.query(wmDaAgent));
             }
         }
-//
-//		if(null!=agentTypeId)
-//		{
-//			if()
-//		}
-
 
         return R.ok(listWmDaAgent);
     }
 
-
-//	private String getBuildName(String deptId,String type)
-//	{
-//		SysDept sysDept=sysDeptService.getById(deptId);
-//		String buildName="";
-//		if("user".equals(type))
-//		{
-//
-//		}else if("agent".equals(type))
-//		{
-//			if(null!=sysDept) {
-//				sysDept = sysDeptService.getById(sysDept.getParentId());
-//			}
-//		}
-//
-//		if(null!=sysDept&&sysDept.getLevel()==3)
-//		{
-//
-//			if(null!=sysDept.getLevel1Id()&&!"".equals(sysDept.getLevel1Id()))
-//			{
-//				WmDaDrugEnt wmDaDrugEnt=wmDaDrugEntService.getById(sysDept.getLevel1Id());
-//				if(null!=wmDaDrugEnt)
-//				{
-//					if(!"".equals(buildName))
-//					{
-//						buildName=buildName+"-"+wmDaDrugEnt.getEntname();
-//					}else{
-//						buildName=wmDaDrugEnt.getEntname();
-//					}
-//				}
-//			}
-//
-//
-//			if(null!=sysDept.getLevel2Id()&&!"".equals(sysDept.getLevel2Id()))
-//			{
-//				WmDaAgent wmDaAgent=wmDaAgentService.getById(sysDept.getLevel2Id());
-//				if(null!=wmDaAgent)
-//				{
-//					if(!"".equals(buildName))
-//					{
-//						buildName=buildName+"-"+wmDaAgent.getGsmc();
-//					}else{
-//						buildName=wmDaAgent.getGsmc();
-//					}
-//				}
-//			}
-//
-//
-//		}
-//
-//		if(null!=sysDept&&sysDept.getLevel()==2)
-//		{
-//			if(null!=sysDept.getLevel1Id()&&!"".equals(sysDept.getLevel1Id()))
-//			{
-//				WmDaDrugEnt wmDaDrugEnt=wmDaDrugEntService.getById(sysDept.getLevel1Id());
-//				if(null!=wmDaDrugEnt)
-//				{
-//					if(!"".equals(buildName))
-//					{
-//						buildName=buildName+"-"+wmDaDrugEnt.getEntname();
-//					}else{
-//						buildName=wmDaDrugEnt.getEntname();
-//					}
-//				}
-//			}
-//		}
-//
-//		return  buildName;
-//	}
-
     /**
      * 分页查询
      *
      * @param page      分页对象
      * @param wmDaAgent 档案-代理商
-     * @return
+     * @return 分页
      */
     @GetMapping("/page1")
-    public R getWmDaAgentPage1(Page page, WmDaAgent wmDaAgent) {
+    public R<?> getWmDaAgentPage1(Page page, WmDaAgent wmDaAgent) {
         if (SecurityUtils.getRoles().contains(19)) {
             // CSM只能查看自己维护的企业下的用户, 以及下属维护的企业下的用户
             Integer userId = SecurityUtils.getUser().getId();
@@ -792,7 +722,7 @@ public class WmDaAgentController {
      * @return cso列表 二期  业务平台
      */
     @GetMapping("/listCso")
-    public R listCso(Integer deptId) {
+    public R<?> listCso(Integer deptId) {
 
         if (deptId == null) {
             deptId = SecurityUtils.getUser().getDeptId();
@@ -815,7 +745,7 @@ public class WmDaAgentController {
      * @return cso列表 二期  业务平台
      */
     @GetMapping("/getCso")
-    public R getCso(Integer id) {
+    public R<?> getCso() {
 //		SysDept sysDept1 = new SysDept();
 //		sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
 //		SysDept byId = sysDeptMapper.selectDeptId(sysDept1);
@@ -839,7 +769,7 @@ public class WmDaAgentController {
      * @return 关联服务企业 二期  业务平台
      */
     @GetMapping("/listCsoById")
-    public R listCsoById(WmScorePackage wmScorePackage) {
+    public R<?> listCsoById() {
 //		SysDept sysDept1 = new SysDept();
 //		sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
 //		SysDept byId = sysDeptMapper.selectDeptId(sysDept1);
@@ -872,7 +802,7 @@ public class WmDaAgentController {
      * 通过用户deptId查询用户信息
      */
     @PostMapping("/getUserDeptId")
-    public R getUserDeptId(Integer deptId) {
+    public R<?> getUserDeptId(Integer deptId) {
         return R.ok(wmDaAgentService.selectNameByDeptId(deptId));
     }
 
@@ -880,7 +810,7 @@ public class WmDaAgentController {
      * 通过用户deptId修改用户信息
      */
     @PostMapping("/updateUserByDeptId")
-    public R updateUserByDeptId(@RequestBody WmDaAgent wmDaAgent) {
+    public R<?> updateUserByDeptId(@RequestBody WmDaAgent wmDaAgent) {
         return R.ok(wmDaAgentService.updateUserByDeptId(wmDaAgent));
     }
 
@@ -888,7 +818,7 @@ public class WmDaAgentController {
      * 查询组织架构
      */
     @GetMapping("/listByDept")
-    public R listByDept() {
+    public R<?> listByDept() {
 
         return R.ok(wmDaAgentService.listByDept());
     }

+ 1 - 1
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mapper/WmDaAgentMapper.java

@@ -21,7 +21,7 @@ import java.util.Map;
 public interface WmDaAgentMapper extends DataScopeMapper<WmDaAgent> {
     WmDaAgent selectByDeptId(WmDaAgent wmDaAgent);
 
-    List selectByUserDeptId(Integer deptId);
+    List<WmDaAgent> selectByUserDeptId(Integer deptId);
 
     WmDaAgent selectByDeptIds(Integer deptId);
 

+ 0 - 1
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/SysUserService.java

@@ -1,4 +1,3 @@
-
 package com.qunzhixinxi.hnqz.admin.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;

+ 0 - 17
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/WmDaAgentService.java

@@ -27,27 +27,14 @@ public interface WmDaAgentService extends IService<WmDaAgent> {
 
 	 boolean saveAgent(WmDaAgent wmDaAgent);
 
-	 IPage<WmDaAgent> listPage(Page page, WmDaAgent wmDaAgent);
-
 	WmDaAgent selectByDeptId(Integer deptId);
 
-	List selectByDrugIds(Integer id);
-
-	List selectByRelationId(Integer id);
-
-	List selectByRelationIds(Integer id);
-
-	List selectByDrugId(Integer id);
-
-	List selectEntNameByDrugIds(Integer id);
-
 	List selectNameByDeptId(Integer deptId);
 
 	List listByDept();
 
 	int updateUserByDeptId(WmDaAgent wmDaAgent);
 
-//	List selectByCsoIds(Integer id);
 
 	IPage<WmDaAgent> selectWmManagementList(Page page, @Param("query")WmDaAgent wmDaAgent);
 
@@ -55,8 +42,6 @@ public interface WmDaAgentService extends IService<WmDaAgent> {
 
 	R updateByPrimaryKeySelective(@Param("query")WmDaAgent wmDaAgent);
 
-	WmDaAgent selectDeptId(WmDaAgent wmDaAgent);
-
 	List<Map<String, Object>> selectDeptId1(Integer deptId);
 
 	List selectWmDaDrugEntByDeptId(Integer deptId);
@@ -69,8 +54,6 @@ public interface WmDaAgentService extends IService<WmDaAgent> {
 
 	List selectWmDaAgentByDeptId(String deptId);
 
-	List selectWmDaAgentByDeptIds(String deptId);
-
 	/**
 	 * 根据sys_dept表的level字段查询
 	 *

+ 40 - 46
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysSocialDetailsServiceImpl.java

@@ -28,58 +28,52 @@ import java.util.Map;
 @AllArgsConstructor
 @Service("sysSocialDetailsService")
 public class SysSocialDetailsServiceImpl extends ServiceImpl<SysSocialDetailsMapper, SysSocialDetails>
-		implements SysSocialDetailsService {
+        implements SysSocialDetailsService {
 
-	private final Map<String, LoginHandler> loginHandlerMap;
+    private final Map<String, LoginHandler> loginHandlerMap;
 
-	private final CacheManager cacheManager;
+    private final CacheManager cacheManager;
 
-	private final SysUserMapper sysUserMapper;
+    private final SysUserMapper sysUserMapper;
 
-	/**
-	 * 绑定社交账号
-	 * @param type type
-	 * @param code code
-	 * @return
-	 */
-	@Override
-	public Boolean bindSocial(String type, String code) {
-		String identify = loginHandlerMap.get(type).identify(code);
-		SysUser sysUser = sysUserMapper.selectById(SecurityUtils.getUser().getId());
+    /**
+     * 绑定社交账号
+     *
+     * @param type type
+     * @param code code
+     * @return
+     */
+    @Override
+    public Boolean bindSocial(String type, String code) {
+        String identify = loginHandlerMap.get(type).identify(code);
+        SysUser sysUser = sysUserMapper.selectById(SecurityUtils.getUser().getId());
 
-		if (LoginTypeEnum.GITEE.getType().equals(type)) {
-			sysUser.setGiteeLogin(identify);
-		}
-		else if (LoginTypeEnum.OSC.getType().equals(type)) {
-			sysUser.setOscId(identify);
-		}
-		else if (LoginTypeEnum.WECHAT.getType().equals(type)) {
-			sysUser.setWxOpenid(identify);
-		}
-		else if (LoginTypeEnum.QQ.getType().equals(type)) {
-			sysUser.setQqOpenid(identify);
-		}
-		else if (LoginTypeEnum.MINI_APP.getType().equals(type)) {
-			sysUser.setMiniOpenid(identify);
-		}
+        if (LoginTypeEnum.WECHAT.getType().equals(type)) {
+            sysUser.setWxOpenid(identify);
+        } else if (LoginTypeEnum.QQ.getType().equals(type)) {
+            sysUser.setQqOpenid(identify);
+        } else if (LoginTypeEnum.MINI_APP.getType().equals(type)) {
+            sysUser.setMiniOpenid(identify);
+        }
 
-		sysUserMapper.updateById(sysUser);
-		// 更新緩存
-		cacheManager.getCache(CacheConstants.USER_DETAILS).evict(sysUser.getUsername());
-		return Boolean.TRUE;
-	}
+        sysUserMapper.updateById(sysUser);
+        // 更新緩存
+        cacheManager.getCache(CacheConstants.USER_DETAILS).evict(sysUser.getUsername());
+        return Boolean.TRUE;
+    }
 
-	/**
-	 * 根据入参查询用户信息
-	 * @param inStr TYPE@code
-	 * @return
-	 */
-	@Override
-	public UserInfo getUserInfo(String inStr) {
-		String[] inStrs = inStr.split(StringPool.AT);
-		String type = inStrs[0];
-		String loginStr = inStrs[1];
-		return loginHandlerMap.get(type).handle(loginStr);
-	}
+    /**
+     * 根据入参查询用户信息
+     *
+     * @param inStr TYPE@code
+     * @return
+     */
+    @Override
+    public UserInfo getUserInfo(String inStr) {
+        String[] inStrs = inStr.split(StringPool.AT);
+        String type = inStrs[0];
+        String loginStr = inStrs[1];
+        return loginHandlerMap.get(type).handle(loginStr);
+    }
 
 }

+ 0 - 42
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysUserServiceImpl.java

@@ -514,46 +514,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             userDTO.setUsername(username);
         }
 
-        // 校验省
-        String province = StrUtil.cleanBlank(commonUserDTO.getProvince());
-        if (StringUtils.isEmpty(province)) {
-            log.error("省份为空");
-            errorMap(errorMap, "省份为空", commonUserDTO.getId());
-        } else {
-            province = "全国".equals(province) ? "" : province;
-            userDTO.setProvince(province);
-
-            // 校验城市
-            if (StringUtils.isEmpty(province)) {
-                userDTO.setCity("");
-                userDTO.setProvinceCode("");
-                userDTO.setCityCode("");
-            } else {
-                String provinceCode = StrUtil.cleanBlank(commonUserDTO.getProvinceCode());
-                if (StringUtils.isEmpty(provinceCode)) {
-                    log.error("省份编码为空");
-                    errorMap(errorMap, "省份编码为空", commonUserDTO.getId());
-                }
-                userDTO.setProvinceCode(provinceCode);
-
-                String city = StrUtil.cleanBlank(commonUserDTO.getCity());
-                if (StringUtils.isEmpty(city)) {
-                    log.error("城市为空");
-                    errorMap(errorMap, "城市为空", commonUserDTO.getId());
-                }
-
-                userDTO.setCity(city);
-
-                String cityCode = StrUtil.cleanBlank(commonUserDTO.getCityCode());
-                if (StringUtils.isEmpty(cityCode)) {
-                    log.error("城市编码为空");
-                    errorMap(errorMap, "城市编码为空", commonUserDTO.getId());
-                }
-                userDTO.setCityCode(cityCode);
-
-            }
-        }
-
         // 校验用户角色
         SysDept dept = sysDeptService.getById(creator.getDeptId());
         String roleName = StrUtil.cleanBlank(commonUserDTO.getRoleName());
@@ -709,8 +669,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 // 设置为不允许查到
                 userDTO.setUserIdList(CollUtil.newArrayList(-1));
             }
-            userDTO.setCertStatus(null);
-            userDTO.setRljCertStatus(null);
         }
 
         if (SecurityUtils.getRoles().contains(1) || SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(35)) {

+ 88 - 211
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmDaAgentServiceImpl.java

@@ -1,8 +1,9 @@
-
 package com.qunzhixinxi.hnqz.admin.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -13,15 +14,35 @@ import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysDeptCsm;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysDeptRelation;
 import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
-import com.qunzhixinxi.hnqz.admin.api.entity.*;
+import com.qunzhixinxi.hnqz.admin.api.entity.WmDaAgent;
+import com.qunzhixinxi.hnqz.admin.api.entity.WmDaDrugEnt;
+import com.qunzhixinxi.hnqz.admin.api.entity.WmRelation;
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskType;
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskTypeEntRef;
 import com.qunzhixinxi.hnqz.admin.api.model.input.WmDept;
 import com.qunzhixinxi.hnqz.admin.api.constant.enums.EnableEnum;
-import com.qunzhixinxi.hnqz.admin.mapper.*;
-import com.qunzhixinxi.hnqz.admin.service.*;
+import com.qunzhixinxi.hnqz.admin.mapper.SysDeptCsmMapper;
+import com.qunzhixinxi.hnqz.admin.mapper.SysDeptMapper;
+import com.qunzhixinxi.hnqz.admin.mapper.SysDeptRelationMapper;
+import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
+import com.qunzhixinxi.hnqz.admin.mapper.WmDaAgentMapper;
+import com.qunzhixinxi.hnqz.admin.mapper.WmDaDrugEntMapper;
+import com.qunzhixinxi.hnqz.admin.mapper.WmRelationMapper;
+import com.qunzhixinxi.hnqz.admin.mapper.WmTaskTypeEntRefMapper;
+import com.qunzhixinxi.hnqz.admin.mapper.WmTaskTypeMapper;
+import com.qunzhixinxi.hnqz.admin.service.SysCsmUserRelationService;
+import com.qunzhixinxi.hnqz.admin.service.SysDeptRelationService;
+import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
+import com.qunzhixinxi.hnqz.admin.service.SysEnterpriseAreaService;
+import com.qunzhixinxi.hnqz.admin.service.WmDaAgentService;
+import com.qunzhixinxi.hnqz.admin.service.WmDaDrugEntService;
+import com.qunzhixinxi.hnqz.admin.service.WmRelationService;
+import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionPercentRuleService;
+import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionRuleService;
 import com.qunzhixinxi.hnqz.common.core.constant.CacheConstants;
+import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
 import com.qunzhixinxi.hnqz.common.core.util.R;
 import com.qunzhixinxi.hnqz.common.data.datascope.DataScope;
-import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
 import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
@@ -60,12 +81,12 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
     private final WmTaskTypeMapper wmTaskTypeMapper;
     private final WmTaskTypeEntRefMapper wmTaskTypeEntRefMapper;
     private final SysDeptMapper sysDeptMapper;
-    private final SysDeptSubMapper sysDeptSubMapper;
     private final WmTaskSubmissionRuleService taskSubmissionRuleService;
     private final WmTaskSubmissionPercentRuleService taskSubmissionPercentRuleService;
     private final SysCsmUserRelationService sysCsmUserRelationService;
     private final SysDeptCsmMapper sysDeptCsmMapper;
-    private final RedisTemplate redisTemplate;
+    private final RedisTemplate<String, Object> redisTemplate;
+    private final SysEnterpriseAreaService enterpriseAreaService;
 
     public String getDeptBuildName(String deptId) {
         String buildName = "";
@@ -103,13 +124,6 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
         return wmDaAgentMapper.selectListByScope(queryWrapper, new DataScope());
     }
 
-    /**
-     * @Modify: start
-     * @Version: v2021.4.16
-     * @Author: ryz
-     * @Date: 2021/4/26
-     * sysDept.setTaxCode(wmDaAgent.getZjNumber());
-     */
     public boolean saveAgent(WmDaAgent wmDaAgent) {
         Integer deptId = SecurityUtils.getUser().getDeptId();
         SysDept queryDept = sysDeptMapper.selectById(deptId);
@@ -118,9 +132,11 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
         boolean isSave = super.save(wmDaAgent);
         List<SysDept> list = sysDeptMapper.selectByName(wmDaAgent.getGsmc());
         if (isSave) {
+
             if (SecurityUtils.getRoles().contains(3)) {
-                if (list.size() == 0) {
+                if (CollUtil.isEmpty(list)) {
                     SysDept sysDept = new SysDept();
+                    sysDept.setDeptId((int) System.currentTimeMillis() / 1000);
                     sysDept.setName(wmDaAgent.getGsmc());
                     sysDept.setTaxCode(wmDaAgent.getZjNumber());
                     sysDept.setLevel(3);
@@ -132,25 +148,30 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
                     wmDaAgent.setDeptId(list.get(0).getDeptId());
                     wmDaAgentMapper.updateById(wmDaAgent);
                 }
+                // 区域关系
+                if (CollUtil.isNotEmpty(wmDaAgent.getAreaCodes())) {
+                    enterpriseAreaService.saveRelation(Long.valueOf(wmDaAgent.getDeptId()), wmDaAgent.getAreaCodes());
+                }
 
                 // 初始化企业限制信息
-                taskSubmissionRuleService.initDeptTaskSubmissionRule(Collections.singleton(Integer.valueOf(wmDaAgent.getDeptId())), deptId);
+                taskSubmissionRuleService.initDeptTaskSubmissionRule(Collections.singleton(wmDaAgent.getDeptId()), deptId);
                 // 初始化企业的任务类型配置的信息
-                taskSubmissionPercentRuleService.initTaskTypeConfigRule(Collections.singleton(Integer.valueOf(wmDaAgent.getDeptId())), deptId);
+                taskSubmissionPercentRuleService.initTaskTypeConfigRule(Collections.singleton(wmDaAgent.getDeptId()), deptId);
 
-                List<SysDeptRelation> newList = new ArrayList<>();
+                List<SysDeptRelation> newList = new ArrayList<>(2);
                 SysDeptRelation sysDeptRelation = new SysDeptRelation();
                 sysDeptRelation.setAncestor(SecurityUtils.getUser().getDeptId());
-                sysDeptRelation.setDescendant(Integer.valueOf(wmDaAgent.getDeptId()));
+                sysDeptRelation.setDescendant(wmDaAgent.getDeptId());
                 newList.add(sysDeptRelation);
                 SysDeptRelation sysDeptRelation1 = new SysDeptRelation();
-                sysDeptRelation1.setAncestor(Integer.valueOf(wmDaAgent.getDeptId()));
-                sysDeptRelation1.setDescendant(Integer.valueOf(wmDaAgent.getDeptId()));
+                sysDeptRelation1.setAncestor(wmDaAgent.getDeptId());
+                sysDeptRelation1.setDescendant(wmDaAgent.getDeptId());
                 newList.add(sysDeptRelation1);
                 return sysDeptRelationService.saveBatch(newList);
             } else if (SecurityUtils.getRoles().contains(4)) {
-                if (list.size() == 0) {
+                if (CollUtil.isEmpty(list)) {
                     SysDept sysDept = new SysDept();
+                    sysDept.setDeptId((int) System.currentTimeMillis() / 1000);
                     sysDept.setName(wmDaAgent.getGsmc());
                     sysDept.setLevel(4);
                     sysDept.setTaxCode(wmDaAgent.getZjNumber());
@@ -162,89 +183,31 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
                     wmDaAgent.setDeptId(list.get(0).getDeptId());
                     wmDaAgentMapper.updateById(wmDaAgent);
                 }
+                // 区域关系
+                if (CollUtil.isNotEmpty(wmDaAgent.getAreaCodes())) {
+                    enterpriseAreaService.saveRelation(Long.valueOf(wmDaAgent.getDeptId()), wmDaAgent.getAreaCodes());
+                }
 
                 // 初始化企业限制信息
-                taskSubmissionRuleService.initDeptTaskSubmissionRule(Collections.singleton(Integer.valueOf(wmDaAgent.getDeptId())), deptId);
+                taskSubmissionRuleService.initDeptTaskSubmissionRule(Collections.singleton(wmDaAgent.getDeptId()), deptId);
                 // 初始化企业的任务类型配置的信息
-                taskSubmissionPercentRuleService.initTaskTypeConfigRule(Collections.singleton(Integer.valueOf(wmDaAgent.getDeptId())), deptId);
+                taskSubmissionPercentRuleService.initTaskTypeConfigRule(Collections.singleton(wmDaAgent.getDeptId()), deptId);
 
-                List<SysDeptRelation> newList = new ArrayList<>();
+                List<SysDeptRelation> newList = new ArrayList<>(2);
                 SysDeptRelation sysDeptRelation = new SysDeptRelation();
                 sysDeptRelation.setAncestor(SecurityUtils.getUser().getDeptId());
-                sysDeptRelation.setDescendant(Integer.valueOf(wmDaAgent.getDeptId()));
+                sysDeptRelation.setDescendant(wmDaAgent.getDeptId());
                 newList.add(sysDeptRelation);
                 SysDeptRelation sysDeptRelation1 = new SysDeptRelation();
-                sysDeptRelation1.setAncestor(Integer.valueOf(wmDaAgent.getDeptId()));
-                sysDeptRelation1.setDescendant(Integer.valueOf(wmDaAgent.getDeptId()));
+                sysDeptRelation1.setAncestor(wmDaAgent.getDeptId());
+                sysDeptRelation1.setDescendant(wmDaAgent.getDeptId());
                 newList.add(sysDeptRelation1);
                 return sysDeptRelationService.saveBatch(newList);
             }
 
-        }
-        return false;
-    }
 
-    @Override
-    public IPage<WmDaAgent> listPage(Page page, WmDaAgent wmDaAgent) {
-        QueryWrapper queryWrapper = Wrappers.query();
-        if (null != wmDaAgent.getGsmc()) {
-            queryWrapper.like("gsmc", wmDaAgent.getGsmc());
         }
-        if (null != wmDaAgent.getZjNumber()) {
-            queryWrapper.like("zj_number", wmDaAgent.getZjNumber());
-        }
-//		if(null!=wmDaAgent.getTemp2())
-//		{
-//			QueryWrapper queryWrapper1=Wrappers.query();
-//			List<SysDept> sysDeptList=sysDeptService.list(queryWrapper1.eq(true,"level2_id",wmDaAgent.getTemp2()));
-//			List<String> stringList=new ArrayList<>();
-//			for (SysDept sysDept:sysDeptList) {
-//				stringList.add(sysDept.getDeptId()+"");
-//			}
-//			queryWrapper.in("dept_id",stringList);
-//		}
-        if (SecurityUtils.getRoles().contains(4)) {
-            wmDaAgent.setDeptId(SecurityUtils.getUser().getDeptId());
-            WmDaAgent wmDaAgent1 = wmDaAgentMapper.selectDeptId(wmDaAgent);
-            WmRelation wmRelation = new WmRelation();
-            if (wmDaAgent1 != null) {
-                wmRelation.setUpId(wmDaAgent1.getDeptId());
-            } else {
-                wmRelation.setUpId(null);
-            }
-            List<WmRelation> taskList = wmRelationMapper.selectUpIdList(wmRelation);
-            List<Integer> ids2 = taskList.stream().map(p -> p.getDownId()).collect(Collectors.toList());
-            if (taskList.size() != 0) {
-                List<WmDaAgent> newList = new ArrayList<>();
-                for (Integer id : ids2) {
-                    WmDaAgent wmDaAgent3 = new WmDaAgent();
-                    wmDaAgent3.setDeptId(id);
-                    WmDaAgent wmDaAgent2 = wmDaAgentMapper.selectDeptId(wmDaAgent3);
-                    newList.add(wmDaAgent2);
-                }
-                queryWrapper.like("ext_drug_ent", newList.get(0).getExtDrugEnt());
-                page.setRecords(newList);
-            } else {
-                return null;
-            }
-        } else if (SecurityUtils.getRoles().contains(3)) {
-            WmRelation wmRelation = new WmRelation();
-            wmRelation.setUpId(SecurityUtils.getUser().getDeptId());
-            List<WmRelation> taskList = wmRelationMapper.selectUpIdList(wmRelation);
-            List<Integer> ids2 = taskList.stream().map(p -> p.getDownId()).collect(Collectors.toList());
-            if (taskList.size() != 0) {
-                List<WmDaAgent> newList = new ArrayList<>();
-                for (Integer id : ids2) {
-                    WmDaAgent wmDaAgent2 = wmDaAgentMapper.selectById(id);
-                    newList.add(wmDaAgent2);
-                }
-                page.setRecords(newList);
-            } else {
-                return null;
-            }
-        }
-        return wmDaAgentMapper.selectPageByScope(page, queryWrapper, new DataScope());
-
+        return false;
     }
 
     @Override
@@ -258,39 +221,12 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
             queryWrapper.like("zjNamber", wmDaAgent.getZjNumber());
         }
 
-        IPage<WmDaAgent> wmDaAgentIPage = wmDaAgentMapper.selectWmManagementPage(page, wmDaAgent);
-
-        wmDaAgentIPage.getRecords().forEach(agent -> {
-
-            //Map<String, Integer> collect = sysDeptSubMapper.selectList(Wrappers.<SysDeptSub>lambdaQuery()
-            //		//.eq(SysDeptSub::getEnableFlag, SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode())
-            //		.eq(SysDeptSub::getDeptId, agent.getDeptId()))
-            //		.stream().collect(Collectors.toMap(sysDeptSub -> sysDeptSub.getSubjectLocation().name(), SysDeptSub::getSubjectChannel));
-            //agent.setSubjectType(collect.keySet().toArray(collect.keySet().toArray(new String[0])));
-            //agent.setSubjectTypeAndChannel(collect);
-
-            // MAH结算权限开关
-            agent.setMahSettleFlag(agent.getMahSettleDeptId() != null);
-
-        });
-
-//		wmDaAgentIPage.getRecords().forEach(agent -> {
-//			SysDeptSub sysDeptSub = new SysDeptSub();
-//			sysDeptSub.setDeptId(Integer.valueOf(agent.getDeptId()));
-//			sysDeptSub.setEnableFlag(SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode());
-//			List<SysDeptSub> subList = sysDeptSubMapper.selectList(Wrappers.query(sysDeptSub));
-//			if (CollUtil.isNotEmpty(subList)) {
-//				String[] subTypeArr = subList.stream().map(SysDeptSub::getSubjectType).distinct().toArray(String[]::new);
-//				agent.setSubjectType(subTypeArr);
-//			}
-//		});
-
-        return wmDaAgentIPage;
+        return wmDaAgentMapper.selectWmManagementPage(page, wmDaAgent);
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public R insert(WmDaAgent wmDaAgent) {
+    public R<?> insert(WmDaAgent wmDaAgent) {
         LocalDateTime now = LocalDateTime.now();
 
         WmDaAgent query = new WmDaAgent();
@@ -300,14 +236,14 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
         wmDaAgent1.setZjNumber(wmDaAgent.getZjNumber());
         List<WmDaAgent> list2 = wmDaAgentMapper.selectList(Wrappers.query(wmDaAgent1));
 
-        if (list1.size() > 0) {
+        if (CollUtil.isNotEmpty(list1)) {
             return R.failed("企业名称已存在");
         }
-        if (list2.size() > 0) {
+        if (CollUtil.isNotEmpty(list2)) {
             return R.failed("统一社会信用代码已经存在");
         }
         wmDaAgent.setTenantId(1);
-        wmDaAgent.setDelFlag(0 + "");
+        wmDaAgent.setDelFlag(CommonConstants.STATUS_NORMAL);
         List<WmDaDrugEnt> listEnts = new ArrayList<>();
         if (wmDaAgent.getExtDrugEnt() != null) {
             String[] ents = wmDaAgent.getExtDrugEnt().split(",");
@@ -315,7 +251,7 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
         }
         List<String> ids = listEnts.stream().map(p -> p.getDeptId().toString()).collect(Collectors.toList());
         String temp1 = "";
-        if (listEnts.size() > 0) {
+        if (CollUtil.isNotEmpty(listEnts)) {
             for (WmDaDrugEnt wmD : listEnts) {
                 temp1 += wmD.getEntname() + ",";
             }
@@ -325,18 +261,13 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
         wmDaAgent.setCreateTime(now);
         wmDaAgent.setCreateUser(SecurityUtils.getUser().getId());
         wmDaAgent.setManagement(String.valueOf(1));
-        wmDaAgent.setPgqx(1 + "");
+        wmDaAgent.setPgqx("1");
         super.save(wmDaAgent);
         List<SysDept> list3 = sysDeptMapper.selectByName(wmDaAgent.getGsmc());
         int deptId;
         if (list3.size() == 0) {
-            SysDept sysDept = new SysDept();/**
-             * @Modify: start
-             * @Version: 2021.4.16
-             * @Author: ryz
-             * @Date: 2021/4/20
-             */
-
+            SysDept sysDept = new SysDept();
+            sysDept.setDeptId((int) System.currentTimeMillis() / 1000);
             sysDept.setTaxCode(wmDaAgent.getZjNumber());
             sysDept.setDeptPermissions(wmDaAgent.getDeptPermissions());
             sysDept.setFinancialReviewType(wmDaAgent.getFinancialReviewType());
@@ -352,26 +283,6 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
             }
 
             deptId = sysDept.getDeptId();
-            // for (Map.Entry<String, Integer> entry : wmDaAgent.getSubjectTypeAndChannel().entrySet()){
-            // 	SysDeptSub deptSub = new SysDeptSub();
-            // 	deptSub.setDeptId(sysDept.getDeptId());
-            // 	deptSub.setSubjectType(entry.getKey());
-            // 	deptSub.setSubjectChannel(entry.getValue());
-            // 	deptSub.setUpdateTime(LocalDateTime.now());
-            // 	deptSub.setEnableFlag(SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode());
-            // 	sysDeptSubMapper.insert(deptSub);
-            // }
-
-            for (String subType : wmDaAgent.getSubjectType()) {
-                SysDeptSub deptSub = new SysDeptSub();
-                deptSub.setDeptId(sysDept.getDeptId());
-                deptSub.setSubjectType(subType);
-                //deptSub.setEnableFlag(SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode());
-                sysDeptSubMapper.insert(deptSub);
-            }
-            /**
-             * @Modify: end
-             */
 
 
             wmDaAgent.setDeptId(sysDept.getDeptId());
@@ -436,8 +347,8 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
         insert.setDeptId(deptId);
         insert.setUserId(userId);
         insert.setCsmName(user.getRealname());
-        insert.setQrCodeId(" ");
-        insert.setCorpId(" ");
+        insert.setQrCodeId(null);
+        insert.setCorpId(null);
         sysDeptCsmMapper.insert(insert);
 
         List<WmRelation> newList = new ArrayList<>();
@@ -448,27 +359,36 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
             newList.add(wmRelation);
         }
         wmRelationService.saveBatch(newList);
+
+        // cso
         if (wmDaAgent.getQylx().equals("0")) {
             WmTaskTypeEntRef wmTaskTypeEntRef = new WmTaskTypeEntRef();
             wmTaskTypeEntRef.setAgentId(wmDaAgent.getId());
             wmTaskTypeEntRef.setDrugentId(null);
-            WmTaskType wmTaskType = new WmTaskType();
-            wmTaskType.setDurgentId(Integer.parseInt(wmDaAgent.getDrugEntId()));
-            wmTaskType.setLevel1Id(wmDaAgent.getId());
-            wmTaskType.setDelFlag("0");
-            List<WmTaskType> list = wmTaskTypeMapper.selectList(Wrappers.query(wmTaskType));
-            if (list.size() > 0) {
+
+            String [] drugId = null;
+            if (StrUtil.isNotBlank(wmDaAgent.getDrugEntId())){
+                drugId  = wmDaAgent.getDrugEntId().contains(StrUtil.COMMA) ? wmDaAgent.getDrugEntId().split(StrUtil.COMMA) : new String[]{wmDaAgent.getDrugEntId()};
+            }
+
+            List<WmTaskType> list = wmTaskTypeMapper.selectList(Wrappers.<WmTaskType>lambdaQuery()
+                    .in(ArrayUtil.isNotEmpty(drugId), WmTaskType::getDurgentId,  Arrays.stream(drugId).collect(Collectors.toSet()))
+                    .eq(WmTaskType::getLevel1Id, wmDaAgent.getId())
+                    .eq(WmTaskType::getDelFlag, CommonConstants.STATUS_NORMAL)
+
+            );
+            if (CollUtil.isNotEmpty(list)) {
                 return R.failed("一代积分规则已分配");
             } else {
                 if (null != wmDaAgent) {
                     wmTaskTypeEntRef.setDeptId(wmDaAgent.getDeptId().toString());
                 }
-                int isSave = wmTaskTypeEntRefMapper.insert(wmTaskTypeEntRef);
+                wmTaskTypeEntRefMapper.insert(wmTaskTypeEntRef);
 
                 WmTaskType wmTaskTypeQ = new WmTaskType();
                 wmTaskTypeQ.setTaskTypeLevel("1");
-                wmTaskTypeQ.setStatus("0");
-                wmTaskTypeQ.setDelFlag("0");
+                wmTaskTypeQ.setStatus(CommonConstants.STATUS_NORMAL);
+                wmTaskTypeQ.setDelFlag(CommonConstants.STATUS_NORMAL);
 
                 List<WmTaskType> tempList = wmTaskTypeMapper.selectList(Wrappers.query(wmTaskTypeQ));
 
@@ -481,7 +401,7 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
                     newOne.setRuleId(wmTaskTypeEntRef.getAgentId().toString());
                     newOne.setDeptId(wmDaAgent.getDeptId());
                     newOne.setCreateTime(LocalDateTime.now());
-                    newOne.setStatus("0");
+                    newOne.setStatus(CommonConstants.STATUS_NORMAL);
                     newOne.setBaseId(wmTaskType1.getId());
                     wmTaskTypeMapper.insert(newOne);
                 }
@@ -653,12 +573,6 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
         return R.ok();
     }
 
-    @Override
-    public WmDaAgent selectDeptId(WmDaAgent wmDaAgent) {
-        wmDaAgent.setDeptId(SecurityUtils.getUser().getDeptId());
-        return wmDaAgentMapper.selectDeptId(wmDaAgent);
-    }
-
     @Override
     public List<Map<String, Object>> selectDeptId1(Integer deptId) {
         List<Map<String, Object>> map1;
@@ -697,41 +611,12 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
         return wmDaAgentMapper.selectWmDaAgentByDeptId(deptId);
     }
 
-    @Override
-    public List selectWmDaAgentByDeptIds(String deptId) {
-        return wmDaAgentMapper.selectWmDaAgentByDeptIds(deptId);
-    }
-
 
     @Override
     public WmDaAgent selectByDeptId(Integer deptId) {
         return wmDaAgentMapper.selectByDeptIds(deptId);
     }
 
-    @Override
-    public List selectByDrugIds(Integer id) {
-        return wmDaAgentMapper.selectByDrugIds(id);
-    }
-
-    @Override
-    public List selectByRelationId(Integer id) {
-        return wmDaAgentMapper.selectByRelationId(id);
-    }
-
-    @Override
-    public List selectByRelationIds(Integer id) {
-        return wmDaAgentMapper.selectByRelationIds(id);
-    }
-
-    @Override
-    public List selectByDrugId(Integer id) {
-        return wmDaAgentMapper.selectByDrugId(id);
-    }
-
-    @Override
-    public List selectEntNameByDrugIds(Integer id) {
-        return wmDaAgentMapper.selectEntNameByDrugIds(id);
-    }
 
     @Override
     public List listByDept() {
@@ -843,12 +728,10 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
     }
 
     @Override
-    public List selectNameByDeptId(Integer deptId) {
-//		SysDept sysDept1 = new SysDept();
-//		sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
-//		SysDept deptIds = sysDeptMapper.selectDeptId(sysDept1);
+    public List<WmDaAgent> selectNameByDeptId(Integer deptId) {
+
         SysDept deptIds = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
-        List wmDaDrugEnts = null;
+        List<WmDaAgent> wmDaDrugEnts = null;
         if (deptIds.getLevel() == 2) {
             wmDaDrugEnts = wmDaDrugEntMapper.selectByUserDeptId(SecurityUtils.getUser().getDeptId());
         } else if (deptIds.getLevel() == 3 || deptIds.getLevel() == 4) {
@@ -859,9 +742,7 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
 
     @Override
     public int updateUserByDeptId(WmDaAgent wmDaAgent) {
-//		SysDept sysDept1 = new SysDept();
-//		sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
-//		SysDept deptIds = sysDeptMapper.selectDeptId(sysDept1);
+
         SysDept deptIds = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
         WmDaDrugEnt wmDaDrugEnt = new WmDaDrugEnt();
         Integer wmDaDrugEnts = null;
@@ -904,10 +785,6 @@ public class WmDaAgentServiceImpl extends ServiceImpl<WmDaAgentMapper, WmDaAgent
     public List<WmDaAgent> listAgentByDeptRelation(Integer deptId) {
         return wmDaAgentMapper.listAgentByDeptRelation(deptId);
     }
-//	@Override
-//	public List selectByCsoIds(Integer id) {
-//		return wmDaAgentMapper.selectByCsoIds(id);
-//	}
 
 
 }

+ 589 - 724
hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/SysUserMapper.xml

@@ -2,760 +2,625 @@
 
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper">
-	<resultMap id="userResultMap" type="com.qunzhixinxi.hnqz.admin.api.entity.SysUser">
-		<id column="user_id" property="userId"/>
-		<result column="username" property="username"/>
-		<result column="password" property="password"/>
-		<result column="salt" property="salt"/>
-		<result column="phone" property="phone"/>
-		<result column="id_card_number" property="idCardNumber"/>
-		<result column="userSign" property="user_sign"/>
-		<result column="avatar" property="avatar"/>
-		<result column="wx_openid" property="wxOpenid"/>
-		<result column="qq_openid" property="qqOpenid"/>
-		<result column="create_time" property="createTime"/>
-		<result column="update_time" property="updateTime"/>
-		<result column="lock_flag" property="lockFlag"/>
-		<result column="del_flag" property="delFlag"/>
-		<result column="dept_id" property="deptId"/>
-		<result column="tenant_id" property="tenantId"/>
-		<result column="dept_name" property="deptName"/>
-		<result column="realname" property="realname"/>
-		<result column="province" property="province"/>
-		<result column="city" property="city"/>
-		<result column="area" property="area"/>
-		<result column="address" property="address"/>
-		<result column="temp1" property="temp1"/>
-		<result column="temp2" property="temp2"/>
-		<result column="temp3" property="temp3"/>
-		<result column="temp4" property="temp4"/>
-		<result column="temp5" property="temp5"/>
-		<result column="w1" property="w1"/>
-		<result column="plat_id" property="platId"/>
-		<result column="drug_ent_id" property="drugEntId"/>
-		<result column="cert_status" property="certStatus"/>
-		<result column="rlj_cert_status" property="rljCertStatus"/>
-		<result column="cert_remark" property="certRemark"/>
-		<result column="province_code" property="provinceCode"/>
-		<result column="city_code" property="cityCode"/>
-		<result column="user_type" property="userType"/>
-		<result column="bank_card_number" property="bankCardNumber"/>
-		<result column="bank_phone" property="bankPhone"/>
-		<result column="tax_helper_agreement_signature" property="taxHelperAgreementSignature"/>
-	</resultMap>
+    <resultMap id="userResultMap" type="com.qunzhixinxi.hnqz.admin.api.entity.SysUser">
+        <id column="user_id" property="userId"/>
+        <result column="username" property="username"/>
+        <result column="password" property="password"/>
+        <result column="salt" property="salt"/>
+        <result column="phone" property="phone"/>
+        <result column="id_card_number" property="idCardNumber"/>
+        <result column="userSign" property="user_sign"/>
+        <result column="avatar" property="avatar"/>
+        <result column="wx_openid" property="wxOpenid"/>
+        <result column="qq_openid" property="qqOpenid"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="lock_flag" property="lockFlag"/>
+        <result column="del_flag" property="delFlag"/>
+        <result column="dept_id" property="deptId"/>
+        <result column="tenant_id" property="tenantId"/>
+        <result column="dept_name" property="deptName"/>
+        <result column="realname" property="realname"/>
+        <result column="temp1" property="temp1"/>
+        <result column="temp2" property="temp2"/>
+        <result column="temp3" property="temp3"/>
+        <result column="temp4" property="temp4"/>
+        <result column="temp5" property="temp5"/>
+        <result column="w1" property="w1"/>
+        <result column="plat_id" property="platId"/>
+        <result column="drug_ent_id" property="drugEntId"/>
+    </resultMap>
 
-	<!-- 通用查询映射结果 -->
-	<resultMap id="baseResultMap" type="com.qunzhixinxi.hnqz.admin.api.vo.UserVO">
-		<id column="user_id" property="userId"/>
-		<result column="username" property="username"/>
-		<result column="password" property="password"/>
-		<result column="salt" property="salt"/>
-		<result column="phone" property="phone"/>
-		<result column="id_card_number" property="idCardNumber"/>
-		<result column="userSign" property="user_sign"/>
-		<result column="avatar" property="avatar"/>
-		<result column="wx_openid" property="wxOpenid"/>
-		<result column="qq_openid" property="qqOpenid"/>
-		<result column="ucreate_time" property="createTime"/>
-		<result column="uupdate_time" property="updateTime"/>
-		<result column="lock_flag" property="lockFlag"/>
-		<result column="udel_flag" property="delFlag"/>
-		<result column="dept_id" property="deptId"/>
-		<result column="tenant_id" property="tenantId"/>
-		<result column="dept_name" property="deptName"/>
-		<result column="realname" property="realname"/>
-		<result column="province" property="province"/>
-		<result column="city" property="city"/>
-		<result column="area" property="area"/>
-		<result column="address" property="address"/>
-		<result column="temp1" property="temp1"/>
-		<result column="temp2" property="temp2"/>
-		<result column="temp3" property="temp3"/>
-		<result column="temp4" property="temp4"/>
-		<result column="temp5" property="temp5"/>
-		<result column="w1" property="w1"/>
-		<result column="plat_id" property="platId"/>
-		<result column="drug_ent_id" property="drugEntId"/>
-		<result column="cert_status" property="certStatus"/>
-		<result column="rlj_cert_status" property="rljCertStatus"/>
-		<result column="cert_remark" property="certRemark"/>
-		<result column="province_code" property="provinceCode"/>
-		<result column="city_code" property="cityCode"/>
-		<result column="user_type" property="userType"/>
-		<result column="bank_phone" property="bankPhone"/>
-		<result column="bank_card_number" property="bankCardNumber"/>
-		<result column="sign_agreement" property="signAgreement"/>
-		<result column="age_reminder" property="ageReminder"/>
-		<collection property="roleList" ofType="com.qunzhixinxi.hnqz.admin.api.entity.SysRole"
-					select="com.qunzhixinxi.hnqz.admin.mapper.SysRoleMapper.listRolesByUserId" column="user_id">
-		</collection>
-	</resultMap>
+    <!-- 通用查询映射结果 -->
+    <resultMap id="baseResultMap" type="com.qunzhixinxi.hnqz.admin.api.vo.UserVO">
+        <id column="user_id" property="userId"/>
+        <result column="username" property="username"/>
+        <result column="password" property="password"/>
+        <result column="salt" property="salt"/>
+        <result column="phone" property="phone"/>
+        <result column="id_card_number" property="idCardNumber"/>
+        <result column="userSign" property="user_sign"/>
+        <result column="avatar" property="avatar"/>
+        <result column="wx_openid" property="wxOpenid"/>
+        <result column="qq_openid" property="qqOpenid"/>
+        <result column="ucreate_time" property="createTime"/>
+        <result column="uupdate_time" property="updateTime"/>
+        <result column="lock_flag" property="lockFlag"/>
+        <result column="udel_flag" property="delFlag"/>
+        <result column="dept_id" property="deptId"/>
+        <result column="tenant_id" property="tenantId"/>
+        <result column="dept_name" property="deptName"/>
+        <result column="realname" property="realname"/>
+        <result column="address" property="address"/>
+        <result column="temp1" property="temp1"/>
+        <result column="temp2" property="temp2"/>
+        <result column="temp3" property="temp3"/>
+        <result column="temp4" property="temp4"/>
+        <result column="temp5" property="temp5"/>
+        <result column="w1" property="w1"/>
+        <result column="plat_id" property="platId"/>
+        <result column="drug_ent_id" property="drugEntId"/>
+        <result column="sign_agreement" property="signAgreement"/>
+        <result column="age_reminder" property="ageReminder"/>
+        <collection property="roleList" ofType="com.qunzhixinxi.hnqz.admin.api.entity.SysRole"
+                    select="com.qunzhixinxi.hnqz.admin.mapper.SysRoleMapper.listRolesByUserId" column="user_id">
+        </collection>
+    </resultMap>
 
-	<!-- userVo结果集 -->
-	<resultMap id="userVoResultMap" type="com.qunzhixinxi.hnqz.admin.api.vo.UserVO">
-		<id column="user_id" property="userId"/>
-		<result column="username" property="username"/>
-		<result column="password" property="password"/>
-		<result column="salt" property="salt"/>
-		<result column="phone" property="phone"/>
-		<result column="id_card_number" property="idCardNumber"/>
-		<result column="avatar" property="avatar"/>
-		<result column="wx_openid" property="wxOpenid"/>
-		<result column="qq_openid" property="qqOpenid"/>
-		<result column="create_time" property="createTime"/>
-		<result column="update_time" property="updateTime"/>
-		<result column="lock_flag" property="lockFlag"/>
-		<result column="del_flag" property="delFlag"/>
-		<result column="dept_id" property="deptId"/>
-		<result column="tenant_id" property="tenantId"/>
-		<result column="dept_name" property="deptName"/>
-		<result column="realname" property="realname"/>
-		<result column="province" property="province"/>
-		<result column="city" property="city"/>
-		<result column="area" property="area"/>
-		<result column="address" property="address"/>
-		<result column="temp1" property="temp1"/>
-		<result column="temp2" property="temp2"/>
-		<result column="temp3" property="temp3"/>
-		<result column="temp4" property="temp4"/>
-		<result column="temp5" property="temp5"/>
-		<result column="plat_id" property="platId"/>
-		<result column="w1" property="w1"/>
-		<result column="drug_ent_id" property="drugEntId"/>
-		<result column="cert_status" property="certStatus"/>
-		<result column="rlj_cert_status" property="rljCertStatus"/>
-		<result column="cert_remark" property="certRemark"/>
-		<result column="province_code" property="provinceCode"/>
-		<result column="city_code" property="cityCode"/>
-		<result column="user_type" property="userType"/>
-		<result column="bank_phone" property="bankPhone"/>
-		<result column="bank_card_number" property="bankCardNumber"/>
-		<collection property="roleList" ofType="com.qunzhixinxi.hnqz.admin.api.entity.SysRole">
-			<id column="role_id" property="roleId"/>
-			<result column="role_name" property="roleName"/>
-			<result column="role_code" property="roleCode"/>
-			<result column="role_desc" property="roleDesc"/>
-			<result column="rcreate_time" property="createTime"/>
-			<result column="rupdate_time" property="updateTime"/>
-		</collection>
-	</resultMap>
+    <!-- userVo结果集 -->
+    <resultMap id="userVoResultMap" type="com.qunzhixinxi.hnqz.admin.api.vo.UserVO">
+        <id column="user_id" property="userId"/>
+        <result column="username" property="username"/>
+        <result column="password" property="password"/>
+        <result column="salt" property="salt"/>
+        <result column="phone" property="phone"/>
+        <result column="id_card_number" property="idCardNumber"/>
+        <result column="avatar" property="avatar"/>
+        <result column="wx_openid" property="wxOpenid"/>
+        <result column="qq_openid" property="qqOpenid"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="lock_flag" property="lockFlag"/>
+        <result column="del_flag" property="delFlag"/>
+        <result column="dept_id" property="deptId"/>
+        <result column="tenant_id" property="tenantId"/>
+        <result column="dept_name" property="deptName"/>
+        <result column="realname" property="realname"/>
+        <result column="address" property="address"/>
+        <result column="temp1" property="temp1"/>
+        <result column="temp2" property="temp2"/>
+        <result column="temp3" property="temp3"/>
+        <result column="temp4" property="temp4"/>
+        <result column="temp5" property="temp5"/>
+        <result column="plat_id" property="platId"/>
+        <result column="w1" property="w1"/>
+        <result column="drug_ent_id" property="drugEntId"/>
+        <collection property="roleList" ofType="com.qunzhixinxi.hnqz.admin.api.entity.SysRole">
+            <id column="role_id" property="roleId"/>
+            <result column="role_name" property="roleName"/>
+            <result column="role_code" property="roleCode"/>
+            <result column="role_desc" property="roleDesc"/>
+            <result column="rcreate_time" property="createTime"/>
+            <result column="rupdate_time" property="updateTime"/>
+        </collection>
+    </resultMap>
 
 
+    <sql id="userRoleSql">
+        distinct
+        u.user_id,
+        u.username,
+        u.password,
+        u.salt,
+        u.phone,
+        u.id_card_number,
+        u.user_type,
+        u.bank_card_number,
+        u.avatar,
+        u.wx_openid,
+        u.qq_openid,
+        u.dept_id,
+        u.del_flag,
+        u.lock_flag,
+        u.tenant_id,
+        u.create_time ucreate_time,
+        u.update_time uupdate_time,
+        r.role_id,
+        r.role_name,
+        r.role_code,
+        r.role_desc,
+        r.create_time rcreate_time,
+        r.update_time rupdate_time,
+        u.realname,
+        u.temp1,
+        u.temp2,
+        u.temp3,
+        u.temp4,
+        u.temp5,
+        u.plat_id,
+        u.drug_ent_id,
+        u.w1,
+        r.role_id,
+        r.role_name,
+        r.role_code,
+        r.role_desc,
+        r.create_time rcreate_time,
+        r.update_time rupdate_time
+    </sql>
 
-	<sql id="userRoleSql">
-		distinct
-		u.user_id,
-		u.username,
-		u.password,
-		u.salt,
-		u.phone,
-		u.id_card_number,
-		u.user_type,
-		u.bank_card_number,
-		u.avatar,
-		u.wx_openid,
-		u.qq_openid,
-		u.dept_id,
-		u.del_flag,
-		u.lock_flag,
-		u.tenant_id,
-		u.create_time  ucreate_time,
-		u.update_time  uupdate_time,
-		r.role_id,
-		r.role_name,
-		r.role_code,
-		r.role_desc,
-		r.create_time  rcreate_time,
-		r.update_time  rupdate_time,
-		u.realname,
-		u.province,
-		u.city,
-		u.province_code,
-		u.city_code,
-		u.area,
-		u.address,
-		u.temp1,
-		u.temp2,
-		u.temp3,
-		u.temp4,
-		u.temp5,
-		u.plat_id,
-		u.drug_ent_id,
-		u.cert_status,
-		u.rlj_cert_status,
-		u.cert_remark,
-		u.w1,
-		r.role_id,
-		r.role_name,
-		r.role_code,
-		r.role_desc,
-		r.create_time  rcreate_time,
-		r.update_time  rupdate_time
-	</sql>
-
-	<sql id="userRoleDeptSql">
-		distinct
-		u.user_id,
-		u.username,
-		u.password,
-		u.salt,
-		u.phone,
-		u.id_card_number,
-		u.user_type,
-		u.bank_card_number,
-		u.avatar,
-		u.wx_openid,
-		u.qq_openid,
-		u.del_flag,
-		u.lock_flag,
-		u.tenant_id,
-		u.create_time  ucreate_time,
-		u.update_time  uupdate_time,
-		r.role_id,
-		r.role_name,
-		r.role_code,
-		r.role_desc,
-		r.create_time  rcreate_time,
-		r.update_time  rupdate_time,
-		u.realname,
-		u.province,
-		u.city,
-		u.province_code,
-		u.city_code,
-		u.area,
-		u.address,
-		u.temp1,
-		u.temp2,
-		u.temp3,
-		u.temp4,
-		u.temp5,
-		u.plat_id,
-		u.drug_ent_id,
-		u.cert_status,
-		u.rlj_cert_status,
-		u.cert_remark,
-		u.w1,
-		r.role_id,
-		r.role_name,
-		r.role_code,
-		r.role_desc,
-		r.create_time  rcreate_time,
-		r.update_time  rupdate_time,
-		d.name  dept_name,
-		d.dept_id
+    <sql id="userRoleDeptSql">
+        distinct
+        u.user_id,
+        u.username,
+        u.password,
+        u.salt,
+        u.phone,
+        u.id_card_number,
+        u.user_type,
+        u.bank_card_number,
+        u.avatar,
+        u.wx_openid,
+        u.qq_openid,
+        u.del_flag,
+        u.lock_flag,
+        u.tenant_id,
+        u.create_time ucreate_time,
+        u.update_time uupdate_time,
+        r.role_id,
+        r.role_name,
+        r.role_code,
+        r.role_desc,
+        r.create_time rcreate_time,
+        r.update_time rupdate_time,
+        u.realname,
+        u.temp1,
+        u.temp2,
+        u.temp3,
+        u.temp4,
+        u.temp5,
+        u.plat_id,
+        u.drug_ent_id,
+        u.cert_status,
+        u.rlj_cert_status,
+        u.cert_remark,
+        u.w1,
+        r.role_id,
+        r.role_name,
+        r.role_code,
+        r.role_desc,
+        r.create_time rcreate_time,
+        r.update_time rupdate_time,
+        d.name dept_name,
+        d.dept_id
     </sql>
 
-	<select id="selectByDeptId" resultMap="userVoResultMap">
-		SELECT
-		*
-		FROM
-		sys_user  u
-		LEFT JOIN sys_dept  d ON d.dept_id = u.dept_id
-		LEFT JOIN sys_user_role  ur ON ur.user_id = u.user_id
-		LEFT JOIN sys_role  r ON r.role_id = ur.role_id
-		LEFT JOIN sys_dept_sub s ON s.dept_id = u.dept_id and s.enable_flag = '1'
-		where
-		u.del_flag = 0
-		<if test="query.username != null and query.username !=''">
-			AND u.username like CONCAT('%',#{query.username},'%')
-		</if>
-		<if test="query.realname != null and query.realname !=''">
-			AND u.realname like CONCAT('%',#{query.realname},'%')
-		</if>
-		<if test="query.deptId != null and query.deptId != ''">
-			AND u.dept_id = #{query.deptId}
-		</if>
-		<if test="query.certStatus != null and query.certStatus != ''">
-			<choose>
-				<when test="query.certStatus == 10">
-					AND (u.cert_status = #{query.certStatus} OR u.cert_status IS NULL)
-				</when>
-				<otherwise>
-					AND u.cert_status = #{query.certStatus}
-				</otherwise>
-			</choose>
-		</if>
-		<if test="query.rljCertStatus != null and query.rljCertStatus != ''">
-			<choose>
-				<when test="query.rljCertStatus == 4">
-					AND (u.rlj_cert_status = #{query.rljCertStatus} OR u.rlj_cert_status IS NULL)
-				</when>
-				<otherwise>
-					AND u.rlj_cert_status = #{query.rljCertStatus}
-				</otherwise>
-			</choose>
-		</if>
-		<if test="query.subType != null and query.subType != ''">
-			AND s.subject_type = #{query.subType}
-		</if>
-		<if test="query.lockFlag != null and query.lockFlag != ''">
-			AND u.lock_flag = #{query.lockFlag}
-		</if>
-		<if test="query.role != null and query.role.size()>0">
-			AND r.role_id in (
-			<foreach collection="query.role" item="pid" index="index" separator=",">
-				#{pid}
-			</foreach>
-			)
-		</if>
-		<if test="query.userIdList != null and query.userIdList.size() > 0">
-			AND u.user_id in (
-			<foreach collection="query.userIdList" item="userId" index="index" separator=",">
-				#{userId}
-			</foreach>
-			)
-		</if>
-	</select>
+    <select id="selectByDeptId" resultMap="userVoResultMap">
+        SELECT
+        *
+        FROM
+        sys_user u
+        LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        LEFT JOIN sys_dept_sub s ON s.dept_id = u.dept_id and s.enable_flag = '1'
+        where
+        u.del_flag = 0
+        <if test="query.username != null and query.username !=''">
+            AND u.username like CONCAT('%',#{query.username},'%')
+        </if>
+        <if test="query.realname != null and query.realname !=''">
+            AND u.realname like CONCAT('%',#{query.realname},'%')
+        </if>
+        <if test="query.deptId != null and query.deptId != ''">
+            AND u.dept_id = #{query.deptId}
+        </if>
+        <if test="query.lockFlag != null and query.lockFlag != ''">
+            AND u.lock_flag = #{query.lockFlag}
+        </if>
+        <if test="query.role != null and query.role.size()>0">
+            AND r.role_id in (
+            <foreach collection="query.role" item="pid" index="index" separator=",">
+                #{pid}
+            </foreach>
+            )
+        </if>
+        <if test="query.userIdList != null and query.userIdList.size() > 0">
+            AND u.user_id in (
+            <foreach collection="query.userIdList" item="userId" index="index" separator=",">
+                #{userId}
+            </foreach>
+            )
+        </if>
+    </select>
 
-	<select id="selectByPhone" resultMap="userVoResultMap">
-		SELECT
-		*
-		FROM
-		sys_user  u
-		LEFT JOIN sys_user_role  ur ON ur.user_id = u.user_id
-		LEFT JOIN sys_role  r ON r.role_id = ur.role_id
-		where
-		u.del_flag = 0
-		<if test="query.username != null and query.username !=''">
-			AND u.username = #{query.username}
-		</if>
-		<if test="query.role != null and query.role.size()>0">
-			AND r.role_id in (
-			<foreach collection="query.role" item="pid" index="index" separator=",">
-				#{pid}
-			</foreach>
-			)
-		</if>
-	</select>
+    <select id="selectByPhone" resultMap="userVoResultMap">
+        SELECT
+        *
+        FROM
+        sys_user u
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        where
+        u.del_flag = 0
+        <if test="query.username != null and query.username !=''">
+            AND u.username = #{query.username}
+        </if>
+        <if test="query.role != null and query.role.size()>0">
+            AND r.role_id in (
+            <foreach collection="query.role" item="pid" index="index" separator=",">
+                #{pid}
+            </foreach>
+            )
+        </if>
+    </select>
 
-	<select id="getUserVoByUsername" resultMap="userVoResultMap">
-		SELECT
-			<include refid="userRoleSql"/>
-		FROM
-		sys_user  u
-		LEFT JOIN sys_user_role  ur ON ur.user_id = u.user_id
-		LEFT JOIN sys_role  r ON r.role_id = ur.role_id
-			WHERE u.username = #{username} and r.role_id not in (5,6)
-			and u.lock_flag=0
-	</select>
+    <select id="getUserVoByUsername" resultMap="userVoResultMap">
+        SELECT
+        <include refid="userRoleSql"/>
+        FROM
+        sys_user u
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        WHERE u.username = #{username} and r.role_id not in (5,6)
+        and u.lock_flag=0
+    </select>
 
-	<select id="getUserVoById" resultMap="userVoResultMap">
+    <select id="getUserVoById" resultMap="userVoResultMap">
         SELECT
-	   		<include refid="userRoleDeptSql"/>
+        <include refid="userRoleDeptSql"/>
         FROM
-            sys_user  u
-            LEFT JOIN sys_user_role  ur ON ur.user_id = u.user_id
-            LEFT JOIN sys_role  r ON r.role_id = ur.role_id
-            LEFT JOIN sys_dept  d ON d.dept_id = u.dept_id
+        sys_user u
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
         WHERE
-           u.user_id = #{id}
-           and u.lock_flag=0
+        u.user_id = #{id}
+        and u.lock_flag=0
     </select>
 
-	<select id="getByIdIgnore" resultMap="userResultMap">
-		SELECT * FROM sys_user  where user_id = #{id}
-	</select>
-
-	<select id="selectByUserId" resultMap="userVoResultMap">
-		SELECT
-		*
-		FROM
-		sys_user  u
-		LEFT JOIN sys_dept  d ON d.dept_id = u.dept_id
-		LEFT JOIN sys_user_role  ur ON ur.user_id = u.user_id
-		LEFT JOIN sys_role  r ON r.role_id = ur.role_id
-		where
-		u.del_flag = 0
-		<if test="query.username != null and query.username !=''">
-			AND u.username like CONCAT('%',#{query.username},'%')
-		</if>
-		<if test="query.realname != null and query.realname !=''">
-			AND u.realname like CONCAT('%',#{query.realname},'%')
-		</if>
-		<if test="query.userId != null and query.userId != ''">
-			AND u.user_id = #{query.userId}
-		</if>
-		<if test="query.lockFlag != null and query.lockFlag != ''">
-			AND u.lock_flag = #{query.lockFlag}
-		</if>
-		<if test="query.role != null and query.role.size()>0">
-			AND r.role_id in (
-			<foreach collection="query.role" item="pid" index="index" separator=",">
-				#{pid}
-			</foreach>
-			)
-		</if>
-	</select>
+    <select id="getByIdIgnore" resultMap="userResultMap">
+        SELECT * FROM sys_user where user_id = #{id}
+    </select>
 
-	<select id="selectUserByName" resultMap="userResultMap">
-		SELECT
-		*
-		FROM
-		sys_user
-		where
-		username = #{username}
-		and
-		dept_id = #{deptId}
-	</select>
+    <select id="selectByUserId" resultMap="userVoResultMap">
+        SELECT
+        *
+        FROM
+        sys_user u
+        LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        where
+        u.del_flag = 0
+        <if test="query.username != null and query.username !=''">
+            AND u.username like CONCAT('%',#{query.username},'%')
+        </if>
+        <if test="query.realname != null and query.realname !=''">
+            AND u.realname like CONCAT('%',#{query.realname},'%')
+        </if>
+        <if test="query.userId != null and query.userId != ''">
+            AND u.user_id = #{query.userId}
+        </if>
+        <if test="query.lockFlag != null and query.lockFlag != ''">
+            AND u.lock_flag = #{query.lockFlag}
+        </if>
+        <if test="query.role != null and query.role.size()>0">
+            AND r.role_id in (
+            <foreach collection="query.role" item="pid" index="index" separator=",">
+                #{pid}
+            </foreach>
+            )
+        </if>
+    </select>
 
-	<select id="selectUserById" resultMap="userResultMap">
-		SELECT
-		*
-		FROM
-		sys_user
-		where
-		dept_id = #{deptId}
-	</select>
+    <select id="selectUserByName" resultMap="userResultMap">
+        SELECT
+        *
+        FROM
+        sys_user
+        where
+        username = #{username}
+        and
+        dept_id = #{deptId}
+    </select>
 
-	<select id="getUserVosPage" resultMap="baseResultMap">
-		SELECT
-		distinct
-		u.user_id,
-		u.username,
-		u.password,
-		u.id_card_number,
-		u.user_type,
-		u.salt,
-		u.phone,
-		u.avatar,
-		u.wx_openid,
-		u.qq_openid,
-		u.dept_id,
-		u.create_time  ucreate_time,
-		u.update_time  uupdate_time,
-		u.del_flag,
-		u.lock_flag,
-		u.tenant_id,
-		d.name  dept_name,
-		u.realname,
-		u.province,
-		u.city,
-		u.province_code,
-		u.city_code,
-		u.area,
-		u.address,
-		u.temp1,
-		u.temp2,
-		u.temp3,
-		u.temp4,
-		u.temp5,
-		u.w1,
-		u.plat_id,
-		u.drug_ent_id,
-		u.cert_status,
-		u.rlj_cert_status,
-		u.cert_remark,
-		u.bank_card_number
-		FROM
-		sys_user  u
-		LEFT JOIN sys_dept  d ON d.dept_id = u.dept_id
-		LEFT JOIN sys_user_role  ur ON ur.user_id = u.user_id
-		LEFT JOIN sys_role  r ON r.role_id = ur.role_id
-		LEFT JOIN sys_dept_sub s ON s.dept_id = u.dept_id and s.enable_flag = '1'
-		<if test="query.csmUserIdList != null and query.csmUserIdList.size() > 0">
-			left join sys_dept_csm dc on dc.dept_id=u.dept_id
-		</if>
-		<where>
-			u.del_flag = '0'
-			<if test="query.username != null and query.username != ''">
-				AND u.username LIKE CONCAT('%',#{query.username},'%')
-			</if>
-			<if test="query.realname != null and query.realname != ''">
-				AND u.realname LIKE CONCAT('%',#{query.realname},'%')
-			</if>
-			<if test="query.deptId != null and query.deptId != ''">
-				AND u.dept_id = #{query.deptId}
-			</if>
-			<if test="query.certStatus != null and query.certStatus != ''">
-				<choose>
-					<when test="query.certStatus == 10">
-						AND (u.cert_status = #{query.certStatus} OR u.cert_status IS NULL)
-					</when>
-					<otherwise>
-						AND u.cert_status = #{query.certStatus}
-					</otherwise>
-				</choose>
-			</if>
-			<if test="query.rljCertStatus != null and query.rljCertStatus != ''">
-				<choose>
-					<when test="query.rljCertStatus == 4">
-						AND (u.rlj_cert_status = #{query.rljCertStatus} OR u.rlj_cert_status IS NULL)
-					</when>
-					<otherwise>
-						AND u.rlj_cert_status = #{query.rljCertStatus}
-					</otherwise>
-				</choose>
-			</if>
-			<if test="query.subType != null and query.subType != ''">
-				AND s.subject_type = #{query.subType}
-			</if>
-			<if test="query.role != null and query.role.size()>0">
-				AND r.role_id in (
-				<foreach collection="query.role" item="pid" index="index" separator=",">
-					#{pid}
-				</foreach>
-				)
-			</if>
+    <select id="selectUserById" resultMap="userResultMap">
+        SELECT
+        *
+        FROM
+        sys_user
+        where
+        dept_id = #{deptId}
+    </select>
 
-			<if test="query.platId != null and query.platId != ''">
-				AND u.plat_id =#{query.platId}
-			</if>
-			<if test="query.lockFlag != null and query.lockFlag != ''">
-				AND u.lock_flag =#{query.lockFlag}
-			</if>
-			<if test="query.userIdList != null and query.userIdList.size() > 0">
-				AND u.user_id in (
-				<foreach collection="query.userIdList" item="userId" index="index" separator=",">
-					#{userId}
-				</foreach>
-				)
-			</if>
-			<if test="query.csmUserIdList != null and query.csmUserIdList.size() > 0">
-				and dc.user_id in (
-				<foreach collection="query.csmUserIdList" item="userId" index="index" separator=",">
-					#{userId}
-				</foreach>
-				)
-			</if>
-			AND <![CDATA[ u.username<>'admin']]>
-		</where>
-		ORDER BY u.create_time DESC
-	</select>
+    <select id="getUserVosPage" resultMap="baseResultMap">
+        SELECT
+        distinct
+        u.user_id,
+        u.username,
+        u.password,
+        u.id_card_number,
+        u.user_type,
+        u.salt,
+        u.phone,
+        u.avatar,
+        u.wx_openid,
+        u.qq_openid,
+        u.dept_id,
+        u.create_time ucreate_time,
+        u.update_time uupdate_time,
+        u.del_flag,
+        u.lock_flag,
+        u.tenant_id,
+        d.name dept_name,
+        u.realname,
+        u.temp1,
+        u.temp2,
+        u.temp3,
+        u.temp4,
+        u.temp5,
+        u.w1,
+        u.plat_id,
+        u.drug_ent_id
+        FROM
+        sys_user u
+        LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        <if test="query.csmUserIdList != null and query.csmUserIdList.size() > 0">
+            left join sys_dept_csm dc on dc.dept_id=u.dept_id
+        </if>
+        <where>
+            u.del_flag = '0'
+            <if test="query.username != null and query.username != ''">
+                AND u.username LIKE CONCAT('%',#{query.username},'%')
+            </if>
+            <if test="query.realname != null and query.realname != ''">
+                AND u.realname LIKE CONCAT('%',#{query.realname},'%')
+            </if>
+            <if test="query.deptId != null and query.deptId != ''">
+                AND u.dept_id = #{query.deptId}
+            </if>
+            <if test="query.role != null and query.role.size()>0">
+                AND r.role_id in (
+                <foreach collection="query.role" item="pid" index="index" separator=",">
+                    #{pid}
+                </foreach>
+                )
+            </if>
+            <if test="query.platId != null and query.platId != ''">
+                AND u.plat_id =#{query.platId}
+            </if>
+            <if test="query.lockFlag != null and query.lockFlag != ''">
+                AND u.lock_flag =#{query.lockFlag}
+            </if>
+            <if test="query.userIdList != null and query.userIdList.size() > 0">
+                AND u.user_id in (
+                <foreach collection="query.userIdList" item="userId" index="index" separator=",">
+                    #{userId}
+                </foreach>
+                )
+            </if>
+            <if test="query.csmUserIdList != null and query.csmUserIdList.size() > 0">
+                and dc.user_id in (
+                <foreach collection="query.csmUserIdList" item="userId" index="index" separator=",">
+                    #{userId}
+                </foreach>
+                )
+            </if>
+            AND <![CDATA[ u.username<>'admin']]>
+        </where>
+        ORDER BY u.create_time DESC
+    </select>
 
-	<select id="getUserVosPageNoLock" resultMap="baseResultMap">
-		SELECT
-		distinct
-		u.user_id,
-		u.username,
-		u.password,
-		u.id_card_number,
-		u.user_type,
-		u.salt,
-		u.phone,
-		u.avatar,
-		u.wx_openid,
-		u.qq_openid,
-		u.dept_id,
-		u.create_time  ucreate_time,
-		u.update_time  uupdate_time,
-		u.del_flag,
-		u.lock_flag,
-		u.tenant_id,
-		d.name  dept_name,
-		u.realname,
-		u.province,
-		u.city,
-		u.area,
-		u.province_code,
-		u.city_code,
-		u.address,
-		u.temp1,
-		u.temp2,
-		u.temp3,
-		u.temp4,
-		u.temp5,
-		u.w1,
-		u.plat_id,
-		u.drug_ent_id,
-		u.cert_status,
-		u.rlj_cert_status,
-		u.cert_remark,
-		u.bank_card_number
-		FROM
-		sys_user  u
-		LEFT JOIN sys_dept  d ON d.dept_id = u.dept_id
-		LEFT JOIN sys_user_role  ur ON ur.user_id = u.user_id
-		LEFT JOIN sys_role  r ON r.role_id = ur.role_id
-		<where>
-			u.del_flag = '0'
-			<if test="query.username != null and query.username != ''">
-				AND u.username LIKE CONCAT('%',#{query.username},'%')
-			</if>
-			<if test="query.realname != null and query.realname != ''">
-				AND u.realname LIKE CONCAT('%',#{query.realname},'%')
-			</if>
-			<if test="query.deptId != null and query.deptId != ''">
-				AND u.dept_id = #{query.deptId}
-			</if>
-			<if test="query.role != null and query.role.size()>0">
-				AND r.role_id in (
-				<foreach collection="query.role" item="pid" index="index" separator=",">
-					#{pid}
-				</foreach>
-				)
-			</if>
+    <select id="getUserVosPageNoLock" resultMap="baseResultMap">
+        SELECT
+        distinct
+        u.user_id,
+        u.username,
+        u.password,
+        u.id_card_number,
+        u.user_type,
+        u.salt,
+        u.phone,
+        u.avatar,
+        u.wx_openid,
+        u.qq_openid,
+        u.dept_id,
+        u.create_time ucreate_time,
+        u.update_time uupdate_time,
+        u.del_flag,
+        u.lock_flag,
+        u.tenant_id,
+        d.name dept_name,
+        u.realname,
+        u.temp1,
+        u.temp2,
+        u.temp3,
+        u.temp4,
+        u.temp5,
+        u.w1,
+        u.plat_id,
+        u.drug_ent_id
+        FROM
+        sys_user u
+        LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        <where>
+            u.del_flag = '0'
+            <if test="query.username != null and query.username != ''">
+                AND u.username LIKE CONCAT('%',#{query.username},'%')
+            </if>
+            <if test="query.realname != null and query.realname != ''">
+                AND u.realname LIKE CONCAT('%',#{query.realname},'%')
+            </if>
+            <if test="query.deptId != null and query.deptId != ''">
+                AND u.dept_id = #{query.deptId}
+            </if>
+            <if test="query.role != null and query.role.size()>0">
+                AND r.role_id in (
+                <foreach collection="query.role" item="pid" index="index" separator=",">
+                    #{pid}
+                </foreach>
+                )
+            </if>
 
-			<if test="query.platId != null and query.platId != ''">
-				AND u.plat_id =#{query.platId}
-			</if>
-			AND <![CDATA[ u.username<>'admin']]>
-		</where>
-		ORDER BY u.create_time DESC
-	</select>
+            <if test="query.platId != null and query.platId != ''">
+                AND u.plat_id =#{query.platId}
+            </if>
+            AND <![CDATA[ u.username<>'admin']]>
+        </where>
+        ORDER BY u.create_time DESC
+    </select>
 
 
-	<select id="getUserVoByPlatId" resultMap="baseResultMap">
-		SELECT
-		distinct
-		u.user_id,
-		u.username,
-		u.password,
-		u.id_card_number,
-		u.user_type,
-		u.user_sign,
-		u.salt,
-		u.phone,
-		u.avatar,
-		u.wx_openid,
-		u.qq_openid,
-		u.dept_id,
-		u.create_time  ucreate_time,
-		u.update_time  uupdate_time,
-		u.del_flag,
-		u.lock_flag,
-		u.tenant_id,
-		d.name  dept_name,
-		u.realname,
-		u.province,
-		u.city,
-		u.province_code,
-		u.city_code,
-		u.area,
-		u.address,
-		u.temp1,
-		u.temp2,
-		u.temp3,
-		u.temp4,
-		u.temp5,
-		u.w1,
-		u.plat_id,
-		u.drug_ent_id,
-		u.cert_status,
-		u.rlj_cert_status,
-		u.cert_remark,
-		u.bank_card_number,
-	  	u.bank_phone,
-	  	u.bank_name,
-		u.tax_helper_agreement_signature,
-		u.sign_agreement,
-		u.age_reminder,
-		u.re_signed_agreement
-		FROM
-		sys_user  u
-		LEFT JOIN sys_dept  d ON d.dept_id = u.dept_id
-		LEFT JOIN sys_user_role  ur ON ur.user_id = u.user_id
-		LEFT JOIN sys_role  r ON r.role_id = ur.role_id
-		<where>
-			u.del_flag = '0'
-			and u.lock_flag=0
-			<if test="query.username != null and query.username != ''">
-				AND u.username LIKE CONCAT('%',#{query.username},'%')
-			</if>
-			<if test="query.realname != null and query.realname != ''">
-				AND u.realname LIKE CONCAT('%',#{query.realname},'%')
-			</if>
-			<if test="query.deptId != null and query.deptId != ''">
-				AND u.dept_id = #{query.deptId}
-			</if>
-			<if test="query.role != null and query.role.size()>0">
-				AND r.role_id in (
-				<foreach collection="query.role" item="pid" index="index" separator=",">
-					#{pid}
-				</foreach>
-				)
-			</if>
+    <select id="getUserVoByPlatId" resultMap="baseResultMap">
+        SELECT
+        distinct
+        u.user_id,
+        u.username,
+        u.password,
+        u.id_card_number,
+        u.user_type,
+        u.user_sign,
+        u.salt,
+        u.phone,
+        u.avatar,
+        u.wx_openid,
+        u.qq_openid,
+        u.dept_id,
+        u.create_time ucreate_time,
+        u.update_time uupdate_time,
+        u.del_flag,
+        u.lock_flag,
+        u.tenant_id,
+        d.name dept_name,
+        u.realname,
+        u.temp1,
+        u.temp2,
+        u.temp3,
+        u.temp4,
+        u.temp5,
+        u.w1,
+        u.plat_id,
+        u.drug_ent_id,
+        u.sign_agreement,
+        u.age_reminder,
+        u.re_signed_agreement
+        FROM
+        sys_user u
+        LEFT JOIN sys_dept d ON d.dept_id = u.dept_id
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        <where>
+            u.del_flag = '0'
+            and u.lock_flag=0
+            <if test="query.username != null and query.username != ''">
+                AND u.username LIKE CONCAT('%',#{query.username},'%')
+            </if>
+            <if test="query.realname != null and query.realname != ''">
+                AND u.realname LIKE CONCAT('%',#{query.realname},'%')
+            </if>
+            <if test="query.deptId != null and query.deptId != ''">
+                AND u.dept_id = #{query.deptId}
+            </if>
+            <if test="query.role != null and query.role.size()>0">
+                AND r.role_id in (
+                <foreach collection="query.role" item="pid" index="index" separator=",">
+                    #{pid}
+                </foreach>
+                )
+            </if>
 
-			<if test="query.platId != null and query.platId != ''">
-				AND u.plat_id =#{query.platId}
-			</if>
+            <if test="query.platId != null and query.platId != ''">
+                AND u.plat_id =#{query.platId}
+            </if>
 
-			<if test="query.drugEntId != null and query.drugEntId != ''">
-				AND u.drug_ent_id =#{query.drugEntId}
-			</if>
+            <if test="query.drugEntId != null and query.drugEntId != ''">
+                AND u.drug_ent_id =#{query.drugEntId}
+            </if>
 
-		</where>
-		ORDER BY u.create_time DESC
-	</select>
+        </where>
+        ORDER BY u.create_time DESC
+    </select>
 
-	<!-- 根据部门id和角色id查询 -->
-	<select id="selectByDeptIdAndRoleId" resultMap="userResultMap">
-		SELECT
-			u.user_id,
-			u.username,
-			u.phone,
-			u.avatar,
-			u.dept_id,
-			u.create_time,
-			u.update_time,
-			r.role_id,
-			u.realname
-		FROM
-			sys_user u
-				LEFT JOIN sys_user_role r ON r.user_id = u.user_id
-		WHERE
-			u.dept_id = #{deptId}
-		  <if test="realNameOrPhone != null and realNameOrPhone != ''">
-		  	AND (u.username LIKE CONCAT('%',#{realNameOrPhone},'%') OR u.realname LIKE CONCAT('%',#{realNameOrPhone},'%'))
-		  </if>
-		  AND r.role_id IN (
-			<foreach collection="roleList" item="roleId" index="index" separator=",">
-				#{roleId}
-			</foreach>
-			)
-	</select>
+    <!-- 根据部门id和角色id查询 -->
+    <select id="selectByDeptIdAndRoleId" resultMap="userResultMap">
+        SELECT
+        u.user_id,
+        u.username,
+        u.phone,
+        u.avatar,
+        u.dept_id,
+        u.create_time,
+        u.update_time,
+        r.role_id,
+        u.realname
+        FROM
+        sys_user u
+        LEFT JOIN sys_user_role r ON r.user_id = u.user_id
+        WHERE
+        u.dept_id = #{deptId}
+        <if test="realNameOrPhone != null and realNameOrPhone != ''">
+            AND (u.username LIKE CONCAT('%',#{realNameOrPhone},'%') OR u.realname LIKE
+            CONCAT('%',#{realNameOrPhone},'%'))
+        </if>
+        AND r.role_id IN (
+        <foreach collection="roleList" item="roleId" index="index" separator=",">
+            #{roleId}
+        </foreach>
+        )
+    </select>
 
-	<update id="updateByPrimaryKeySelective" parameterType="com.qunzhixinxi.hnqz.admin.api.entity.SysUser" >
-		update sys_user
-		<set >
-			<if test="delFlag != null" >
-				del_flag = #{delFlag,jdbcType=VARCHAR},
-			</if>
-		</set>
-		where user_id = #{userId,jdbcType=BIGINT}
-	</update>
+    <update id="updateByPrimaryKeySelective" parameterType="com.qunzhixinxi.hnqz.admin.api.entity.SysUser">
+        update sys_user
+        <set>
+            <if test="delFlag != null">
+                del_flag = #{delFlag,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where user_id = #{userId,jdbcType=BIGINT}
+    </update>
 
 
-	<select id="listUserDetails" resultMap="baseResultMap">
-		SELECT u.user_id,
-			   u.realname,
-			   u.username,
-			   u.id_card_number,
-			   u.tenant_id,
-			   u.dept_id,
-			   u.bank_phone,
-		       us.bank_card_number,
-			   us.gig_type,
-			   us.cert_status
-		FROM sys_user u
-				 LEFT JOIN sys_user_sub us on us.user_id = u.user_id
-		<where>
-			u.user_id in
-			<foreach collection="userIds" index="idx" item="userId" open="(" close=")" separator=",">
-				#{userId}
-			</foreach>
-		</where>
+    <select id="listUserDetails" resultMap="baseResultMap">
+        SELECT u.user_id,
+        u.realname,
+        u.username,
+        u.id_card_number,
+        u.tenant_id,
+        u.dept_id,
+        FROM sys_user u
+        LEFT JOIN sys_user_sub us on us.user_id = u.user_id
+        <where>
+            u.user_id in
+            <foreach collection="userIds" index="idx" item="userId" open="(" close=")" separator=",">
+                #{userId}
+            </foreach>
+        </where>
 
-	</select>
+    </select>
 
-	<select id="listUserByRole" resultMap="baseResultMap">
-		SELECT
-		distinct
-		u.user_id,
-		u.username,
-		u.realname
-		FROM
-		sys_user  u
-		LEFT JOIN sys_user_role  ur ON ur.user_id = u.user_id
-		<where>
-			u.del_flag = '0'
-			<if test="query.role != null and query.role.size()>0">
-				AND ur.role_id in (
-				<foreach collection="query.role" item="pid" index="index" separator=",">
-					#{pid}
-				</foreach>
-				)
-			</if>
-		</where>
-		ORDER BY u.create_time DESC
-	</select>
+    <select id="listUserByRole" resultMap="baseResultMap">
+        SELECT
+        distinct
+        u.user_id,
+        u.username,
+        u.realname
+        FROM
+        sys_user u
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        <where>
+            u.del_flag = '0'
+            <if test="query.role != null and query.role.size()>0">
+                AND ur.role_id in (
+                <foreach collection="query.role" item="pid" index="index" separator=",">
+                    #{pid}
+                </foreach>
+                )
+            </if>
+        </where>
+        ORDER BY u.create_time DESC
+    </select>
 </mapper>