|
@@ -3,12 +3,14 @@ package com.unis.module.coding.service.delivery;
|
3
|
3
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
4
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
5
|
5
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
6
|
|
-import com.unis.framework.common.util.kqbm.KQBMUtils;
|
|
6
|
+import com.unis.framework.common.util.orderNum.OrderNumberUtil;
|
7
|
7
|
import com.unis.module.coding.controller.admin.caxx.vo.CaxxSaveReqVO;
|
8
|
8
|
import com.unis.module.coding.controller.admin.cwxx.vo.CwxxSaveReqVO;
|
9
|
9
|
import com.unis.module.coding.controller.admin.cwxxyear.vo.CwxxYearSaveReqVO;
|
10
|
10
|
import com.unis.module.coding.controller.admin.delivery.vo.CaxxUpdateReqVO;
|
11
|
11
|
import com.unis.module.coding.controller.admin.delivery.vo.DeliverySaveVO;
|
|
12
|
+import com.unis.module.coding.dal.dataobject.cwxx.CwxxDO;
|
|
13
|
+import com.unis.module.coding.dal.dataobject.cwxxyear.CwxxYearDO;
|
12
|
14
|
import com.unis.module.coding.dal.dataobject.dwxx.DwxxDO;
|
13
|
15
|
import com.unis.module.coding.dal.dataobject.kqxx.KqxxDO;
|
14
|
16
|
import com.unis.module.coding.dal.mysql.cwxx.CwxxMapper;
|
|
@@ -25,8 +27,11 @@ import com.unis.module.system.dal.mysql.arealevel.AreaLevelMapper;
|
25
|
27
|
import lombok.extern.slf4j.Slf4j;
|
26
|
28
|
import org.springframework.stereotype.Service;
|
27
|
29
|
import org.springframework.transaction.annotation.Transactional;
|
|
30
|
+
|
28
|
31
|
import javax.annotation.Resource;
|
|
32
|
+import java.util.ArrayList;
|
29
|
33
|
import java.util.List;
|
|
34
|
+
|
30
|
35
|
import static com.unis.framework.common.exception.util.ServiceExceptionUtil.exception;
|
31
|
36
|
import static com.unis.module.infra.enums.ErrorCodeConstants.ERROR;
|
32
|
37
|
|
|
@@ -84,17 +89,19 @@ public class DeliveryServiceImpl implements DeliveryService {
|
84
|
89
|
List<DwxxDO> tyxydm1 = dwxxMapper.selectList(
|
85
|
90
|
new QueryWrapper<DwxxDO>()
|
86
|
91
|
.eq("TYXYDM", createReqVO.getDwxxReqVO().getTyxydm()));
|
|
92
|
+
|
|
93
|
+ log.info("根据统一信用编码查询单位是否存在,存在数量,({})", tyxydm1.size());
|
87
|
94
|
Long dwxx = null;
|
88
|
|
- //数据来源
|
89
|
|
- createReqVO.getDwxxReqVO().setSjly(0);
|
|
95
|
+
|
90
|
96
|
if (CollectionUtils.isEmpty(tyxydm1)) {
|
|
97
|
+ createReqVO.getDwxxReqVO().setSjly(0);
|
91
|
98
|
dwxx = dwxxService.createDwxx(createReqVO.getDwxxReqVO());
|
92
|
99
|
} else {
|
93
|
100
|
log.info("根据统一信用编码查询之前已经添加过该单位({})", tyxydm1.get(0).getId());
|
94
|
101
|
dwxx = tyxydm1.get(0).getId();
|
95
|
102
|
createReqVO.getDwxxReqVO().setId(dwxx);
|
96
|
103
|
//是交收库新建的单位就能更新
|
97
|
|
- if (tyxydm1.get(0).getSjly().equals(1)) {
|
|
104
|
+ if (tyxydm1.get(0).getSjly().equals(0)) {
|
98
|
105
|
dwxxService.updateDwxx(createReqVO.getDwxxReqVO());
|
99
|
106
|
} else {
|
100
|
107
|
log.info("该单位信息已经存在");
|
|
@@ -112,18 +119,23 @@ public class DeliveryServiceImpl implements DeliveryService {
|
112
|
119
|
new QueryWrapper<KqxxDO>()
|
113
|
120
|
.eq("DWID", dwxx)
|
114
|
121
|
.orderByDesc("CREATE_TIME"));
|
115
|
|
- //todo 同一单位(DELIVERY_DWXX)下多个库区,生成规则 01 02 ...
|
116
|
|
- String kqdm = "";
|
|
122
|
+ //同一单位(DELIVERY_DWXX)下多个库区,生成规则 01 02 ...
|
|
123
|
+ String kqdm = OrderNumberUtil.initNum(2, count.get(0).getKqdm());
|
|
124
|
+
|
117
|
125
|
createReqVO.getKqxxReqVO().setKqdm(kqdm);
|
118
|
|
- //库区编码
|
119
|
|
- String kqbm = "";
|
120
|
126
|
// 单位信息社会统一信用编码
|
121
|
127
|
String tyxydm = createReqVO.getDwxxReqVO().getTyxydm();
|
122
|
|
- tyxydm = tyxydm.length() <= 18 ? tyxydm : tyxydm.substring(0, 18);
|
|
128
|
+
|
123
|
129
|
//企业性质
|
124
|
130
|
String qyxz = createReqVO.getDwxxReqVO().getQyxz();
|
125
|
131
|
//todo 库区编码
|
126
|
|
- kqbm = KQBMUtils.createKQBM(qyxz, tyxydm, kqdm);
|
|
132
|
+ List kqbmlist = new ArrayList();
|
|
133
|
+ kqbmlist.add(qyxz);//企业性质
|
|
134
|
+ kqbmlist.add(tyxydm);//统一信用编码
|
|
135
|
+ kqbmlist.add(kqdm);//库区代码
|
|
136
|
+ String kqbm = OrderNumberUtil.generateCode(kqbmlist);
|
|
137
|
+ log.info("获取库区编码({})", kqbm);
|
|
138
|
+
|
127
|
139
|
createReqVO.getKqxxReqVO().setKqbm(kqbm);
|
128
|
140
|
//省市县编码获取
|
129
|
141
|
if (ObjectUtils.isNotEmpty(createReqVO.getKqxxReqVO().getSheng())) {
|
|
@@ -150,24 +162,56 @@ public class DeliveryServiceImpl implements DeliveryService {
|
150
|
162
|
caxx.setYxcf(1);
|
151
|
163
|
caxx.setKqid(kqxx);
|
152
|
164
|
caxx.setKqmc(createReqVO.getKqxxReqVO().getKqmc());
|
153
|
|
- //todo 仓房代码生成
|
154
|
|
- String cfdn = KQBMUtils.getCFDM(finalKqbm, caxx.getCfbm());
|
|
165
|
+ //仓房代码生成
|
|
166
|
+ List cfdnlist = new ArrayList();
|
|
167
|
+ cfdnlist.add(finalKqbm);//统一信用编码
|
|
168
|
+ cfdnlist.add(caxx.getCfbm());//库区代码
|
|
169
|
+ String cfdn = OrderNumberUtil.generateCode(cfdnlist);
|
155
|
170
|
caxx.setCfdm(cfdn);
|
156
|
171
|
caxxService.createCaxx(caxx);
|
|
172
|
+ log.info("仓房({})的仓房编码为({})", cfdn);
|
157
|
173
|
});
|
158
|
174
|
}
|
159
|
|
-
|
160
|
175
|
// --财务信息--------------------
|
161
|
176
|
CwxxSaveReqVO cwxxReqVO = createReqVO.getCwxxReqVO();
|
162
|
177
|
if (ObjectUtils.isNotEmpty(cwxxReqVO)) {
|
163
|
178
|
cwxxReqVO.setKqid(kqxx);
|
164
|
179
|
cwxxReqVO.setDeptId(dwxx);
|
165
|
|
- Long cwxx = cwxxService.createCwxx(cwxxReqVO);
|
|
180
|
+
|
|
181
|
+ Long cwxx = null;
|
|
182
|
+ List<CwxxDO> cwxxDOS = cwxxMapper.selectList(new QueryWrapper<CwxxDO>().eq("DEPT_ID", dwxx));
|
|
183
|
+ if (CollectionUtils.isEmpty(cwxxDOS)) {
|
|
184
|
+ cwxx = cwxxService.createCwxx(cwxxReqVO);
|
|
185
|
+ } else {
|
|
186
|
+ //更改
|
|
187
|
+ cwxx = cwxxDOS.get(0).getId();
|
|
188
|
+ cwxxReqVO.setId(cwxxDOS.get(0).getId());
|
|
189
|
+ cwxxService.updateCwxx(cwxxReqVO);
|
|
190
|
+ }
|
166
|
191
|
// ---财年信息-------------
|
167
|
192
|
if (CollectionUtils.isNotEmpty(cwxxReqVO.getCwxxYearList())) {
|
168
|
|
- for (CwxxYearSaveReqVO cwxxYear : cwxxReqVO.getCwxxYearList()) {
|
169
|
|
- cwxxYear.setCwxxId(cwxx);
|
170
|
|
- cwxxYearService.createCwxxYear(cwxxYear);
|
|
193
|
+ //以前添加过财年,更改
|
|
194
|
+ if (CollectionUtils.isEmpty(cwxxDOS)) {
|
|
195
|
+ for (CwxxYearSaveReqVO cwxxYear : cwxxReqVO.getCwxxYearList()) {
|
|
196
|
+ cwxxYear.setCwxxId(cwxx);
|
|
197
|
+ cwxxYearService.createCwxxYear(cwxxYear);
|
|
198
|
+ }
|
|
199
|
+ } else {
|
|
200
|
+ //更改
|
|
201
|
+ for (int i = 0; i < cwxxReqVO.getCwxxYearList().size(); i++) {
|
|
202
|
+ CwxxYearSaveReqVO yearSaveReqVO = cwxxReqVO.getCwxxYearList().get(i);
|
|
203
|
+ yearSaveReqVO.setCwxxId(cwxx);
|
|
204
|
+ List<CwxxYearDO> oldCwxxYearDOS = cwxxYearMapper.selectList(new QueryWrapper<CwxxYearDO>()
|
|
205
|
+ .eq("CWXX_ID", cwxx)
|
|
206
|
+ .eq("CN", cwxxReqVO.getCwxxYearList().get(i).getCn()));
|
|
207
|
+ if (CollectionUtils.isEmpty(oldCwxxYearDOS)) {
|
|
208
|
+ cwxxYearService.createCwxxYear(yearSaveReqVO);
|
|
209
|
+ } else {
|
|
210
|
+ yearSaveReqVO.setId(oldCwxxYearDOS.get(0).getId());
|
|
211
|
+ cwxxYearService.updateCwxxYear(yearSaveReqVO);
|
|
212
|
+ }
|
|
213
|
+
|
|
214
|
+ }
|
171
|
215
|
}
|
172
|
216
|
}
|
173
|
217
|
}
|
|
@@ -176,4 +220,6 @@ public class DeliveryServiceImpl implements DeliveryService {
|
176
|
220
|
// 交通运输情况
|
177
|
221
|
return null;
|
178
|
222
|
}
|
|
223
|
+
|
179
|
224
|
}
|
|
225
|
+
|