gaodd 4 years ago
parent
commit
e7fdc06ae9

+ 19 - 0
src/main/java/com/unissoft/systemManage/controller/QuantityStatisticsController.java

@@ -1,9 +1,14 @@
1 1
 package com.unissoft.systemManage.controller;
2 2
 
3 3
 
4
+import java.text.DateFormat;
5
+import java.text.ParseException;
6
+import java.text.SimpleDateFormat;
7
+import java.util.Date;
4 8
 import java.util.List;
5 9
 import java.util.Map;
6 10
 
11
+import org.junit.Test;
7 12
 import org.springframework.beans.factory.annotation.Autowired;
8 13
 import org.springframework.web.bind.annotation.PostMapping;
9 14
 import org.springframework.web.bind.annotation.RequestBody;
@@ -78,4 +83,18 @@ public class QuantityStatisticsController {
78 83
 		Map<String, Object> map = quantityStatisticsService.getOutInNumber(pageParam);
79 84
 		return ResultView.success(map);
80 85
 	}
86
+    
87
+    
88
+    /**
89
+     * 库区图
90
+     */
91
+    @SystemLog(operModul = "首页", operType = "库区图", operDesc = "库区图")
92
+    @PostMapping("/getHouseMessage")
93
+	@ApiOperation(value="库区图", notes="库区图")
94
+	public ResultView getHouseMessage(@RequestBody PageParam pageParam) {
95
+		Map<String, Object> map = quantityStatisticsService.getHouseMessage(pageParam);
96
+		return ResultView.success(map);
97
+	}
98
+    
99
+    
81 100
 }

+ 6 - 0
src/main/java/com/unissoft/systemManage/model/OrgInfo.java

@@ -96,4 +96,10 @@ public class OrgInfo implements Serializable {
96 96
     @TableField("last_time")
97 97
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
98 98
     private Date lastTime;
99
+    
100
+    @TableField(exist = false)
101
+	private String pzName; //品种名称
102
+    
103
+    @TableField(exist = false)
104
+	private String lsNumber; //当前粮食数量
99 105
 }

+ 2 - 0
src/main/java/com/unissoft/systemManage/service/QuantityStatisticsService.java

@@ -24,4 +24,6 @@ public interface QuantityStatisticsService extends IService<QuantityStatistics>
24 24
 
25 25
 	Map<String, Object> getOutInNumber(PageParam pageParam);
26 26
 
27
+	Map<String, Object> getHouseMessage(PageParam pageParam);
28
+
27 29
 }

+ 124 - 5
src/main/java/com/unissoft/systemManage/service/impl/QuantityStatisticsServiceImpl.java

@@ -19,7 +19,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
19 19
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
20 20
 
21 21
 import java.math.BigDecimal;
22
+import java.text.DateFormat;
23
+import java.text.ParseException;
22 24
 import java.text.SimpleDateFormat;
25
+import java.util.ArrayList;
23 26
 import java.util.Calendar;
24 27
 import java.util.Date;
25 28
 import java.util.HashMap;
@@ -98,12 +101,16 @@ public class QuantityStatisticsServiceImpl extends ServiceImpl<QuantityStatistic
98 101
 
99 102
 	@Override
100 103
 	public Map<String, Object> getDataChange(PageParam pageParam) {
104
+		
105
+        
101 106
 		// TODO Auto-generated method stub
102 107
 		Map<String, Object> map = new HashMap<>();
103 108
 		String condition = pageParam.getCondition();
104 109
 		if (!StringUtils.isEmpty(condition)) {
105 110
         	JSONObject jsStr = JSON.parseObject(condition);
106 111
         	Integer houseId = jsStr.getIntValue("houseId");
112
+        	String startTime = jsStr.getString("startTime");
113
+        	String endTime = jsStr.getString("endTime");
107 114
         	if(null != houseId && !"".equals(houseId)){
108 115
         		OrgInfo orgInfo = orgInfoMapper.selectById(houseId);
109 116
         		Map<String, Object> parm_map = new HashMap<>();
@@ -122,7 +129,8 @@ public class QuantityStatisticsServiceImpl extends ServiceImpl<QuantityStatistic
122 129
             	    QueryWrapper<NBasicEdge> queryWrapper1 = new QueryWrapper<>();
123 130
             	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//注意月份是MM
124 131
             	    Calendar calendar = Calendar.getInstance();
125
-            		calendar.setTime(new Date());
132
+            	    Date date = new Date();
133
+            		calendar.setTime(date);
126 134
             		calendar.add(Calendar.DAY_OF_MONTH, -1);  // 在当前日基础上-1
127 135
             		//System.out.println(sdf.format(calendar.getTime()));
128 136
             		queryWrapper1.likeRight("begin_time", sdf.format(calendar.getTime()));
@@ -135,14 +143,78 @@ public class QuantityStatisticsServiceImpl extends ServiceImpl<QuantityStatistic
135 143
             	    }
136 144
             	    if(nBasicEdgeList.size()>1){
137 145
             	    	BigDecimal thisNumber = new BigDecimal(nBasicEdgeList.get(0).getLkWeight());
138
-            	    	BigDecimal lastNumber = new BigDecimal(lastList.get(0).getLkWeight());
146
+            	    	BigDecimal lastNumber = new BigDecimal(0);
147
+            	    	if(lastList.size()>0){
148
+                	         lastNumber = new BigDecimal(lastList.get(0).getLkWeight());
149
+            	    	}
139 150
             	    	BigDecimal poor = thisNumber.subtract(lastNumber);
140 151
             	    	BigDecimal complete = poor.divide(lastNumber,2,BigDecimal.ROUND_HALF_UP);
141 152
             	    	BigDecimal changeRatio = complete.multiply(new BigDecimal("100"));
142 153
             	    	list.get(0).setChangeRatio(changeRatio.stripTrailingZeros().toPlainString());
143 154
             	    }
144 155
             	    map.put("clxx", list.get(0));
145
-            	    map.put("nBasicEdgeList", nBasicEdgeList);
156
+            	    
157
+            	    QueryWrapper<NBasicEdge> ew = new QueryWrapper<>();
158
+            	    ew.eq("house_id", houseId);
159
+            	    if(StringUtils.isEmpty(startTime) && StringUtils.isEmpty(endTime)){
160
+            	    	Calendar calendar1 = Calendar.getInstance();
161
+                 		calendar1.setTime(date);
162
+                 		calendar1.add(Calendar.DAY_OF_MONTH, -7);  // 在当前日基础上-7
163
+                 		//System.out.println(sdf.format(calendar.getTime()));
164
+                 		endTime = sdf.format(date);
165
+                 		startTime = sdf.format(calendar1.getTime());
166
+                 		System.out.println(startTime+"---------------"+endTime);
167
+                 		map.put("startTime", startTime);
168
+                 		map.put("endTime", endTime);
169
+                 		
170
+            	    }
171
+            	    
172
+            	    ew.apply(!StringUtils.isEmpty(startTime),
173
+                            "date_format (begin_time,'%Y-%m-%d') >= date_format('" + startTime + "','%Y-%m-%d')")
174
+                    .apply(!StringUtils.isEmpty(endTime),
175
+                            "date_format (begin_time,'%Y-%m-%d') <= date_format('" + endTime + "','%Y-%m-%d')");
176
+            	    
177
+            	    ew.orderByDesc("id");
178
+            	    List<NBasicEdge> nBasicEdgeList1 = nBasicEdgeMapper.selectList(ew);
179
+            	    List dayList = new ArrayList<>();
180
+            	    List wightList = new ArrayList<>();
181
+            	    
182
+            	    
183
+            	    for (int i = 0; i < nBasicEdgeList1.size(); i++) {
184
+						if(i==0 || (i!=0 && !dayList.contains(sdf.format(nBasicEdgeList1.get(i).getBeginTime())))){
185
+							dayList.add(sdf.format(nBasicEdgeList1.get(i).getBeginTime()));
186
+							wightList.add(nBasicEdgeList1.get(i).getLkWeight());
187
+						}
188
+					}
189
+
190
+            		
191
+                    Long startT;
192
+            		try {
193
+            			startT = sdf.parse(startTime).getTime();
194
+            			 Long endT = sdf.parse(endTime).getTime();  
195
+            		     Long oneDay = 1000 * 60 * 60 * 24l;  
196
+            		     Long time = endT;  
197
+            		        while (time >= startT) {  
198
+            		            Date d = new Date(time);  
199
+            		            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");  
200
+            		            String date1=df.format(d);
201
+            		            System.out.println(date1+"****************");
202
+            		            if(!dayList.contains(date1)){
203
+            		            	dayList.add(date1);
204
+        							wightList.add(0);
205
+            		            }
206
+            		            
207
+            		            time -= oneDay; 
208
+            		        }
209
+            		} catch (ParseException e) {
210
+            			// TODO Auto-generated catch block
211
+            			e.printStackTrace();
212
+            		}  
213
+                   
214
+            		
215
+            	    
216
+            	    map.put("dayList", dayList);
217
+            	    map.put("wightList", wightList);
146 218
             	    
147 219
         	    }else{
148 220
         	    	map.put("clxx", "无储粮信息");
@@ -212,7 +284,11 @@ public class QuantityStatisticsServiceImpl extends ServiceImpl<QuantityStatistic
212 284
 				BigDecimal number = new BigDecimal(nBasicEdgeList.get(i).getLkWeight());
213 285
 				//System.out.println(nBasicEdgeList.get(i).getHStatus()+"--------------"+nBasicEdgeList.get(i).getLkWeight());
214 286
 				if(i == 0){
215
-					BigDecimal lastDayNumber = new BigDecimal(lastList.get(0).getLkWeight());
287
+					BigDecimal lastDayNumber = new BigDecimal(0);
288
+
289
+					if(lastList.size()>0){
290
+						 lastDayNumber = new BigDecimal(lastList.get(0).getLkWeight());
291
+					}
216 292
 					
217 293
 					if(nBasicEdgeList.get(i).getHStatus().equals("2")){ //2入库 4 出库
218 294
 						inNumber = inNumber.add(number.subtract(lastDayNumber));
@@ -237,7 +313,8 @@ public class QuantityStatisticsServiceImpl extends ServiceImpl<QuantityStatistic
237 313
 			for (int i = 0; i < lastList.size(); i++) {
238 314
 				BigDecimal number = new BigDecimal(lastList.get(i).getLkWeight());
239 315
 				if(lastList.size() == i+1){
240
-					BigDecimal lastDayNumber = null ;
316
+					
317
+					BigDecimal lastDayNumber = new BigDecimal(0);
241 318
 					if(lastEstList.size()>0){
242 319
 					   lastDayNumber = new BigDecimal(lastEstList.get(0).getLkWeight());
243 320
 					}
@@ -294,6 +371,48 @@ public class QuantityStatisticsServiceImpl extends ServiceImpl<QuantityStatistic
294 371
 		 map.put("remainingNumber", remainingNumber);
295 372
 		return map;
296 373
 	}
374
+
375
+	@Override
376
+	public Map<String, Object> getHouseMessage(PageParam pageParam) {
377
+		// TODO Auto-generated method stub
378
+		Map<String, Object> map = new HashMap<>();
379
+		String condition = pageParam.getCondition();
380
+		if (!StringUtils.isEmpty(condition)) {
381
+	        
382
+        	JSONObject jsStr = JSON.parseObject(condition);
383
+        	Integer orgId = jsStr.getIntValue("orgId");
384
+    		
385
+    		Map<String, Object> parm_map = new HashMap<>();
386
+    		if(!StringUtils.isEmpty(orgId.toString())){
387
+    			parm_map.put("parent_id", orgId);
388
+    		}
389
+    	    parm_map.put("store_type_code", 300003);
390
+    	    List<OrgInfo> list = orgInfoMapper.selectByMap(parm_map);
391
+    	    
392
+    	    //List<StorehouseClxx> list = storehouseClxxMapper.selectByMap(parm_map);
393
+    	    if(list.size()>0){
394
+    	    	for (OrgInfo orgInfo : list) {
395
+    	    		Map<String, Object> mp = new HashMap<>();
396
+    	    	    mp.put("main_id", orgInfo.getId());
397
+    	    	    List<StorehouseClxx> clxxList = storehouseClxxMapper.selectByMap(mp);
398
+    	    	    BasicEnum basicEnum = basicEnumMapper.selectById(clxxList.get(0).getPz());
399
+    	    	    orgInfo.setPzName(basicEnum.getEnumName());//粮食种类
400
+            	    
401
+            	    QueryWrapper<NBasicEdge> queryWrapper = new QueryWrapper<>();
402
+            	    queryWrapper.eq("house_id", orgInfo.getId());
403
+            	    queryWrapper.orderByDesc("id");
404
+            	    List<NBasicEdge> nBasicEdgeList = nBasicEdgeMapper.selectList(queryWrapper);
405
+            	    if(nBasicEdgeList.size()>0){
406
+            	    	orgInfo.setLsNumber(nBasicEdgeList.get(0).getLkWeight().toString());
407
+            	    }
408
+            	   
409
+				}
410
+    	    }
411
+    	    map.put("list", list);
412
+    	    
413
+		}	
414
+		return map;
415
+	}
297 416
 	
298 417
 
299 418
 }