diff --git a/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/DateUtils.java b/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/DateUtils.java index 18323e81..b87530a1 100644 --- a/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/DateUtils.java +++ b/lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/DateUtils.java @@ -113,6 +113,24 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils return DateFormatUtils.format(now, "yyyyMMdd"); } + + + public static Date dateTransMonth(Date date) + { + Calendar cal=Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH,1); + // 时 + cal.set(Calendar.HOUR_OF_DAY, 0); + // 分 + cal.set(Calendar.MINUTE, 0); + // 秒 + cal.set(Calendar.SECOND, 0); + // 毫秒 + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } + /** * 日期型字符串转化为日期 格式 */ diff --git a/lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppLawEnforcementWarningListController.java b/lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppLawEnforcementWarningListController.java index 21426023..f1aee3b9 100644 --- a/lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppLawEnforcementWarningListController.java +++ b/lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppLawEnforcementWarningListController.java @@ -4,6 +4,8 @@ import com.zdxt.code.domain.LawEnforcementWarningList; import com.zdxt.code.service.ILawEnforcementWarningListService; import com.zdxt.common.ZDResponse; import com.zdxt.common.controller.BaseController; +import com.zdxt.common.util.Constants; +import com.zdxt.common.util.ServletUtils; import com.zdxt.common.util.TableDataInfo; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -12,6 +14,7 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.stream.Collectors; /** @@ -62,6 +65,31 @@ public class AppLawEnforcementWarningListController extends BaseController List list = lawEnforcementWarningListService.selectLawEnforcementWarningListList(lawEnforcementWarningList); return getDataTable(list); } + + /** + * 查询执法预警列表列表-改造 + */ + @GetMapping("/queryListNew") + @ResponseBody + public TableDataInfo queryListNew(LawEnforcementWarningList lawEnforcementWarningList) + { + List list = lawEnforcementWarningListService.selectLawEnforcementWarningListNew(lawEnforcementWarningList); + TableDataInfo dataTable = getDataTable(list); + //手动分页 + dataTable.setRows(list.stream() + .skip(ServletUtils.getParameterToInt(Constants.PAGE_NUM)) + .limit(ServletUtils.getParameterToInt(Constants.PAGE_SIZE)) + .collect(Collectors.toList())); + return dataTable; + } + + @GetMapping("/queryListByEnterpriseNumberNew") + @ResponseBody + public ZDResponse queryListByEnterpriseNumberNew(LawEnforcementWarningList lawEnforcementWarningList) + { + List list = lawEnforcementWarningListService.selectLawEnforcementWarningByEnterpriseNumberNew(lawEnforcementWarningList); + return ZDResponse.success("获取当前企业本月预警信息",list); + } @GetMapping("/queryListByEnterpriseNumber") @ResponseBody public ZDResponse queryListByEnterpriseNumber(LawEnforcementWarningList lawEnforcementWarningList) diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/LawEnforcementWarningList.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/LawEnforcementWarningList.java index ea784310..c624ed63 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/LawEnforcementWarningList.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/LawEnforcementWarningList.java @@ -72,6 +72,7 @@ public class LawEnforcementWarningList extends BaseDomain private Boolean show = false; /** * 快捷搜索 日期类型 + * 1:本月 2:本季 3:本年 */ private Integer dateType; diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/LawEnforcementWarningListMapper.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/LawEnforcementWarningListMapper.java index a0670a7b..d52275b5 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/LawEnforcementWarningListMapper.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/LawEnforcementWarningListMapper.java @@ -28,6 +28,8 @@ public interface LawEnforcementWarningListMapper List selectLawEnforcementWarningListList(LawEnforcementWarningList lawEnforcementWarningList); List selectLawEnforcementWarningListList1(LawEnforcementWarningList lawEnforcementWarningList); List selectLawEnforcementWarningListList2(LawEnforcementWarningList lawEnforcementWarningList); + + List selectLawEnforcementWarningListList3(LawEnforcementWarningList lawEnforcementWarningList); List selectLawEnforcementWarningListListTypeIs1(LawEnforcementWarningList lawEnforcementWarningList); /** diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/ILawEnforcementWarningListService.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/ILawEnforcementWarningListService.java index 5cd86706..a36855e1 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/ILawEnforcementWarningListService.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/ILawEnforcementWarningListService.java @@ -1,6 +1,8 @@ package com.zdxt.code.service; import com.zdxt.code.domain.LawEnforcementWarningList; +import com.zdxt.common.util.TableDataInfo; + import java.util.List; /** @@ -27,6 +29,8 @@ public interface ILawEnforcementWarningListService */ List selectLawEnforcementWarningListList(LawEnforcementWarningList lawEnforcementWarningList); + List selectLawEnforcementWarningListNew(LawEnforcementWarningList lawEnforcementWarningList); + List selectLawEnforcementWarningListListOrderByNumber(LawEnforcementWarningList lawEnforcementWarningList); List selectLawEnforcementWarningListList1(LawEnforcementWarningList lawEnforcementWarningList); @@ -42,6 +46,9 @@ public interface ILawEnforcementWarningListService */ List selectLawEnforcementWarningByEnterpriseNumber(LawEnforcementWarningList lawEnforcementWarningList); + + List selectLawEnforcementWarningByEnterpriseNumberNew(LawEnforcementWarningList lawEnforcementWarningList); + /** * 新增执法预警列表 * diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/LawEnforcementWarningListServiceImpl.java b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/LawEnforcementWarningListServiceImpl.java index 7d7471a3..1da1d12a 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/LawEnforcementWarningListServiceImpl.java +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/LawEnforcementWarningListServiceImpl.java @@ -1,9 +1,15 @@ package com.zdxt.code.service.impl; -import java.util.List; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; import cn.hutool.core.convert.Convert; -import com.zdxt.common.util.DateUtils; +import com.sun.jna.platform.win32.ObjBase; +import com.zdxt.code.domain.EnforcementRegistration; +import com.zdxt.common.util.*; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.zdxt.code.mapper.LawEnforcementWarningListMapper; @@ -12,113 +18,159 @@ import com.zdxt.code.service.ILawEnforcementWarningListService; /** * 执法预警列表Service业务层处理 - * + * * @author chenrui * @date 2024-03-22 */ @Service -public class LawEnforcementWarningListServiceImpl implements ILawEnforcementWarningListService -{ +public class LawEnforcementWarningListServiceImpl implements ILawEnforcementWarningListService { @Autowired private LawEnforcementWarningListMapper lawEnforcementWarningListMapper; /** * 查询执法预警列表 - * + * * @param id 执法预警列表ID * @return 执法预警列表 */ @Override - public LawEnforcementWarningList selectLawEnforcementWarningListById(String id) - { + public LawEnforcementWarningList selectLawEnforcementWarningListById(String id) { return lawEnforcementWarningListMapper.selectLawEnforcementWarningListById(id); } /** * 查询执法预警列表列表 - * + * * @param lawEnforcementWarningList 执法预警列表 * @return 执法预警列表 */ @Override - public List selectLawEnforcementWarningListList(LawEnforcementWarningList lawEnforcementWarningList) - { + public List selectLawEnforcementWarningListList(LawEnforcementWarningList lawEnforcementWarningList) { return lawEnforcementWarningListMapper.selectLawEnforcementWarningListList(lawEnforcementWarningList); } + + @Override + public List selectLawEnforcementWarningListNew(LawEnforcementWarningList lawEnforcementWarningList) { + //dateType null:全部 1:本月 2:本季 3:本年 + List list = new ArrayList<>(); + List lawEnforcementWarningLists = + lawEnforcementWarningListMapper.selectLawEnforcementWarningListList3(lawEnforcementWarningList); + if (CollectionUtils.isNotEmpty(lawEnforcementWarningLists)) { + //如果展示本年 则筛选出每个月最高级别次数 分组累加得到全部检查次数 + + Map> collect = lawEnforcementWarningLists.stream() + .filter(i -> StringUtils.isNotEmpty(i.getEnterpriseNumber())) + .filter(i -> Objects.nonNull(i.getWarningTime())) + .peek(i -> i.setWarningTime(DateUtils.dateTransMonth(i.getWarningTime()))) + .collect(Collectors.groupingBy(LawEnforcementWarningList::getEnterpriseNumber)).entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().stream() + .sorted(Comparator.comparing(LawEnforcementWarningList::getCreateTime).reversed()) + .collect(Collectors.toList()) + )); + + List finalList = list; + collect.forEach((id, values) -> { + LawEnforcementWarningList warningList = new LawEnforcementWarningList(); + BeanUtils.copyProperties(values.get(0), warningList); + + //此时取每个公司每个月级别最高的一条预警累加 循环得到全部预警条数 + Collection values1 = values.stream().collect( + Collectors.toMap(LawEnforcementWarningList::getWarningTime, + Function.identity(), (t1, t2) -> t1.getEnforcementNumber() > t2.getEnforcementNumber() ? t1 : t2) + ).values(); + + warningList.setEnforcementNumber(values1.stream() + .map(LawEnforcementWarningList::getEnforcementNumber).reduce(Integer::sum).get()); + warningList.setWarningCause("对该企业已检查" + warningList.getEnforcementNumber() + "次"); + finalList.add(warningList); + }); + } + return list; + } + @Override - public List selectLawEnforcementWarningListListOrderByNumber(LawEnforcementWarningList lawEnforcementWarningList) - { + public List selectLawEnforcementWarningListListOrderByNumber(LawEnforcementWarningList lawEnforcementWarningList) { return lawEnforcementWarningListMapper.selectLawEnforcementWarningListListOrderByNumber(lawEnforcementWarningList); } + @Override - public List selectLawEnforcementWarningListList1(LawEnforcementWarningList lawEnforcementWarningList) - { + public List selectLawEnforcementWarningListList1(LawEnforcementWarningList lawEnforcementWarningList) { return lawEnforcementWarningListMapper.selectLawEnforcementWarningListList1(lawEnforcementWarningList); } + @Override - public List selectLawEnforcementWarningListList2(LawEnforcementWarningList lawEnforcementWarningList) - { + public List selectLawEnforcementWarningListList2(LawEnforcementWarningList lawEnforcementWarningList) { return lawEnforcementWarningListMapper.selectLawEnforcementWarningListList2(lawEnforcementWarningList); } @Override - public List selectLawEnforcementWarningListListTypeIs1(LawEnforcementWarningList lawEnforcementWarningList) - { + public List selectLawEnforcementWarningListListTypeIs1(LawEnforcementWarningList lawEnforcementWarningList) { return lawEnforcementWarningListMapper.selectLawEnforcementWarningListListTypeIs1(lawEnforcementWarningList); } + @Override public List selectLawEnforcementWarningByEnterpriseNumber(LawEnforcementWarningList lawEnforcementWarningList) { return lawEnforcementWarningListMapper.selectLawEnforcementWarningByEnterpriseNumber(lawEnforcementWarningList); } + + @Override + public List selectLawEnforcementWarningByEnterpriseNumberNew(LawEnforcementWarningList lawEnforcementWarningList) { + List list = + lawEnforcementWarningListMapper.selectLawEnforcementWarningListList3(lawEnforcementWarningList); + if (CollectionUtils.isNotEmpty(list)) { + list = list.stream().sorted( + Comparator.comparing( + LawEnforcementWarningList::getCreateTime).reversed()) + .collect(Collectors.toList()); + } + return list; + } + /** * 新增执法预警列表 - * + * * @param lawEnforcementWarningList 执法预警列表 * @return 结果 */ @Override - public int insertLawEnforcementWarningList(LawEnforcementWarningList lawEnforcementWarningList) - { + public int insertLawEnforcementWarningList(LawEnforcementWarningList lawEnforcementWarningList) { lawEnforcementWarningList.setCreateTime(DateUtils.getNowDate()); return lawEnforcementWarningListMapper.insertLawEnforcementWarningList(lawEnforcementWarningList); } /** * 修改执法预警列表 - * + * * @param lawEnforcementWarningList 执法预警列表 * @return 结果 */ @Override - public int updateLawEnforcementWarningList(LawEnforcementWarningList lawEnforcementWarningList) - { + public int updateLawEnforcementWarningList(LawEnforcementWarningList lawEnforcementWarningList) { lawEnforcementWarningList.setUpdateTime(DateUtils.getNowDate()); return lawEnforcementWarningListMapper.updateLawEnforcementWarningList(lawEnforcementWarningList); } /** * 删除执法预警列表对象 - * + * * @param ids 需要删除的数据ID * @return 结果 */ @Override - public int deleteLawEnforcementWarningListByIds(String ids) - { + public int deleteLawEnforcementWarningListByIds(String ids) { return lawEnforcementWarningListMapper.deleteLawEnforcementWarningListByIds(Convert.toStrArray(ids)); } /** * 删除执法预警列表信息 - * + * * @param id 执法预警列表ID * @return 结果 */ @Override - public int deleteLawEnforcementWarningListById(String id) - { + public int deleteLawEnforcementWarningListById(String id) { return lawEnforcementWarningListMapper.deleteLawEnforcementWarningListById(id); } } diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml index 0be63a41..2d34c261 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml @@ -557,7 +557,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM ( SELECT enterprise_name, enterprise_number, bureau_dept_id,bureau_dept_name, unite_check, create_time , count( enterprise_number ) AS total FROM enforcement_registration - WHERE = #{beginTime} AND create_time <= #{endTime} ]]> AND bureau_dept_id IS NOT NULL + WHERE = #{beginTime} AND create_time <= #{endTime} ]]> GROUP BY IFNULL(unite_check, RAND()) ,bureau_dept_id ) AS t1 GROUP BY t1.bureau_dept_id,t1.enterprise_number @@ -572,7 +572,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ( SELECT enterprise_name, enterprise_number, bureau_dept_id, unite_check, create_time , count( enterprise_number ) AS total FROM enforcement_registration WHERE = #{beginTime} AND create_time <= #{endTime} ]]> - AND bureau_dept_id IS NOT NULL GROUP BY IFNULL(unite_check, RAND()) ,bureau_dept_id ) AS t1 GROUP BY t1.enterprise_number diff --git a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/LawEnforcementWarningListMapper.xml b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/LawEnforcementWarningListMapper.xml index 75f0d372..649cd3e0 100644 --- a/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/LawEnforcementWarningListMapper.xml +++ b/lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/LawEnforcementWarningListMapper.xml @@ -59,6 +59,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and DATE_FORMAT(warning_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m') + + and DATE_FORMAT(create_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m') + AND DATE_FORMAT(warning_time, '%Y-%m') >= CONCAT(YEAR(CURDATE()), '-', CASE WHEN QUARTER(CURDATE()) IN (1) THEN '01' @@ -80,6 +83,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ORDER BY enforcement_number DESC,create_time DESC LIMIT 1000000000 ) t GROUP BY t.enterprise_number order by t.create_time desc + +