新增相关统计接口
This commit is contained in:
parent
42f6754ef0
commit
ea43afd3b2
@ -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<Map<String, Object>> 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<Map<String, Object>> 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<List<Map<String, Object>>> 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<Map<String, Object>> 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<Map<String, Object>> countCheckDetailTable(@PathVariable("year") String year) {
|
||||
return countService.countCheckDetailTable(year);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,4 +63,21 @@ public interface ICheckPlanDao {
|
||||
*/
|
||||
List<CheckPlanDTO> listCheckPlan(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 统计计划条数
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countCheckPlan(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 统计计划书总数
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countTotalCheckPlan(Map<String, Object> params) throws SearchException;
|
||||
}
|
||||
|
@ -125,4 +125,13 @@ public interface IEnterpriseOfGridOperatorDao {
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countUnclaimedEnterprise(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 统计认领企业
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countClaimedEnterprise(Map<String, Object> params) throws SearchException;
|
||||
}
|
||||
|
@ -143,4 +143,36 @@ public interface ICheckPlanService {
|
||||
* @throws SearchException
|
||||
*/
|
||||
SuccessResultList<List<CheckPlanDTO>> listPageCheckPlanOfMine(String token, ListPage page) throws SearchException;
|
||||
|
||||
/**
|
||||
* 统计计划数量
|
||||
*
|
||||
* @param userIdList
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countCheckPlanByUserIdsAndDate(List<String> userIdList, String startDate, String endDate) throws SearchException;
|
||||
|
||||
/**
|
||||
* 统计检查计划数量(按照开始时间和结束时间,yyyy-MM-dd)
|
||||
*
|
||||
* @param userIdList
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countTotalCheckCheckPlanByUserIdsAndDate(List<String> userIdList, String startDate, String endDate) throws SearchException;
|
||||
|
||||
/**
|
||||
* 统计年度检查计划
|
||||
*
|
||||
* @param userIdList
|
||||
* @param year
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countCheckPlanByUserIdsAndYear(List<String> userIdList, String year) throws SearchException;
|
||||
}
|
||||
|
@ -203,6 +203,51 @@ public class CheckPlanServiceImpl extends BaseService implements ICheckPlanServi
|
||||
return new SuccessResultList<>(checkPlanDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countCheckPlanByUserIdsAndDate(List<String> userIdList, String startDate, String endDate) throws SearchException {
|
||||
Map<String, Object> 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<String> userIdList, String startDate, String endDate) throws SearchException {
|
||||
Map<String, Object> 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<String> userIdList, String year) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("userIdList", userIdList);
|
||||
params.put("year", year);
|
||||
Integer result = checkPlanDao.countTotalCheckPlan(params);
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultData<Map<String, Object>> countCurrentMonthCheckPlanOfMine() throws SearchException {
|
||||
return countCurrentMonthCheckPlanOfMine(null);
|
||||
|
@ -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<Map<String, Object>> countWorkTable(String startDate, String endDate) throws SearchException;
|
||||
|
||||
/**
|
||||
* 检查统计表
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
SuccessResultData<Map<String, Object>> countCheckTable(String startDate, String endDate) throws SearchException;
|
||||
|
||||
/**
|
||||
* 行业企业统计表
|
||||
*
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
SuccessResultData<List<Map<String, Object>>> countIndustryEnterpriseTable() throws SearchException;
|
||||
|
||||
/**
|
||||
* 企业认领情况统计表
|
||||
*
|
||||
* @param year
|
||||
* @return
|
||||
* @throws SearchExceptionx
|
||||
*/
|
||||
SuccessResultData<Map<String, Object>> countEnterpriseReceive(String year) throws SearchException;
|
||||
|
||||
/**
|
||||
* 检查统计详情表
|
||||
*
|
||||
* @param year
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
SuccessResultData<Map<String, Object>> countCheckDetailTable(String year) throws SearchException;
|
||||
}
|
@ -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<Map<String, Object>> countWorkTable(String startDate, String endDate) throws SearchException {
|
||||
LOG.debug("获取三级区域");
|
||||
List<DataDictionaryDTO> areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8");
|
||||
LOG.debug("统计区域下的人员计划数量");
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
for (DataDictionaryDTO areaDTO : areaDTOs) {
|
||||
Map<String, Object> resultListMap = getHashMap(3);
|
||||
// 查找区域下的人员
|
||||
params.put("area3", areaDTO.getDictionaryId());
|
||||
List<GridPersonnelDTO> 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<Map<String, Object>> countCheckTable(String startDate, String endDate) throws SearchException {
|
||||
LOG.debug("获取三级区域");
|
||||
List<DataDictionaryDTO> areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8");
|
||||
LOG.debug("统计区域下的人员计划数量");
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
for (DataDictionaryDTO areaDTO : areaDTOs) {
|
||||
Map<String, Object> resultListMap = getHashMap(3);
|
||||
List<String> 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<List<Map<String, Object>>> countIndustryEnterpriseTable() throws SearchException {
|
||||
LOG.debug("获取三级区域");
|
||||
List<DataDictionaryDTO> areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8");
|
||||
LOG.debug("获取行业分类");
|
||||
List<DataDictionaryDTO> dataDictionaryDTOs = dataDictionaryService.listDictionaryByParentId("b97630ab-45b7-45bc-a624-507d4df952ff");
|
||||
Map<String, Object> params = getHashMap(5);
|
||||
params.put("isLogOff", 0);
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
for (DataDictionaryDTO areaDTO : areaDTOs) {
|
||||
Map<String, Object> resultListMap = getHashMap(3);
|
||||
resultListMap.put("areaName", areaDTO.getDictionaryName());
|
||||
params.put("area3", areaDTO.getDictionaryId());
|
||||
List<Map<String, Object>> industryTypeCountList = new ArrayList<>();
|
||||
for (DataDictionaryDTO dataDictionaryDTO : dataDictionaryDTOs) {
|
||||
params.put("industryType", dataDictionaryDTO.getDictionaryId());
|
||||
Map<String, Object> 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<Map<String, Object>> countEnterpriseReceive(String year) throws SearchException {
|
||||
LOG.debug("获取三级区域");
|
||||
List<DataDictionaryDTO> areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8");
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
Map<String, Object> params = getHashMap(3);
|
||||
for (DataDictionaryDTO areaDTO : areaDTOs) {
|
||||
Map<String, Object> 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<String, Object> result = getHashMap(3);
|
||||
result.put("year", year);
|
||||
result.put("areaList", resultList);
|
||||
return new SuccessResultData<>(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultData<Map<String, Object>> countCheckDetailTable(String year) throws SearchException {
|
||||
LOG.debug("获取三级区域");
|
||||
List<DataDictionaryDTO> areaDTOs = dataDictionaryService.listDictionaryByParentId("3f62e230-47a5-4ad9-ab01-08fd2c5218d8");
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
for (DataDictionaryDTO areaDTO : areaDTOs) {
|
||||
Map<String, Object> resultListMap = getHashMap(10);
|
||||
resultListMap.put("areaName", areaDTO.getDictionaryName());
|
||||
// 地区认领企业总数
|
||||
Integer enterpriseReceiveCount = countEnterpriseOfArea(areaDTO.getDictionaryId(), year);
|
||||
resultListMap.put("enterpriseReceiveCount", enterpriseReceiveCount);
|
||||
// 网格员的Id列表
|
||||
List<String> 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<String, Object> 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<String, Object> 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<Map<String, Object>> returnCountResult(List<Map<String, Object>> resultList, String startDate, String endDate) {
|
||||
Map<String, Object> 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<String> listGridPersonnelUserId(String area3Id) {
|
||||
Map<String, Object> params = getHashMap(3);
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
params.put("area3", area3Id);
|
||||
List<GridPersonnelDTO> 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<String> userIdList, String startDate, String endDate) {
|
||||
if (userIdList.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
Map<String, Object> 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<String> userIdList, String startDate, String endDate) {
|
||||
if (userIdList.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
Map<String, Object> 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<String> userIdList, String year) {
|
||||
if (userIdList.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
Map<String, Object> 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<String, Object> resultListMap, List<String> userIdList, String startDate, String endDate) {
|
||||
int unRectificationCount = 0;
|
||||
int rectificationCount = 0;
|
||||
if (!userIdList.isEmpty()) {
|
||||
Map<String, Object> 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);
|
||||
}
|
||||
|
||||
}
|
@ -190,6 +190,15 @@ public interface IEnterpriseService {
|
||||
*/
|
||||
SuccessResultData<Map<String, Object>> countEnterpriseByNature(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 企业统计
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countEnterpriseReturnInteger(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 我的企业列表
|
||||
*
|
||||
|
@ -330,8 +330,7 @@ public class EnterpriseServiceImpl extends BaseService implements IEnterpriseSer
|
||||
@Override
|
||||
public SuccessResultData<Integer> countEnterprise(Map<String, Object> 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<String, Object> params) throws SearchException {
|
||||
Integer countResult = enterpriseDao.countEnterprise(params);
|
||||
return countResult == null ? 0 : countResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnterpriseDTO> listEnterpriseOfMine(String token) throws SearchException {
|
||||
return listEnterpriseByUserId(AppTokenManager.getInstance().getToken(token).getAppTokenUser().getId());
|
||||
|
@ -208,4 +208,13 @@ public interface IEnterpriseOfGridOperatorService {
|
||||
* @throws SearchException
|
||||
*/
|
||||
SuccessResultData<Integer> countUnclaimedEnterpriseOfMine(String token) throws SearchException;
|
||||
|
||||
/**
|
||||
* 统计地区认领企业
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countEnterpriseOfArea(Map<String, Object> params) throws SearchException;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ public class EnterpriseOfGridOperatorServiceImpl extends BaseService implements
|
||||
public SuccessResultList<List<EnterpriseOfGridOperatorDTO>> 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<String, Object> params) throws SearchException {
|
||||
Integer countEnterprise = enterpriseOfGridOperatorDao.countClaimedEnterprise(params);
|
||||
return countEnterprise == null ? 0 : countEnterprise;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化未认领地区
|
||||
*
|
||||
|
@ -328,9 +328,21 @@
|
||||
AND
|
||||
task_check_id = #{taskCheckId}
|
||||
</if>
|
||||
<if test="isComplete != null">
|
||||
AND
|
||||
is_complete = #{isComplete}
|
||||
<if test="rectificationType != null">
|
||||
<if test="rectificationType == 0">
|
||||
AND (
|
||||
is_complete = 0
|
||||
OR
|
||||
creator != modifier
|
||||
)
|
||||
</if>
|
||||
<if test="rectificationType == 1">
|
||||
AND (
|
||||
is_complete = 1
|
||||
AND
|
||||
creator = modifier
|
||||
)
|
||||
</if>
|
||||
</if>
|
||||
<if test="checkType != null">
|
||||
AND
|
||||
@ -340,6 +352,10 @@
|
||||
AND
|
||||
is_coordination = #{isCoordination}
|
||||
</if>
|
||||
<if test="isComplete != null and isComplete != ''">
|
||||
AND
|
||||
is_complete = #{isComplete}
|
||||
</if>
|
||||
<if test="checkDay != null and checkDay != ''">
|
||||
AND
|
||||
LEFT(gmt_create, 10) = #{checkDay}
|
||||
@ -348,6 +364,25 @@
|
||||
AND
|
||||
LEFT(gmt_create, 7) = #{checkMonth}
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
AND
|
||||
LEFT(gmt_create, 7) <![CDATA[ >= ]]> #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
AND
|
||||
LEFT(gmt_create, 7) <![CDATA[ <= ]]> #{endDate}
|
||||
</if>
|
||||
<if test="year != null and year != ''">
|
||||
AND
|
||||
LEFT(gmt_create, 4) = #{year}
|
||||
</if>
|
||||
<if test="userIdList != null">
|
||||
AND
|
||||
creator IN
|
||||
<foreach collection="userIdList" index="index" open="(" separator="," close=")">
|
||||
#{userIdList[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -150,4 +150,74 @@
|
||||
t1.check_plan_year DESC, t1.check_plan_month DESC
|
||||
</select>
|
||||
|
||||
<!-- 统计计划总数 -->
|
||||
<select id="countCheckPlan" parameterType="map" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
gen_check_plan
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="userIdList != null and userIdList.size > 0">
|
||||
AND
|
||||
creator IN
|
||||
<foreach collection="userIdList" index="index" open="(" separator="," close=")">
|
||||
#{userIdList[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startYear != null and startYear != ''">
|
||||
AND
|
||||
check_plan_year <![CDATA[ >= ]]> #{startYear}
|
||||
</if>
|
||||
<if test="startMonth != null and startMonth != ''">
|
||||
AND
|
||||
check_plan_month <![CDATA[ >= ]]> #{startMonth}
|
||||
</if>
|
||||
<if test="endYear != null and endYear != ''">
|
||||
AND
|
||||
check_plan_year <![CDATA[ <= ]]> #{endYear}
|
||||
</if>
|
||||
<if test="endMonth != null and endMonth != ''">
|
||||
AND
|
||||
check_plan_month <![CDATA[ <= ]]> #{endMonth}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 统计计划书总数 -->
|
||||
<select id="countTotalCheckPlan" parameterType="map" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
SUM(check_plan_count)
|
||||
FROM
|
||||
gen_check_plan
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="userIdList != null and userIdList.size > 0">
|
||||
AND
|
||||
creator IN
|
||||
<foreach collection="userIdList" index="index" open="(" separator="," close=")">
|
||||
#{userIdList[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startYear != null and startYear != ''">
|
||||
AND
|
||||
check_plan_year <![CDATA[ >= ]]> #{startYear}
|
||||
</if>
|
||||
<if test="startMonth != null and startMonth != ''">
|
||||
AND
|
||||
check_plan_month <![CDATA[ >= ]]> #{startMonth}
|
||||
</if>
|
||||
<if test="endYear != null and endYear != ''">
|
||||
AND
|
||||
check_plan_year <![CDATA[ <= ]]> #{endYear}
|
||||
</if>
|
||||
<if test="endMonth != null and endMonth != ''">
|
||||
AND
|
||||
check_plan_month <![CDATA[ <= ]]> #{endMonth}
|
||||
</if>
|
||||
<if test="year != null and year != ''">
|
||||
AND
|
||||
check_plan_year = #{year}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -484,19 +484,35 @@
|
||||
<!-- 统计企业 -->
|
||||
<select id="countEnterprise" parameterType="map" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
COUNT(*)
|
||||
FROM
|
||||
gen_enterprise
|
||||
gen_enterprise
|
||||
WHERE
|
||||
is_delete = 0
|
||||
is_delete = 0
|
||||
<if test="isLogOff != null">
|
||||
AND
|
||||
AND
|
||||
is_log_off = #{isLogOff}
|
||||
</if>
|
||||
<if test="nature != null and nature != ''">
|
||||
AND
|
||||
AND
|
||||
nature = #{nature}
|
||||
</if>
|
||||
<if test="area3 != null and area3 != ''">
|
||||
AND
|
||||
area3 = #{area3}
|
||||
</if>
|
||||
<if test="industryType != null and industryType != ''">
|
||||
AND
|
||||
industry_type = #{industryType}
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND
|
||||
industry = #{industry}
|
||||
</if>
|
||||
<if test="year != null and year != ''">
|
||||
AND
|
||||
LEFT(gmt_create, 4) <![CDATA[ <= ]]> #{year}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 用户企业列表 -->
|
||||
|
@ -590,6 +590,57 @@
|
||||
AND
|
||||
t1.name LIKE CONCAT('%', #{keywords}, '%')
|
||||
</if>
|
||||
<if test="year != null and year != ''">
|
||||
AND
|
||||
LEFT(t1.gmt_create, 4) <![CDATA[ <= ]]> #{year}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 统计认领企业 -->
|
||||
<select id="countClaimedEnterprise" parameterType="map" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
gen_enterprise t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.enterprise_id IN (
|
||||
SELECT
|
||||
wt1.enterprise_id
|
||||
FROM
|
||||
gen_enterprise_of_grid_operator wt1
|
||||
GROUP BY
|
||||
wt1.enterprise_id
|
||||
)
|
||||
<if test="area1 != null and area1 != ''">
|
||||
AND
|
||||
t1.area1 = #{area1}
|
||||
</if>
|
||||
<if test="area2 != null and area2 != ''">
|
||||
AND
|
||||
t1.area2 = #{area2}
|
||||
</if>
|
||||
<if test="area3 != null and area3 != ''">
|
||||
AND
|
||||
t1.area3 = #{area3}
|
||||
</if>
|
||||
<if test="area4 != null and area4 != ''">
|
||||
AND
|
||||
t1.area4 = #{area4}
|
||||
</if>
|
||||
<if test="area5 != null and area5 != ''">
|
||||
AND
|
||||
t1.area5 = #{area5}
|
||||
</if>
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND
|
||||
t1.name LIKE CONCAT('%', #{keywords}, '%')
|
||||
</if>
|
||||
<if test="year != null and year != ''">
|
||||
AND
|
||||
LEFT(t1.gmt_create, 4) <![CDATA[ <= ]]> #{year}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user