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

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

@@ -33,5 +33,5 @@ public class InstitutionDTO implements Serializable {
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,6 +33,9 @@ public class Institution implements Serializable {
33 33
     @TableId(type = IdType.UUID)
34 34
     private String institutionId;
35 35
 
36
+    /** 父级组织机构id */
37
+    private String parentInstitutionId ;
38
+
36 39
     /**
37 40
      * 组织代码
38 41
      */
@@ -48,11 +51,6 @@ public class Institution implements Serializable {
48 51
      */
49 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,6 +11,7 @@ import com.yunzhi.marketing.xlk.service.IInstitutionService;
11 11
 import org.springframework.beans.factory.annotation.Autowired;
12 12
 import org.springframework.stereotype.Service;
13 13
 
14
+import java.time.LocalDateTime;
14 15
 import java.util.List;
15 16
 
16 17
 /**
@@ -34,47 +35,30 @@ public class InstitutionServiceImpl extends ServiceImpl<InstitutionMapper, Insti
34 35
      */
35 36
     @Override
36 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 40
         // 根据code获取机构
43 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 62
         institutionMapper.insert(institution);
79 63
 
80 64
         return ResponseBean.success(institution);
@@ -107,50 +91,7 @@ public class InstitutionServiceImpl extends ServiceImpl<InstitutionMapper, Insti
107 91
      */
108 92
     @Override
109 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 94
         institutionMapper.updateById(institution);
153
-
154 95
         return ResponseBean.success(institution);
155 96
     }
156 97
 

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

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