|
|
@@ -4,12 +4,20 @@ import com.chinaitop.depot.business.mapper.BusinessDrugStandingBookMapper;
|
|
4
|
4
|
import com.chinaitop.depot.business.model.*;
|
|
5
|
5
|
import com.chinaitop.depot.business.service.BusinessDrugStandingBookService;
|
|
6
|
6
|
import com.chinaitop.depot.utils.ParameterUtil;
|
|
|
7
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
8
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
7
|
9
|
import com.github.pagehelper.PageHelper;
|
|
8
|
10
|
import org.apache.commons.lang.StringUtils;
|
|
9
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
12
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
13
|
+import org.springframework.context.annotation.Bean;
|
|
10
|
14
|
import org.springframework.stereotype.Service;
|
|
11
|
15
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
16
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
17
|
+import org.springframework.util.MultiValueMap;
|
|
|
18
|
+import org.springframework.web.client.RestTemplate;
|
|
12
|
19
|
|
|
|
20
|
+import javax.annotation.Resource;
|
|
13
|
21
|
import javax.servlet.http.HttpServletRequest;
|
|
14
|
22
|
import java.math.BigDecimal;
|
|
15
|
23
|
import java.util.ArrayList;
|
|
|
@@ -35,6 +43,13 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
35
|
43
|
|
|
36
|
44
|
@Autowired
|
|
37
|
45
|
private BusinessDrugStandingBookMapper drugStandingBookMapper;
|
|
|
46
|
+
|
|
|
47
|
+ @Resource
|
|
|
48
|
+ private RestTemplate restTemplate;
|
|
|
49
|
+
|
|
|
50
|
+ @Value("${jsgjjsjUrl}")
|
|
|
51
|
+ private String jsgjjsjUrl;
|
|
|
52
|
+
|
|
38
|
53
|
|
|
39
|
54
|
/**
|
|
40
|
55
|
* 入库新增台账数据.
|
|
|
@@ -94,6 +109,7 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
94
|
109
|
drugStandingBookBefore.setIsLastShelfData(0);
|
|
95
|
110
|
drugStandingBookBefore.setUpdatetime(new Date());
|
|
96
|
111
|
drugStandingBookMapper.updateByPrimaryKeySelective(drugStandingBookBefore);
|
|
|
112
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "u");
|
|
97
|
113
|
} else {
|
|
98
|
114
|
// 第一次,两个台账数量都等于入库数量.
|
|
99
|
115
|
String new_amount = amount(amount, drugStorage.getStorageCount(), SCALE_ADD);//入库后的最新台账数量
|
|
|
@@ -103,6 +119,8 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
103
|
119
|
// 新增.
|
|
104
|
120
|
drugStandingBook.setUpdatetime(new Date());
|
|
105
|
121
|
drugStandingBookMapper.insert(drugStandingBook);
|
|
|
122
|
+
|
|
|
123
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "i");
|
|
106
|
124
|
}
|
|
107
|
125
|
|
|
108
|
126
|
@Override
|
|
|
@@ -171,6 +189,7 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
171
|
189
|
drugStandingBookBefore.setIsLastShelfData(0);
|
|
172
|
190
|
drugStandingBookBefore.setUpdatetime(new Date());
|
|
173
|
191
|
drugStandingBookMapper.updateByPrimaryKeySelective(drugStandingBookBefore);
|
|
|
192
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "u");
|
|
174
|
193
|
} else {
|
|
175
|
194
|
// 第一次.
|
|
176
|
195
|
throw new RuntimeException("没有对应的数据可以出库!");
|
|
|
@@ -178,6 +197,7 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
178
|
197
|
// 新增.
|
|
179
|
198
|
drugStandingBook.setUpdatetime(new Date());
|
|
180
|
199
|
drugStandingBookMapper.insert(drugStandingBook);
|
|
|
200
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "i");
|
|
181
|
201
|
}
|
|
182
|
202
|
|
|
183
|
203
|
private String amount(String y_num, String rk_num, String type) {
|
|
|
@@ -322,6 +342,7 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
322
|
342
|
drugStandingBookBefore.setIsLastShelfData(0);
|
|
323
|
343
|
drugStandingBookBefore.setUpdatetime(new Date());
|
|
324
|
344
|
drugStandingBookMapper.updateByPrimaryKeySelective(drugStandingBookBefore);
|
|
|
345
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "u");
|
|
325
|
346
|
}
|
|
326
|
347
|
|
|
327
|
348
|
} else if (Double.parseDouble(checkCount) < Double.parseDouble(shelfAmount)) {
|
|
|
@@ -343,6 +364,7 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
343
|
364
|
drugStandingBookBefore.setIsLastShelfData(0);
|
|
344
|
365
|
drugStandingBookBefore.setUpdatetime(new Date());
|
|
345
|
366
|
drugStandingBookMapper.updateByPrimaryKeySelective(drugStandingBookBefore);
|
|
|
367
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "u");
|
|
346
|
368
|
} else {
|
|
347
|
369
|
// 第一次.
|
|
348
|
370
|
throw new RuntimeException("没有对应的数据可以出库!");
|
|
|
@@ -354,6 +376,7 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
354
|
376
|
// 新增台账.
|
|
355
|
377
|
drugStandingBook.setUpdatetime(new Date());
|
|
356
|
378
|
drugStandingBookMapper.insert(drugStandingBook);
|
|
|
379
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "i");
|
|
357
|
380
|
}
|
|
358
|
381
|
}
|
|
359
|
382
|
|
|
|
@@ -436,6 +459,7 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
436
|
459
|
drugStandingBookBefore.setIsLastShelfData(0);
|
|
437
|
460
|
drugStandingBookBefore.setUpdatetime(new Date());
|
|
438
|
461
|
drugStandingBookMapper.updateByPrimaryKeySelective(drugStandingBookBefore);
|
|
|
462
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "u");
|
|
439
|
463
|
} else {
|
|
440
|
464
|
// 第一次.
|
|
441
|
465
|
throw new RuntimeException("没有对应的数据可以归还!");
|
|
|
@@ -443,6 +467,7 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
443
|
467
|
// 新增
|
|
444
|
468
|
drugStandingBook.setUpdatetime(new Date());
|
|
445
|
469
|
drugStandingBookMapper.insertSelective(drugStandingBook);
|
|
|
470
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "i");
|
|
446
|
471
|
}
|
|
447
|
472
|
|
|
448
|
473
|
/**
|
|
|
@@ -503,10 +528,14 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
503
|
528
|
standingBookOld.setIsLastShelfData(0);
|
|
504
|
529
|
standingBookOld.setUpdatetime(new Date());
|
|
505
|
530
|
drugStandingBookMapper.updateByPrimaryKeySelective(standingBookOld);
|
|
|
531
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "u");
|
|
|
532
|
+
|
|
506
|
533
|
|
|
507
|
534
|
// 新增.
|
|
508
|
535
|
drugStandingBook.setUpdatetime(new Date());
|
|
509
|
536
|
drugStandingBookMapper.insert(drugStandingBook);
|
|
|
537
|
+ this.gjjjk(drugStandingBook.getId(), drugStandingBook.getOrgId(), "i");
|
|
|
538
|
+
|
|
510
|
539
|
} else {
|
|
511
|
540
|
throw new IllegalArgumentException("没有相应的数据!");
|
|
512
|
541
|
}
|
|
|
@@ -682,5 +711,38 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
|
|
682
|
711
|
|
|
683
|
712
|
return list;
|
|
684
|
713
|
}
|
|
|
714
|
+
|
|
|
715
|
+
|
|
|
716
|
+ /**
|
|
|
717
|
+ * 国家局数据
|
|
|
718
|
+ */
|
|
|
719
|
+ public void gjjjk(Integer id, Integer orgId,String czbz) {
|
|
|
720
|
+
|
|
|
721
|
+ Map<String, Object> gjjMap = drugStandingBookMapper.getYjGjjDate(id);
|
|
|
722
|
+ gjjMap.put("czbz",czbz);
|
|
|
723
|
+ gjjMap.put("is_upload", 0);
|
|
|
724
|
+ String tableName = "ODS_UP_YJXXJK";
|
|
|
725
|
+
|
|
|
726
|
+ /**
|
|
|
727
|
+ * restTemplate调用
|
|
|
728
|
+ */
|
|
|
729
|
+ //String url = "http://localhost:9022/recPublish/sendMessage";//
|
|
|
730
|
+ // 发送post请求,并打印结果,以String类型接收响应结果JSON字符串
|
|
|
731
|
+ MultiValueMap<String, Object> sendMap = new LinkedMultiValueMap<>();
|
|
|
732
|
+ //Map<String, Object> sendMap = new HashMap<String, Object>();
|
|
|
733
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
734
|
+ String jsonMap;
|
|
|
735
|
+ try {
|
|
|
736
|
+ jsonMap = objectMapper.writeValueAsString(gjjMap);
|
|
|
737
|
+ sendMap.add("gjjMapJson",jsonMap);
|
|
|
738
|
+ } catch (JsonProcessingException e) {
|
|
|
739
|
+ // TODO Auto-generated catch block
|
|
|
740
|
+ e.printStackTrace();
|
|
|
741
|
+ }
|
|
|
742
|
+ sendMap.add("tableName", tableName);
|
|
|
743
|
+ sendMap.add("orgId",orgId);
|
|
|
744
|
+
|
|
|
745
|
+ String result = (String) restTemplate.postForObject(jsgjjsjUrl, sendMap, String.class);
|
|
|
746
|
+ }
|
|
685
|
747
|
|
|
686
|
748
|
}
|