添加联动代码
This commit is contained in:
parent
fe9fac27a4
commit
bde7a82f29
@ -0,0 +1,53 @@
|
||||
package com.cm.inspection.controller.resources.taskcheck.v2;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cm.common.annotation.CheckRequestBodyAnnotation;
|
||||
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.inspection.service.taskcheck.v2.ITaskCheckService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: TaskCheckResourceController
|
||||
* @Description: 检查任务
|
||||
* @Author: WenG
|
||||
* @Date: 2020-04-18 17:17
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Api(tags = ISystemConstant.API_TAGS_RESOURCE_PREFIX + "检查任务接口")
|
||||
@RestController("TaskCheckResourceV2Controller")
|
||||
@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/taskcheck/v2")
|
||||
public class TaskCheckResourceController extends AbstractController {
|
||||
|
||||
@Autowired
|
||||
private ITaskCheckService taskCheckService;
|
||||
|
||||
@ApiOperation(value = "保存污染物任务", notes = "保存污染物任务接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save-pollutant-task")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult savePollutantTask(@RequestBody JSONObject body) throws Exception {
|
||||
JSONArray enterpriseIdJsonArray = body.getJSONArray("enterpriseIds");
|
||||
if (enterpriseIdJsonArray == null || enterpriseIdJsonArray.isEmpty()) {
|
||||
throw new ParamsException("企业参数为空");
|
||||
}
|
||||
List<String> enterpriseIds = enterpriseIdJsonArray.toJavaList(String.class);
|
||||
taskCheckService.savePollutantTask(enterpriseIds);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
package com.cm.inspection.service.taskcheck;
|
||||
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SaveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultData;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO;
|
||||
import com.cm.inspection.pojo.dtos.taskcheck.TaskCheckDTO;
|
||||
@ -136,5 +134,4 @@ public interface ITaskCheckService {
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<GridPersonnelDTO> listGridPersonnelByEnterpriseId(String enterpriseId) throws SearchException;
|
||||
|
||||
}
|
||||
|
@ -9,16 +9,12 @@ import com.cm.common.result.SuccessResultList;
|
||||
import com.cm.inspection.pojo.dtos.enterprise.EnterpriseDTO;
|
||||
import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO;
|
||||
import com.cm.inspection.pojo.dtos.taskcheck.v2.TaskCheckDTO;
|
||||
import com.cm.inspection.pojo.dtos.taskcheck.v2.TaskCheckEnterpriseDTO;
|
||||
import com.cm.inspection.pojo.dtos.taskcheck.v2.TaskCheckReportCheckItemDTO;
|
||||
import com.cm.inspection.pojo.dtos.taskcheck.v2.TaskCheckReportDTO;
|
||||
import com.cm.inspection.pojo.vos.taskcheck.v2.TaskCheckReportVO;
|
||||
import com.cm.inspection.pojo.vos.taskcheck.v2.TaskCheckVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -186,4 +182,13 @@ public interface ITaskCheckService {
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<TaskCheckReportCheckItemDTO> listTaskCheckReport(Integer checkItemListType, String taskEnterpriseId) throws SearchException;
|
||||
|
||||
|
||||
/**
|
||||
* 保存污染物任务
|
||||
*
|
||||
* @param enterpriseIds
|
||||
* @throws Exception
|
||||
*/
|
||||
void savePollutantTask(List<String> enterpriseIds) throws Exception;
|
||||
}
|
||||
|
@ -14,6 +14,9 @@ import com.cm.common.utils.DateUtil;
|
||||
import com.cm.common.utils.HashMapUtil;
|
||||
import com.cm.common.utils.UUIDUtil;
|
||||
import com.cm.inspection.dao.taskcheck.v2.ITaskCheckDao;
|
||||
import com.cm.inspection.enums.task.v2.CheckItemListTypeEnum;
|
||||
import com.cm.inspection.enums.task.v2.TaskTypeEnum;
|
||||
import com.cm.inspection.enums.task.v2.TaskTypeSubEnum;
|
||||
import com.cm.inspection.pojo.dtos.checkitem.CheckItemDTO;
|
||||
import com.cm.inspection.pojo.dtos.enterprise.EnterpriseDTO;
|
||||
import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO;
|
||||
@ -101,7 +104,7 @@ public class TaskCheckServiceImpl extends BaseService implements ITaskCheckServi
|
||||
setSaveInfo(params);
|
||||
taskCheckDao.saveTask(params);
|
||||
// 开启线程执行任务
|
||||
TaskCheckSaveRunnable taskCheckSaveRunnable = new TaskCheckSaveRunnable(securityComponent.getCurrentUser().getUserId(), taskId, taskCheckVO);
|
||||
TaskCheckSaveRunnable taskCheckSaveRunnable = new TaskCheckSaveRunnable(securityComponent.getCurrentUser() == null ? "1" : securityComponent.getCurrentUser().getUserId(), taskId, taskCheckVO);
|
||||
taskCheckSaveRunnable.setDataSourceTransactionManager(dataSourceTransactionManager);
|
||||
taskCheckSaveRunnable.setTaskCheckDao(taskCheckDao);
|
||||
taskCheckSaveRunnable.setCheckItemService(checkItemV2Service);
|
||||
@ -445,6 +448,32 @@ public class TaskCheckServiceImpl extends BaseService implements ITaskCheckServi
|
||||
return taskCheckReportCheckItemDTOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePollutantTask(List<String> enterpriseIds) throws Exception {
|
||||
TaskCheckVO taskCheckVO = new TaskCheckVO();
|
||||
taskCheckVO.setTaskName("污染企业检查任务");
|
||||
taskCheckVO.setTaskSummary("对污染物监控企业进行检查,企业的污染物超标报警已经超过单日最大次数,该任务有系统自动下发");
|
||||
// 指定任务
|
||||
taskCheckVO.setTaskType(TaskTypeEnum.ALLOCATE.getValue());
|
||||
// 不限时任务
|
||||
taskCheckVO.setTaskTypeSub(TaskTypeSubEnum.UN_LIMIT.getValue());
|
||||
// 关联项 + 自定义项
|
||||
taskCheckVO.setCheckItemListType(CheckItemListTypeEnum.DEFAULT.getValue());
|
||||
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("enterpriseIds", enterpriseIds);
|
||||
List<EnterpriseDTO> enterpriseDTOs = enterpriseService.listEnterprise(params);
|
||||
List<TaskCheckVO.EnterpriseVO> enterpriseVOs = new ArrayList<>();
|
||||
taskCheckVO.setEnterprises(enterpriseVOs);
|
||||
for (EnterpriseDTO enterpriseDTO : enterpriseDTOs) {
|
||||
TaskCheckVO.EnterpriseVO enterpriseVO = new TaskCheckVO.EnterpriseVO();
|
||||
enterpriseVO.setEnterpriseId(enterpriseDTO.getEnterpriseId());
|
||||
enterpriseVO.setIndustryId(enterpriseDTO.getIndustryType());
|
||||
enterpriseVOs.add(enterpriseVO);
|
||||
}
|
||||
save(taskCheckVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskCheckDTO.EnterpriseDTO.CheckItemDTO> listCheckItem(Integer checkItemListType, String taskEnterpriseId) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
|
Loading…
Reference in New Issue
Block a user