SpStatementInlandLowServiceImpl.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. package com.shcd.service.impl;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  4. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5. import com.shanghaigeography.Util.DateUtils;
  6. import com.shcd.conf.SnowflakeMakeConf;
  7. import com.shcd.entity.ShorePowerDeviceUsage;
  8. import com.shcd.entity.SpStatementInlandLow;
  9. import com.shcd.enums.AreaSortEnum;
  10. import com.shcd.enums.ShorePowerConnRecordInfoEnum;
  11. import com.shcd.service.SpStatementInlandLowService;
  12. import com.shcd.mapper.SpStatementInlandLowMapper;
  13. import com.shcd.utils.PrintLogUtils;
  14. import com.shcd.vo.ShorePowerConnRecordInfoVo;
  15. import java.math.BigDecimal;
  16. import java.math.RoundingMode;
  17. import java.text.ParseException;
  18. import java.util.ArrayList;
  19. import java.util.Calendar;
  20. import java.util.Date;
  21. import java.util.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. import java.util.Objects;
  25. import java.util.stream.Collectors;
  26. import javax.annotation.Resource;
  27. import lombok.extern.slf4j.Slf4j;
  28. import org.springframework.stereotype.Service;
  29. import org.springframework.util.CollectionUtils;
  30. /**
  31. * @author 14390
  32. * @description 针对表【SP_STATEMENT_INLAND_LOW(内河低压分析表)】的数据库操作Service实现
  33. * @createDate 2024-01-22 14:57:44
  34. */
  35. @Service
  36. @Slf4j
  37. public class SpStatementInlandLowServiceImpl extends
  38. ServiceImpl<SpStatementInlandLowMapper, SpStatementInlandLow>
  39. implements SpStatementInlandLowService {
  40. @Resource
  41. SpStatementInlandLowMapper mapper;
  42. @Resource
  43. SnowflakeMakeConf snowflakeMakeConf;
  44. @Override
  45. public List<ShorePowerDeviceUsage> getOriginDataFromPage(String date) {
  46. Map<String, Object> params = new HashMap<>(2);
  47. params.put("reportDateStart", date);
  48. params.put("reportDateEnd", date);
  49. return mapper.getOriginDataFromPage(params);
  50. }
  51. @Override
  52. public List<ShorePowerDeviceUsage> getCurrentYearOriginDataFromPage() {
  53. return mapper.getCurrentYearOriginDataFromPage();
  54. }
  55. @Override
  56. public SpStatementInlandLow getLastMonthReportData(String date, Integer type) {
  57. return mapper.getLastMonthReportData(date, type);
  58. }
  59. @Override
  60. public List<ShorePowerConnRecordInfoVo> selectDataFromShorePower(Map<String, Object> params) {
  61. return mapper.selectDataFromShorePower(params);
  62. }
  63. @Override
  64. public List<ShorePowerConnRecordInfoVo> selectCurrentYearDataFromShorePower() {
  65. return mapper.selectCurrentYearDataFromShorePower();
  66. }
  67. @Override
  68. public void deleteAllCurrentMonthReport1(Date reportDate) {
  69. mapper.deleteAllCurrentMonthReport1(
  70. DateUtils.dateToString(reportDate, DateUtils.DATE_FORMAT_12));
  71. }
  72. @Override
  73. public void deleteAllCurrentMonthReport2(Date reportDate) {
  74. mapper.deleteAllCurrentMonthReport2(
  75. DateUtils.dateToString(reportDate, DateUtils.DATE_FORMAT_12));
  76. }
  77. @Override
  78. public List<SpStatementInlandLow> selectCurrentMonthReport2Count(Date reportDate) {
  79. return mapper.selectList(Wrappers.<SpStatementInlandLow>lambdaQuery()
  80. .eq(SpStatementInlandLow::getReportDate, reportDate)
  81. .eq(SpStatementInlandLow::getType, "2"));
  82. }
  83. @Override
  84. public List<SpStatementInlandLow> selectCurrentMonthReport1Count(Date reportDate) {
  85. return mapper.selectList(Wrappers.<SpStatementInlandLow>lambdaQuery()
  86. .eq(SpStatementInlandLow::getReportDate, reportDate)
  87. .eq(SpStatementInlandLow::getType, "1"));
  88. }
  89. @Override
  90. public void makeReport1(String currentMonthDate, String lastMonthDate) {
  91. try {
  92. // 查询当前年月的内河非标岸电设备使用情况
  93. List<ShorePowerDeviceUsage> originList = this.getOriginDataFromPage(
  94. currentMonthDate);
  95. log.info("统计当月原始数据为:{}", JSONObject.toJSONString(originList));
  96. // 查询上个月报表数据 用来计算环比
  97. List<SpStatementInlandLow> lastReportDataList = this.getAllLastMonthReportData(lastMonthDate,
  98. 1);
  99. log.info("统计上月报表数据为:{}", JSONObject.toJSONString(lastReportDataList));
  100. // 查询全年原始数据 用来计算当年累计
  101. // List<ShorePowerDeviceUsage> currentYearOriginList = this.getCurrentYearOriginDataFromPage();
  102. // log.info("当年累计原始数据为:{}", JSONObject.toJSONString(currentYearOriginList));
  103. List<SpStatementInlandLow> spStatementInlandLowList = new ArrayList<>(originList.size());
  104. // 计算各区
  105. executeEveryDistrict(originList, lastReportDataList, spStatementInlandLowList, currentMonthDate);
  106. // 计算合计
  107. executeTotal(spStatementInlandLowList, lastMonthDate);
  108. log.info("最终存储的内河低压分析表1为:{}", JSONObject.toJSONString(spStatementInlandLowList));
  109. // 查询本月报表数据
  110. List<SpStatementInlandLow> currentList = this.selectCurrentMonthReport1Count(
  111. spStatementInlandLowList.get(0).getReportDate());
  112. // 有数据情况下先删除后插入
  113. if (!CollectionUtils.isEmpty(currentList)) {
  114. this.deleteAllCurrentMonthReport1(
  115. spStatementInlandLowList.get(0).getReportDate());
  116. }
  117. super.saveBatch(spStatementInlandLowList);
  118. } catch (Exception e) {
  119. e.printStackTrace();
  120. log.error("内河低压分析表 表1 中间表生成逻辑出错....原因:{}", e.getMessage());
  121. }
  122. }
  123. @Override
  124. public void makeReport2(String currentDate, String lastMonthDate, String last2MonthDate,
  125. String last3MonthDate) {
  126. try {
  127. String date = currentDate + "-24 23:59:59";
  128. String lastMonthDate11 = lastMonthDate + "-25 00:00:00";
  129. Map<String, Object> params = new HashMap<>(2);
  130. params.put("reportDateStart", lastMonthDate11);
  131. params.put("reportDateEnd", date);
  132. params.put("lastReportDateStart", last2MonthDate + "-25 00:00:00");
  133. params.put("lastReportDateEnd", lastMonthDate + "-24 23:59:59");
  134. // List<ShorePowerConnRecordInfoVo> currentMonthData = this.selectDataFromShorePower(
  135. // params);
  136. //低压标准化计算逻辑变更,这个是第二个版本,
  137. List<ShorePowerConnRecordInfoVo> currentMonthData = this.selectDataFromShorePowerV2(params);
  138. log.info("市级平台自动上传<当月>数据为:{}", JSONObject.toJSONString(currentMonthData));
  139. // 查询上个月报表数据 用来计算环比
  140. List<SpStatementInlandLow> lastReportDataList = this.getAllLastMonthReportData(lastMonthDate,
  141. 2);
  142. log.info("市级平台自动上传<上月>数据为:{}", JSONObject.toJSONString(lastReportDataList));
  143. // 查询全年原始数据 用来计算当年累计
  144. // String yearStartDate =
  145. // (Integer.parseInt(currentDate.split("-")[0]) - 1) + "-12-25 00:00:00";
  146. // String yearEndDate = currentDate + "-24 23:59:59";
  147. // Map<String, Object> yearParams = new HashMap<>(2);
  148. // yearParams.put("reportDateStart", yearStartDate);
  149. // yearParams.put("reportDateEnd", yearEndDate);
  150. // List<ShorePowerConnRecordInfoVo> currentYearDataList = this.selectDataFromShorePower(
  151. // yearParams);
  152. // log.info("市级平台自动上传<全年>数据为:{}", JSONObject.toJSONString(currentYearDataList));
  153. // 计算各区
  154. List<SpStatementInlandLow> spStatementInlandLowList = executeEveryDistrict2(currentMonthData,
  155. lastReportDataList, currentDate);
  156. // 计算合计
  157. executeTotal2(spStatementInlandLowList, lastMonthDate);
  158. // 查询当月是否有数据
  159. List<SpStatementInlandLow> currentList = this.selectCurrentMonthReport2Count(
  160. spStatementInlandLowList.get(0).getReportDate());
  161. // 有数据先删除,后插入
  162. if (!CollectionUtils.isEmpty(currentList)) {
  163. this.deleteAllCurrentMonthReport2(
  164. spStatementInlandLowList.get(0).getReportDate());
  165. }
  166. log.info("最终存储的内河低压分析表2为:{}", JSONObject.toJSONString(spStatementInlandLowList));
  167. super.saveBatch(spStatementInlandLowList);
  168. } catch (Exception e) {
  169. e.printStackTrace();
  170. log.error("内河低压分析表 表2 中间表生成逻辑出错....原因:{}", e.getMessage());
  171. }
  172. }
  173. private List<ShorePowerConnRecordInfoVo> selectDataFromShorePowerV2(Map<String, Object> params) {
  174. return mapper.selectDataFromShorePowerV2(params);
  175. }
  176. @Override
  177. public List<SpStatementInlandLow> getAllLastMonthReportData(String lastMonthDate, int type) {
  178. return mapper.getAllLastMonthReportData(lastMonthDate, type);
  179. }
  180. private void executeEveryDistrict(List<ShorePowerDeviceUsage> originList,
  181. List<SpStatementInlandLow> lastReportDataList,
  182. List<SpStatementInlandLow> spStatementInlandLowList,String currentMonthDate) {
  183. try {
  184. // for (ShorePowerDeviceUsage thisMonthData : originList) {
  185. for (AreaSortEnum thisMonthData : AreaSortEnum.values()) {
  186. // 计算各区 当月数据
  187. SpStatementInlandLow spStatementInlandLow = new SpStatementInlandLow();
  188. String id = String.valueOf(snowflakeMakeConf.snowflakeId());
  189. spStatementInlandLow.setId(id);
  190. spStatementInlandLow.setSort(thisMonthData.getSort());
  191. spStatementInlandLow.setDistrict(thisMonthData.getArea());
  192. List<ShorePowerDeviceUsage> filterUsageList = originList.stream()
  193. .filter(i->i.getDistrict().equals(thisMonthData.getArea()))
  194. .collect(Collectors.toList());
  195. if (filterUsageList.isEmpty()) {
  196. spStatementInlandLow.setBoatUseNumberMonth(BigDecimal.ZERO);
  197. spStatementInlandLow.setPowerConnHoursMonth(BigDecimal.ZERO);
  198. spStatementInlandLow.setElectricityUsageMonth(BigDecimal.ZERO);
  199. spStatementInlandLow.setReportDate(
  200. DateUtils.stringToDate(currentMonthDate, DateUtils.DATE_FORMAT_12));
  201. } else {
  202. spStatementInlandLow.setBoatUseNumberMonth(filterUsageList.get(0).getShorePowerBoatUseNumber());
  203. spStatementInlandLow.setPowerConnHoursMonth(filterUsageList.get(0).getPowerConnHours());
  204. spStatementInlandLow.setElectricityUsageMonth(filterUsageList.get(0).getElectricityConsumption());
  205. spStatementInlandLow.setReportDate(
  206. DateUtils.stringToDate(currentMonthDate, DateUtils.DATE_FORMAT_12));
  207. }
  208. spStatementInlandLow.setType(1);
  209. // 计算当年累计 以及 环比
  210. Calendar thisCalendar = Calendar.getInstance();
  211. thisCalendar.setTime(DateUtils.stringToDate(currentMonthDate, DateUtils.DATE_FORMAT_12));
  212. for (SpStatementInlandLow lastReportData : lastReportDataList) {
  213. if (lastReportData.getDistrict().equals(spStatementInlandLow.getDistrict())) {
  214. if (thisCalendar.get(Calendar.MONTH) == Calendar.JANUARY) {
  215. spStatementInlandLow.setBoatUseNumberYearTotal(
  216. spStatementInlandLow.getBoatUseNumberMonth());
  217. spStatementInlandLow.setPowerConnHoursYearTotal(
  218. spStatementInlandLow.getPowerConnHoursMonth());
  219. spStatementInlandLow.setElectricityUsageYearTotal(
  220. spStatementInlandLow.getElectricityUsageMonth());
  221. }else{
  222. spStatementInlandLow.setBoatUseNumberYearTotal(
  223. spStatementInlandLow.getBoatUseNumberMonth()
  224. .add(lastReportData.getBoatUseNumberYearTotal())
  225. .setScale(2, RoundingMode.HALF_UP));
  226. spStatementInlandLow.setPowerConnHoursYearTotal(
  227. spStatementInlandLow.getPowerConnHoursMonth()
  228. .add(lastReportData.getPowerConnHoursYearTotal())
  229. .setScale(2, RoundingMode.HALF_UP));
  230. spStatementInlandLow.setElectricityUsageYearTotal(
  231. spStatementInlandLow.getElectricityUsageMonth()
  232. .add(lastReportData.getElectricityUsageYearTotal())
  233. .setScale(2, RoundingMode.HALF_UP));
  234. }
  235. // 计算环比
  236. spStatementInlandLow.setBoatUseNumberChain(
  237. getRate(spStatementInlandLow.getBoatUseNumberMonth(),
  238. lastReportData.getBoatUseNumberMonth()));
  239. }
  240. }
  241. spStatementInlandLowList.add(spStatementInlandLow);
  242. }
  243. }catch (Exception e){
  244. PrintLogUtils.printErrorLogInfo(e,"executeEveryDistrict异常");
  245. }
  246. }
  247. private static BigDecimal getRate(BigDecimal thisMonthData,
  248. BigDecimal lastMonthData) {
  249. if (Objects.isNull(lastMonthData) || lastMonthData.equals(BigDecimal.ZERO)) {
  250. return null;
  251. }
  252. BigDecimal result = (thisMonthData.subtract(lastMonthData)).multiply(BigDecimal.valueOf(100))
  253. .divide(lastMonthData, 2, RoundingMode.HALF_UP);
  254. return result.setScale(2, RoundingMode.HALF_UP);
  255. }
  256. private void executeTotal(List<SpStatementInlandLow> spStatementInlandLowList, String lastMonthDate) {
  257. // 计算合计
  258. SpStatementInlandLow spStatementInlandLow = new SpStatementInlandLow();
  259. spStatementInlandLow.setId(String.valueOf(snowflakeMakeConf.snowflakeStringId()));
  260. spStatementInlandLow.setSort(12);
  261. spStatementInlandLow.setDistrict("合计");
  262. spStatementInlandLow.setBoatUseNumberMonth(BigDecimal.ZERO);
  263. spStatementInlandLow.setBoatUseNumberChain(BigDecimal.ZERO);
  264. spStatementInlandLow.setBoatUseNumberYearTotal(BigDecimal.ZERO);
  265. spStatementInlandLow.setPowerConnHoursMonth(BigDecimal.ZERO);
  266. spStatementInlandLow.setPowerConnHoursYearTotal(BigDecimal.ZERO);
  267. spStatementInlandLow.setElectricityUsageMonth(BigDecimal.ZERO);
  268. spStatementInlandLow.setElectricityUsageYearTotal(BigDecimal.ZERO);
  269. spStatementInlandLowList.forEach(x -> {
  270. spStatementInlandLow.setBoatUseNumberMonth(
  271. x.getBoatUseNumberMonth().add(spStatementInlandLow.getBoatUseNumberMonth()));
  272. spStatementInlandLow.setBoatUseNumberYearTotal(
  273. x.getBoatUseNumberYearTotal().add(spStatementInlandLow.getBoatUseNumberYearTotal()));
  274. spStatementInlandLow.setPowerConnHoursMonth(
  275. x.getPowerConnHoursMonth().add(spStatementInlandLow.getPowerConnHoursMonth()));
  276. spStatementInlandLow.setPowerConnHoursYearTotal(
  277. x.getPowerConnHoursYearTotal().add(spStatementInlandLow.getPowerConnHoursYearTotal()));
  278. spStatementInlandLow.setElectricityUsageMonth(
  279. x.getElectricityUsageMonth().add(spStatementInlandLow.getElectricityUsageMonth()));
  280. spStatementInlandLow.setElectricityUsageYearTotal(x.getElectricityUsageYearTotal()
  281. .add(spStatementInlandLow.getElectricityUsageYearTotal()));
  282. spStatementInlandLow.setType(x.getType());
  283. spStatementInlandLow.setReportDate(x.getReportDate());
  284. });
  285. // 获取上个月的合计值用来计算环比
  286. SpStatementInlandLow lastMonthReportData = this.getLastMonthReportData(
  287. lastMonthDate, spStatementInlandLow.getType());
  288. if (Objects.isNull(lastMonthReportData) || Objects.isNull(
  289. lastMonthReportData.getBoatUseNumberMonth())
  290. || lastMonthReportData.getBoatUseNumberMonth().equals(BigDecimal.ZERO)) {
  291. spStatementInlandLow.setBoatUseNumberChain(null);
  292. } else {
  293. BigDecimal rate = (spStatementInlandLow.getBoatUseNumberMonth()
  294. .subtract(lastMonthReportData.getBoatUseNumberMonth())).multiply(
  295. BigDecimal.valueOf(100))
  296. .divide(lastMonthReportData.getBoatUseNumberMonth(), 2, RoundingMode.HALF_UP);
  297. spStatementInlandLow.setBoatUseNumberChain(rate);
  298. }
  299. spStatementInlandLowList.add(spStatementInlandLow);
  300. }
  301. private void executeTotal2(List<SpStatementInlandLow> spStatementInlandLowList,
  302. String lastMonthDate) {
  303. SpStatementInlandLow spStatementInlandLow = new SpStatementInlandLow();
  304. spStatementInlandLow.setId(String.valueOf(snowflakeMakeConf.snowflakeStringId()));
  305. spStatementInlandLow.setSort(12);
  306. spStatementInlandLow.setDistrict("合计");
  307. spStatementInlandLow.setBoatUseNumberMonth(BigDecimal.ZERO);
  308. spStatementInlandLow.setBoatUseNumberChain(BigDecimal.ZERO);
  309. spStatementInlandLow.setBoatUseNumberYearTotal(BigDecimal.ZERO);
  310. spStatementInlandLow.setPowerConnHoursMonth(BigDecimal.ZERO);
  311. spStatementInlandLow.setPowerConnHoursYearTotal(BigDecimal.ZERO);
  312. spStatementInlandLow.setElectricityUsageMonth(BigDecimal.ZERO);
  313. spStatementInlandLow.setElectricityUsageYearTotal(BigDecimal.ZERO);
  314. spStatementInlandLowList.forEach(x -> {
  315. spStatementInlandLow.setBoatUseNumberMonth(
  316. x.getBoatUseNumberMonth().add(spStatementInlandLow.getBoatUseNumberMonth()));
  317. spStatementInlandLow.setBoatUseNumberYearTotal(
  318. x.getBoatUseNumberYearTotal().add(spStatementInlandLow.getBoatUseNumberYearTotal()));
  319. spStatementInlandLow.setPowerConnHoursMonth(
  320. x.getPowerConnHoursMonth().add(spStatementInlandLow.getPowerConnHoursMonth()));
  321. spStatementInlandLow.setPowerConnHoursYearTotal(
  322. x.getPowerConnHoursYearTotal().add(spStatementInlandLow.getPowerConnHoursYearTotal()));
  323. spStatementInlandLow.setElectricityUsageMonth(
  324. x.getElectricityUsageMonth().add(spStatementInlandLow.getElectricityUsageMonth()));
  325. spStatementInlandLow.setElectricityUsageYearTotal(x.getElectricityUsageYearTotal()
  326. .add(spStatementInlandLow.getElectricityUsageYearTotal()));
  327. spStatementInlandLow.setType(x.getType());
  328. spStatementInlandLow.setReportDate(x.getReportDate());
  329. });
  330. // 拿上个月的中间表的"合计"数据 用来计算使用岸电船舶(艘次)的环比
  331. SpStatementInlandLow lastMonthReportData = this.getLastMonthReportData(
  332. lastMonthDate, spStatementInlandLow.getType());
  333. if (Objects.isNull(lastMonthReportData) || Objects.isNull(
  334. lastMonthReportData.getBoatUseNumberMonth())
  335. || lastMonthReportData.getBoatUseNumberMonth().equals(BigDecimal.ZERO)) {
  336. spStatementInlandLow.setBoatUseNumberChain(null);
  337. } else {
  338. BigDecimal rate = (spStatementInlandLow.getBoatUseNumberMonth()
  339. .subtract(lastMonthReportData.getBoatUseNumberMonth())).multiply(
  340. BigDecimal.valueOf(100))
  341. .divide(lastMonthReportData.getBoatUseNumberMonth(), 2, RoundingMode.HALF_UP);
  342. spStatementInlandLow.setBoatUseNumberChain(rate);
  343. }
  344. spStatementInlandLowList.add(spStatementInlandLow);
  345. }
  346. private List<SpStatementInlandLow> executeEveryDistrict2(
  347. List<ShorePowerConnRecordInfoVo> currentMonthData,
  348. List<SpStatementInlandLow> lastReportDataList, String currentDate)
  349. throws ParseException {
  350. List<SpStatementInlandLow> spStatementInlandLowList = new ArrayList<>(
  351. currentMonthData.size());
  352. for (ShorePowerConnRecordInfoEnum areaEnum : ShorePowerConnRecordInfoEnum.values()) {
  353. SpStatementInlandLow spStatementInlandLow = new SpStatementInlandLow();
  354. spStatementInlandLow.setId(String.valueOf(snowflakeMakeConf.snowflakeId()));
  355. spStatementInlandLow.setDistrict(areaEnum.getArea());
  356. spStatementInlandLow.setReportDate(
  357. DateUtils.stringToDate(currentDate, DateUtils.DATE_FORMAT_12));
  358. spStatementInlandLow.setSort(
  359. AreaSortEnum.getByArea(spStatementInlandLow.getDistrict()).getOwningArea());
  360. spStatementInlandLow.setType(2);
  361. List<ShorePowerConnRecordInfoVo> areaCollectData = currentMonthData.stream()
  362. .filter(
  363. i -> ShorePowerConnRecordInfoEnum.getByArea(Integer.parseInt(i.getArea())).getArea()
  364. .equals(areaEnum.getArea())).collect(
  365. Collectors.toList());
  366. ShorePowerConnRecordInfoVo currentMonth;
  367. if (!CollectionUtils.isEmpty(areaCollectData)) {
  368. currentMonth = areaCollectData.get(0);
  369. } else {
  370. currentMonth = new ShorePowerConnRecordInfoVo();
  371. }
  372. spStatementInlandLow.setBoatUseNumberMonth(currentMonth.getTotal());
  373. // 使用岸电小时在查询数据库时已经转换为小时计算
  374. spStatementInlandLow.setPowerConnHoursMonth(currentMonth.getDuration());
  375. spStatementInlandLow.setElectricityUsageMonth(currentMonth.getElect());
  376. // 计算当年累计 以及 环比
  377. Calendar thisCalendar = Calendar.getInstance();
  378. thisCalendar.setTime(DateUtils.stringToDate(currentDate, DateUtils.DATE_FORMAT_12));
  379. for (SpStatementInlandLow lastReportData : lastReportDataList) {
  380. if (lastReportData.getDistrict().equals(spStatementInlandLow.getDistrict())) {
  381. if (thisCalendar.get(Calendar.MONTH) == Calendar.JANUARY) {
  382. spStatementInlandLow.setBoatUseNumberYearTotal(
  383. spStatementInlandLow.getBoatUseNumberMonth());
  384. spStatementInlandLow.setPowerConnHoursYearTotal(
  385. spStatementInlandLow.getPowerConnHoursMonth());
  386. spStatementInlandLow.setElectricityUsageYearTotal(
  387. spStatementInlandLow.getElectricityUsageMonth());
  388. } else {
  389. spStatementInlandLow.setBoatUseNumberYearTotal(
  390. spStatementInlandLow.getBoatUseNumberMonth()
  391. .add(lastReportData.getBoatUseNumberYearTotal())
  392. .setScale(2, RoundingMode.HALF_UP));
  393. spStatementInlandLow.setPowerConnHoursYearTotal(
  394. spStatementInlandLow.getPowerConnHoursMonth()
  395. .add(lastReportData.getPowerConnHoursYearTotal())
  396. .setScale(2, RoundingMode.HALF_UP));
  397. spStatementInlandLow.setElectricityUsageYearTotal(
  398. spStatementInlandLow.getElectricityUsageMonth()
  399. .add(lastReportData.getElectricityUsageYearTotal())
  400. .setScale(2, RoundingMode.HALF_UP));
  401. }
  402. // 计算环比
  403. spStatementInlandLow.setBoatUseNumberChain(
  404. getRate(spStatementInlandLow.getBoatUseNumberMonth(),
  405. lastReportData.getBoatUseNumberMonth()));
  406. }
  407. }
  408. spStatementInlandLowList.add(spStatementInlandLow);
  409. }
  410. return spStatementInlandLowList;
  411. }
  412. }