Browse Source

Merge branch 'develop' of http://git.ycjcjy.com/marketing/services into develop

Your Name 3 years ago
parent
commit
9f60259091

+ 2
- 3
src/main/java/com/yunzhi/marketing/xlk/controller/InstitutionController.java View File

62
             LambdaQueryWrapper<Institution> queryWrapper = new LambdaQueryWrapper<>();
62
             LambdaQueryWrapper<Institution> queryWrapper = new LambdaQueryWrapper<>();
63
             queryWrapper.eq(Institution::getOrgId,getOrgId(request));
63
             queryWrapper.eq(Institution::getOrgId,getOrgId(request));
64
             if (StringUtils.isEmpty(institutionCode)){
64
             if (StringUtils.isEmpty(institutionCode)){
65
-                queryWrapper.eq(Institution::getType,1);
65
+                queryWrapper.likeRight(Institution::getInstitutionCode,"01");
66
             }else {
66
             }else {
67
                 Institution institution = iInstitutionService.getById(institutionCode);
67
                 Institution institution = iInstitutionService.getById(institutionCode);
68
-                queryWrapper.eq(Institution::getType,institution.getType() + 1);
69
                 queryWrapper.likeRight(Institution::getInstitutionCode,institution.getInstitutionCode());
68
                 queryWrapper.likeRight(Institution::getInstitutionCode,institution.getInstitutionCode());
70
             }
69
             }
71
             queryWrapper.orderByDesc(Institution::getCreateDate);
70
             queryWrapper.orderByDesc(Institution::getCreateDate);
139
             Institution institution = new Institution();
138
             Institution institution = new Institution();
140
             BeanUtils.copyProperties(institutionDTO,institution);
139
             BeanUtils.copyProperties(institutionDTO,institution);
141
             institution.setOrgId(orgId);
140
             institution.setOrgId(orgId);
142
-            institution.setInstitutionCode(id);
141
+            institution.setInstitutionId(id);
143
              responseBean = iInstitutionService.updateInstitution(institution);
142
              responseBean = iInstitutionService.updateInstitution(institution);
144
         }catch (Exception e){
143
         }catch (Exception e){
145
             e.printStackTrace();
144
             e.printStackTrace();

+ 1
- 1
src/main/java/com/yunzhi/marketing/xlk/dto/InstitutionDTO.java View File

33
     /**
33
     /**
34
      * 组织代码
34
      * 组织代码
35
      */
35
      */
36
-    private String institutionId;
36
+    private String parentInstitutionId;
37
 }
37
 }

+ 3
- 5
src/main/java/com/yunzhi/marketing/xlk/entity/Institution.java View File

33
     @TableId(type = IdType.UUID)
33
     @TableId(type = IdType.UUID)
34
     private String institutionId;
34
     private String institutionId;
35
 
35
 
36
+    /** 父级组织机构id */
37
+    private String parentInstitutionId ;
38
+
36
     /**
39
     /**
37
      * 组织代码
40
      * 组织代码
38
      */
41
      */
48
      */
51
      */
49
     private Integer orgId;
52
     private Integer orgId;
50
 
53
 
51
-    /**
52
-     * 1是集团,2是区域子公司 3,是城市子公司
53
-     */
54
-    private Integer type;
55
-
56
     /**
54
     /**
57
      * 创建时间
55
      * 创建时间
58
      */
56
      */

+ 19
- 78
src/main/java/com/yunzhi/marketing/xlk/service/impl/InstitutionServiceImpl.java View File

11
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.beans.factory.annotation.Autowired;
12
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
13
 
13
 
14
+import java.time.LocalDateTime;
14
 import java.util.List;
15
 import java.util.List;
15
 
16
 
16
 /**
17
 /**
34
      */
35
      */
35
     @Override
36
     @Override
36
     public ResponseBean saveInstitution(Institution institution) {
37
     public ResponseBean saveInstitution(Institution institution) {
37
-        int institutionCodeLength = institution.getInstitutionCode().length();
38
-        if (institutionCodeLength != 2 && institutionCodeLength != 4 && institutionCodeLength != 6){
39
-            return ResponseBean.error("请输入合法长度的code", ResponseBean.ERROR_UNAVAILABLE);
40
-        }
41
 
38
 
39
+        Institution parentInstitution = institutionMapper.selectById(institution.getParentInstitutionId());
42
         // 根据code获取机构
40
         // 根据code获取机构
43
         LambdaQueryWrapper<Institution> queryWrapper = new LambdaQueryWrapper<>();
41
         LambdaQueryWrapper<Institution> queryWrapper = new LambdaQueryWrapper<>();
44
-        queryWrapper.eq(Institution::getInstitutionCode,institution.getInstitutionCode());
45
-        Institution childInstitution = institutionMapper.selectOne(queryWrapper);
46
-        if (null != childInstitution){
47
-            return ResponseBean.error("此组织机构code已存在", ResponseBean.ERROR_UNAVAILABLE);
48
-        }
49
-
50
-        // 判断组织机构长度
51
-        // 集团插入
52
-        if (institutionCodeLength == 2){
53
-            institution.setType(1);
54
-        }
55
-
56
-        // 子区域插入
57
-        if (institutionCodeLength == 4){
58
-            Institution blocInstitution = getChildInstitution(institution.getInstitutionCode(), 0, 2);
59
-            if (null == blocInstitution){
60
-                return ResponseBean.error("请输入合法的有层级的code", ResponseBean.ERROR_UNAVAILABLE);
61
-            }
62
-            institution.setType(2);
63
-        }
64
-
65
-        // 子区域插入
66
-        if (institutionCodeLength == 6){
67
-            Institution blocInstitution = getChildInstitution(institution.getInstitutionCode(), 0, 2);
68
-            if (null == blocInstitution){
69
-                return ResponseBean.error("请输入合法的有层级的code", ResponseBean.ERROR_UNAVAILABLE);
42
+        queryWrapper.eq(Institution::getParentInstitutionId,institution.getParentInstitutionId());
43
+        queryWrapper.orderByDesc(Institution::getInstitutionCode);
44
+        List<Institution> institutions = institutionMapper.selectList(queryWrapper);
45
+        if (institutions.size() > 0) {
46
+            Institution lastInstitution = institutions.get(0);
47
+            String institutionCode = lastInstitution.getInstitutionCode();
48
+            String firstCode = institutionCode.substring(0, institutionCode.length() - 2);
49
+            String lastCode = institutionCode.substring(institutionCode.length() - 2);
50
+            String currentCode =String.valueOf(Integer.parseInt(lastCode) + 1);
51
+            if (currentCode.length() == 1) {
52
+                institution.setInstitutionCode(firstCode + "0" +currentCode);
53
+            }else {
54
+                institution.setInstitutionCode(firstCode + currentCode);
70
             }
55
             }
71
 
56
 
72
-            Institution cityInstitution = getChildInstitution(institution.getInstitutionCode(), 2, 4);
73
-            if (null == cityInstitution){
74
-                return ResponseBean.error("请输入合法的有层级的code", ResponseBean.ERROR_UNAVAILABLE);
75
-            }
76
-            institution.setType(3);
57
+        }else {
58
+            institution.setInstitutionCode(parentInstitution.getInstitutionCode() + "01");
77
         }
59
         }
60
+
61
+        institution.setCreateDate(LocalDateTime.now());
78
         institutionMapper.insert(institution);
62
         institutionMapper.insert(institution);
79
 
63
 
80
         return ResponseBean.success(institution);
64
         return ResponseBean.success(institution);
107
      */
91
      */
108
     @Override
92
     @Override
109
     public ResponseBean updateInstitution(Institution institution) {
93
     public ResponseBean updateInstitution(Institution institution) {
110
-        int institutionCodeLength = institution.getInstitutionCode().length();
111
-        if (institutionCodeLength != 2 && institutionCodeLength != 4 && institutionCodeLength != 6){
112
-            return ResponseBean.error("请输入合法长度的code", ResponseBean.ERROR_UNAVAILABLE);
113
-        }
114
-
115
-        // 根据code获取机构
116
-        LambdaQueryWrapper<Institution> queryWrapper = new LambdaQueryWrapper<>();
117
-        queryWrapper.eq(Institution::getInstitutionCode,institution.getInstitutionCode());
118
-        queryWrapper.ne(Institution::getInstitutionCode,institution.getInstitutionCode());
119
-        Institution childInstitution = institutionMapper.selectOne(queryWrapper);
120
-        if (null != childInstitution){
121
-            return ResponseBean.error("此组织机构code已存在", ResponseBean.ERROR_UNAVAILABLE);
122
-        }
123
-
124
-        // 判断组织机构长度
125
-        // 集团插入
126
-        if (institutionCodeLength == 2){
127
-            institution.setType(1);
128
-        }
129
-
130
-        // 子区域插入
131
-        if (institutionCodeLength == 4){
132
-            Institution blocInstitution = getChildInstitution(institution.getInstitutionCode(), 0, 1);
133
-            if (null == blocInstitution){
134
-                return ResponseBean.error("请输入合法的有层级的code", ResponseBean.ERROR_UNAVAILABLE);
135
-            }
136
-            institution.setType(2);
137
-        }
138
-
139
-        // 子区域插入
140
-        if (institutionCodeLength == 6){
141
-            Institution blocInstitution = getChildInstitution(institution.getInstitutionCode(), 0, 1);
142
-            if (null == blocInstitution){
143
-                return ResponseBean.error("请输入合法的有层级的code", ResponseBean.ERROR_UNAVAILABLE);
144
-            }
145
-
146
-            Institution cityInstitution = getChildInstitution(institution.getInstitutionCode(), 2, 3);
147
-            if (null == cityInstitution){
148
-                return ResponseBean.error("请输入合法的有层级的code", ResponseBean.ERROR_UNAVAILABLE);
149
-            }
150
-            institution.setType(3);
151
-        }
152
         institutionMapper.updateById(institution);
94
         institutionMapper.updateById(institution);
153
-
154
         return ResponseBean.success(institution);
95
         return ResponseBean.success(institution);
155
     }
96
     }
156
 
97
 

+ 1
- 1
src/main/resources/mapper/TaRecommendCustomerMapper.xml View File

908
         xlk_channel_customer a
908
         xlk_channel_customer a
909
         LEFT JOIN ta_person b ON a.person_id = b.person_id
909
         LEFT JOIN ta_person b ON a.person_id = b.person_id
910
         where a.recommend_person = #{customerId}
910
         where a.recommend_person = #{customerId}
911
-        and a.status = 1
911
+        and a.status not in (2,3)
912
         <if test="status != null and status !=''">
912
         <if test="status != null and status !=''">
913
             and a.status = #{status}
913
             and a.status = #{status}
914
         </if>
914
         </if>