|
@@ -1,14 +1,14 @@
|
1
|
1
|
package com.chinaitop.depot.pushs.service.impl;
|
2
|
2
|
|
3
|
3
|
import java.math.BigDecimal;
|
4
|
|
-import java.util.*;
|
|
4
|
+import java.util.ArrayList;
|
|
5
|
+import java.util.Arrays;
|
|
6
|
+import java.util.HashMap;
|
|
7
|
+import java.util.List;
|
|
8
|
+import java.util.Map;
|
5
|
9
|
|
6
|
10
|
import javax.annotation.Resource;
|
7
|
11
|
|
8
|
|
-import com.chinaitop.depot.business.mapper.BusinessStoreWareDetailMapper;
|
9
|
|
-import com.chinaitop.depot.business.model.*;
|
10
|
|
-import com.chinaitop.depot.business.service.ReceiveNoticeService;
|
11
|
|
-import com.chinaitop.depot.utils.ParameterUtil;
|
12
|
12
|
import org.apache.commons.lang.ArrayUtils;
|
13
|
13
|
import org.slf4j.Logger;
|
14
|
14
|
import org.slf4j.LoggerFactory;
|
|
@@ -19,9 +19,21 @@ import com.alibaba.fastjson.JSON;
|
19
|
19
|
import com.chinaitop.depot.business.mapper.BusinessContractMapper;
|
20
|
20
|
import com.chinaitop.depot.business.mapper.BusinessDeliveryStorageNoticeMapper;
|
21
|
21
|
import com.chinaitop.depot.business.mapper.BusinessLadingMapper;
|
|
22
|
+import com.chinaitop.depot.business.mapper.BusinessMergeNoticeMapper;
|
22
|
23
|
import com.chinaitop.depot.business.mapper.BusinessNoticeReceiveMapper;
|
|
24
|
+import com.chinaitop.depot.business.mapper.BusinessStoreWareDetailMapper;
|
|
25
|
+import com.chinaitop.depot.business.model.BusinessContract;
|
|
26
|
+import com.chinaitop.depot.business.model.BusinessContractExample;
|
|
27
|
+import com.chinaitop.depot.business.model.BusinessDeliveryStorageNotice;
|
|
28
|
+import com.chinaitop.depot.business.model.BusinessDeliveryStorageNoticeExample;
|
|
29
|
+import com.chinaitop.depot.business.model.BusinessMergeNoticeDetail;
|
|
30
|
+import com.chinaitop.depot.business.model.BusinessNoticeReceive;
|
|
31
|
+import com.chinaitop.depot.business.model.BusinessStoreWareDetail;
|
|
32
|
+import com.chinaitop.depot.business.model.BusinessStoreWareDetailExample;
|
|
33
|
+import com.chinaitop.depot.business.service.ReceiveNoticeService;
|
23
|
34
|
import com.chinaitop.depot.pushs.service.PushsService;
|
24
|
35
|
import com.chinaitop.depot.unissoft.model.ResponseEntity;
|
|
36
|
+import com.chinaitop.depot.utils.ParameterUtil;
|
25
|
37
|
|
26
|
38
|
@Service
|
27
|
39
|
public class PushServiceImpl implements PushsService{
|
|
@@ -41,6 +53,8 @@ public class PushServiceImpl implements PushsService{
|
41
|
53
|
private ReceiveNoticeService receiveNoticeService;
|
42
|
54
|
@Resource
|
43
|
55
|
private BusinessNoticeReceiveMapper receiveNoticeMapper;
|
|
56
|
+ @Resource
|
|
57
|
+ private BusinessMergeNoticeMapper businessMergeNoticeMapper;
|
44
|
58
|
|
45
|
59
|
|
46
|
60
|
|
|
@@ -217,19 +231,136 @@ public class PushServiceImpl implements PushsService{
|
217
|
231
|
|
218
|
232
|
List<Map<String,Object>> mainList1 =businessDeliveryStorageNoticeMapper.getNoticeData(mapCondition1);
|
219
|
233
|
//再根据主数据id查出相关的从数据插入
|
220
|
|
- for (Map<String,Object> mains : mainList1) {
|
221
|
|
- //单位转化为公斤
|
222
|
|
- BigDecimal bignum = new BigDecimal(1000);
|
223
|
|
- //数量转化为公斤
|
224
|
|
- if(mains.get("shiping_count")!=null && !mains.get("shiping_count").equals("")){
|
225
|
|
- BigDecimal count = new BigDecimal(mains.get("shiping_count").toString());
|
226
|
|
- mains.put("shiping_count", count.multiply(bignum).toString());
|
|
234
|
+ for (Map<String,Object> mains : mainList1) {
|
|
235
|
+ //单位转化为公斤
|
|
236
|
+ BigDecimal bignum = new BigDecimal(1000);
|
|
237
|
+ //数量转化为公斤
|
|
238
|
+ if(mains.get("shiping_count")!=null && !mains.get("shiping_count").equals("")){
|
|
239
|
+ BigDecimal count = new BigDecimal(mains.get("shiping_count").toString());
|
|
240
|
+ mains.put("shiping_count", count.multiply(bignum).toString());
|
|
241
|
+ }
|
|
242
|
+ }
|
|
243
|
+
|
|
244
|
+ //查所有合并过的数据
|
|
245
|
+ BusinessMergeNoticeDetail detailObj = new BusinessMergeNoticeDetail();
|
|
246
|
+ detailObj.setOrgId(Integer.parseInt(orgId));
|
|
247
|
+
|
|
248
|
+ List<Map<String,Object>> mainList2 = new ArrayList<>();
|
|
249
|
+ List<BusinessMergeNoticeDetail> hbtzdList = businessMergeNoticeMapper.findByZidDetailList(detailObj);
|
|
250
|
+ if (null != hbtzdList && hbtzdList.size() > 0) {
|
|
251
|
+ List<Integer> tzdids = new ArrayList<>();
|
|
252
|
+ for (BusinessMergeNoticeDetail detail : hbtzdList) {
|
|
253
|
+ tzdids.add(Integer.parseInt(detail.getTzdid()));
|
|
254
|
+ }
|
|
255
|
+ Map<String,Object> mapCondition2 = new HashMap<String, Object>();
|
|
256
|
+ mapCondition2.put("ids", tzdids);
|
|
257
|
+
|
|
258
|
+ mainList2 = businessDeliveryStorageNoticeMapper.getNoticeData(mapCondition2);
|
|
259
|
+ //再根据主数据id查出相关的从数据插入
|
|
260
|
+ for (Map<String,Object> mains : mainList2) {
|
|
261
|
+ BusinessStoreWareDetailExample businessStoreWareDetailExample = new BusinessStoreWareDetailExample();
|
|
262
|
+ BusinessStoreWareDetailExample.Criteria criteria = businessStoreWareDetailExample.createCriteria();
|
|
263
|
+ criteria.andZidEqualTo(Integer.valueOf(mains.get("id").toString()));
|
|
264
|
+ criteria.andTypeEqualTo("notice");//默认查询通知单类型数据
|
|
265
|
+ List<BusinessStoreWareDetail> json = businessStoreWareDetailMapper.selectByExample(businessStoreWareDetailExample);
|
|
266
|
+ //单位转化为公斤
|
|
267
|
+ BigDecimal bignum = new BigDecimal(1000);
|
|
268
|
+ if(json.size()>0 && json!=null){
|
|
269
|
+ if(mains.get("bill_type").toString().equals("2")){
|
|
270
|
+ for (int i = 0; i < json.size(); i++) {
|
|
271
|
+ if(null != json.get(i).getInCount() && !json.get(i).getInCount().equals("")){
|
|
272
|
+ BigDecimal bignum1 = new BigDecimal(json.get(i).getInCount());
|
|
273
|
+ BigDecimal inCount = bignum1.multiply(bignum);
|
|
274
|
+ json.get(i).setInCount(inCount.toString());
|
|
275
|
+ }
|
|
276
|
+ if(null != json.get(i).getOutCount() && !json.get(i).getOutCount().equals("")){
|
|
277
|
+ BigDecimal bignum2 = new BigDecimal(json.get(i).getOutCount());
|
|
278
|
+ BigDecimal outCount = bignum2.multiply(bignum);
|
|
279
|
+ json.get(i).setOutCount(outCount.toString());
|
|
280
|
+ }
|
|
281
|
+ }
|
|
282
|
+ }else{
|
|
283
|
+ for (int i = 0; i < json.size(); i++) {
|
|
284
|
+ if(null != json.get(i).getInCount() && !json.get(i).getInCount().equals("") && !json.get(i).getInPrice().equals("") && null != json.get(i).getInPrice()){
|
|
285
|
+ BigDecimal bignum1 = new BigDecimal(json.get(i).getInCount());
|
|
286
|
+ BigDecimal biginprice1 = new BigDecimal(json.get(i).getInPrice());
|
|
287
|
+ BigDecimal inCount = bignum1.multiply(bignum);
|
|
288
|
+ //BigDecimal inDetailTotalPrice = inCount.multiply(biginprice1);
|
|
289
|
+ BigDecimal inPrice = biginprice1.divide(bignum);
|
|
290
|
+ json.get(i).setInCount(inCount.toString());
|
|
291
|
+ json.get(i).setInPrice(inPrice.toString());
|
|
292
|
+ }
|
|
293
|
+ if(null != json.get(i).getOutCount() && !json.get(i).getOutCount().equals("") && null != json.get(i).getOutPrice() && !json.get(i).getOutPrice().equals("")){
|
|
294
|
+ BigDecimal bignum2 = new BigDecimal(json.get(i).getOutCount());
|
|
295
|
+ BigDecimal biginprice2 = new BigDecimal(json.get(i).getOutPrice());
|
|
296
|
+ BigDecimal outCount = bignum2.multiply(bignum);
|
|
297
|
+ //BigDecimal outDetailTotalPrice = outCount.multiply(biginprice2);
|
|
298
|
+ BigDecimal outPrice = biginprice2.divide(bignum);
|
|
299
|
+ json.get(i).setOutCount(outCount.toString());
|
|
300
|
+ json.get(i).setOutPrice(outPrice.toString());
|
|
301
|
+ }
|
|
302
|
+ }
|
227
|
303
|
}
|
|
304
|
+
|
|
305
|
+ //判断出库期限 储备粮通知单
|
|
306
|
+ if(mains.containsKey("create_unit") && mains.get("bill_type").toString().equals("3")){
|
|
307
|
+ if(mains.get("create_unit").toString().equals("1")){ //取储备粮的通知单
|
|
308
|
+ for (int j = 0; j < json.size(); j++) {
|
|
309
|
+ if(json.get(j).getJstzdId().length()>0 && json.get(j).getJstzdId()!=null){
|
|
310
|
+ BusinessNoticeReceive noticeReceive = receiveNoticeMapper.selectByPrimaryKey(Integer.valueOf(json.get(j).getJstzdId()));
|
|
311
|
+ json.get(j).setOutboundExpirationDate(noticeReceive.getOutgoingPeriod());
|
|
312
|
+ }
|
|
313
|
+ }
|
|
314
|
+ }
|
|
315
|
+ }
|
|
316
|
+
|
228
|
317
|
}
|
229
|
|
-
|
|
318
|
+
|
|
319
|
+ mains.put("fromData",json);//从表数据以json形式插入主表数据
|
|
320
|
+
|
|
321
|
+ //数量转化为公斤
|
|
322
|
+ if(mains.get("shiping_count")!=null && !mains.get("shiping_count").equals("")){
|
|
323
|
+ BigDecimal count = new BigDecimal(mains.get("shiping_count").toString());
|
|
324
|
+ mains.put("shiping_count", count.multiply(bignum).toString());
|
|
325
|
+ }
|
|
326
|
+
|
|
327
|
+ //处理储备粮中的通知单
|
|
328
|
+ if(null != mains.get("create_unit")){
|
|
329
|
+ if(mains.get("create_unit").equals(1)){
|
|
330
|
+ //传字段 计划文件号 和摘要 用于分仓保管账
|
|
331
|
+ for (BusinessStoreWareDetail businessStoreWareDetail : json) {
|
|
332
|
+ BusinessNoticeReceive businessNoticeReceive =new BusinessNoticeReceive();
|
|
333
|
+ businessNoticeReceive.setHouseId(businessStoreWareDetail.getHouseId());
|
|
334
|
+ businessNoticeReceive.setWareHouseId(businessStoreWareDetail.getWareHouseId());
|
|
335
|
+ businessNoticeReceive.setGrainKind(businessStoreWareDetail.getGrainKind());
|
|
336
|
+ businessNoticeReceive.setGrainAttribute(businessStoreWareDetail.getGrainAttribute());
|
|
337
|
+ businessNoticeReceive.setOrgId(businessStoreWareDetail.getOrgId());
|
|
338
|
+ List<BusinessNoticeReceive> noticeRecevieList = receiveNoticeService.queryByExample(null, null, businessNoticeReceive, null,null);
|
|
339
|
+ if(null != noticeRecevieList && noticeRecevieList.size()>0){
|
|
340
|
+ String jhwjh = noticeRecevieList.get(0).getNoticeNumber();
|
|
341
|
+ String zy = noticeRecevieList.get(0).getYwtype();
|
|
342
|
+ if(("1").equals(zy)){ //1收储 2 销售 3轮换
|
|
343
|
+ zy = "收储";
|
|
344
|
+ }else if(("2").equals(zy)){
|
|
345
|
+ zy = "销售";
|
|
346
|
+ }else if(("3").equals(zy)){
|
|
347
|
+ zy = "轮换";
|
|
348
|
+ }
|
|
349
|
+ mains.put("jhwjh", jhwjh);
|
|
350
|
+ mains.put("zy", zy);
|
|
351
|
+ }
|
|
352
|
+ }
|
|
353
|
+ }
|
|
354
|
+
|
|
355
|
+ }
|
|
356
|
+ }
|
|
357
|
+
|
|
358
|
+ }
|
|
359
|
+
|
230
|
360
|
Map<String,Object> mapData = new HashMap<String, Object>();
|
231
|
361
|
mapData.put("mainData", mainList);
|
232
|
362
|
mapData.put("mainData1", mainList1);
|
|
363
|
+ mapData.put("mainData2", mainList2);
|
233
|
364
|
mapData.put("status", "success");
|
234
|
365
|
return JSON.toJSONString(ResponseEntity.ok(mapData));
|
235
|
366
|
}
|