diff --git a/src/main/java/com/cm/inspection/controller/apis/count/CountController.java b/src/main/java/com/cm/inspection/controller/apis/count/CountController.java index 6c58478..365685b 100644 --- a/src/main/java/com/cm/inspection/controller/apis/count/CountController.java +++ b/src/main/java/com/cm/inspection/controller/apis/count/CountController.java @@ -2,9 +2,13 @@ package com.cm.inspection.controller.apis.count; import com.cm.common.base.AbstractController; import com.cm.common.constants.ISystemConstant; +import com.cm.common.exception.ParamsException; import com.cm.common.result.ErrorResult; +import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; +import com.cm.common.utils.RegexUtil; import com.cm.inspection.service.check.ICheckService; +import com.cm.inspection.service.count.ICountService; import com.cm.inspection.service.enterprise.IEnterpriseService; import com.cm.inspection.service.gridpersonnel.IGridPersonnelService; import io.swagger.annotations.*; @@ -14,6 +18,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; import java.util.Map; /** @@ -37,6 +42,8 @@ public class CountController extends AbstractController { private IEnterpriseService enterpriseService; @Autowired private ICheckService checkService; + @Autowired + private ICountService countService; @ApiOperation(value = "统计网格员", notes = "统计网格员接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @@ -81,4 +88,65 @@ public class CountController extends AbstractController { return enterpriseService.countEnterpriseByNature(params); } + @ApiOperation(value = "工作综合报告", notes = "工作综合报告接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "path"), + @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("countworktable/{startDate}/{endDate}") + public SuccessResultData> countWorkTable(@PathVariable("startDate") String startDate, @PathVariable("endDate") String endDate) { + if (!RegexUtil.isDate(startDate)) { + throw new ParamsException("开始时间格式错误"); + } + if (!RegexUtil.isDate(endDate)) { + throw new ParamsException("结束时间格式错误"); + } + return countService.countWorkTable(startDate, endDate); + } + + @ApiOperation(value = "检查统计表", notes = "检查统计表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "path"), + @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("countchecktable/{startDate}/{endDate}") + public SuccessResultData> countCheckTable(@PathVariable("startDate") String startDate, @PathVariable("endDate") String endDate) { + if (!RegexUtil.isDate(startDate)) { + throw new ParamsException("开始时间格式错误"); + } + if (!RegexUtil.isDate(endDate)) { + throw new ParamsException("结束时间格式错误"); + } + return countService.countCheckTable(startDate, endDate); + } + + @ApiOperation(value = "行业统计表", notes = "检查统计表接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("countindustryenterprisetable") + public SuccessResultData>> countIndustryEnterpriseTable() { + return countService.countIndustryEnterpriseTable(); + } + + @ApiOperation(value = "企业认领情况统计表", notes = "企业认领情况统计表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "year", value = "年份", paramType = "path"), + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("countenterprisereceive/{year}") + public SuccessResultData> countEnterpriseReceive(@PathVariable("year") String year) { + return countService.countEnterpriseReceive(year); + } + + @ApiOperation(value = "检查统计详情表", notes = "检查统计详情表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "year", value = "年份", paramType = "path"), + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("countCheckDetailTable/{year}") + public SuccessResultData> countCheckDetailTable(@PathVariable("year") String year) { + return countService.countCheckDetailTable(year); + } + } diff --git a/src/main/java/com/cm/inspection/dao/checkplan/ICheckPlanDao.java b/src/main/java/com/cm/inspection/dao/checkplan/ICheckPlanDao.java index dab233b..0a28062 100644 --- a/src/main/java/com/cm/inspection/dao/checkplan/ICheckPlanDao.java +++ b/src/main/java/com/cm/inspection/dao/checkplan/ICheckPlanDao.java @@ -63,4 +63,21 @@ public interface ICheckPlanDao { */ List listCheckPlan(Map params) throws SearchException; + /** + * 统计计划条数 + * + * @param params + * @return + * @throws SearchException + */ + Integer countCheckPlan(Map params) throws SearchException; + + /** + * 统计计划书总数 + * + * @param params + * @return + * @throws SearchException + */ + Integer countTotalCheckPlan(Map params) throws SearchException; } diff --git a/src/main/java/com/cm/inspection/dao/enterpriseofgridoperator/IEnterpriseOfGridOperatorDao.java b/src/main/java/com/cm/inspection/dao/enterpriseofgridoperator/IEnterpriseOfGridOperatorDao.java index 32b85c9..35d4287 100644 --- a/src/main/java/com/cm/inspection/dao/enterpriseofgridoperator/IEnterpriseOfGridOperatorDao.java +++ b/src/main/java/com/cm/inspection/dao/enterpriseofgridoperator/IEnterpriseOfGridOperatorDao.java @@ -125,4 +125,13 @@ public interface IEnterpriseOfGridOperatorDao { * @throws SearchException */ Integer countUnclaimedEnterprise(Map params) throws SearchException; + + /** + * 统计认领企业 + * + * @param params + * @return + * @throws SearchException + */ + Integer countClaimedEnterprise(Map params) throws SearchException; } diff --git a/src/main/java/com/cm/inspection/service/checkplan/ICheckPlanService.java b/src/main/java/com/cm/inspection/service/checkplan/ICheckPlanService.java index 676cf0a..8a762a4 100644 --- a/src/main/java/com/cm/inspection/service/checkplan/ICheckPlanService.java +++ b/src/main/java/com/cm/inspection/service/checkplan/ICheckPlanService.java @@ -143,4 +143,36 @@ public interface ICheckPlanService { * @throws SearchException */ SuccessResultList> listPageCheckPlanOfMine(String token, ListPage page) throws SearchException; + + /** + * 统计计划数量 + * + * @param userIdList + * @param startDate + * @param endDate + * @return + * @throws SearchException + */ + Integer countCheckPlanByUserIdsAndDate(List userIdList, String startDate, String endDate) throws SearchException; + + /** + * 统计检查计划数量(按照开始时间和结束时间,yyyy-MM-dd) + * + * @param userIdList + * @param startDate + * @param endDate + * @return + * @throws SearchException + */ + Integer countTotalCheckCheckPlanByUserIdsAndDate(List userIdList, String startDate, String endDate) throws SearchException; + + /** + * 统计年度检查计划 + * + * @param userIdList + * @param year + * @return + * @throws SearchException + */ + Integer countCheckPlanByUserIdsAndYear(List userIdList, String year) throws SearchException; } diff --git a/src/main/java/com/cm/inspection/service/checkplan/impl/CheckPlanServiceImpl.java b/src/main/java/com/cm/inspection/service/checkplan/impl/CheckPlanServiceImpl.java index 62c5122..9c880fb 100644 --- a/src/main/java/com/cm/inspection/service/checkplan/impl/CheckPlanServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/checkplan/impl/CheckPlanServiceImpl.java @@ -203,6 +203,51 @@ public class CheckPlanServiceImpl extends BaseService implements ICheckPlanServi return new SuccessResultList<>(checkPlanDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); } + @Override + public Integer countCheckPlanByUserIdsAndDate(List userIdList, String startDate, String endDate) throws SearchException { + Map params = getHashMap(10); + if (!StringUtils.isBlank(startDate)) { + String[] startDateArray = startDate.split("\\-"); + params.put("startYear", startDateArray[0]); + params.put("startMonth", startDateArray[1]); + } + if (!StringUtils.isBlank(endDate)) { + String[] endDateArray = endDate.split("\\-"); + params.put("endYear", endDateArray[0]); + params.put("endMonth", endDateArray[1]); + } + params.put("userIdList", userIdList); + Integer result = checkPlanDao.countCheckPlan(params); + return result == null ? 0 : result; + } + + @Override + public Integer countTotalCheckCheckPlanByUserIdsAndDate(List userIdList, String startDate, String endDate) throws SearchException { + Map params = getHashMap(10); + if (!StringUtils.isBlank(startDate)) { + String[] startDateArray = startDate.split("\\-"); + params.put("startYear", startDateArray[0]); + params.put("startMonth", startDateArray[1]); + } + if (!StringUtils.isBlank(endDate)) { + String[] endDateArray = endDate.split("\\-"); + params.put("endYear", endDateArray[0]); + params.put("endMonth", endDateArray[1]); + } + params.put("userIdList", userIdList); + Integer result = checkPlanDao.countTotalCheckPlan(params); + return result == null ? 0 : result; + } + + @Override + public Integer countCheckPlanByUserIdsAndYear(List userIdList, String year) throws SearchException { + Map params = getHashMap(4); + params.put("userIdList", userIdList); + params.put("year", year); + Integer result = checkPlanDao.countTotalCheckPlan(params); + return result == null ? 0 : result; + } + @Override public SuccessResultData> countCurrentMonthCheckPlanOfMine() throws SearchException { return countCurrentMonthCheckPlanOfMine(null); diff --git a/src/main/java/com/cm/inspection/service/count/ICountService.java b/src/main/java/com/cm/inspection/service/count/ICountService.java new file mode 100644 index 0000000..4e1a8e1 --- /dev/null +++ b/src/main/java/com/cm/inspection/service/count/ICountService.java @@ -0,0 +1,66 @@ +package com.cm.inspection.service.count; + +import com.cm.common.exception.SearchException; +import com.cm.common.result.SuccessResultData; + +import java.util.List; +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: ICountService + * @Description: 统计 + * @Author: WangGeng + * @Date: 2020/7/14 14:49 + * @Version: 1.0 + **/ +public interface ICountService { + + /** + * 工作综合报告 + * + * @param startDate + * @param endDate + * @return + * @throws SearchException + */ + SuccessResultData> countWorkTable(String startDate, String endDate) throws SearchException; + + /** + * 检查统计表 + * + * @param startDate + * @param endDate + * @return + * @throws SearchException + */ + SuccessResultData> countCheckTable(String startDate, String endDate) throws SearchException; + + /** + * 行业企业统计表 + * + * @return + * @throws SearchException + */ + SuccessResultData>> countIndustryEnterpriseTable() throws SearchException; + + /** + * 企业认领情况统计表 + * + * @param year + * @return + * @throws SearchExceptionx + */ + SuccessResultData> countEnterpriseReceive(String year) throws SearchException; + + /** + * 检查统计详情表 + * + * @param year + * @return + * @throws SearchException + */ + SuccessResultData> countCheckDetailTable(String year) throws SearchException; +} diff --git a/src/main/java/com/cm/inspection/service/count/impl/CountServiceImpl.java b/src/main/java/com/cm/inspection/service/count/impl/CountServiceImpl.java new file mode 100644 index 0000000..13d448f --- /dev/null +++ b/src/main/java/com/cm/inspection/service/count/impl/CountServiceImpl.java @@ -0,0 +1,333 @@ +package com.cm.inspection.service.count.impl; + +import com.cm.common.exception.SearchException; +import com.cm.common.plugin.pojo.dtos.datadictionary.DataDictionaryDTO; +import com.cm.common.plugin.service.datadictionary.IDataDictionaryService; +import com.cm.common.result.SuccessResultData; +import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO; +import com.cm.inspection.service.BaseService; +import com.cm.inspection.service.check.ICheckService; +import com.cm.inspection.service.checkplan.ICheckPlanService; +import com.cm.inspection.service.count.ICountService; +import com.cm.inspection.service.enterprise.IEnterpriseService; +import com.cm.inspection.service.enterpriseofgridoperator.IEnterpriseOfGridOperatorService; +import com.cm.inspection.service.gridpersonnel.IGridPersonnelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: CountServiceImpl + * @Description: 统计 + * @Author: WangGeng + * @Date: 2020/7/14 14:49 + * @Version: 1.0 + **/ +@Service +public class CountServiceImpl extends BaseService implements ICountService { + + @Autowired + private IDataDictionaryService dataDictionaryService; + @Autowired + private IGridPersonnelService gridPersonnelService; + @Autowired + private ICheckPlanService checkPlanService; + @Autowired + private ICheckService checkService; + @Autowired + private IEnterpriseService enterpriseService; + @Autowired + private IEnterpriseOfGridOperatorService enterpriseOfGridOperatorService; + + @Override + public SuccessResultData> countWorkTable(String startDate, String endDate) throws SearchException { + LOG.debug("获取三级区域"); + List areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8"); + LOG.debug("统计区域下的人员计划数量"); + Map params = getHashMap(4); + List userIdList = new ArrayList<>(); + List> resultList = new ArrayList<>(); + for (DataDictionaryDTO areaDTO : areaDTOs) { + Map resultListMap = getHashMap(3); + // 查找区域下的人员 + params.put("area3", areaDTO.getDictionaryId()); + List gridPersonnelDTOs = gridPersonnelService.listGridPersonnel(params); + userIdList.clear(); + for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) { + userIdList.add(gridPersonnelDTO.getUserId().split("\\|")[0]); + } + resultListMap.put("areaName", areaDTO.getDictionaryName()); + // 统计计划总数 + Integer planCount = 0; + if (!userIdList.isEmpty()) { + planCount = checkPlanService.countCheckPlanByUserIdsAndDate(userIdList, startDate, endDate); + } + resultListMap.put("planCount", planCount); + resultList.add(resultListMap); + } + return returnCountResult(resultList, startDate, endDate); + } + + + @Override + public SuccessResultData> countCheckTable(String startDate, String endDate) throws SearchException { + LOG.debug("获取三级区域"); + List areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8"); + LOG.debug("统计区域下的人员计划数量"); + Map params = getHashMap(4); + List> resultList = new ArrayList<>(); + for (DataDictionaryDTO areaDTO : areaDTOs) { + Map resultListMap = getHashMap(3); + List userIdList = listGridPersonnelUserId(areaDTO.getDictionaryId()); + resultListMap.put("areaName", areaDTO.getDictionaryName()); + // 统计计划总数 + Integer planCount = 0; + if (!userIdList.isEmpty()) { + planCount = checkPlanService.countTotalCheckCheckPlanByUserIdsAndDate(userIdList, startDate, endDate); + } + resultListMap.put("planCount", planCount); + // 检查数量 + Integer checkCount = getCheckCount(userIdList, startDate, endDate); + Integer checkTotalCount = getCheckTotalCount(userIdList, startDate, endDate); + resultListMap.put("checkCount", checkCount); + resultListMap.put("checkTotalCount", checkTotalCount); + // 设置整改情况 + setRectificationCount(resultListMap, userIdList, startDate, endDate); + resultList.add(resultListMap); + } + return returnCountResult(resultList, startDate, endDate); + } + + @Override + public SuccessResultData>> countIndustryEnterpriseTable() throws SearchException { + LOG.debug("获取三级区域"); + List areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8"); + LOG.debug("获取行业分类"); + List dataDictionaryDTOs = dataDictionaryService.listDictionaryByParentId("b97630ab-45b7-45bc-a624-507d4df952ff"); + Map params = getHashMap(5); + params.put("isLogOff", 0); + List> resultList = new ArrayList<>(); + for (DataDictionaryDTO areaDTO : areaDTOs) { + Map resultListMap = getHashMap(3); + resultListMap.put("areaName", areaDTO.getDictionaryName()); + params.put("area3", areaDTO.getDictionaryId()); + List> industryTypeCountList = new ArrayList<>(); + for (DataDictionaryDTO dataDictionaryDTO : dataDictionaryDTOs) { + params.put("industryType", dataDictionaryDTO.getDictionaryId()); + Map industryTypeCountMap = getHashMap(3); + industryTypeCountMap.put("areaName", dataDictionaryDTO.getDictionaryName()); + industryTypeCountMap.put("enterpriseCount", enterpriseService.countEnterpriseReturnInteger(params)); + industryTypeCountList.add(industryTypeCountMap); + } + resultListMap.put("industryTypeCountList", industryTypeCountList); + resultList.add(resultListMap); + } + return new SuccessResultData<>(resultList); + } + + @Override + public SuccessResultData> countEnterpriseReceive(String year) throws SearchException { + LOG.debug("获取三级区域"); + List areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8"); + List> resultList = new ArrayList<>(); + Map params = getHashMap(3); + for (DataDictionaryDTO areaDTO : areaDTOs) { + Map resultListMap = getHashMap(3); + resultListMap.put("areaName", areaDTO.getDictionaryName()); + // 地区企业总数 + params.put("isLogOff", 0); + params.put("area3", areaDTO.getDictionaryId()); + params.put("year", year); + Integer enterpriseCount = enterpriseService.countEnterpriseReturnInteger(params); + resultListMap.put("enterpriseCount", enterpriseCount); + // 地区企业认领总数 + Integer enterpriseReceiveCount = countEnterpriseOfArea(areaDTO.getDictionaryId(), year); + resultListMap.put("enterpriseReceiveCount", enterpriseReceiveCount); + resultListMap.put("enterpriseReceiveRatio", enterpriseCount == 0 ? 0 : new BigDecimal((double) enterpriseReceiveCount / enterpriseCount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100); + resultList.add(resultListMap); + } + Map result = getHashMap(3); + result.put("year", year); + result.put("areaList", resultList); + return new SuccessResultData<>(result); + } + + @Override + public SuccessResultData> countCheckDetailTable(String year) throws SearchException { + LOG.debug("获取三级区域"); + List areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8"); + List> resultList = new ArrayList<>(); + for (DataDictionaryDTO areaDTO : areaDTOs) { + Map resultListMap = getHashMap(10); + resultListMap.put("areaName", areaDTO.getDictionaryName()); + // 地区认领企业总数 + Integer enterpriseReceiveCount = countEnterpriseOfArea(areaDTO.getDictionaryId(), year); + resultListMap.put("enterpriseReceiveCount", enterpriseReceiveCount); + // 网格员的Id列表 + List userIdList = listGridPersonnelUserId(areaDTO.getDictionaryId()); + // 年度计划数量 + Integer checkPlanCount = checkPlanService.countCheckPlanByUserIdsAndYear(userIdList, year); + resultListMap.put("checkPlanCount", checkPlanCount); + // 实际检查企业统计 + Integer checkCount = getCheckCountByYear(userIdList, year); + resultListMap.put("checkCount", checkCount); + resultListMap.put("completeRatio", checkPlanCount == null ? 0 : new BigDecimal((double) checkCount / checkPlanCount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + // 待复查企业 + // 超期企业 + // 企业隐患总数 + // 隐患整改总数 + // 整改率 + // 不配合次数(上报条数) + + resultList.add(resultListMap); + } + Map result = getHashMap(5); + result.put("year", year); + result.put("resultList", resultList); + return new SuccessResultData<>(result); + } + + /** + * 统计地区认领企业 + * + * @param areaId + * @param year + * @return + */ + private Integer countEnterpriseOfArea(String areaId, String year) { + Map params = getHashMap(6); + params.put("isLogOff", 0); + params.put("area3", areaId); + params.put("year", year); + return enterpriseOfGridOperatorService.countEnterpriseOfArea(params); + } + + /** + * 设置统计返回结果 + * + * @param resultList + * @param startDate + * @param endDate + * @return + */ + private SuccessResultData> returnCountResult(List> resultList, String startDate, String endDate) { + Map result = getHashMap(5); + result.put("startDate", startDate.substring(0, 7).replace("-", "年")); + result.put("endDate", endDate.substring(0, 7).replace("-", "年")); + result.put("resultList", resultList); + return new SuccessResultData<>(result); + } + + /** + * 查找区域下的人员Id列表 + * + * @param area3Id + * @return + */ + private List listGridPersonnelUserId(String area3Id) { + Map params = getHashMap(3); + List userIdList = new ArrayList<>(); + params.put("area3", area3Id); + List gridPersonnelDTOs = gridPersonnelService.listGridPersonnel(params); + for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) { + userIdList.add(gridPersonnelDTO.getUserId().split("\\|")[0]); + } + return userIdList; + } + + /** + * 检查总次数 + * + * @param userIdList + * @param startDate + * @param endDate + * @return + */ + private Integer getCheckTotalCount(List userIdList, String startDate, String endDate) { + if (userIdList.isEmpty()) { + return 0; + } + Map params = getHashMap(7); + params.put("userIdList", userIdList); + params.put("startDate", startDate); + params.put("endDate", endDate); + return checkService.countCheck(params); + } + + /** + * 实际检查情况,不算复查 + * + * @param userIdList + * @param startDate + * @param endDate + * @return + */ + private Integer getCheckCount(List userIdList, String startDate, String endDate) { + if (userIdList.isEmpty()) { + return 0; + } + Map params = getHashMap(7); + params.put("userIdList", userIdList); + params.put("startDate", startDate); + params.put("endDate", endDate); + params.put("checkType", 1); + return checkService.countCheck(params); + } + + /** + * 年度实际检查情况,不算复查 + * + * @param userIdList + * @param year + * @return + */ + private Integer getCheckCountByYear(List userIdList, String year) { + if (userIdList.isEmpty()) { + return 0; + } + Map params = getHashMap(7); + params.put("userIdList", userIdList); + params.put("year", year); + params.put("checkType", 1); + return checkService.countCheck(params); + } + + /** + * 设置整改情况统计 + * + * @param resultListMap + * @param userIdList + * @param startDate + * @param endDate + */ + private void setRectificationCount(Map resultListMap, List userIdList, String startDate, String endDate) { + int unRectificationCount = 0; + int rectificationCount = 0; + if (!userIdList.isEmpty()) { + Map params = getHashMap(8); + // 未整改:复查后,isComplete状态为未完成(0)或者创建人和修改人不为同一人 + params.put("userIdList", userIdList); + params.put("startDate", startDate); + params.put("endDate", endDate); + params.replace("checkType", 2); + params.put("rectificationType", 0); + unRectificationCount = checkService.countCheck(params); + // 已整改:复查后,isComplete状态为完成(1),并且创建人和修改人为同一人 + params.put("rectificationType", 1); + rectificationCount = checkService.countCheck(params); + } + resultListMap.put("unRectificationCount", unRectificationCount); + resultListMap.put("rectificationCount", rectificationCount); + int totalRectificationCount = unRectificationCount + rectificationCount; + // 整改率 + resultListMap.put("rectificationRatio", totalRectificationCount == 0 ? 0 : new BigDecimal((double) rectificationCount / (unRectificationCount + rectificationCount)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100); + } + +} diff --git a/src/main/java/com/cm/inspection/service/enterprise/IEnterpriseService.java b/src/main/java/com/cm/inspection/service/enterprise/IEnterpriseService.java index 57d22af..b8569d6 100644 --- a/src/main/java/com/cm/inspection/service/enterprise/IEnterpriseService.java +++ b/src/main/java/com/cm/inspection/service/enterprise/IEnterpriseService.java @@ -190,6 +190,15 @@ public interface IEnterpriseService { */ SuccessResultData> countEnterpriseByNature(Map params) throws SearchException; + /** + * 企业统计 + * + * @param params + * @return + * @throws SearchException + */ + Integer countEnterpriseReturnInteger(Map params) throws SearchException; + /** * 我的企业列表 * diff --git a/src/main/java/com/cm/inspection/service/enterprise/impl/EnterpriseServiceImpl.java b/src/main/java/com/cm/inspection/service/enterprise/impl/EnterpriseServiceImpl.java index ab32da6..a248fe6 100644 --- a/src/main/java/com/cm/inspection/service/enterprise/impl/EnterpriseServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/enterprise/impl/EnterpriseServiceImpl.java @@ -330,8 +330,7 @@ public class EnterpriseServiceImpl extends BaseService implements IEnterpriseSer @Override public SuccessResultData countEnterprise(Map params) throws SearchException { params.put("isLogOff", 0); - Integer countResult = enterpriseDao.countEnterprise(params); - return new SuccessResultData<>(countResult == null ? 0 : countResult); + return new SuccessResultData<>(countEnterpriseReturnInteger(params)); } @Override @@ -355,6 +354,12 @@ public class EnterpriseServiceImpl extends BaseService implements IEnterpriseSer return new SuccessResultData<>(result); } + @Override + public Integer countEnterpriseReturnInteger(Map params) throws SearchException { + Integer countResult = enterpriseDao.countEnterprise(params); + return countResult == null ? 0 : countResult; + } + @Override public List listEnterpriseOfMine(String token) throws SearchException { return listEnterpriseByUserId(AppTokenManager.getInstance().getToken(token).getAppTokenUser().getId()); diff --git a/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java b/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java index c98e87e..6ef6206 100644 --- a/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java +++ b/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java @@ -208,4 +208,13 @@ public interface IEnterpriseOfGridOperatorService { * @throws SearchException */ SuccessResultData countUnclaimedEnterpriseOfMine(String token) throws SearchException; + + /** + * 统计地区认领企业 + * + * @param params + * @return + * @throws SearchException + */ + Integer countEnterpriseOfArea(Map params) throws SearchException; } diff --git a/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/impl/EnterpriseOfGridOperatorServiceImpl.java b/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/impl/EnterpriseOfGridOperatorServiceImpl.java index 69bb34c..2681ac9 100644 --- a/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/impl/EnterpriseOfGridOperatorServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/impl/EnterpriseOfGridOperatorServiceImpl.java @@ -186,7 +186,7 @@ public class EnterpriseOfGridOperatorServiceImpl extends BaseService implements public SuccessResultList> listPageEnterpriseOfGridOperatorByUserId(String userId, ListPage page) { page.getParams().put("userId", userId); GridPersonnelDTO gridPersonnelDTO = gridPersonnelService.getGridPersonnelByUserId(userId); - if(gridPersonnelDTO == null) { + if (gridPersonnelDTO == null) { throw new SearchException(""); } page.getParams().put("area1", gridPersonnelDTO.getArea1()); @@ -259,6 +259,12 @@ public class EnterpriseOfGridOperatorServiceImpl extends BaseService implements return new SuccessResultData<>(countResult == null ? 0 : countResult); } + @Override + public Integer countEnterpriseOfArea(Map params) throws SearchException { + Integer countEnterprise = enterpriseOfGridOperatorDao.countClaimedEnterprise(params); + return countEnterprise == null ? 0 : countEnterprise; + } + /** * 初始化未认领地区 * diff --git a/src/main/resources/mybatis/mapper/check/check-mapper.xml b/src/main/resources/mybatis/mapper/check/check-mapper.xml index 0c13e63..a82365e 100644 --- a/src/main/resources/mybatis/mapper/check/check-mapper.xml +++ b/src/main/resources/mybatis/mapper/check/check-mapper.xml @@ -328,9 +328,21 @@ AND task_check_id = #{taskCheckId} - - AND - is_complete = #{isComplete} + + + AND ( + is_complete = 0 + OR + creator != modifier + ) + + + AND ( + is_complete = 1 + AND + creator = modifier + ) + AND @@ -340,6 +352,10 @@ AND is_coordination = #{isCoordination} + + AND + is_complete = #{isComplete} + AND LEFT(gmt_create, 10) = #{checkDay} @@ -348,6 +364,25 @@ AND LEFT(gmt_create, 7) = #{checkMonth} + + AND + LEFT(gmt_create, 7) = ]]> #{startDate} + + + AND + LEFT(gmt_create, 7) #{endDate} + + + AND + LEFT(gmt_create, 4) = #{year} + + + AND + creator IN + + #{userIdList[${index}]} + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/checkplan/checkplan-mapper.xml b/src/main/resources/mybatis/mapper/checkplan/checkplan-mapper.xml index 990cab6..84ff653 100644 --- a/src/main/resources/mybatis/mapper/checkplan/checkplan-mapper.xml +++ b/src/main/resources/mybatis/mapper/checkplan/checkplan-mapper.xml @@ -150,4 +150,74 @@ t1.check_plan_year DESC, t1.check_plan_month DESC + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml b/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml index ffd9980..41c5116 100644 --- a/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml +++ b/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml @@ -484,19 +484,35 @@ diff --git a/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml b/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml index 918d236..3b95140 100644 --- a/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml +++ b/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml @@ -590,6 +590,57 @@ AND t1.name LIKE CONCAT('%', #{keywords}, '%') + + AND + LEFT(t1.gmt_create, 4) #{year} + + + + + \ No newline at end of file