From a1602cd9098f8768b80895a20418899c1fa328b4 Mon Sep 17 00:00:00 2001 From: WenG <450292408@qq.com> Date: Tue, 15 Sep 2020 12:47:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/apis/count/CountAppController.java | 48 +++++++++++++++++++ .../IEnterpriseOfGridOperatorDao.java | 8 ++++ .../service/count/ICountService.java | 9 ++++ .../service/count/impl/CountServiceImpl.java | 34 +++++++++++++ .../IEnterpriseOfGridOperatorService.java | 9 ++++ .../EnterpriseOfGridOperatorServiceImpl.java | 6 +++ src/main/resources/application-test.yml | 4 +- .../mybatis/mapper/check/check-mapper.xml | 8 ++++ .../enterpriseofgridoperator-mapper.xml | 22 +++++++++ 9 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/cm/inspection/controller/app/apis/count/CountAppController.java diff --git a/src/main/java/com/cm/inspection/controller/app/apis/count/CountAppController.java b/src/main/java/com/cm/inspection/controller/app/apis/count/CountAppController.java new file mode 100644 index 0000000..275dcb6 --- /dev/null +++ b/src/main/java/com/cm/inspection/controller/app/apis/count/CountAppController.java @@ -0,0 +1,48 @@ +package com.cm.inspection.controller.app.apis.count; + +import com.cm.common.base.AbstractService; +import com.cm.common.constants.ISystemConstant; +import com.cm.common.result.ErrorResult; +import com.cm.common.result.SuccessResultData; +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.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: CountAppController + * @Description: App端统计 + * @Author: WangGeng + * @Date: 2020/9/15 10:36 + * @Version: 1.0 + **/ +@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "统计接口") +@RestController +@RequestMapping(ISystemConstant.APP_PREFIX + "/count") +public class CountAppController extends AbstractService { + + @Autowired + private ICountService countService; + + @ApiOperation(value = "统计本月个人相关数据", notes = "统计本月个人相关数据接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header"), + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("countcurrentmonthofmine") + public SuccessResultData> countCurrentMonthOfMine(@RequestHeader("token") String token) { + return countService.countCurrentMonthOfMine(token); + } + +} 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 35d4287..5c859ab 100644 --- a/src/main/java/com/cm/inspection/dao/enterpriseofgridoperator/IEnterpriseOfGridOperatorDao.java +++ b/src/main/java/com/cm/inspection/dao/enterpriseofgridoperator/IEnterpriseOfGridOperatorDao.java @@ -134,4 +134,12 @@ public interface IEnterpriseOfGridOperatorDao { * @throws SearchException */ Integer countClaimedEnterprise(Map params) throws SearchException; + + /** + * 统计认领企业 + * @param params + * @return + * @throws SearchException + */ + Integer countEnterpriseOfGridOperatorSimple(Map params) throws SearchException; } diff --git a/src/main/java/com/cm/inspection/service/count/ICountService.java b/src/main/java/com/cm/inspection/service/count/ICountService.java index 374af65..0a6fe83 100644 --- a/src/main/java/com/cm/inspection/service/count/ICountService.java +++ b/src/main/java/com/cm/inspection/service/count/ICountService.java @@ -106,4 +106,13 @@ public interface ICountService { * @throws SearchException */ SuccessResultData> countEnterprisePlanRealCheckTable(String areaId, Integer areaLevel, String year) throws SearchException; + + /** + * 统计本月个人相关数据 + * + * @param token + * @return + * @throws SearchException + */ + SuccessResultData> countCurrentMonthOfMine(String token) 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 index e0a5d12..36d502b 100644 --- a/src/main/java/com/cm/inspection/service/count/impl/CountServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/count/impl/CountServiceImpl.java @@ -1,9 +1,12 @@ package com.cm.inspection.service.count.impl; +import com.cm.common.constants.ISystemConstant; 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.common.token.app.AppTokenManager; +import com.cm.common.token.app.entity.AppToken; import com.cm.common.utils.HashMapUtil; import com.cm.inspection.pojo.dtos.check.CheckDTO; import com.cm.inspection.pojo.dtos.checkitem.CheckItemDTO; @@ -25,6 +28,7 @@ import org.activiti.engine.task.Task; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; +import org.omg.PortableInterceptor.USER_EXCEPTION; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -424,6 +428,36 @@ public class CountServiceImpl extends BaseService implements ICountService { return new SuccessResultData<>(result); } + @Override + public SuccessResultData> countCurrentMonthOfMine(String token) throws SearchException { + String userId = AppTokenManager.getInstance().getToken(token).getUserId(); + DateTime nowDateTime = DateTime.now(); + String yearMonth = nowDateTime.toString(DateTimeFormat.forPattern("yyyy-MM")); + Map params = getHashMap(4); + params.put("userId", userId); + params.put("dateYearMonth", yearMonth); + // 本月认领企业 + Integer enterpriseCount = enterpriseOfGridOperatorService.countEnterpriseOfGridOperator(params); + // 本月计划健查数 + List userIds = new ArrayList<>(); + userIds.add(userId); + Integer checkPlanCount = checkPlanService.countCheckPlanByUserIdsAndYearMonth(userIds, nowDateTime.getYear() + "", nowDateTime.getMonthOfYear()); + // 本月健查企业数 + params.put("userId", userId); + params.put("checkType", 1); + params.put("yearMonth", yearMonth); + Integer checkEnterpriseCount = checkService.countEnterpriseCheck(params); + params.put("checkType", 2); + // 本月复查企业数 + Integer recheckEnterpriseCount = checkService.countEnterpriseCheck(params); + Map result = new HashMap<>(8); + result.put("enterpriseCount", enterpriseCount); + result.put("checkPlanCount", checkPlanCount); + result.put("checkEnterpriseCount", checkEnterpriseCount); + result.put("recheckEnterpriseCount", recheckEnterpriseCount); + return new SuccessResultData<>(result); + } + /** * 构建检查结果到检查项中 * 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 6ef6206..a890059 100644 --- a/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java +++ b/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java @@ -217,4 +217,13 @@ public interface IEnterpriseOfGridOperatorService { * @throws SearchException */ Integer countEnterpriseOfArea(Map params) throws SearchException; + + /** + * 统计网格员企业 + * + * @param params + * @return + * @throws SearchException + */ + Integer countEnterpriseOfGridOperator(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 2681ac9..1d0ac9d 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 @@ -265,6 +265,12 @@ public class EnterpriseOfGridOperatorServiceImpl extends BaseService implements return countEnterprise == null ? 0 : countEnterprise; } + @Override + public Integer countEnterpriseOfGridOperator(Map params) throws SearchException { + Integer count = enterpriseOfGridOperatorDao.countEnterpriseOfGridOperatorSimple(params); + return count == null ? 0 : count; + } + /** * 初始化未认领地区 * diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 300c320..7fddcf4 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -1,6 +1,6 @@ server: port: 7006 - url: http://192.168.0.113:7006/inspection + url: http://192.168.0.103:7006/inspection title: 隐患上报系统 servlet: context-path: /inspection @@ -78,7 +78,7 @@ file: # 安全 security: oauth2: - oauth-server: http://192.168.0.113:7001/usercenter + oauth-server: http://192.168.0.103:7001/usercenter oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url} client: client-id: 32ec344a5fd04fd9911586df5d1dc36b diff --git a/src/main/resources/mybatis/mapper/check/check-mapper.xml b/src/main/resources/mybatis/mapper/check/check-mapper.xml index a5246c3..d4f25c1 100644 --- a/src/main/resources/mybatis/mapper/check/check-mapper.xml +++ b/src/main/resources/mybatis/mapper/check/check-mapper.xml @@ -473,6 +473,14 @@ AND LEFT(gmt_create, 7) = #{yearMonth} + + AND + check_type = #{checkType} + + + AND + creator = #{userId} + AND creator IN diff --git a/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml b/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml index bf64f2f..00183ca 100644 --- a/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml +++ b/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml @@ -643,4 +643,26 @@ + + + \ No newline at end of file