|
@@ -12,14 +12,16 @@ import com.jeeplus.test.oss.service.OssService;
|
|
import com.jeeplus.test.wdt.disposeRubbish.domain.DisposeRubbish;
|
|
import com.jeeplus.test.wdt.disposeRubbish.domain.DisposeRubbish;
|
|
import com.jeeplus.test.wdt.disposeRubbish.domain.WorkOverNo;
|
|
import com.jeeplus.test.wdt.disposeRubbish.domain.WorkOverNo;
|
|
import com.jeeplus.test.wdt.disposeRubbish.mapper.DisposeRubbishMapper;
|
|
import com.jeeplus.test.wdt.disposeRubbish.mapper.DisposeRubbishMapper;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.Calendar;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
+import java.time.YearMonth;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author: 徐滕
|
|
* @author: 徐滕
|
|
@@ -111,7 +113,7 @@ public class DisposeRubbishService extends ServiceImpl<DisposeRubbishMapper, Dis
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* 根据id获取巡视工单信息
|
|
* 根据id获取巡视工单信息
|
|
- * @param procInsId
|
|
|
|
|
|
+ * @param procInsIdList
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public List<DisposeRubbish> getByProcInsId(List<String> procInsIdList) {
|
|
public List<DisposeRubbish> getByProcInsId(List<String> procInsIdList) {
|
|
@@ -129,4 +131,144 @@ public class DisposeRubbishService extends ServiceImpl<DisposeRubbishMapper, Dis
|
|
return fileList1;
|
|
return fileList1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据id获取巡视工单信息
|
|
|
|
+ * @param officeId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<DisposeRubbish> getDetailCollectByOfficeId(String officeId) {
|
|
|
|
+ // 根据部门id查询所有年-月 信息汇总
|
|
|
|
+ List<String> allYearMonthByOfficeIdList = baseMapper.getAllYearMonthByOfficeId(officeId);
|
|
|
|
+ // 根据部门id查询所有工单信息
|
|
|
|
+ List<DisposeRubbish> allYearMonthByOfficeIdDisposeRubbishList = baseMapper.getDisposeRubbishAllYearMonthByOfficeId(officeId);
|
|
|
|
+ //根据发起年月对工单信息进行分组处理
|
|
|
|
+ Map<String, List<DisposeRubbish>> temporaryListMap = dataMessageDispose(allYearMonthByOfficeIdDisposeRubbishList);
|
|
|
|
+ //遍历该部门所有的年月信息,将年月信息和分组信息进行比对,并将分组信息进行汇总返回
|
|
|
|
+ List<DisposeRubbish> dataList = Lists.newArrayList();
|
|
|
|
+ for (String yearMonth : allYearMonthByOfficeIdList) {
|
|
|
|
+ for (String key : temporaryListMap.keySet()) {
|
|
|
|
+ if(StringUtils.isNotBlank(yearMonth) && yearMonth.equals(key)){
|
|
|
|
+ List<DisposeRubbish> mapList = temporaryListMap.get(key);
|
|
|
|
+ DisposeRubbish data = new DisposeRubbish();
|
|
|
|
+ data.setCreateDateStr(yearMonth);
|
|
|
|
+ data.setCount(mapList.size());
|
|
|
|
+ BigDecimal weightB = new BigDecimal(0);
|
|
|
|
+ BigDecimal subsidyB = new BigDecimal(0);
|
|
|
|
+ for (DisposeRubbish info : mapList) {
|
|
|
|
+ if(StringUtils.isNotBlank(info.getWeight())){
|
|
|
|
+ weightB = weightB.add(new BigDecimal(info.getWeight()));
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotBlank(info.getSubsidy())){
|
|
|
|
+ subsidyB = subsidyB.add(new BigDecimal(info.getSubsidy()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ weightB = weightB.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ subsidyB = subsidyB.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ data.setWeight(weightB.toString());
|
|
|
|
+ data.setSubsidy(subsidyB.toString());
|
|
|
|
+
|
|
|
|
+ dataList.add(data);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(dataList.size()>0){
|
|
|
|
+ DisposeRubbish data = new DisposeRubbish();
|
|
|
|
+
|
|
|
|
+ BigDecimal weightB = new BigDecimal(0);
|
|
|
|
+ BigDecimal subsidyB = new BigDecimal(0);
|
|
|
|
+ int count = 0;
|
|
|
|
+ for (DisposeRubbish info : dataList) {
|
|
|
|
+ count += info.getCount();
|
|
|
|
+ if(StringUtils.isNotBlank(info.getWeight())){
|
|
|
|
+ weightB = weightB.add(new BigDecimal(info.getWeight()));
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotBlank(info.getSubsidy())){
|
|
|
|
+ subsidyB = subsidyB.add(new BigDecimal(info.getSubsidy()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ data.setCreateDateStr("汇总");
|
|
|
|
+ data.setCount(count);
|
|
|
|
+ weightB = weightB.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ subsidyB = subsidyB.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ data.setWeight(weightB.toString());
|
|
|
|
+ data.setSubsidy(subsidyB.toString());
|
|
|
|
+ dataList.add(data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //遍历查询出来的数据,对数据进行汇总处理
|
|
|
|
+ System.out.println();
|
|
|
|
+
|
|
|
|
+ return dataList;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 分组
|
|
|
|
+ * @param list
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private Map<String, List<DisposeRubbish>> dataMessageDispose(List<DisposeRubbish> list) {
|
|
|
|
+ Map<String, List<DisposeRubbish>> infoMap = new HashMap<>();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
+ // 分组
|
|
|
|
+ for (DisposeRubbish vo : list) {
|
|
|
|
+ List<DisposeRubbish> tempList = infoMap.get(vo.getAuditPassDateStr());
|
|
|
|
+ /*如果取不到数据,那么直接new一个空的ArrayList**/
|
|
|
|
+ if (tempList == null) {
|
|
|
|
+ tempList = new ArrayList<>();
|
|
|
|
+ tempList.add(vo);
|
|
|
|
+ infoMap.put(vo.getAuditPassDateStr(), tempList);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ /*某个vo之前已经存放过了,则直接追加数据到原来的List里**/
|
|
|
|
+ tempList.add(vo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return infoMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据id和年月获取巡视工单信息
|
|
|
|
+ * @param officeId
|
|
|
|
+ * @param yearMonth
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<DisposeRubbish> getDetailCollectByOfficeIdAndMonth(String officeId,String yearMonth) {
|
|
|
|
+ // 将年月时间进行处理
|
|
|
|
+ String startOfMonth = "";
|
|
|
|
+ String endOfMonth = "";
|
|
|
|
+ if(StringUtils.isNotBlank(yearMonth) && yearMonth.contains("-")){
|
|
|
|
+ startOfMonth = yearMonth + "-01 00:00:00";
|
|
|
|
+ // 使用 YearMonth 获取给定年月的最后一天
|
|
|
|
+ YearMonth endyearMonth = YearMonth.parse(yearMonth);
|
|
|
|
+ int lastDay = endyearMonth.lengthOfMonth(); // 当月的最后一天
|
|
|
|
+ // 拼接上月份的最后一天并精确到时分秒
|
|
|
|
+ endOfMonth = endyearMonth + "-" + lastDay + " 23:59:59";
|
|
|
|
+ }
|
|
|
|
+ //遍历该部门所有的年月信息,将年月信息和分组信息进行比对,并将分组信息进行汇总返回
|
|
|
|
+ List<DisposeRubbish> dataList = Lists.newArrayList();
|
|
|
|
+ if(StringUtils.isNotBlank(officeId) && StringUtils.isNotBlank(startOfMonth) && StringUtils.isNotBlank(endOfMonth)){
|
|
|
|
+
|
|
|
|
+ // 根据部门id和起始时间查询所有工单信息
|
|
|
|
+ dataList = baseMapper.getDetailCollectByOfficeIdAndMonth(officeId,startOfMonth,endOfMonth);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return dataList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据id获取巡视工单信息
|
|
|
|
+ * @param no
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public DisposeRubbish getByNo(String no) {
|
|
|
|
+ if (StringUtils.isNotBlank(no)){
|
|
|
|
+ return baseMapper.getByNo(no);
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|