hanqingsong преди 1 година
родител
ревизия
6679c47af6

+ 8 - 1
pom.xml

@@ -62,7 +62,7 @@
62 62
 		</dependency>
63 63
 		<dependency>
64 64
 			<groupId>org.springframework.cloud</groupId>
65
-			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
65
+			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
66 66
 		</dependency>
67 67
 		<dependency>
68 68
             <groupId>org.springframework.cloud</groupId>
@@ -152,6 +152,13 @@
152 152
 		    <!-- 注意版本.这里我使用的是1.3.2 -->
153 153
 		    <version>1.3.2</version>
154 154
 		</dependency>
155
+		<!-- lombok -->
156
+		<dependency>
157
+			<groupId>org.projectlombok</groupId>
158
+			<artifactId>lombok</artifactId>
159
+			<version>1.18.22</version>
160
+			<scope>provided</scope>
161
+		</dependency>
155 162
 	</dependencies>
156 163
 
157 164
 	<dependencyManagement>

+ 17 - 0
src/main/java/com/chinaitop/depot/profitlossStatement/controller/DataStatisticsController.java

@@ -1,17 +1,22 @@
1 1
 package com.chinaitop.depot.profitlossStatement.controller;
2 2
 
3 3
 import java.io.OutputStream;
4
+import java.util.ArrayList;
4 5
 import java.util.HashMap;
6
+import java.util.List;
5 7
 import java.util.Map;
6 8
 
7 9
 import javax.annotation.Resource;
8 10
 import javax.servlet.http.HttpServletRequest;
9 11
 import javax.servlet.http.HttpServletResponse;
10 12
 
13
+import com.chinaitop.depot.profitlossStatement.model.PayoffsInfo;
14
+import com.chinaitop.depot.profitlossStatement.param.PayoffsRequestParam;
11 15
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
12 16
 import org.slf4j.Logger;
13 17
 import org.slf4j.LoggerFactory;
14 18
 import org.springframework.http.MediaType;
19
+import org.springframework.web.bind.annotation.RequestBody;
15 20
 import org.springframework.web.bind.annotation.RequestMapping;
16 21
 import org.springframework.web.bind.annotation.RequestMethod;
17 22
 import org.springframework.web.bind.annotation.RestController;
@@ -140,4 +145,16 @@ public class DataStatisticsController {
140 145
 			logger.error(e.getMessage(), e);
141 146
 		}
142 147
 	}
148
+
149
+	@RequestMapping(value="/getPayoffsInfo",produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.POST)
150
+	@ApiOperation(value="损益单分析汇总列表", notes = "不支持分页")
151
+	@ApiImplicitParam(name = "param", value = "条件对象", paramType = "body")
152
+	public List<PayoffsInfo> getPayoffsInfo(@RequestBody PayoffsRequestParam param) {
153
+		try {
154
+			return dataStatisticsService.getPayoffsInfo(param);
155
+		} catch (Exception e) {
156
+			logger.error(e.getMessage(), e);
157
+		}
158
+		return new ArrayList<>();
159
+	}
143 160
 }

+ 5 - 0
src/main/java/com/chinaitop/depot/profitlossStatement/mapper/DataStatisticsMapper.java

@@ -4,6 +4,9 @@ import java.util.List;
4 4
 import java.util.Map;
5 5
 
6 6
 import com.chinaitop.depot.profitlossStatement.model.DataStatistics;
7
+import com.chinaitop.depot.profitlossStatement.model.PayoffsInfo;
8
+import com.chinaitop.depot.profitlossStatement.param.PayoffsRequestParam;
9
+import org.apache.ibatis.annotations.Param;
7 10
 
8 11
 public interface DataStatisticsMapper {
9 12
 
@@ -30,4 +33,6 @@ public interface DataStatisticsMapper {
30 33
 	 * @return
31 34
 	 */
32 35
 	List<DataStatistics> selectByKdmc(Map<String, String> paramMap);
36
+
37
+    List<PayoffsInfo> getPayoffsInfo(PayoffsRequestParam param);
33 38
 }

+ 46 - 0
src/main/java/com/chinaitop/depot/profitlossStatement/mapper/DataStatisticsMapper.xml

@@ -140,4 +140,50 @@
140 140
     </if>
141 141
     group by org.org_name
142 142
   </select>
143
+  <select id="getPayoffsInfo" parameterType="com.chinaitop.depot.profitlossStatement.param.PayoffsRequestParam" resultType="com.chinaitop.depot.profitlossStatement.model.PayoffsInfo">
144
+    select distinct
145
+      sps.id,
146
+      sps.org_id orgId,
147
+      be.enumname areaName,
148
+      oi.org_name orgName,
149
+      bs.storehouse_name storehouseName,
150
+      nvl(bw.warehouse_name, '一一') warehouseName,
151
+      be1.enumname varietyName,
152
+      be2.enumname gradeName,
153
+      nvl(be3.enumname, '一一') harvestYear,
154
+      be4.enumname grainNatureName,
155
+      TO_CHAR(sps.rksj, 'yyyy-mm-dd') rq,
156
+      nvl(sps.rksl,0) rksl,
157
+      nvl(sps.cksl,0) cksl,
158
+      sps.sssl,
159
+      round(sps.sssl/sps.rksl*100, 2) ssl,
160
+      nvl(sps.sjshsl,0) sjshsl,
161
+      round(sps.sjshsl/sps.rksl*100, 2) shl,
162
+      nvl(sps.yysl,0) yysl,
163
+      case when sps.chsl==0 then '否' else '是' end sfch,
164
+      nvl(sps.chsl,0) chsl
165
+    from
166
+        storage_profitloss_statement sps
167
+        left join org_info oi on sps.org_id = oi.org_id
168
+        left join basic_enum be on oi.zc_county = be.enumid
169
+        left join basic_storehouse bs on sps.cforyg = bs.storehouse_id
170
+        left join basic_warehouse bw on sps.hwid = bw.warehouse_id
171
+        left join basic_enum be1 on be1.enumid = sps.pz
172
+        left join basic_enum be2 on be2.enumid = sps.dj
173
+        left join lsreport_ts:data_kcgl_fcbgz_default kfd on kfd.ch = sps.cforyg and kfd.hwh = sps.hwid and TO_CHAR(sps.rksj,'yyyy-mm-dd hh24:mi:ss') = TO_CHAR(kfd.rq,'yyyy-mm-dd hh24:mi:ss')
174
+        left join basic_enum be3 on be3.enumid = kfd.scnf
175
+        left join basic_enum be4 on be4.enumid = sps.lsxz
176
+    <where>
177
+      sps.audit_state = 6
178
+      <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
179
+        and sps.cksj between #{startTime} and #{endTime}
180
+      </if>
181
+      <if test="orgName != null and orgName != ''">
182
+        and oi.org_name like '%'||#{orgName}||'%'
183
+      </if>
184
+      <if test="areaName != null and areaName != ''">
185
+        and be.enumname like '%'||#{areaName}||'%'
186
+      </if>
187
+    </where>
188
+  </select>
143 189
 </mapper>

+ 53 - 0
src/main/java/com/chinaitop/depot/profitlossStatement/model/PayoffsInfo.java

@@ -0,0 +1,53 @@
1
+package com.chinaitop.depot.profitlossStatement.model;
2
+
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+
6
+import java.io.Serializable;
7
+import java.math.BigDecimal;
8
+
9
+/**
10
+ * @author qingsong.han
11
+ * @description: 损益单分析汇总
12
+ * @create 2024-11-18 10:16
13
+ */
14
+@Getter @Setter
15
+public class PayoffsInfo implements Serializable {
16
+    private static final long serialVersionUID = -9027285257515748650L;
17
+    // 地区
18
+    private String areaName;
19
+    // 企业名称
20
+    private String orgName;
21
+    // 仓房名称
22
+    private String storehouseName;
23
+    // 货位名称
24
+    private String warehouseName;
25
+    // 粮食品种
26
+    private String varietyName;
27
+    // 质量等级
28
+    private String gradeName;
29
+    // 收获年度
30
+    private String harvestYear;
31
+    // 粮食性质
32
+    private String grainNatureName;
33
+    // 入库日期
34
+    private String rq;
35
+    // 入库数量(kg)
36
+    private BigDecimal rksl;
37
+    // 出库数量(kg)
38
+    private BigDecimal cksl;
39
+    // 损失量(kg)
40
+    private String sssl;
41
+    // 损失率(%)
42
+    private String ssl;
43
+    // 损耗量(kg)
44
+    private BigDecimal sjshsl;
45
+    // 损耗率(%)
46
+    private BigDecimal shl;
47
+    // 溢余数量(kg)
48
+    private BigDecimal yysl;
49
+    // 是否超耗
50
+    private String sfch;
51
+    // 超耗数量(kg)
52
+    private BigDecimal chsl;
53
+}

+ 24 - 0
src/main/java/com/chinaitop/depot/profitlossStatement/param/PayoffsRequestParam.java

@@ -0,0 +1,24 @@
1
+package com.chinaitop.depot.profitlossStatement.param;
2
+
3
+import lombok.Data;
4
+
5
+import java.io.Serializable;
6
+
7
+/**
8
+ * @author qingsong.han
9
+ * @description:
10
+ * @create 2024-11-18 9:31
11
+ */
12
+@Data
13
+public class PayoffsRequestParam implements Serializable {
14
+    private static final long serialVersionUID = -7711211178033937446L;
15
+
16
+    // 出库完成时间-开始
17
+    private String startTime;
18
+    // 出库完成时间-结束
19
+    private String endTime;
20
+    // 企业名称
21
+    private String orgName;
22
+    // 地区名称
23
+    private String areaName;
24
+}

+ 5 - 0
src/main/java/com/chinaitop/depot/profitlossStatement/service/DataStatisticsService.java

@@ -1,7 +1,10 @@
1 1
 package com.chinaitop.depot.profitlossStatement.service;
2 2
 
3
+import java.util.List;
3 4
 import java.util.Map;
4 5
 
6
+import com.chinaitop.depot.profitlossStatement.model.PayoffsInfo;
7
+import com.chinaitop.depot.profitlossStatement.param.PayoffsRequestParam;
5 8
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
6 9
 
7 10
 public interface DataStatisticsService {
@@ -52,4 +55,6 @@ public interface DataStatisticsService {
52 55
 	 * @return
53 56
 	 */
54 57
 	HSSFWorkbook exportData(String startTime, String endTime, String orgCode) throws Exception;
58
+
59
+    List<PayoffsInfo> getPayoffsInfo(PayoffsRequestParam param);
55 60
 }

+ 475 - 412
src/main/java/com/chinaitop/depot/profitlossStatement/service/impl/DataStatisticsServiceImpl.java

@@ -2,12 +2,17 @@ package com.chinaitop.depot.profitlossStatement.service.impl;
2 2
 
3 3
 import java.math.BigDecimal;
4 4
 import java.math.RoundingMode;
5
+import java.util.ArrayList;
5 6
 import java.util.HashMap;
6 7
 import java.util.List;
7 8
 import java.util.Map;
9
+import java.util.stream.Collectors;
8 10
 
9 11
 import javax.annotation.Resource;
10 12
 
13
+import com.chinaitop.depot.profitlossStatement.model.PayoffsInfo;
14
+import com.chinaitop.depot.profitlossStatement.param.PayoffsRequestParam;
15
+import lombok.extern.slf4j.Slf4j;
11 16
 import org.apache.commons.lang3.StringUtils;
12 17
 import org.apache.poi.hssf.usermodel.HSSFCell;
13 18
 import org.apache.poi.hssf.usermodel.HSSFCellStyle;
@@ -23,424 +28,482 @@ import com.chinaitop.depot.profitlossStatement.service.DataStatisticsService;
23 28
 import com.chinaitop.depot.utils.HSSFWorkBookUtils;
24 29
 import com.github.pagehelper.PageHelper;
25 30
 import com.github.pagehelper.PageInfo;
31
+import org.springframework.util.CollectionUtils;
26 32
 
33
+@Slf4j
27 34
 @Service
28 35
 public class DataStatisticsServiceImpl implements DataStatisticsService {
29 36
 
30
-	@Resource
31
-	private DataStatisticsMapper dataStatisticsMapper;
32
-
33
-	/**
34
-	 * 获取合计行数据
35
-	 * @return
36
-	 */
37
-	private DataStatistics getHjDate(List<DataStatistics> listall) {
38
-
39
-		DataStatistics hj_obj = new DataStatistics();
40
-
41
-		//入库数量合计
42
-		BigDecimal rksl_hj = listall.stream().map(DataStatistics::getRksl).reduce(BigDecimal.ZERO, BigDecimal::add);
43
-		hj_obj.setRksl(rksl_hj);
44
-
45
-		//出库数量合计
46
-		BigDecimal cksl_hj = listall.stream().map(DataStatistics::getCksl).reduce(BigDecimal.ZERO, BigDecimal::add);
47
-		hj_obj.setCksl(cksl_hj);
48
-
49
-		//损失数量合计
50
-		BigDecimal sssl_hj = listall.stream().map(DataStatistics::getSssl).reduce(BigDecimal.ZERO, BigDecimal::add);
51
-		hj_obj.setSssl(sssl_hj);
52
-
53
-		//损耗数量合计
54
-		BigDecimal shsl_hj = listall.stream().map(DataStatistics::getShsl).reduce(BigDecimal.ZERO, BigDecimal::add);
55
-		hj_obj.setShsl(shsl_hj);
56
-
57
-		//溢余数量合计
58
-		BigDecimal yysl_hj = listall.stream().map(DataStatistics::getYysl).reduce(BigDecimal.ZERO, BigDecimal::add);
59
-		hj_obj.setYysl(yysl_hj);
60
-
61
-		//超耗数量合计
62
-		BigDecimal chsl_hj = listall.stream().map(DataStatistics::getChsl).reduce(BigDecimal.ZERO, BigDecimal::add);
63
-		hj_obj.setChsl(chsl_hj);
64
-		
65
-		//水杂减量合计
66
-		BigDecimal szjlhj_hj = listall.stream().map(DataStatistics::getSzjlhj).reduce(BigDecimal.ZERO, BigDecimal::add);
67
-		hj_obj.setSzjlhj(szjlhj_hj);
68
-		
69
-		//保管自然损耗定额数量合计
70
-		BigDecimal bgzrshdesl_hj = listall.stream().map(DataStatistics::getBgzrshdesl).reduce(BigDecimal.ZERO, BigDecimal::add);
71
-		hj_obj.setBgzrshdesl(bgzrshdesl_hj);
72
-
73
-		//合计损失率(四射五入保留两位小数):损失数量 / 入库数量 * 100
74
-		BigDecimal ssl_hj = sssl_hj.divide(rksl_hj, 5, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
75
-		hj_obj.setSsl(ssl_hj);
76
-
77
-		//合计损耗率(四射五入保留两位小数):损耗数量 / 入库数量 * 100
78
-		BigDecimal shl_hj = shsl_hj.divide(rksl_hj, 5, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
79
-		hj_obj.setShl(shl_hj);
80
-
81
-		return hj_obj;
82
-	}
83
-	@Override
84
-	public Map<String, Object> selectByCflx(Integer pageNum, Integer pageSize, String startTime, String endTime, String orgCode) throws Exception {
85
-		Map<String, Object> map = new HashMap<>();
86
-		PageInfo<DataStatistics> pageInfo = null;
87
-		Map<String, String> paramMap = new HashMap<String, String>();
88
-		if (StringUtils.isNotBlank(orgCode)) {
89
-			paramMap.put("orgCode", orgCode);
90
-		}
91
-		if (StringUtils.isNotBlank(startTime)) {
92
-			startTime = startTime+" 00:00:00";
93
-			paramMap.put("startTime", startTime);
94
-		}
95
-		if (StringUtils.isNotBlank(endTime)) {
96
-			endTime = endTime+" 23:59:59";
97
-			paramMap.put("endTime", endTime);
98
-		}
99
-		List<DataStatistics> listall = dataStatisticsMapper.selectByCflx(paramMap);
100
-
101
-		//获取合计行数据
102
-		DataStatistics hj_obj = getHjDate(listall);
103
-
104
-		map.put("ht_object", hj_obj);
105
-
106
-		if (null != pageNum && null != pageSize) {
107
-			PageHelper.startPage(pageNum, pageSize);
108
-		}
109
-		List<DataStatistics> list = dataStatisticsMapper.selectByCflx(paramMap);
110
-		pageInfo = new PageInfo<DataStatistics>(list);
111
-
112
-		map.put("pageInfo", pageInfo);
113
-
114
-		return map;
115
-	}
116
-
117
-	@Override
118
-	public Map<String, Object> selectByLspz(Integer pageNum, Integer pageSize, String startTime, String endTime, String orgCode) throws Exception {
119
-		Map<String, Object> map = new HashMap<>();
120
-
121
-		PageInfo<DataStatistics> pageInfo = null;
37
+    @Resource
38
+    private DataStatisticsMapper dataStatisticsMapper;
39
+
40
+    /**
41
+     * 获取合计行数据
42
+     *
43
+     * @return
44
+     */
45
+    private DataStatistics getHjDate(List<DataStatistics> listall) {
46
+
47
+        DataStatistics hj_obj = new DataStatistics();
48
+
49
+        //入库数量合计
50
+        BigDecimal rksl_hj = listall.stream().map(DataStatistics::getRksl).reduce(BigDecimal.ZERO, BigDecimal::add);
51
+        hj_obj.setRksl(rksl_hj);
52
+
53
+        //出库数量合计
54
+        BigDecimal cksl_hj = listall.stream().map(DataStatistics::getCksl).reduce(BigDecimal.ZERO, BigDecimal::add);
55
+        hj_obj.setCksl(cksl_hj);
56
+
57
+        //损失数量合计
58
+        BigDecimal sssl_hj = listall.stream().map(DataStatistics::getSssl).reduce(BigDecimal.ZERO, BigDecimal::add);
59
+        hj_obj.setSssl(sssl_hj);
60
+
61
+        //损耗数量合计
62
+        BigDecimal shsl_hj = listall.stream().map(DataStatistics::getShsl).reduce(BigDecimal.ZERO, BigDecimal::add);
63
+        hj_obj.setShsl(shsl_hj);
64
+
65
+        //溢余数量合计
66
+        BigDecimal yysl_hj = listall.stream().map(DataStatistics::getYysl).reduce(BigDecimal.ZERO, BigDecimal::add);
67
+        hj_obj.setYysl(yysl_hj);
68
+
69
+        //超耗数量合计
70
+        BigDecimal chsl_hj = listall.stream().map(DataStatistics::getChsl).reduce(BigDecimal.ZERO, BigDecimal::add);
71
+        hj_obj.setChsl(chsl_hj);
72
+
73
+        //水杂减量合计
74
+        BigDecimal szjlhj_hj = listall.stream().map(DataStatistics::getSzjlhj).reduce(BigDecimal.ZERO, BigDecimal::add);
75
+        hj_obj.setSzjlhj(szjlhj_hj);
76
+
77
+        //保管自然损耗定额数量合计
78
+        BigDecimal bgzrshdesl_hj = listall.stream().map(DataStatistics::getBgzrshdesl).reduce(BigDecimal.ZERO, BigDecimal::add);
79
+        hj_obj.setBgzrshdesl(bgzrshdesl_hj);
80
+
81
+        //合计损失率(四射五入保留两位小数):损失数量 / 入库数量 * 100
82
+        BigDecimal ssl_hj = sssl_hj.divide(rksl_hj, 5, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
83
+        hj_obj.setSsl(ssl_hj);
84
+
85
+        //合计损耗率(四射五入保留两位小数):损耗数量 / 入库数量 * 100
86
+        BigDecimal shl_hj = shsl_hj.divide(rksl_hj, 5, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
87
+        hj_obj.setShl(shl_hj);
88
+
89
+        return hj_obj;
90
+    }
91
+
92
+    @Override
93
+    public Map<String, Object> selectByCflx(Integer pageNum, Integer pageSize, String startTime, String endTime, String orgCode) throws Exception {
94
+        Map<String, Object> map = new HashMap<>();
95
+        PageInfo<DataStatistics> pageInfo = null;
96
+        Map<String, String> paramMap = new HashMap<String, String>();
97
+        if (StringUtils.isNotBlank(orgCode)) {
98
+            paramMap.put("orgCode", orgCode);
99
+        }
100
+        if (StringUtils.isNotBlank(startTime)) {
101
+            startTime = startTime + " 00:00:00";
102
+            paramMap.put("startTime", startTime);
103
+        }
104
+        if (StringUtils.isNotBlank(endTime)) {
105
+            endTime = endTime + " 23:59:59";
106
+            paramMap.put("endTime", endTime);
107
+        }
108
+        List<DataStatistics> listall = dataStatisticsMapper.selectByCflx(paramMap);
109
+
110
+        //获取合计行数据
111
+        DataStatistics hj_obj = getHjDate(listall);
112
+
113
+        map.put("ht_object", hj_obj);
114
+
115
+        if (null != pageNum && null != pageSize) {
116
+            PageHelper.startPage(pageNum, pageSize);
117
+        }
118
+        List<DataStatistics> list = dataStatisticsMapper.selectByCflx(paramMap);
119
+        pageInfo = new PageInfo<DataStatistics>(list);
120
+
121
+        map.put("pageInfo", pageInfo);
122
+
123
+        return map;
124
+    }
125
+
126
+    @Override
127
+    public Map<String, Object> selectByLspz(Integer pageNum, Integer pageSize, String startTime, String endTime, String orgCode) throws Exception {
128
+        Map<String, Object> map = new HashMap<>();
129
+
130
+        PageInfo<DataStatistics> pageInfo = null;
131
+
132
+        Map<String, String> paramMap = new HashMap<String, String>();
133
+        if (StringUtils.isNotBlank(orgCode)) {
134
+            paramMap.put("orgCode", orgCode);
135
+        }
136
+        if (StringUtils.isNotBlank(startTime)) {
137
+            startTime = startTime + " 00:00:00";
138
+            paramMap.put("startTime", startTime);
139
+        }
140
+        if (StringUtils.isNotBlank(endTime)) {
141
+            endTime = endTime + " 23:59:59";
142
+            paramMap.put("endTime", endTime);
143
+        }
144
+        List<DataStatistics> listall = dataStatisticsMapper.selectByLspz(paramMap);
145
+
146
+        //获取合计行数据
147
+        DataStatistics hj_obj = getHjDate(listall);
148
+
149
+        map.put("ht_object", hj_obj);
150
+
151
+        if (null != pageNum && null != pageSize) {
152
+            PageHelper.startPage(pageNum, pageSize);
153
+        }
154
+        List<DataStatistics> list = dataStatisticsMapper.selectByLspz(paramMap);
155
+        pageInfo = new PageInfo<DataStatistics>(list);
156
+
157
+        map.put("pageInfo", pageInfo);
158
+
159
+        return map;
160
+    }
161
+
162
+    @Override
163
+    public Map<String, Object> selectByLsxz(Integer pageNum, Integer pageSize, String startTime, String endTime, String orgCode) throws Exception {
164
+        Map<String, Object> map = new HashMap<>();
165
+
166
+        PageInfo<DataStatistics> pageInfo = null;
167
+
168
+        Map<String, String> paramMap = new HashMap<String, String>();
169
+        if (StringUtils.isNotBlank(orgCode)) {
170
+            paramMap.put("orgCode", orgCode);
171
+        }
172
+        if (StringUtils.isNotBlank(startTime)) {
173
+            startTime = startTime + " 00:00:00";
174
+            paramMap.put("startTime", startTime);
175
+        }
176
+        if (StringUtils.isNotBlank(endTime)) {
177
+            endTime = endTime + " 23:59:59";
178
+            paramMap.put("endTime", endTime);
179
+        }
180
+
181
+        List<DataStatistics> listall = dataStatisticsMapper.selectByLsxz(paramMap);
182
+
183
+        //获取合计行数据
184
+        DataStatistics hj_obj = getHjDate(listall);
185
+
186
+        map.put("ht_object", hj_obj);
187
+
188
+        if (null != pageNum && null != pageSize) {
189
+            PageHelper.startPage(pageNum, pageSize);
190
+        }
191
+
192
+        List<DataStatistics> list = dataStatisticsMapper.selectByLsxz(paramMap);
193
+        pageInfo = new PageInfo<DataStatistics>(list);
194
+
195
+        map.put("pageInfo", pageInfo);
196
+
197
+        return map;
198
+    }
199
+
200
+    @Override
201
+    public Map<String, Object> selectByKdmc(Integer pageNum, Integer pageSize, String startTime, String endTime, String orgCode) throws Exception {
202
+        Map<String, Object> map = new HashMap<>();
203
+
204
+        PageInfo<DataStatistics> pageInfo = null;
122 205
 
123 206
         Map<String, String> paramMap = new HashMap<String, String>();
124 207
         if (StringUtils.isNotBlank(orgCode)) {
125
-			paramMap.put("orgCode", orgCode);
126
-		}
208
+            paramMap.put("orgCode", orgCode);
209
+        }
127 210
         if (StringUtils.isNotBlank(startTime)) {
128
-			startTime = startTime+" 00:00:00";
129
-			paramMap.put("startTime", startTime);
130
-		}
131
-		if (StringUtils.isNotBlank(endTime)) {
132
-			endTime = endTime+" 23:59:59";
133
-			paramMap.put("endTime", endTime);
134
-		}
135
-		List<DataStatistics> listall = dataStatisticsMapper.selectByLspz(paramMap);
136
-
137
-		//获取合计行数据
138
-		DataStatistics hj_obj = getHjDate(listall);
139
-
140
-		map.put("ht_object", hj_obj);
141
-		
142
-		if (null != pageNum && null != pageSize) {
143
-			PageHelper.startPage(pageNum, pageSize);
144
-		}
145
-		List<DataStatistics> list = dataStatisticsMapper.selectByLspz(paramMap);
146
-		pageInfo = new PageInfo<DataStatistics>(list);
147
-
148
-		map.put("pageInfo", pageInfo);
149
-
150
-		return map;
151
-	}
152
-
153
-	@Override
154
-	public Map<String, Object> selectByLsxz(Integer pageNum, Integer pageSize, String startTime, String endTime, String orgCode) throws Exception {
155
-		Map<String, Object> map = new HashMap<>();
156
-
157
-		PageInfo<DataStatistics> pageInfo = null;
158
-
159
-		Map<String, String> paramMap = new HashMap<String, String>();
160
-		if (StringUtils.isNotBlank(orgCode)) {
161
-			paramMap.put("orgCode", orgCode);
162
-		}
163
-		if (StringUtils.isNotBlank(startTime)) {
164
-			startTime = startTime+" 00:00:00";
165
-			paramMap.put("startTime", startTime);
166
-		}
167
-		if (StringUtils.isNotBlank(endTime)) {
168
-			endTime = endTime+" 23:59:59";
169
-			paramMap.put("endTime", endTime);
170
-		}
171
-
172
-		List<DataStatistics> listall = dataStatisticsMapper.selectByLsxz(paramMap);
173
-
174
-		//获取合计行数据
175
-		DataStatistics hj_obj = getHjDate(listall);
176
-
177
-		map.put("ht_object", hj_obj);
178
-
179
-		if (null != pageNum && null != pageSize) {
180
-			PageHelper.startPage(pageNum, pageSize);
181
-		}
182
-
183
-		List<DataStatistics> list = dataStatisticsMapper.selectByLsxz(paramMap);
184
-		pageInfo = new PageInfo<DataStatistics>(list);
185
-
186
-		map.put("pageInfo", pageInfo);
187
-
188
-		return map;
189
-	}
190
-
191
-	@Override
192
-	public Map<String, Object> selectByKdmc(Integer pageNum, Integer pageSize, String startTime, String endTime, String orgCode) throws Exception {
193
-		Map<String, Object> map = new HashMap<>();
194
-
195
-		PageInfo<DataStatistics> pageInfo = null;
196
-
197
-		Map<String, String> paramMap = new HashMap<String, String>();
198
-		if (StringUtils.isNotBlank(orgCode)) {
199
-			paramMap.put("orgCode", orgCode);
200
-		}
201
-		if (StringUtils.isNotBlank(startTime)) {
202
-			startTime = startTime+" 00:00:00";
203
-			paramMap.put("startTime", startTime);
204
-		}
205
-		if (StringUtils.isNotBlank(endTime)) {
206
-			endTime = endTime+" 23:59:59";
207
-			paramMap.put("endTime", endTime);
208
-		}
209
-
210
-		List<DataStatistics> listall = dataStatisticsMapper.selectByKdmc(paramMap);
211
-
212
-		//获取合计行数据
213
-		DataStatistics hj_obj = getHjDate(listall);
214
-
215
-		map.put("ht_object", hj_obj);
216
-
217
-		if (null != pageNum && null != pageSize) {
218
-			PageHelper.startPage(pageNum, pageSize);
219
-		}
220
-		List<DataStatistics> list = dataStatisticsMapper.selectByKdmc(paramMap);
221
-		pageInfo = new PageInfo<DataStatistics>(list);
222
-
223
-		map.put("pageInfo", pageInfo);
224
-
225
-		return map;
226
-	}
227
-
228
-	@Override
229
-	public HSSFWorkbook exportData(String startTime, String endTime, String orgCode) throws Exception {
230
-		HSSFWorkbook wb = new HSSFWorkbook();
231
-
232
-		CellRangeAddress cellRange = new CellRangeAddress(0, 0, 0, 11); // A1到J1的区域
233
-
234
-		// 创建"仓房类型统计"工作表
235
-		HSSFSheet sheetCflx = wb.createSheet("仓房类型统计");
236
-		sheetCflx.addMergedRegion(cellRange);
237
-		setSheetData(wb, sheetCflx, "cflx", startTime, endTime, orgCode);
238
-
239
-		HSSFSheet sheetLspz = wb.createSheet("粮食品种统计");
240
-		sheetLspz.addMergedRegion(cellRange);
241
-		setSheetData(wb, sheetLspz, "lspz", startTime, endTime, orgCode);
242
-
243
-		HSSFSheet sheetLsxz = wb.createSheet("粮食性质统计");
244
-		sheetLsxz.addMergedRegion(cellRange);
245
-		setSheetData(wb, sheetLsxz, "lsxz", startTime, endTime, orgCode);
246
-
247
-		HSSFSheet sheetKdmc = wb.createSheet("库点统计");
248
-		sheetKdmc.addMergedRegion(cellRange);
249
-		setSheetData(wb, sheetKdmc, "kdmc", startTime, endTime, orgCode);
250
-
251
-		return wb;
252
-	}
253
-
254
-	@SuppressWarnings("unchecked")
255
-	public void setSheetData(HSSFWorkbook wb, HSSFSheet sheet, String sheetNum, String startTime, String endTime, String orgCode) throws Exception {
256
-		HSSFCellStyle headStyle = HSSFWorkBookUtils.headStyle(wb);
257
-		HSSFCellStyle contentStyle = HSSFWorkBookUtils.contentStyle(wb);
258
-		
259
-		sheet.setColumnWidth(2, 20*256);
260
-		sheet.setColumnWidth(3, 20*256);
261
-		sheet.setColumnWidth(4, 20*256);
262
-		sheet.setColumnWidth(5, 20*256);
263
-		sheet.setColumnWidth(6, 20*256);
264
-		sheet.setColumnWidth(7, 20*256);
265
-		sheet.setColumnWidth(8, 20*256);
266
-		sheet.setColumnWidth(9, 20*256);
267
-		sheet.setColumnWidth(10, 20*256);
268
-		sheet.setColumnWidth(11, 20*256);
269
-
270
-		//第一行:标题行
271
-		HSSFRow sheetRow = sheet.createRow(0);
272
-		HSSFCell cell = sheetRow.createCell(0);
273
-		String tilleName = "";
274
-		List<DataStatistics> list = null;
275
-		Map<String, Object> map = null;
276
-		DataStatistics ds = null;
277
-		String cell2Name = ""; //第二行第二列的名称
278
-		if ("cflx".equals(sheetNum)) {
279
-			tilleName = "按照仓房类型统计分析汇总表";
280
-			cell2Name = "仓房类型";
281
-			sheet.setColumnWidth(1, 18*256);
282
-			map = selectByCflx(null, null, startTime, endTime, orgCode);
283
-			ds = (DataStatistics) map.get("ht_object");
284
-			list = ((PageInfo<DataStatistics>)map.get("pageInfo")).getList();
285
-		} else if ("lspz".equals(sheetNum)) {
286
-			tilleName = "按照粮食品种统计分析汇总表";
287
-			cell2Name = "粮食品种";
288
-			sheet.setColumnWidth(1, 20*256);
289
-			map = selectByLspz(null, null, startTime, endTime, orgCode);
290
-			ds = (DataStatistics) map.get("ht_object");
291
-			list = ((PageInfo<DataStatistics>)map.get("pageInfo")).getList();
292
-		} else if ("lsxz".equals(sheetNum)) {
293
-			tilleName = "按照粮食性质统计分析汇总表";
294
-			cell2Name = "粮食性质";
295
-			sheet.setColumnWidth(1, 40*256);
296
-			map = selectByLsxz(null, null, startTime, endTime, orgCode);
297
-			ds = (DataStatistics) map.get("ht_object");
298
-			list = ((PageInfo<DataStatistics>)map.get("pageInfo")).getList();
299
-		} else if ("kdmc".equals(sheetNum)) {
300
-			tilleName = "按照库点统计分析汇总表";
301
-			cell2Name = "库点名称";
302
-			sheet.setColumnWidth(1, 45*256);
303
-			map = selectByKdmc(null, null, startTime, endTime, orgCode);
304
-			ds = (DataStatistics) map.get("ht_object");
305
-			list = ((PageInfo<DataStatistics>)map.get("pageInfo")).getList();
306
-		}
307
-
308
-		cell.setCellValue(tilleName);
309
-		cell.setCellStyle(headStyle);
310
-
311
-		//第二行
312
-		HSSFRow sheetRow1 = sheet.createRow(1);//列名所在行
313
-		HSSFCell rowCell1 = sheetRow1.createCell(0);
314
-		rowCell1.setCellValue("序号");
315
-		rowCell1.setCellStyle(contentStyle);
316
-		HSSFCell rowCell2 = sheetRow1.createCell(1);
317
-		//第二行第二列的名称
318
-		rowCell2.setCellValue(cell2Name);
319
-		rowCell2.setCellStyle(contentStyle);
320
-		HSSFCell rowCell3 = sheetRow1.createCell(2);
321
-		rowCell3.setCellValue("入库数量(kg)");
322
-		rowCell3.setCellStyle(contentStyle);
323
-		HSSFCell rowCell4 = sheetRow1.createCell(3);
324
-		rowCell4.setCellValue("出库数量(kg)");
325
-		rowCell4.setCellStyle(contentStyle);
326
-		HSSFCell rowCell5 = sheetRow1.createCell(4);
327
-		rowCell5.setCellValue("损失数量(kg)");
328
-		rowCell5.setCellStyle(contentStyle);
329
-		HSSFCell rowCell6 = sheetRow1.createCell(5);
330
-		rowCell6.setCellValue("损失率(%)");
331
-		rowCell6.setCellStyle(contentStyle);
332
-		HSSFCell rowCell7 = sheetRow1.createCell(6);
333
-		rowCell7.setCellValue("损耗数量(kg)");
334
-		rowCell7.setCellStyle(contentStyle);
335
-		HSSFCell rowCell8 = sheetRow1.createCell(7);
336
-		rowCell8.setCellValue("损耗率(%)");
337
-		rowCell8.setCellStyle(contentStyle);
338
-		HSSFCell rowCell9 = sheetRow1.createCell(8);
339
-		rowCell9.setCellValue("溢余数量(kg)");
340
-		rowCell9.setCellStyle(contentStyle);
341
-		HSSFCell rowCell10 = sheetRow1.createCell(9);
342
-		rowCell10.setCellValue("超耗数量(kg)");
343
-		rowCell10.setCellStyle(contentStyle);
344
-		HSSFCell rowCell11 = sheetRow1.createCell(10);
345
-		rowCell11.setCellValue("水杂减量合计(kg)");
346
-		rowCell11.setCellStyle(contentStyle);
347
-		HSSFCell rowCell12 = sheetRow1.createCell(11);
348
-		rowCell12.setCellValue("保管自然损耗定额(kg)");
349
-		rowCell12.setCellStyle(contentStyle);
350
-
351
-		//第三行:合计行
352
-		HSSFRow sheetRow2 = sheet.createRow(2);//列名所在行
353
-		HSSFCell row2Cell1 = sheetRow2.createCell(0);
354
-		row2Cell1.setCellValue("——");
355
-		row2Cell1.setCellStyle(contentStyle);
356
-		HSSFCell row2Cell2 = sheetRow2.createCell(1);
357
-		//第二行第二列的名称
358
-		row2Cell2.setCellValue("合计");
359
-		row2Cell2.setCellStyle(headStyle);
360
-		HSSFCell row2Cell3 = sheetRow2.createCell(2);
361
-		row2Cell3.setCellValue(ds.getRksl()+"");
362
-		row2Cell3.setCellStyle(contentStyle);
363
-		HSSFCell row2Cell4 = sheetRow2.createCell(3);
364
-		row2Cell4.setCellValue(ds.getCksl()+"");
365
-		row2Cell4.setCellStyle(contentStyle);
366
-		HSSFCell row2Cell5 = sheetRow2.createCell(4);
367
-		row2Cell5.setCellValue(ds.getSssl()+"");
368
-		row2Cell5.setCellStyle(contentStyle);
369
-		HSSFCell row2Cell6 = sheetRow2.createCell(5);
370
-		row2Cell6.setCellValue(ds.getSsl()+"");
371
-		row2Cell6.setCellStyle(contentStyle);
372
-		HSSFCell row2Cell7 = sheetRow2.createCell(6);
373
-		row2Cell7.setCellValue(ds.getShsl()+"");
374
-		row2Cell7.setCellStyle(contentStyle);
375
-		HSSFCell row2Cell8 = sheetRow2.createCell(7);
376
-		row2Cell8.setCellValue(ds.getShl()+"");
377
-		row2Cell8.setCellStyle(contentStyle);
378
-		HSSFCell row2Cell9 = sheetRow2.createCell(8);
379
-		row2Cell9.setCellValue(ds.getYysl()+"");
380
-		row2Cell9.setCellStyle(contentStyle);
381
-		HSSFCell row2Cell10 = sheetRow2.createCell(9);
382
-		row2Cell10.setCellValue(ds.getChsl()+"");
383
-		row2Cell10.setCellStyle(contentStyle);
384
-		HSSFCell row2Cell11 = sheetRow2.createCell(10);
385
-		row2Cell11.setCellValue(ds.getSzjlhj()+"");
386
-		row2Cell11.setCellStyle(contentStyle);
387
-		HSSFCell row2Cell12 = sheetRow2.createCell(11);
388
-		row2Cell12.setCellValue(ds.getBgzrshdesl()+"");
389
-		row2Cell12.setCellStyle(contentStyle);
390
-
391
-		Integer xh=1;
392
-		int rowNum = 2;
393
-		HSSFRow rowData = null;
394
-		DataStatistics data = null;
395
-		for (int i = 0; i < list.size(); i++) {
396
-			rowNum = rowNum + 1;
397
-			data = list.get(i);
398
-			rowData = sheet.createRow(rowNum);
399
-			HSSFCell rowCellData1 = rowData.createCell(0);
400
-			rowCellData1.setCellValue(xh);
401
-			rowCellData1.setCellStyle(contentStyle);
402
-			HSSFCell rowCellData2 = rowData.createCell(1);
403
-			if ("cflx".equals(sheetNum)) {
404
-				rowCellData2.setCellValue(data.getCflx());
405
-			} else if ("lspz".equals(sheetNum)) {
406
-				rowCellData2.setCellValue(data.getLspz());
407
-			} else if ("lsxz".equals(sheetNum)) {
408
-				rowCellData2.setCellValue(data.getLsxz());
409
-			} else if ("kdmc".equals(sheetNum)) {
410
-				rowCellData2.setCellValue(data.getKdmc());
411
-			}
412
-			rowCellData2.setCellStyle(contentStyle);
413
-			HSSFCell rowCellData3 = rowData.createCell(2);
414
-			rowCellData3.setCellValue(data.getRksl() == null ? "":data.getRksl().toString());
415
-			rowCellData3.setCellStyle(contentStyle);
416
-			HSSFCell rowCellData4 = rowData.createCell(3);
417
-			rowCellData4.setCellValue(data.getCksl() == null ? "":data.getCksl().toString());
418
-			rowCellData4.setCellStyle(contentStyle);
419
-			HSSFCell rowCellData5 = rowData.createCell(4);
420
-			rowCellData5.setCellValue(data.getSssl() == null ? "":data.getSssl().toString());
421
-			rowCellData5.setCellStyle(contentStyle);
422
-			HSSFCell rowCellData6 = rowData.createCell(5);
423
-			rowCellData6.setCellValue(data.getSsl() == null ? "":data.getSsl().toString());
424
-			rowCellData6.setCellStyle(contentStyle);
425
-			HSSFCell rowCellData7 = rowData.createCell(6);
426
-			rowCellData7.setCellValue(data.getShsl() == null ? "":data.getShsl().toString());
427
-			rowCellData7.setCellStyle(contentStyle);
428
-			HSSFCell rowCellData8 = rowData.createCell(7);
429
-			rowCellData8.setCellValue(data.getShl() == null ? "":data.getShl().toString());
430
-			rowCellData8.setCellStyle(contentStyle);
431
-			HSSFCell rowCellData9 = rowData.createCell(8);
432
-			rowCellData9.setCellValue(data.getYysl() == null ? "":data.getYysl().toString());
433
-			rowCellData9.setCellStyle(contentStyle);
434
-			HSSFCell rowCellData10 = rowData.createCell(9);
435
-			rowCellData10.setCellValue(data.getChsl() == null ? "":data.getChsl().toString());
436
-			rowCellData10.setCellStyle(contentStyle);
437
-			HSSFCell rowCellData11 = rowData.createCell(10);
438
-			rowCellData11.setCellValue(data.getSzjlhj() == null ? "":data.getSzjlhj().toString());
439
-			rowCellData11.setCellStyle(contentStyle);
440
-			HSSFCell rowCellData12 = rowData.createCell(11);
441
-			rowCellData12.setCellValue(data.getBgzrshdesl() == null ? "":data.getChsl().toString());
442
-			rowCellData12.setCellStyle(contentStyle);
443
-			++xh;
444
-		}
445
-	}
211
+            startTime = startTime + " 00:00:00";
212
+            paramMap.put("startTime", startTime);
213
+        }
214
+        if (StringUtils.isNotBlank(endTime)) {
215
+            endTime = endTime + " 23:59:59";
216
+            paramMap.put("endTime", endTime);
217
+        }
218
+
219
+        List<DataStatistics> listall = dataStatisticsMapper.selectByKdmc(paramMap);
220
+
221
+        //获取合计行数据
222
+        DataStatistics hj_obj = getHjDate(listall);
223
+
224
+        map.put("ht_object", hj_obj);
225
+
226
+        if (null != pageNum && null != pageSize) {
227
+            PageHelper.startPage(pageNum, pageSize);
228
+        }
229
+        List<DataStatistics> list = dataStatisticsMapper.selectByKdmc(paramMap);
230
+        pageInfo = new PageInfo<DataStatistics>(list);
231
+
232
+        map.put("pageInfo", pageInfo);
233
+
234
+        return map;
235
+    }
236
+
237
+    @Override
238
+    public HSSFWorkbook exportData(String startTime, String endTime, String orgCode) throws Exception {
239
+        HSSFWorkbook wb = new HSSFWorkbook();
240
+
241
+        CellRangeAddress cellRange = new CellRangeAddress(0, 0, 0, 11); // A1到J1的区域
242
+
243
+        // 创建"仓房类型统计"工作表
244
+        HSSFSheet sheetCflx = wb.createSheet("仓房类型统计");
245
+        sheetCflx.addMergedRegion(cellRange);
246
+        setSheetData(wb, sheetCflx, "cflx", startTime, endTime, orgCode);
247
+
248
+        HSSFSheet sheetLspz = wb.createSheet("粮食品种统计");
249
+        sheetLspz.addMergedRegion(cellRange);
250
+        setSheetData(wb, sheetLspz, "lspz", startTime, endTime, orgCode);
251
+
252
+        HSSFSheet sheetLsxz = wb.createSheet("粮食性质统计");
253
+        sheetLsxz.addMergedRegion(cellRange);
254
+        setSheetData(wb, sheetLsxz, "lsxz", startTime, endTime, orgCode);
255
+
256
+        HSSFSheet sheetKdmc = wb.createSheet("库点统计");
257
+        sheetKdmc.addMergedRegion(cellRange);
258
+        setSheetData(wb, sheetKdmc, "kdmc", startTime, endTime, orgCode);
259
+
260
+        return wb;
261
+    }
262
+
263
+    @SuppressWarnings("unchecked")
264
+    public void setSheetData(HSSFWorkbook wb, HSSFSheet sheet, String sheetNum, String startTime, String endTime, String orgCode) throws Exception {
265
+        HSSFCellStyle headStyle = HSSFWorkBookUtils.headStyle(wb);
266
+        HSSFCellStyle contentStyle = HSSFWorkBookUtils.contentStyle(wb);
267
+
268
+        sheet.setColumnWidth(2, 20 * 256);
269
+        sheet.setColumnWidth(3, 20 * 256);
270
+        sheet.setColumnWidth(4, 20 * 256);
271
+        sheet.setColumnWidth(5, 20 * 256);
272
+        sheet.setColumnWidth(6, 20 * 256);
273
+        sheet.setColumnWidth(7, 20 * 256);
274
+        sheet.setColumnWidth(8, 20 * 256);
275
+        sheet.setColumnWidth(9, 20 * 256);
276
+        sheet.setColumnWidth(10, 20 * 256);
277
+        sheet.setColumnWidth(11, 20 * 256);
278
+
279
+        //第一行:标题行
280
+        HSSFRow sheetRow = sheet.createRow(0);
281
+        HSSFCell cell = sheetRow.createCell(0);
282
+        String tilleName = "";
283
+        List<DataStatistics> list = null;
284
+        Map<String, Object> map = null;
285
+        DataStatistics ds = null;
286
+        String cell2Name = ""; //第二行第二列的名称
287
+        if ("cflx".equals(sheetNum)) {
288
+            tilleName = "按照仓房类型统计分析汇总表";
289
+            cell2Name = "仓房类型";
290
+            sheet.setColumnWidth(1, 18 * 256);
291
+            map = selectByCflx(null, null, startTime, endTime, orgCode);
292
+            ds = (DataStatistics) map.get("ht_object");
293
+            list = ((PageInfo<DataStatistics>) map.get("pageInfo")).getList();
294
+        } else if ("lspz".equals(sheetNum)) {
295
+            tilleName = "按照粮食品种统计分析汇总表";
296
+            cell2Name = "粮食品种";
297
+            sheet.setColumnWidth(1, 20 * 256);
298
+            map = selectByLspz(null, null, startTime, endTime, orgCode);
299
+            ds = (DataStatistics) map.get("ht_object");
300
+            list = ((PageInfo<DataStatistics>) map.get("pageInfo")).getList();
301
+        } else if ("lsxz".equals(sheetNum)) {
302
+            tilleName = "按照粮食性质统计分析汇总表";
303
+            cell2Name = "粮食性质";
304
+            sheet.setColumnWidth(1, 40 * 256);
305
+            map = selectByLsxz(null, null, startTime, endTime, orgCode);
306
+            ds = (DataStatistics) map.get("ht_object");
307
+            list = ((PageInfo<DataStatistics>) map.get("pageInfo")).getList();
308
+        } else if ("kdmc".equals(sheetNum)) {
309
+            tilleName = "按照库点统计分析汇总表";
310
+            cell2Name = "库点名称";
311
+            sheet.setColumnWidth(1, 45 * 256);
312
+            map = selectByKdmc(null, null, startTime, endTime, orgCode);
313
+            ds = (DataStatistics) map.get("ht_object");
314
+            list = ((PageInfo<DataStatistics>) map.get("pageInfo")).getList();
315
+        }
316
+
317
+        cell.setCellValue(tilleName);
318
+        cell.setCellStyle(headStyle);
319
+
320
+        //第二行
321
+        HSSFRow sheetRow1 = sheet.createRow(1);//列名所在行
322
+        HSSFCell rowCell1 = sheetRow1.createCell(0);
323
+        rowCell1.setCellValue("序号");
324
+        rowCell1.setCellStyle(contentStyle);
325
+        HSSFCell rowCell2 = sheetRow1.createCell(1);
326
+        //第二行第二列的名称
327
+        rowCell2.setCellValue(cell2Name);
328
+        rowCell2.setCellStyle(contentStyle);
329
+        HSSFCell rowCell3 = sheetRow1.createCell(2);
330
+        rowCell3.setCellValue("入库数量(kg)");
331
+        rowCell3.setCellStyle(contentStyle);
332
+        HSSFCell rowCell4 = sheetRow1.createCell(3);
333
+        rowCell4.setCellValue("出库数量(kg)");
334
+        rowCell4.setCellStyle(contentStyle);
335
+        HSSFCell rowCell5 = sheetRow1.createCell(4);
336
+        rowCell5.setCellValue("损失数量(kg)");
337
+        rowCell5.setCellStyle(contentStyle);
338
+        HSSFCell rowCell6 = sheetRow1.createCell(5);
339
+        rowCell6.setCellValue("损失率(%)");
340
+        rowCell6.setCellStyle(contentStyle);
341
+        HSSFCell rowCell7 = sheetRow1.createCell(6);
342
+        rowCell7.setCellValue("损耗数量(kg)");
343
+        rowCell7.setCellStyle(contentStyle);
344
+        HSSFCell rowCell8 = sheetRow1.createCell(7);
345
+        rowCell8.setCellValue("损耗率(%)");
346
+        rowCell8.setCellStyle(contentStyle);
347
+        HSSFCell rowCell9 = sheetRow1.createCell(8);
348
+        rowCell9.setCellValue("溢余数量(kg)");
349
+        rowCell9.setCellStyle(contentStyle);
350
+        HSSFCell rowCell10 = sheetRow1.createCell(9);
351
+        rowCell10.setCellValue("超耗数量(kg)");
352
+        rowCell10.setCellStyle(contentStyle);
353
+        HSSFCell rowCell11 = sheetRow1.createCell(10);
354
+        rowCell11.setCellValue("水杂减量合计(kg)");
355
+        rowCell11.setCellStyle(contentStyle);
356
+        HSSFCell rowCell12 = sheetRow1.createCell(11);
357
+        rowCell12.setCellValue("保管自然损耗定额(kg)");
358
+        rowCell12.setCellStyle(contentStyle);
359
+
360
+        //第三行:合计行
361
+        HSSFRow sheetRow2 = sheet.createRow(2);//列名所在行
362
+        HSSFCell row2Cell1 = sheetRow2.createCell(0);
363
+        row2Cell1.setCellValue("——");
364
+        row2Cell1.setCellStyle(contentStyle);
365
+        HSSFCell row2Cell2 = sheetRow2.createCell(1);
366
+        //第二行第二列的名称
367
+        row2Cell2.setCellValue("合计");
368
+        row2Cell2.setCellStyle(headStyle);
369
+        HSSFCell row2Cell3 = sheetRow2.createCell(2);
370
+        row2Cell3.setCellValue(ds.getRksl() + "");
371
+        row2Cell3.setCellStyle(contentStyle);
372
+        HSSFCell row2Cell4 = sheetRow2.createCell(3);
373
+        row2Cell4.setCellValue(ds.getCksl() + "");
374
+        row2Cell4.setCellStyle(contentStyle);
375
+        HSSFCell row2Cell5 = sheetRow2.createCell(4);
376
+        row2Cell5.setCellValue(ds.getSssl() + "");
377
+        row2Cell5.setCellStyle(contentStyle);
378
+        HSSFCell row2Cell6 = sheetRow2.createCell(5);
379
+        row2Cell6.setCellValue(ds.getSsl() + "");
380
+        row2Cell6.setCellStyle(contentStyle);
381
+        HSSFCell row2Cell7 = sheetRow2.createCell(6);
382
+        row2Cell7.setCellValue(ds.getShsl() + "");
383
+        row2Cell7.setCellStyle(contentStyle);
384
+        HSSFCell row2Cell8 = sheetRow2.createCell(7);
385
+        row2Cell8.setCellValue(ds.getShl() + "");
386
+        row2Cell8.setCellStyle(contentStyle);
387
+        HSSFCell row2Cell9 = sheetRow2.createCell(8);
388
+        row2Cell9.setCellValue(ds.getYysl() + "");
389
+        row2Cell9.setCellStyle(contentStyle);
390
+        HSSFCell row2Cell10 = sheetRow2.createCell(9);
391
+        row2Cell10.setCellValue(ds.getChsl() + "");
392
+        row2Cell10.setCellStyle(contentStyle);
393
+        HSSFCell row2Cell11 = sheetRow2.createCell(10);
394
+        row2Cell11.setCellValue(ds.getSzjlhj() + "");
395
+        row2Cell11.setCellStyle(contentStyle);
396
+        HSSFCell row2Cell12 = sheetRow2.createCell(11);
397
+        row2Cell12.setCellValue(ds.getBgzrshdesl() + "");
398
+        row2Cell12.setCellStyle(contentStyle);
399
+
400
+        Integer xh = 1;
401
+        int rowNum = 2;
402
+        HSSFRow rowData = null;
403
+        DataStatistics data = null;
404
+        for (int i = 0; i < list.size(); i++) {
405
+            rowNum = rowNum + 1;
406
+            data = list.get(i);
407
+            rowData = sheet.createRow(rowNum);
408
+            HSSFCell rowCellData1 = rowData.createCell(0);
409
+            rowCellData1.setCellValue(xh);
410
+            rowCellData1.setCellStyle(contentStyle);
411
+            HSSFCell rowCellData2 = rowData.createCell(1);
412
+            if ("cflx".equals(sheetNum)) {
413
+                rowCellData2.setCellValue(data.getCflx());
414
+            } else if ("lspz".equals(sheetNum)) {
415
+                rowCellData2.setCellValue(data.getLspz());
416
+            } else if ("lsxz".equals(sheetNum)) {
417
+                rowCellData2.setCellValue(data.getLsxz());
418
+            } else if ("kdmc".equals(sheetNum)) {
419
+                rowCellData2.setCellValue(data.getKdmc());
420
+            }
421
+            rowCellData2.setCellStyle(contentStyle);
422
+            HSSFCell rowCellData3 = rowData.createCell(2);
423
+            rowCellData3.setCellValue(data.getRksl() == null ? "" : data.getRksl().toString());
424
+            rowCellData3.setCellStyle(contentStyle);
425
+            HSSFCell rowCellData4 = rowData.createCell(3);
426
+            rowCellData4.setCellValue(data.getCksl() == null ? "" : data.getCksl().toString());
427
+            rowCellData4.setCellStyle(contentStyle);
428
+            HSSFCell rowCellData5 = rowData.createCell(4);
429
+            rowCellData5.setCellValue(data.getSssl() == null ? "" : data.getSssl().toString());
430
+            rowCellData5.setCellStyle(contentStyle);
431
+            HSSFCell rowCellData6 = rowData.createCell(5);
432
+            rowCellData6.setCellValue(data.getSsl() == null ? "" : data.getSsl().toString());
433
+            rowCellData6.setCellStyle(contentStyle);
434
+            HSSFCell rowCellData7 = rowData.createCell(6);
435
+            rowCellData7.setCellValue(data.getShsl() == null ? "" : data.getShsl().toString());
436
+            rowCellData7.setCellStyle(contentStyle);
437
+            HSSFCell rowCellData8 = rowData.createCell(7);
438
+            rowCellData8.setCellValue(data.getShl() == null ? "" : data.getShl().toString());
439
+            rowCellData8.setCellStyle(contentStyle);
440
+            HSSFCell rowCellData9 = rowData.createCell(8);
441
+            rowCellData9.setCellValue(data.getYysl() == null ? "" : data.getYysl().toString());
442
+            rowCellData9.setCellStyle(contentStyle);
443
+            HSSFCell rowCellData10 = rowData.createCell(9);
444
+            rowCellData10.setCellValue(data.getChsl() == null ? "" : data.getChsl().toString());
445
+            rowCellData10.setCellStyle(contentStyle);
446
+            HSSFCell rowCellData11 = rowData.createCell(10);
447
+            rowCellData11.setCellValue(data.getSzjlhj() == null ? "" : data.getSzjlhj().toString());
448
+            rowCellData11.setCellStyle(contentStyle);
449
+            HSSFCell rowCellData12 = rowData.createCell(11);
450
+            rowCellData12.setCellValue(data.getBgzrshdesl() == null ? "" : data.getChsl().toString());
451
+            rowCellData12.setCellStyle(contentStyle);
452
+            ++xh;
453
+        }
454
+    }
455
+
456
+    @SuppressWarnings("all")
457
+    @Override
458
+    public List<PayoffsInfo> getPayoffsInfo(PayoffsRequestParam param) {
459
+        // 先查询合计
460
+        List<PayoffsInfo> initList = dataStatisticsMapper.getPayoffsInfo(param);
461
+        log.info("initList: {}", initList);
462
+        List<PayoffsInfo> resultList = new ArrayList<>();
463
+        if (!CollectionUtils.isEmpty(initList)) {
464
+            // 天津市合计
465
+            PayoffsInfo tjs = new PayoffsInfo();
466
+            tjs.setAreaName("天津市");
467
+            BigDecimal rksl = initList.stream().map(PayoffsInfo::getRksl).reduce(BigDecimal.ZERO, BigDecimal::add);
468
+            tjs.setRksl(rksl);
469
+            BigDecimal cksl = initList.stream().map(PayoffsInfo::getChsl).reduce(BigDecimal.ZERO, BigDecimal::add);
470
+            tjs.setCksl(cksl);
471
+            BigDecimal sjshsl = initList.stream().map(PayoffsInfo::getSjshsl).reduce(BigDecimal.ZERO, BigDecimal::add);
472
+            tjs.setSjshsl(sjshsl);
473
+            float shlF = sjshsl.floatValue() / rksl.floatValue() * 100;
474
+            BigDecimal shlB = new BigDecimal(shlF);
475
+            BigDecimal shl = shlB.setScale(2, BigDecimal.ROUND_HALF_UP);
476
+            tjs.setShl(shl);
477
+            BigDecimal yysl = initList.stream().map(PayoffsInfo::getYysl).reduce(BigDecimal.ZERO, BigDecimal::add);
478
+            tjs.setYysl(yysl);
479
+            BigDecimal chsl = initList.stream().map(PayoffsInfo::getChsl).reduce(BigDecimal.ZERO, BigDecimal::add);
480
+            tjs.setChsl(chsl);
481
+            resultList.add(tjs);
482
+
483
+            // 区合计
484
+            Map<String, List<PayoffsInfo>> areaGroup = initList.stream().collect(Collectors.groupingBy(p -> p.getAreaName()));// 分组
485
+            areaGroup.forEach((areaName, payoffsInfoList) -> {
486
+                PayoffsInfo areaData = new PayoffsInfo();
487
+                areaData.setAreaName(String.format("%s%s", areaName, "合计"));
488
+                BigDecimal rksl_area = payoffsInfoList.stream().map(PayoffsInfo::getRksl).reduce(BigDecimal.ZERO, BigDecimal::add);
489
+                areaData.setRksl(rksl_area);
490
+                BigDecimal cksl_area = payoffsInfoList.stream().map(PayoffsInfo::getChsl).reduce(BigDecimal.ZERO, BigDecimal::add);
491
+                areaData.setCksl(cksl_area);
492
+                BigDecimal sjshsl_area = payoffsInfoList.stream().map(PayoffsInfo::getSjshsl).reduce(BigDecimal.ZERO, BigDecimal::add);
493
+                areaData.setSjshsl(sjshsl_area);
494
+                float shlF_area = sjshsl_area.floatValue() / rksl_area.floatValue() * 100;
495
+                BigDecimal shlB_area = new BigDecimal(shlF_area);
496
+                BigDecimal shl_area = shlB_area.setScale(2, BigDecimal.ROUND_HALF_UP);
497
+                areaData.setShl(shl_area);
498
+                BigDecimal yysl_area = payoffsInfoList.stream().map(PayoffsInfo::getYysl).reduce(BigDecimal.ZERO, BigDecimal::add);
499
+                areaData.setYysl(yysl_area);
500
+                BigDecimal chsl_area = payoffsInfoList.stream().map(PayoffsInfo::getChsl).reduce(BigDecimal.ZERO, BigDecimal::add);
501
+                areaData.setChsl(chsl_area);
502
+                resultList.add(areaData);
503
+                // 添加单位数据
504
+                payoffsInfoList.forEach(p -> resultList.add(p));
505
+            });
506
+        }
507
+        return resultList;
508
+    }
446 509
 }