大数据统计接口

This commit is contained in:
ly19960718 2021-08-05 15:19:09 +08:00
parent a418dfb76a
commit 9e6079260e
12 changed files with 426 additions and 13 deletions

View File

@ -37,7 +37,6 @@ public class EnterpriseCountController extends AbstractController {
BigDataResult result = new BigDataResult();
List<Map<String,Object>> list = new ArrayList();
Map<String,Object> params1 = new HashMap<>();
params1.put("enterpriseType",enterpriseTypeEnum.TYOE_1.getValue());
Integer count1 = enterpriseService.countEnterprisePollution(params1);
@ -70,12 +69,50 @@ public class EnterpriseCountController extends AbstractController {
@ApiOperation(value = "统计企业类型", notes = "统计企业类型接口")
@GetMapping("count-enterprisetype-select")
public BigDataResult countEnterpriseTypeSelect(){
BigDataResult result = new BigDataResult();
List<Map<String,Object>> list = new ArrayList();
Map<String,Object> params1 = new HashMap<>();
params1.put("enterpriseType",enterpriseTypeEnum.TYOE_1.getValue());
Integer count1 = enterpriseService.countEnterprisePollution(params1);
params1.clear();
params1.put("name",enterpriseTypeEnum.TYOE_1.getSummary() + ""+count1+"");
params1.put("id",enterpriseTypeEnum.TYOE_1.getValue());
list.add(params1);
Map<String,Object> params2 = new HashMap<>();
params2.put("enterpriseType",enterpriseTypeEnum.TYOE_2.getValue());
Integer count2 = enterpriseService.countEnterprisePollution(params2);
params2.clear();
params2.put("name",enterpriseTypeEnum.TYOE_2.getSummary() + ""+count2+"");
params2.put("id",enterpriseTypeEnum.TYOE_2.getValue());
list.add(params2);
Map<String,Object> params3 = new HashMap<>();
params3.put("enterpriseType",enterpriseTypeEnum.TYOE_3.getValue());
Integer count3 = enterpriseService.countEnterprisePollution(params3);
params3.clear();
params3.put("name",enterpriseTypeEnum.TYOE_3.getSummary() + "" +count3+ "");
params3.put("id",enterpriseTypeEnum.TYOE_3.getValue());
list.add(params3);
result.setList(list);
return result;
}
@ApiOperation(value = "企业列表", notes = "企业列表接口")
@GetMapping("enterprise-list")
public SuccessResultList<List<EnterpriseDTO>> enterpriseList(ListPage page){
public SuccessResultList<List<Map<String,Object>>> enterpriseList(ListPage page){
Map<String, Object> params = requestParams();
page.setParams(params);
return enterpriseService.listPage(page);
SuccessResultList<List<Map<String, Object>>> listSuccessResultList = enterpriseService.listPageBigData(page);
return listSuccessResultList;
}

View File

@ -2,15 +2,18 @@ package com.cm.inspection.controller.app.resources.taskcheck;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.plugin.oauth.service.department.IDepartmentService;
import com.cm.common.plugin.oauth.service.user.IUserService;
import com.cm.common.plugin.pojo.bos.UserResourceBO;
import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO;
import com.cm.common.pojo.ListPage;
import com.cm.common.pojo.dtos.department.DepartmentSortDTO;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.DateUtil;
import com.cm.inspection.controller.app.resources.BigDataResult;
import com.cm.inspection.pojo.dtos.taskcheck.v2.TaskCheckDTO;
import com.cm.inspection.service.taskcheck.v2.ITaskCheckService;
@ -23,6 +26,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -45,9 +50,10 @@ public class TaskcheckV2CountController extends AbstractController {
@Value("${count-big-data.shengtaiwei-dept-id}")
protected String shengtaiweiId;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ApiOperation(value = "检查任务分页列表", notes = "检查任务分页列表接口")
@ApiOperation(value = "集宁区检查任务分页列表", notes = "集宁区检查任务分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "Integer", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "Integer", defaultValue = "20"),
@ -56,14 +62,121 @@ public class TaskcheckV2CountController extends AbstractController {
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagetask")
public SuccessResultList<List<TaskCheckDTO>> listPageTask(ListPage page) {
@GetMapping("listpagetask-jiningqu")
public SuccessResultList<List<Map<String,Object>>> listPageTaskBigDataJiNingQu(ListPage page) {
Map<String, Object> params = requestParams();
List<String> checkUserIds = new ArrayList<>();
boolean flag=params.containsKey("departmentId");
if(flag){
List<String> deptList =new ArrayList<>();
deptList.add(params.get("departmentId").toString());
final List<String> userIds = this.deptUserUtils(userService.listUserDepartmentResourceByDepartmentIds(deptList));
for (String userId : userIds) {
checkUserIds.add(userId);
}
}else{
List<DepartmentSortDTO> departmentSortDTOS = departmentService.listSortByParentId(jinniquId);
for (DepartmentSortDTO departmentSortDTO : departmentSortDTOS) {
List<String> deptList =new ArrayList<>();
deptList.add(departmentSortDTO.getDepartmentId());
final List<String> userIds = this.deptUserUtils(userService.listUserDepartmentResourceByDepartmentIds(deptList));
for (String userId : userIds) {
checkUserIds.add(userId);
}
}
}
if(checkUserIds.size() <= 0 ){
checkUserIds.add("000");
}
params.put("checkUserIds",checkUserIds);
page.setParams(params);
return taskCheckService.listPageTask(page);
SuccessResultList<List<Map<String, Object>>> listSuccessResultList = taskCheckService.listPageTaskBigData(page);
setListParams(listSuccessResultList.getRows());
return listSuccessResultList;
}
@ApiOperation(value = "生态委检查任务分页列表", notes = "生态委检查任务分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "Integer", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "Integer", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagetask-shengtaiwei")
public SuccessResultList<List<Map<String,Object>>> listPageTaskBigDataShengTaiWei(ListPage page) {
Map<String, Object> params = requestParams();
List<String> checkUserIds = new ArrayList<>();
boolean flag=params.containsKey("departmentId");
System.out.println(flag);
if(flag){
List<String> deptList =new ArrayList<>();
deptList.add(params.get("departmentId").toString());
final List<String> userIds = this.deptUserUtils(userService.listUserDepartmentResourceByDepartmentIds(deptList));
for (String userId : userIds) {
checkUserIds.add(userId);
}
}else{
List<DepartmentSortDTO> departmentSortDTOS = departmentService.listSortByParentId(shengtaiweiId);
for (DepartmentSortDTO departmentSortDTO : departmentSortDTOS) {
List<String> deptList =new ArrayList<>();
deptList.add(departmentSortDTO.getDepartmentId());
final List<String> userIds = this.deptUserUtils(userService.listUserDepartmentResourceByDepartmentIds(deptList));
for (String userId : userIds) {
checkUserIds.add(userId);
}
}
}
if(checkUserIds.size() <= 0 ){
checkUserIds.add("000");
}
params.put("checkUserIds",checkUserIds);
page.setParams(params);
SuccessResultList<List<Map<String, Object>>> listSuccessResultList = taskCheckService.listPageTaskBigData(page);
setListParams(listSuccessResultList.getRows());
return listSuccessResultList;
}
public void setListParams(List<Map<String,Object>> list) {
for (Map<String, Object> map : list) {
String taskType = map.get("taskType").toString(); //任务种类
String isChecked = map.get("isChecked").toString(); //是否检查
String isCompleted = map.get("isCompleted").toString(); //是否完成
String checkUserId = map.get("checkUserId").toString();
if(taskType.equals("1")){
map.put("taskTypeText","指定任务");
}
if(taskType.equals("2")){
map.put("taskTypeText","单随机任务");
}
if(taskType.equals("3")){
map.put("taskTypeText","双随机任务");
}
map.put("isCheckedText",isChecked.equals("0") ? "未检查":"已检查");
map.put("isCompletedText",isCompleted.equals("0") ? "未完成":"已完成");
List<String> userIdList = new ArrayList<>();
userIdList.add(map.get("checkUserId").toString());
List<UserResourceBO> userResourceBOS = userService.listUserResourceByIds(userIdList);
map.put("checkUserName",userResourceBOS.size() != 0 ? userResourceBOS.get(0).getUserName():"");
}
}
@ApiOperation(value = "统计当月任务总数", notes = "统计当月任务总数接口")
@ -112,7 +225,7 @@ public class TaskcheckV2CountController extends AbstractController {
@ApiOperation(value = "统计集宁区各科室任务信息", notes = "统计集宁区各科室任务信息接口")
@ApiOperation(value = "统计集宁区各科室任务完成情况", notes = "统计集宁区各科室任务完成情况接口")
@GetMapping("count-jiniqu-dept-taskcheckdata")
public BigDataResult countDepartmentTaskCheckData1(){
BigDataResult result = new BigDataResult();
@ -161,7 +274,7 @@ public class TaskcheckV2CountController extends AbstractController {
}
@ApiOperation(value = "统计生态委各科室任务信息", notes = "统计集宁区各科室任务信息接口")
@ApiOperation(value = "统计生态委各科室任务完成情况", notes = "统计生态委各科室任务完成情况接口")
@GetMapping("count-shengtaiwei-dept-taskcheckdata")
public BigDataResult countDepartmentTaskCheckData2(){
BigDataResult result = new BigDataResult();
@ -218,9 +331,103 @@ public class TaskcheckV2CountController extends AbstractController {
return result;
}
@ApiOperation(value = "统计生态委各科室任务总完成情况", notes = "统计生态委各科室任务总完成情况接口")
@GetMapping("count-shengtaiwei-dept-taskcheckdata-total")
public BigDataResult countDepartmentTaskCheckData2Total(){
BigDataResult result = new BigDataResult();
Integer count0 = 0;
Integer count1 = 0;
List<DepartmentSortDTO> departmentSortDTOS = departmentService.listSortByParentId(shengtaiweiId);
for (DepartmentSortDTO departmentSortDTO : departmentSortDTOS) {
//查询部门用户
List<String> deptList =new ArrayList<>();
deptList.add(departmentSortDTO.getDepartmentId());
final List<String> userIds = this.deptUserUtils(userService.listUserDepartmentResourceByDepartmentIds(deptList));
if(userIds.size() > 0){
//统计未完成
Map<String,Object> params0 = new HashMap<>();
params0.put("isCompleted","0");
params0.put("checkUserIds",userIds);
Integer total0 = taskCheckService.countTaskEnterprise(params0);
count0 +=total0;
//统计已完成
Map<String,Object> params1 = new HashMap<>();
params1.put("isCompleted","1");
params1.put("checkUserIds",userIds);
Integer total1 = taskCheckService.countTaskEnterprise(params1);
count1 +=total1;
}
}
List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> dataParams = new HashMap<>();
dataParams.put("id","0");
dataParams.put("name","未完成任务("+count0+"");
list.add(dataParams);
Map<String,Object> dataParams2 = new HashMap<>();
dataParams2.put("id","1");
dataParams2.put("name","已完成任务("+count1+"");
list.add(dataParams2);
result.setList(list);
return result;
}
@ApiOperation(value = "统计集宁区各科室任务总完成情况", notes = "统计集宁区各科室任务总完成情况接口")
@GetMapping("count-jiniqu-dept-taskcheckdata-total")
public BigDataResult countDepartmentTaskCheckData1Total(){
BigDataResult result = new BigDataResult();
Integer count0 = 0;
Integer count1 = 0;
List<DepartmentSortDTO> departmentSortDTOS = departmentService.listSortByParentId(jinniquId);
for (DepartmentSortDTO departmentSortDTO : departmentSortDTOS) {
//查询部门用户
List<String> deptList =new ArrayList<>();
deptList.add(departmentSortDTO.getDepartmentId());
final List<String> userIds = this.deptUserUtils(userService.listUserDepartmentResourceByDepartmentIds(deptList));
if(userIds.size() > 0){
//统计未完成
Map<String,Object> params0 = new HashMap<>();
params0.put("isCompleted","0");
params0.put("checkUserIds",userIds);
Integer total0 = taskCheckService.countTaskEnterprise(params0);
count0 +=total0;
//统计已完成
Map<String,Object> params1 = new HashMap<>();
params1.put("isCompleted","1");
params1.put("checkUserIds",userIds);
Integer total1 = taskCheckService.countTaskEnterprise(params1);
count1 +=total1;
}
}
List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> dataParams = new HashMap<>();
dataParams.put("id","0");
dataParams.put("name","未完成任务("+count0+"");
list.add(dataParams);
Map<String,Object> dataParams2 = new HashMap<>();
dataParams2.put("id","1");
dataParams2.put("name","已完成任务("+count1+"");
list.add(dataParams2);
result.setList(list);
return result;
}
@ApiOperation(value = "获取生态委科室数据", notes = "获取生态委科室数据接口")
@GetMapping("departmentdata-shengtaiwei")
public BigDataResult departmentData(){
public BigDataResult departmentData1(){
BigDataResult result = new BigDataResult();
List<Map<String, Object>> list = new ArrayList<>();
List<DepartmentSortDTO> departmentSortDTOS = departmentService.listSortByParentId(shengtaiweiId);
@ -235,6 +442,23 @@ public class TaskcheckV2CountController extends AbstractController {
}
@ApiOperation(value = "获取集宁区科室数据", notes = "获取集宁区科室数据接口")
@GetMapping("departmentdata-jiningqu")
public BigDataResult departmentData2(){
BigDataResult result = new BigDataResult();
List<Map<String, Object>> list = new ArrayList<>();
List<DepartmentSortDTO> departmentSortDTOS = departmentService.listSortByParentId(jinniquId);
for (DepartmentSortDTO departmentSortDTO : departmentSortDTOS) {
Map<String,Object> params = new HashMap<>();
params.put("id",departmentSortDTO.getDepartmentId());
params.put("name",departmentSortDTO.getDepartmentName());
list.add(params);
}
result.setList(list);
return result;
}
public List<String> deptUserUtils(List<UserDepartmentResourceBO> list){
List<String> userList = new ArrayList<>();

View File

@ -22,6 +22,14 @@ import java.util.Map;
@Repository
public interface IEnterpriseDao {
/**
* 环保企业 大数据页面
* @param params
* @return
* @throws SearchException
*/
List<Map<String,Object>> listEnterpriseBigData(Map<String, Object> params) throws SearchException;
/**
* 新增企业
*

View File

@ -26,6 +26,14 @@ import java.util.Map;
@Repository("taskCheckV2Dao")
public interface ITaskCheckDao {
/**
* 大数据任务数据列表
* @param params
* @return
* @throws SearchException
*/
List<Map<String,Object>> listBigData(Map<String,Object> params) throws SearchException;
/**
* 统计当月任务数量
* @param params

View File

@ -27,6 +27,15 @@ import java.util.Map;
**/
public interface IEnterpriseService {
/**
* 大数据 环保企业 列表
* @param page
* @return
* @throws SearchException
*/
SuccessResultList<List<Map<String, Object>>> listPageBigData(ListPage page) throws SearchException;
/**
* 新增企业
*

View File

@ -50,6 +50,15 @@ public class EnterpriseServiceImpl extends BaseService implements IEnterpriseSer
@Autowired
private IDataDictionaryService dataDictionaryService;
public SuccessResultList<List<Map<String, Object>>> listPageBigData(ListPage page) throws SearchException {
PageHelper.startPage(page.getPage(), page.getRows());
List<Map<String, Object>> maps = enterpriseDao.listEnterpriseBigData(page.getParams());
PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(maps);
return new SuccessResultList<>(maps, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
public SuccessResult saveEnterprise(EnterpriseVO enterpriseVO) throws Exception {
saveEnterpriseInfo(null, enterpriseVO);

View File

@ -38,6 +38,14 @@ public interface ITaskCheckService {
*/
int CHECK_ITEM_LIST_TYPE_CUSTOM = 2;
/**
* 大数据任务列表
* @param page
* @return
* @throws SearchException
*/
SuccessResultList<List<Map<String,Object>>> listPageTaskBigData(ListPage page) throws SearchException;
/**
* 统计企业任务表
* @param params

View File

@ -82,6 +82,16 @@ public class TaskCheckServiceImpl extends BaseService implements ITaskCheckServi
@Autowired
private IUserService userService;
public SuccessResultList<List<Map<String,Object>>> listPageTaskBigData(ListPage page) throws SearchException {
PageHelper.startPage(page.getPage(), page.getRows());
List<Map<String, Object>> list = taskCheckDao.listBigData(page.getParams());
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
return new SuccessResultList<>(list, pageInfo.getPageNum(), pageInfo.getTotal());
}
public Integer countTheMonthTaskData(Map<String,Object> params) throws SearchException{
return taskCheckDao.countTheMonthTaskData(params);
}

View File

@ -120,3 +120,8 @@ logging:
level:
root: error
com.cm: debug
#大数据统计参数
count-big-data:
jiniqu-dept-id: 0
shengtaiwei-dept-id: 0

View File

@ -799,5 +799,49 @@
enterprise_type = #{enterpriseType}
</select>
<select id="listEnterpriseBigData" parameterType="map" resultType="java.util.HashMap" useCache="true">
SELECT
t1.enterprise_id AS enterpriseId,
t1.name, /*企业名称*/
t1.address, /*地址*/
t1.industry_type AS industryType, /*企业行业*/
t1.industry_type_dictionary_name AS industryTypeDictionaryName,
t1.bussiness_reg_num AS bussinessRegNum, /*组织机构代码*/
t1.summary, /*企业营业范围*/
t1.legal_person AS legalPerson, /*法人*/
t1.legal_phone AS legalPhone,/*法人电话*/
t1.master, /*负责人*/
t1.phone,/*联系电话*/
t2.enterprise_type enterpriseType /*企业类型*/
FROM
gen_enterprise t1
LEFT JOIN gen_enterprise_pollution t2
ON t1.enterprise_id = t2.enterprise_id
WHERE t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND(
t1.name LIKE CONCAT('%', #{keywords}, '%')
OR
t1.bussiness_reg_num LIKE CONCAT('%', #{keywords}, '%')
OR
t1.legal_person LIKE CONCAT('%', #{keywords}, '%')
OR
t1.phone LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="industryType != null and industryType != ''">
AND
t1.industry_type = #{industryType}
</if>
<if test="enterpriseType != null and enterpriseType != ''">
AND
t2.enterprise_type = #{enterpriseType}
</if>
</select>
</mapper>

View File

@ -559,6 +559,57 @@
</if>
</select>
<!--大数据任务列表-->
<select id="listBigData" parameterType="map" resultType="map">
SELECT
t1.task_id AS taskId,
t1.task_name AS taskName,
t1.task_summary AS taskSummary,
t1.task_type AS taskType,
t1.task_type_sub AS taskTypeSub,
t1.check_item_list_type AS checkItemListType,
t1.start_time AS startTime,
t1.end_time AS endTime,
t1.gmt_create AS gmtCreate,
t2.check_user_id AS checkUserId,
t2.is_checked AS isChecked,
t2.is_completed AS isCompleted
FROM gen_task_v2 t1
LEFT JOIN gen_task_enterprise_v2 t2
ON t1.task_id = t2.task_id
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.task_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="taskType != null and taskType != ''">
AND
t1.task_type = #{taskType}
</if>
<if test="isCompleted != null and isCompleted != ''">
AND
t2.is_completed = #{isCompleted}
</if>
<if test="isChecked != null and isChecked != ''">
AND
t2.is_checked = #{isChecked}
</if>
<if test="checkUserIds != null and checkUserIds.size > 0">
AND
t2.check_user_id IN
<foreach collection="checkUserIds" index="index" open="(" separator="," close=")">
#{checkUserIds[${index}]}
</foreach>
</if>
</select>
</mapper>

View File

@ -71,9 +71,9 @@
},
{field: 'enterpriseAddress', width: 400, title: '详细地址', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
var rowData = row[this.field];if(rowData === "1"){return "指定任务"}if(rowData === "2"){return "单随机任务"
}if(rowData === "3"){
return "双随机任务"
}
return rowData;
}