Browse Source

修改单位,修改粮食性质,增加熔断

gaodandan 4 years ago
parent
commit
3d5e0b55d8

+ 25 - 5
pom.xml

@@ -98,7 +98,12 @@
98 98
 		    <artifactId>commons-beanutils</artifactId>
99 99
 		    <version>1.9.1</version>
100 100
 		</dependency>
101
-		
101
+		<dependency>
102
+            <groupId>commons-collections</groupId>
103
+            <artifactId>commons-collections</artifactId>
104
+            <version>3.2.1</version>
105
+        </dependency>
106
+        
102 107
 		<dependency>
103 108
 		    <groupId>org.apache.xmlgraphics</groupId>
104 109
 		    <artifactId>fop</artifactId>
@@ -119,6 +124,14 @@
119 124
 		    <version>1.2.37</version>
120 125
 		</dependency>
121 126
 		
127
+		<!-- JSONObject jar包 -->
128
+		<dependency>
129
+		    <groupId>net.sf.json-lib</groupId>    
130
+		    <artifactId>json-lib</artifactId>    
131
+		    <version>2.4</version>    
132
+		    <classifier>jdk15</classifier>    
133
+		</dependency>
134
+		
122 135
 		<!--添加webservice-->
123 136
 		<dependency>
124 137
 		   <groupId>org.apache.cxf</groupId>
@@ -163,10 +176,11 @@
163 176
         	<groupId>org.springframework.cloud</groupId>
164 177
         	<artifactId>spring-cloud-starter-openfeign</artifactId>
165 178
         </dependency>
166
-        <!-- <dependency>
167
-          <groupId>org.springframework.cloud</groupId>
168
-        	   <artifactId>spring-cloud-starter-openfeign</artifactId>
169
-        </dependency> -->
179
+        <dependency>
180
+		    <groupId>org.springframework.cloud</groupId>
181
+		    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
182
+		</dependency>
183
+        
170 184
 
171 185
 		<dependency>
172 186
 			<groupId>org.apache.commons</groupId>
@@ -212,6 +226,12 @@
212 226
 		    <artifactId>httpclient</artifactId>
213 227
 		</dependency>
214 228
 		
229
+		<!-- 日志-->
230
+        <dependency>
231
+            <groupId>ch.qos.logback</groupId>
232
+            <artifactId>logback-classic</artifactId>
233
+        </dependency>
234
+        
215 235
 		<dependency>  
216 236
 	       <groupId>log4j</groupId>  
217 237
 	       <artifactId>log4j</artifactId>  

+ 2 - 1
src/main/java/com/chinaitop/depot/business/service/FeignAgileService.java

@@ -9,8 +9,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
9 9
 import org.springframework.web.bind.annotation.RequestParam;
10 10
 
11 11
 import com.chinaitop.depot.agile.model.BusinessScedule;
12
+import com.chinaitop.depot.utils.HelloServiceHystrix;
12 13
 
13
-@FeignClient(name = "depot-agile")
14
+@FeignClient(name = "depot-agile", fallback = HelloServiceHystrix.class)
14 15
 public interface FeignAgileService {
15 16
 
16 17
 

+ 3 - 1
src/main/java/com/chinaitop/depot/business/service/FeignBasicService.java

@@ -7,7 +7,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
7 7
 import org.springframework.web.bind.annotation.RequestMethod;
8 8
 import org.springframework.web.bind.annotation.RequestParam;
9 9
 
10
-@FeignClient(name = "depot-basic")
10
+import com.chinaitop.depot.utils.HelloServiceHystrix;
11
+
12
+@FeignClient(name = "depot-basic", fallback = HelloServiceHystrix.class)
11 13
 public interface FeignBasicService {
12 14
 
13 15
 

+ 9 - 2
src/main/java/com/chinaitop/depot/business/service/impl/BusinessContractServiceImpl.java

@@ -1034,7 +1034,10 @@ public class BusinessContractServiceImpl implements BusinessContractService {
1034 1034
                                 // 入库
1035 1035
                                 // 入库数量.
1036 1036
                             	String sumRksl = businessScedule.getSumWcsl();
1037
-                                BigDecimal sumRkslD = new BigDecimal(sumRksl);
1037
+                            	BigDecimal s = new BigDecimal(1000);
1038
+                                BigDecimal sumCkslss = new BigDecimal(sumRksl);
1039
+                   			    BigDecimal sumRkslD = sumCkslss.divide(s);
1040
+                   			    
1038 1041
                                 // 出入库中的出库数量单位是公斤,合同中是吨,所以出入库数量要除以1000.
1039 1042
                                 //sumRkslD = sumRkslD.divide(new BigDecimal("1000"), 4, BigDecimal.ROUND_HALF_DOWN);
1040 1043
                                 
@@ -1055,7 +1058,11 @@ public class BusinessContractServiceImpl implements BusinessContractService {
1055 1058
                                 // 出库
1056 1059
                                 // 出库数量.
1057 1060
                             	String sumCksl = businessScedule.getSumWcsl();
1058
-                                BigDecimal sumCkslD = new BigDecimal(sumCksl);
1061
+                            	BigDecimal s = new BigDecimal(1000);
1062
+                                BigDecimal sumCkslss = new BigDecimal(sumCksl);
1063
+                   			    BigDecimal sumCkslD = sumCkslss.divide(s);
1064
+                   			    
1065
+                   			    
1059 1066
                                 // 出入库中的出库数量单位是公斤,合同中是吨,所以出入库数量要除以1000.
1060 1067
                                 //sumCkslD = sumCkslD.divide(new BigDecimal("1000"), 4, BigDecimal.ROUND_HALF_DOWN);
1061 1068
                                 

+ 13 - 5
src/main/java/com/chinaitop/depot/business/service/impl/BusinessDeliveryStorageNoticeServiceImpl.java

@@ -849,7 +849,7 @@ public class BusinessDeliveryStorageNoticeServiceImpl implements BusinessDeliver
849 849
                     for (BusinessScedule businessScedule : businessSceduleList) {
850 850
 	                    if(businessScedule!=null){
851 851
 	                    		
852
-	                    	if(businessScedule.getCrkLx()==null){//提货单
852
+	                    	/*if(businessScedule.getCrkLx()==null){//提货单
853 853
 	                    		if(businessDeliveryStorageNoticeV.getBillNumber().equals(businessScedule.getThdh())){
854 854
 	                    			 flag = true;
855 855
 	                    			// 在出入库系统中,获取完成数量
@@ -872,7 +872,9 @@ public class BusinessDeliveryStorageNoticeServiceImpl implements BusinessDeliver
872 872
 		                			businessSceduleList.remove(businessScedule);
873 873
 		                			// 跳出当前的出入库循环.
874 874
 		                			break;
875
-	                    	}else{//通知单
875
+	                    	}else{
876
+	                    		
877
+	                    	} */   //通知单
876 878
 	                    		if (businessDeliveryStorageNoticeV.getId().toString().equals(businessScedule.getTzdId())) {
877 879
 	                    			flag = true;
878 880
 	                    			// 在出入库系统中,存在该通知单对应的出入库数据,进行计算,得出完成比率.
@@ -881,7 +883,10 @@ public class BusinessDeliveryStorageNoticeServiceImpl implements BusinessDeliver
881 883
 	                    				// 入库
882 884
 	                    				// 入库数量.
883 885
 	                    				String sumRksl = businessScedule.getSumWcsl();
884
-	                    				BigDecimal sumRkslD = new BigDecimal(sumRksl);
886
+	                    				BigDecimal s = new BigDecimal(1000);
887
+	                                    BigDecimal sumRkslss = new BigDecimal(sumRksl);
888
+	                       			    BigDecimal sumRkslD = sumRkslss.divide(s);
889
+	                       			    
885 890
 	                    				// 赋值:设置完成数量. stripTrailingZeros() 去除结尾的0
886 891
 	                    				businessDeliveryStorageNoticeV.setCompleteAmount(sumRkslD.stripTrailingZeros().toPlainString());
887 892
 	                    				// 通知单要求数量.
@@ -898,7 +903,10 @@ public class BusinessDeliveryStorageNoticeServiceImpl implements BusinessDeliver
898 903
 	                    				// 出库
899 904
 	                    				// 出库数量.
900 905
 	                    				String sumCksl = businessScedule.getSumWcsl();
901
-	                    				BigDecimal sumCkslD = new BigDecimal(sumCksl);
906
+	                    				BigDecimal s = new BigDecimal(1000);
907
+	                                    BigDecimal sumCkslss = new BigDecimal(sumCksl);
908
+	                       			    BigDecimal sumCkslD = sumCkslss.divide(s);
909
+	                       			    
902 910
 	                    				
903 911
 	                    				// 赋值:设置完成数量. stripTrailingZeros() 去除结尾的0
904 912
 	                    				businessDeliveryStorageNoticeV.setCompleteAmount(sumCkslD.stripTrailingZeros().toPlainString());
@@ -919,7 +927,7 @@ public class BusinessDeliveryStorageNoticeServiceImpl implements BusinessDeliver
919 927
 	                    			// 跳出当前的出入库循环.
920 928
 	                    			break;
921 929
 	                    		}
922
-	                    	}
930
+	                    	//}
923 931
 	                    }
924 932
                    }
925 933
                     if (!flag) {

+ 8 - 4
src/main/java/com/chinaitop/depot/business/service/impl/BusinessPlanServiceImpl.java

@@ -637,8 +637,10 @@ public class BusinessPlanServiceImpl implements BusinessPlanService {
637 637
                                 // 入库
638 638
                                 // 入库数量.
639 639
                             	String sumRksl = businessScedule.getSumWcsl();
640
-                                BigDecimal sumRkslD = new BigDecimal(sumRksl);
641
-                                
640
+                                BigDecimal s = new BigDecimal(1000);
641
+                                BigDecimal sumRkslss = new BigDecimal(sumRksl);
642
+                   			    BigDecimal sumRkslD = sumRkslss.divide(s);
643
+                   			 
642 644
                                 // 赋值:设置完成数量. stripTrailingZeros() 去除结尾的0
643 645
                                 businessPlanV.setCompleteAmount(sumRkslD.stripTrailingZeros().toPlainString());
644 646
                                 // 计划要求数量.
@@ -656,8 +658,10 @@ public class BusinessPlanServiceImpl implements BusinessPlanService {
656 658
                                 // 出库
657 659
                                 // 出库数量.
658 660
                             	String sumCksl = businessScedule.getSumWcsl();
659
-                                BigDecimal sumCkslD = new BigDecimal(sumCksl);
660
-                                
661
+                            	BigDecimal s = new BigDecimal(1000);
662
+                                BigDecimal sumCkslss = new BigDecimal(sumCksl);
663
+                   			    BigDecimal sumCkslD = sumCkslss.divide(s);
664
+                   			    
661 665
                                 // 赋值:设置完成数量. stripTrailingZeros() 去除结尾的0
662 666
                                 businessPlanV.setCompleteAmount(sumCkslD.stripTrailingZeros().toPlainString());
663 667
                                 

+ 64 - 17
src/main/java/com/chinaitop/depot/business/service/impl/ReceiveNoticeServiceImpl.java

@@ -1,5 +1,6 @@
1 1
 package com.chinaitop.depot.business.service.impl;
2 2
 
3
+import java.math.BigDecimal;
3 4
 import java.util.Date;
4 5
 import java.util.HashMap;
5 6
 import java.util.List;
@@ -8,6 +9,7 @@ import java.util.Map;
8 9
 import javax.annotation.Resource;
9 10
 
10 11
 import org.apache.commons.lang.ObjectUtils;
12
+import org.springframework.beans.factory.annotation.Value;
11 13
 import org.springframework.stereotype.Service;
12 14
 
13 15
 import com.alibaba.fastjson.JSONObject;
@@ -18,6 +20,7 @@ import com.chinaitop.depot.business.model.BusinessNoticeReceiveExample.Criteria;
18 20
 import com.chinaitop.depot.business.service.FeignAgileService;
19 21
 import com.chinaitop.depot.business.service.FeignBasicService;
20 22
 import com.chinaitop.depot.business.service.ReceiveNoticeService;
23
+import com.chinaitop.depot.utils.createKC;
21 24
 import com.github.pagehelper.PageHelper;
22 25
 
23 26
 @Service
@@ -30,7 +33,10 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
30 33
 	@Resource
31 34
 	private FeignAgileService feignAgileService;
32 35
 	
33
-	
36
+	// 获取ip地址
37
+    @Value("${crk-webservice}")
38
+    private String url;
39
+    
34 40
 	@Override
35 41
 	public List<BusinessNoticeReceive> queryByExample(Integer pageNum, Integer pageSize,
36 42
 			BusinessNoticeReceive businessNoticeReceive,String cktzd,String lyflag) {
@@ -157,6 +163,8 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
157 163
                     
158 164
                     String hwbm = jsonObject.getString("cfbm");
159 165
                     if(hwbm!=null){
166
+                    	Integer grainAttribute = 0 ;
167
+                    	Integer grainKind = 0;
160 168
                     	//根据仓房编码查询仓房、货位、组织机构数据
161 169
                         Map<String, Object> wareDataMap = feignBasicService.getWareDataByHwbm(hwbm);
162 170
                         Integer houseId = (Integer) wareDataMap.get("houseId");
@@ -165,25 +173,28 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
165 173
                         businessNoticeReceive.setHouseId(houseId); //仓房
166 174
                         businessNoticeReceive.setWareHouseId(wareHouseId); //货位
167 175
                         businessNoticeReceive.setOrgId(orgId);  //组织id
168
-                        
169
-                        //根据仓房、货位、orgId获取粮食品种等信息
170
-                        Map<String, Object> map = feignAgileService.getDateByChHwh(orgId, houseId, wareHouseId);
171
-                        Integer grainAttribute = (Integer) map.get("hwxz"); //粮油性质
172
-                        Integer grainKind = (Integer) map.get("pz"); //品种
173
-                        Integer grainDetailKind = (Integer) map.get("mxpz"); //明细品种
174
-                        Integer grainGrade = (Integer) map.get("dj"); //等级
175
-                        
176
-                        businessNoticeReceive.setGrainKind(grainKind); //品种
177
-                        businessNoticeReceive.setGrainDetailKind(grainDetailKind); //明细品种
178
-                        businessNoticeReceive.setGrainGrade(grainGrade); //等级
179
-                        businessNoticeReceive.setGrainAttribute(grainAttribute); //粮油性质
180
-                        
176
+                    	if(ObjectUtils.toString(jsonObject.getString("ywlx")).equals("6")){//竞买的业务类型
177
+                    		if(jsonObject.getString("pz")!=null){
178
+                    			businessNoticeReceive.setGrainKind(Integer.valueOf(jsonObject.getString("pz"))); //接收的品种
179
+                    		}
180
+                    	}else{
181
+                          //根据仓房、货位、orgId获取粮食品种等信息
182
+                            Map<String, Object> map = feignAgileService.getDateByChHwh(orgId, houseId, wareHouseId);
183
+                             grainAttribute = (Integer) map.get("hwxz"); //粮油性质
184
+                             grainKind = (Integer) map.get("pz"); //品种
185
+                            Integer grainDetailKind = (Integer) map.get("mxpz"); //明细品种
186
+                            Integer grainGrade = (Integer) map.get("dj"); //等级
187
+                            businessNoticeReceive.setGrainKind(grainKind); //品种
188
+                            businessNoticeReceive.setGrainDetailKind(grainDetailKind); //明细品种
189
+                            businessNoticeReceive.setGrainGrade(grainGrade); //等级
190
+                            businessNoticeReceive.setGrainAttribute(grainAttribute); //粮油性质
191
+                    	}
181 192
                         String  lsyqsl = jsonObject.getString("lsyqsl");
182
-                        /*BigDecimal s = new BigDecimal(1000);
193
+                        BigDecimal s = new BigDecimal(1000);
183 194
             			 BigDecimal sumjhsl = new BigDecimal(lsyqsl);
184 195
             			 BigDecimal sumCkslss = sumjhsl.multiply(s);
185 196
             			 String count = sumCkslss.toString(); //吨转化为公斤
186
-           */ 			
197
+            			
187 198
                         businessNoticeReceive.setCount(lsyqsl); //计划数量(吨)
188 199
                         businessNoticeReceive.setOutgoingPeriod(jsonObject.getString("ckqx")); //出库期限(日期格式)
189 200
                        
@@ -192,7 +203,43 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
192 203
                        businessNoticeReceive.setReceiveTime(new Date());//接收数据的时间
193 204
                        businessNoticeReceiveMapper.insert(businessNoticeReceive);
194 205
                    	
195
-                       modelMap.put("status", "success");
206
+                       /**
207
+                        * 修改粮食性质(轮换或者销售进行修改)
208
+                        *   parameters[0] = ;     //单位ID
209
+							parameters[1] = ;     //粮食品种
210
+							parameters[2] = null; //空就行
211
+							parameters[3] = ;     //仓房ID
212
+							parameters[4] = ;     //货位ID
213
+							parameters[5] = ;     //需要改变成的粮食性质
214
+							parameters[6] = ;     //原来的粮食性质
215
+							parameters[7] = ;     //库存数量或者要改变的数量
216
+							parameters[8]=;      //批准文号(山西用)
217
+							parameters[9]=;      //性质变动原因
218
+							parameters[10] = ;  //1:新增;2:修改;3:删除
219
+                        */
220
+                       if(!ObjectUtils.toString(jsonObject.getString("ywlx")).equals("6")){
221
+                    	   Object parameters[] = new Object[11];
222
+                    	   parameters[0] = orgId+"";//组织id
223
+                    	   parameters[1] = grainKind+"";//粮食品种
224
+                    	   parameters[2] = null;//
225
+                    	   parameters[3] = houseId+"";//仓房id
226
+                    	   parameters[4] = wareHouseId+"";//货位id
227
+                    	   parameters[5] = 6871+"";//需要改变成的粮食性质(其他商品粮)
228
+                    	   parameters[6] = grainAttribute+"";//原来的粮食性质
229
+                    	   parameters[7] = count+"";//原来的粮食性质
230
+                    	   parameters[8] = jsonObject.getString("tzdid")+"";//原来的粮食性质
231
+                    	   parameters[9] = "转储性质变动";
232
+                    	   parameters[10] = 2+"";
233
+           				   String str = createKC.createKC("ChangeGrainAttribute", url, parameters);
234
+	           			    if ("true".equals(str)) {
235
+	           			    	modelMap.put("status", "success");
236
+	        				} else {
237
+	        					modelMap.put("status", "error");
238
+	        					modelMap.put("msg", "保存失败,库存同步异常,请联系管理员!");
239
+	        					return modelMap;
240
+	        				}
241
+                       }
242
+                       
196 243
                     }else{
197 244
                     	modelMap.put("msg", "仓房编码为空");
198 245
                     	modelMap.put("status", "error");