Commit 4ebd478c authored by suhuiguang's avatar suhuiguang

两个规定 - 一键提交优化

parent 8a68b3d0
......@@ -45,6 +45,11 @@
<version>4.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
</project>
......@@ -39,8 +39,8 @@ public class BasicEntity implements Serializable{
@GeneratedValue(generator = "myIdGeneratorConfig",
strategy = GenerationType.AUTO)
@GenericGenerator(
name = "myIdGeneratorConfig",
strategy = "com.yeejoin.amos.patrol.core.common.request.MyIdGeneratorConfig")
name = "myIdGeneratorConfig",
strategy = "com.yeejoin.amos.patrol.core.common.request.MyIdGeneratorConfig")
@Column(name = "ID",nullable=false,unique=true)
public long getId() {
return id;
......
......@@ -18,7 +18,7 @@ public class Check extends BasicEntity {
private static final long serialVersionUID = 1L;
/**
* 参考地址
......
......@@ -159,7 +159,7 @@ public class PlanTask extends BasicEntity {
/**
* 任务点明细
*/
private List<PlanTaskDetail> taskDetail;
// private List<PlanTaskDetail> taskDetail;
public PlanTask() {
}
......@@ -254,10 +254,10 @@ public class PlanTask extends BasicEntity {
}
@OneToMany(mappedBy = "planTask", fetch= FetchType.EAGER, cascade = {CascadeType.REMOVE,CascadeType.MERGE,CascadeType.PERSIST })
public List<PlanTaskDetail> getTaskDetail() {
return taskDetail;
}
// @OneToMany(mappedBy = "planTask", fetch= FetchType.EAGER, cascade = {CascadeType.REMOVE,CascadeType.MERGE,CascadeType.PERSIST })
// public List<PlanTaskDetail> getTaskDetail() {
// return taskDetail;
// }
public String getInOrder() {
return inOrder;
......@@ -267,9 +267,9 @@ public class PlanTask extends BasicEntity {
this.inOrder = inOrder;
}
public void setTaskDetail(List<PlanTaskDetail> taskDetail) {
this.taskDetail = taskDetail;
}
// public void setTaskDetail(List<PlanTaskDetail> taskDetail) {
// this.taskDetail = taskDetail;
// }
public String getUserId() {
return userId;
......
......@@ -53,7 +53,7 @@ public class PlanTaskDetail extends BasicEntity {
@Column(name="executor_date")
private Date executorDate;
private PlanTask planTask;
// private PlanTask planTask;
/**
* 状态:0 未开始;1 合格;2 不合格;3 漏检
......@@ -97,16 +97,16 @@ public class PlanTaskDetail extends BasicEntity {
this.taskNo = taskNo;
}
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name = "taskNo", referencedColumnName = "id", updatable = false, insertable = false)
public PlanTask getPlanTask() {
return planTask;
}
// @ManyToOne(fetch=FetchType.EAGER)
// @JoinColumn(name = "taskNo", referencedColumnName = "id", updatable = false, insertable = false)
// public PlanTask getPlanTask() {
// return planTask;
// }
public void setPlanTask(PlanTask planTask) {
this.planTask = planTask;
}
// public void setPlanTask(PlanTask planTask) {
// this.planTask = planTask;
// }
public String getStatus() {
......
package com.yeejoin.amos.patrol.utils;
import com.alibaba.ttl.TransmittableThreadLocal;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.context.RequestContextModel;
/**
* @author Administrator
* 主子线程见数据共享
*/
public class UserTransmittableUtils {
private static final TransmittableThreadLocal<RequestContextModel> userLocal = new TransmittableThreadLocal<>();
public static RequestContextModel getUser() {
return userLocal.get();
}
public static void setUser(){
RequestContextModel requestContextModel = new RequestContextModel();
requestContextModel.setAgencyCode(RequestContext.getAgencyCode());
requestContextModel.setAppKey(RequestContext.getAppKey());
requestContextModel.setToken(RequestContext.getToken());
requestContextModel.setProduct(RequestContext.getProduct());
requestContextModel.setExcutedUserId(RequestContext.getExeUserId());
userLocal.set(requestContextModel);
}
public static void clear(){
userLocal.remove();
}
}
......@@ -49,6 +49,7 @@ import com.yeejoin.amos.patrol.dao.entity.*;
import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import com.yeejoin.amos.patrol.mqtt.WebMqttComponent;
import com.yeejoin.amos.patrol.quartz.JobService;
import com.yeejoin.amos.patrol.utils.UserTransmittableUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -230,16 +231,14 @@ public class CheckController extends AbstractBaseController {
@RequestMapping(value = "/saveRecordAll", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public ResponseModel<Object> saveCheckRecordAll(@RequestParam String ids) {
String userId = RequestContext.getExeUserId();
String[] idArr = ids.split(",");
try {
for (String str:idArr
) {
planTaskService.handleAll(str, userId);
}
UserTransmittableUtils.setUser();
planTaskService.handleAllBatch(ids, userId);
} catch (Exception e) {
return ResponseHelperUtil.buildErrorResponse("提交失败:"+e.getMessage());
} finally {
UserTransmittableUtils.clear();
}
return ResponseHelper.buildResponse("提交成功");
}
......
package com.yeejoin.amos.patrol.business.dao.mapper;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface PlanTaskDetailMapper extends BaseMapper {
......@@ -9,4 +11,7 @@ public interface PlanTaskDetailMapper extends BaseMapper {
, @Param(value="executorId") String executorId);
Map findPlanTaskByTaskIdAndPointId(@Param(value="planTaskId") long planTaskId,@Param(value="pointId") long pointId);
List<PlanTaskDetail> findAllByIdInAndStatus(@Param("planTaskIds") List<Long> planTaskNo, @Param("status") String status);
}
package com.yeejoin.amos.patrol.business.dao.mapper;
import com.yeejoin.amos.patrol.business.dto.PlanTaskStaticDto;
import com.yeejoin.amos.patrol.business.dto.StaticTableUpdateDto;
import com.yeejoin.amos.patrol.business.entity.mybatis.CheckChkExListBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PlanTaskPointInputItemBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PointCheckDetailBo;
......@@ -327,4 +328,6 @@ public interface PlanTaskMapper extends BaseMapper {
List<String> getPlanTaskIds(@Param(value = "id") long id);
List<Map<String, String>> selectExcludeItemsByRoutId(long routeId);
void updateStaticTableBatch(@Param("list") List<StaticTableUpdateDto> staticTableUpdateDtos);
}
......@@ -5,6 +5,10 @@ import com.yeejoin.amos.patrol.dao.entity.ESPlanTaskListDto;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ESPlanTaskList extends PagingAndSortingRepository<ESPlanTaskListDto, String> {
List<ESPlanTaskListDto> findAllByPlanTaskIdIn(List<String> planTaskIds);
}
package com.yeejoin.amos.patrol.business.dao.repository;
import com.yeejoin.amos.patrol.dao.entity.ESPlanTaskListDto;
import com.yeejoin.amos.patrol.dao.entity.ESTaskDetailDto;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ESTaskDetail extends PagingAndSortingRepository<ESTaskDetailDto, String> {
List<ESTaskDetailDto> findAllByPlanTaskIdIn(List<String> planTaskIds);
}
......@@ -64,4 +64,11 @@ public interface IPlanTaskDao extends BaseDao<PlanTask, Long> {
@Transactional
@Query(value = "update p_plan_task_detail set is_finish = (?2) where plan_id in (?1)", nativeQuery = true)
void updatePlanTaskDetailFinishStatus(List<Long> collect, int value);
/**
* 查询所有任务
* @param ids
* @return List<PlanTask>
*/
List<PlanTask> findAllByIdIn(List<Long> ids);
}
......@@ -46,4 +46,5 @@ public interface IPlanTaskDetailDao extends BaseDao<PlanTaskDetail, Long> {
@Query(value = "select * FROM p_plan_task_detail WHERE id = ?1 AND status = ?2", nativeQuery = true)
List<PlanTaskDetail> findAllByIdAndStatus(long id, String status);
}
package com.yeejoin.amos.patrol.business.data;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskDetailMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.repository.*;
import com.yeejoin.amos.patrol.business.dto.CheckRecordDataDto;
import com.yeejoin.amos.patrol.business.entity.mybatis.PlanTaskPointInputItemBo;
import com.yeejoin.amos.patrol.common.enums.CheckStatusEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailStatusEnum;
import com.yeejoin.amos.patrol.dao.entity.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.concurrent.BlockingQueue;
/**
* @author Administrator
*/
@Slf4j
public class CheckRecordDataConsumer implements Runnable {
private BlockingQueue<CheckRecordDataDto> blockingQueue;
private ApplicationContext applicationContext;
private IPlanTaskDao iPlanTaskDao;
private ICheckDao iCheckDao;
private ICheckInputDao iCheckInputDao;
private PlanTaskMapper planTaskMapper;
private IPlanTaskDetailDao iPlanTaskDetailDao;
private IInputItemDao inputItemDao;
private Sequence sequence;
private PlanTaskDetailMapper planTaskDetailMapper;
public CheckRecordDataConsumer(BlockingQueue<CheckRecordDataDto> blockingQueue, ApplicationContext applicationContext) {
this.blockingQueue = blockingQueue;
this.applicationContext = applicationContext;
iCheckDao = applicationContext.getBean(ICheckDao.class);
iCheckInputDao = applicationContext.getBean(ICheckInputDao.class);
planTaskMapper = applicationContext.getBean(PlanTaskMapper.class);
iPlanTaskDao = applicationContext.getBean(IPlanTaskDao.class);
iPlanTaskDetailDao = applicationContext.getBean(IPlanTaskDetailDao.class);
inputItemDao = applicationContext.getBean(IInputItemDao.class);
sequence = applicationContext.getBean(Sequence.class);
planTaskDetailMapper = applicationContext.getBean(PlanTaskDetailMapper.class);
}
@Override
public void run() {
while (true) {
try {
CheckRecordDataDto checkRecordDataDto = blockingQueue.take();
iPlanTaskDao.saveAll(checkRecordDataDto.getPlanTasks());
iPlanTaskDetailDao.saveAll(checkRecordDataDto.getPlanTaskDetails());
createCheckRecord(checkRecordDataDto.getPlanTasks(), checkRecordDataDto.getAgencyUserModel());
this.updateTaskDetail(checkRecordDataDto.getPlanTaskDetails(), checkRecordDataDto.getAgencyUserModel());
} catch (Exception e) {
log.error("入库失败", e);
}
}
// 生成巡检记录
}
private void updateTaskDetail(List<PlanTaskDetail> planTaskDetails, AgencyUserModel agencyUserModel) {
planTaskDetails.forEach(planTaskDetail -> {
planTaskDetailMapper.finishTaskDetail(planTaskDetail.getId(), planTaskDetail.getPointId(), planTaskDetail.getTaskNo(), agencyUserModel.getUserId());
});
}
/**
* 创建检查记录
*
* @param planTasks 任务主表
* @param agencyUserModel 用户
*/
public void createCheckRecord(List<PlanTask> planTasks, AgencyUserModel agencyUserModel) {
List<Check> checks = new ArrayList<>();
List<CheckInput> checkInputs = new ArrayList<>();
planTasks.forEach(planTask -> {
List<PlanTaskPointInputItemBo> planTaskPointInputItems = planTaskMapper.getPlanTaskPointInputItemByPlanTaskId(planTask.getId(), PlanTaskDetailStatusEnum.QUALIFIED.getValue());
Map<Long, Check> checkMap = new HashMap<>();
Map<String, String> deptMap = new HashMap<>();
StringBuffer deptName = new StringBuffer();
StringBuffer deptId = new StringBuffer();
StringBuffer userName = new StringBuffer();
if (planTask.getUserDept().indexOf(",") > 0) {
List<String> depts = Arrays.asList(planTask.getUserDept().split(","));
depts.stream().forEach(dept -> {
deptMap.put(dept.split("@")[0], dept.split("@")[2]);
deptName.append(dept.split("@")[2]).append(",");
deptId.append(dept.split("@")[0]).append(",");
});
Set<String> departmentOrgCode = new HashSet<>();
for (String key : deptMap.keySet()) {
departmentOrgCode.add(deptMap.get(key));
}
StringBuffer deptIds = new StringBuffer();
Iterator it = departmentOrgCode.iterator();
while (it.hasNext()) {
deptIds.append(it.next()).append(",");
}
String realNames = "";
if (agencyUserModel != null) {
realNames = agencyUserModel.getRealName().join(",");
userName.append(realNames);
}
}
for (PlanTaskPointInputItemBo arg : planTaskPointInputItems) {
Check check = new Check();
if (checkMap.get(arg.getPointId()) == null) {
check.setOrgCode(arg.getOrgCode());
check.setUserId(planTask.getUserId());
int len = userName.toString().indexOf(",");
if (len != -1) {
check.setUserName(userName.toString());
} else {
check.setUserName(userName.toString());
}
check.setDepName(deptName.toString());
check.setPointId(arg.getPointId());
check.setPointName(arg.getPointName());
check.setRouteName(arg.getRouteName());
check.setPlanName(arg.getPlanName());
check.setErrorClassify(arg.getClassifyName());
check.setUploadTime(new Date());
check.setPlanId(arg.getPlanId());
check.setPlanTaskId(arg.getPlanTaskId());
check.setPlanTaskDetailId(arg.getPlanTaskDetailId());
check.setRouteId(arg.getRouteId());
check.setCheckTime(arg.getEndTime());
check.setIsOk(CheckStatusEnum.QUALIFIED.getCode());
// long checkId = sequence.nextId();
// check.setId(checkId);
// checks.add(check);
iCheckDao.saveAndFlush(check);
checkMap.put(arg.getPointId(), check);
} else {
check = checkMap.get(arg.getPointId());
}
if (arg.getInputItemId() != null) {
InputItem inputItem = inputItemDao.findById(arg.getInputItemId()).get();
CheckInput checkInput = new CheckInput();
if (XJConstant.INPUT_ITEM_SELECT.equals(inputItem.getItemType())) {
checkInput = paraseSelect(checkInput, inputItem.getDataJson(), inputItem.getIsScore());
} else if (XJConstant.INPUT_ITEM_NUMBER.equals(inputItem.getItemType())) {
checkInput.setInputValue(inputItem.getDefaultValue());
} else if (XJConstant.INPUT_ITEM_TEXT.equals(inputItem.getItemType())) {
checkInput.setInputValue(inputItem.getDefaultValue());
}
checkInput.setCheckId(check.getId());
checkInput.setInputId(arg.getInputItemId());
checkInput.setIsOk(CheckStatusEnum.QUALIFIED.getCode());
checkInput.setRoutePointItemId(arg.getRoutePointItemId());
checkInput.setOrderNo(arg.getOrderNo());
checkInput.setOrgCode(arg.getOrgCode());
checkInput.setInputName(arg.getInputName());
checkInput.setPointClassifyId(arg.getClassifyId());
checkInput.setPointClassifyName(arg.getClassifyName());
iCheckInputDao.saveAndFlush(checkInput);
// checkInputs.add(checkInput);
}
}
});
// iCheckDao.saveAll(checks);
// iCheckInputDao.saveAll(checkInputs);
}
private CheckInput paraseSelect(CheckInput checkInput, String json, String isScore) {
JSONArray jsonArray = JSONArray.parseArray(json);
if (!ObjectUtils.isEmpty(jsonArray)) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String validateName = jsonObject.getString("name");
String validateIsOk = jsonObject.getString("isOk");
if (validateIsOk.equals("是")) {
checkInput.setInputValue(validateName);
}
}
}
return checkInput;
}
}
package com.yeejoin.amos.patrol.business.dto;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail;
import lombok.Data;
import java.util.List;
/**
* @author Administrator
*/
@Data
public class CheckRecordDataDto {
List<PlanTask> planTasks;
List<PlanTaskDetail> planTaskDetails;
AgencyUserModel agencyUserModel;
}
package com.yeejoin.amos.patrol.business.dto;
import lombok.Data;
/**
* @author Administrator
*/
@Data
public class StaticTableUpdateDto {
String table;
Integer riskEnd;
Integer noRiskEnd;
String orgCode;
String checkTime;
}
......@@ -209,4 +209,6 @@ public interface IPlanTaskService {
Map<String,Object> queryPatrolInfoList(String bizOrgCode, Date startDate, Date endDate);
void backPatrolInfo();
void handleAllBatch(String ids, String userId);
}
package com.yeejoin.amos.patrol.config;
import com.alibaba.ttl.threadpool.TtlExecutors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
......@@ -59,6 +60,7 @@ public class ExecutorConfig {
executor.initialize();
//等待所有任务结束后再关闭线程池
executor.setWaitForTasksToCompleteOnShutdown(true);
return executor;
return TtlExecutors.getTtlExecutor(executor);
}
}
......@@ -6,31 +6,55 @@ import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.MsgSubscribeMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckDao;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckInputDao;
import com.yeejoin.amos.patrol.business.dao.repository.IInputItemDao;
import com.yeejoin.amos.patrol.business.dao.repository.IMsgDao;
import com.yeejoin.amos.patrol.business.data.CheckRecordDataConsumer;
import com.yeejoin.amos.patrol.business.dto.CheckRecordDataDto;
import com.yeejoin.amos.patrol.business.entity.mybatis.MsgSubscribeBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PlanTaskPointInputItemBo;
import com.yeejoin.amos.patrol.business.param.PushMsgParam;
import com.yeejoin.amos.patrol.business.service.intfc.IMessageService;
import com.yeejoin.amos.patrol.business.service.intfc.ISafety3DDataSendService;
import com.yeejoin.amos.patrol.business.util.Toke;
import com.yeejoin.amos.patrol.common.enums.CheckStatusEnum;
import com.yeejoin.amos.patrol.common.enums.JPushTypeEnum;
import com.yeejoin.amos.patrol.common.enums.MsgSubscribeEnum;
import com.yeejoin.amos.patrol.dao.entity.Msg;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailStatusEnum;
import com.yeejoin.amos.patrol.dao.entity.*;
import com.yeejoin.amos.patrol.email.IEmailService;
import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import com.yeejoin.amos.patrol.utils.UserTransmittableUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.context.RequestContextModel;
import javax.annotation.PostConstruct;
import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
/**
* 异步执行任务
......@@ -38,7 +62,7 @@ import java.util.concurrent.Future;
*
*/
@Component
public class AsyncTask {
public class AsyncTask implements ApplicationContextAware {
private final Logger log = LoggerFactory.getLogger(AsyncTask.class);
@Autowired
......@@ -63,10 +87,19 @@ public class AsyncTask {
@Autowired
AmosRequestContext amosRequestContext;
@Autowired
Executor asyncServiceExecutor;
ApplicationContext applicationContext;
private static final String TOKE = "TOKE";
private static final String TAB = "\r\n";
@Autowired
IInputItemDao inputItemDao;
private final BlockingQueue<CheckRecordDataDto> blockingQueue = new LinkedBlockingDeque<>();
/**
......@@ -294,4 +327,37 @@ public class AsyncTask {
return afterFilterUserIds;
}
private void setRequestContextByLocal(RequestContextModel user) {
RequestContext.setToken(user.getToken());
RequestContext.setProduct(user.getProduct());
RequestContext.setAppKey(user.getAppKey());
UserTransmittableUtils.clear();
}
@Async("asyncServiceExecutor")
public void saveCheckRecordAsync(List<PlanTask> planTasks, List<PlanTaskDetail> planTaskDetails, String userId) {
this.setRequestContextByLocal(UserTransmittableUtils.getUser());
FeignClientResult<AgencyUserModel> agencyUserModel = Privilege.agencyUserClient.queryByUserId(userId);
CheckRecordDataDto dataDto = new CheckRecordDataDto();
dataDto.setPlanTasks(planTasks);
dataDto.setPlanTaskDetails(planTaskDetails);
dataDto.setAgencyUserModel(agencyUserModel.getResult());
blockingQueue.add(dataDto);
UserTransmittableUtils.clear();
}
@PostConstruct
public void init(){
CheckRecordDataConsumer consumer = new CheckRecordDataConsumer(blockingQueue,applicationContext);
for(int i = 0; i < 10; i++){
asyncServiceExecutor.execute(consumer);
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
package com.yeejoin.amos.patrol.quartz;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.patrol.business.entity.mybatis.PointCheckDetailBo;
import com.yeejoin.amos.patrol.business.param.CheckRecordParam;
import com.yeejoin.amos.patrol.dao.entity.Msg;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.dao.entity.Task;
import java.util.Date;
import java.util.List;
public interface IJobService {
......@@ -67,5 +69,7 @@ public interface IJobService {
public void createCheckRecord(PlanTask planTask,String userId);
public JSONObject getCheckInput(Long routeId, Long pointId, String type, CheckRecordParam requestParam);
JSONObject getCheckInput(List<PointCheckDetailBo> pointInputs, String type, CheckRecordParam requestParam);
}
......@@ -589,6 +589,73 @@ public class JobService implements IJobService {
return appResponeMap;
}
@Override
public JSONObject getCheckInput(List<PointCheckDetailBo> pointInputs, String type, CheckRecordParam requestParam) {
List<AppCheckInputRespone> appCheckInputResponeList = new ArrayList<AppCheckInputRespone>();
JSONObject appResponeMap = new JSONObject();
pointInputs.forEach(action -> {
AppCheckInputRespone input = new AppCheckInputRespone();
if ("save".equals(type)) {
input.setInputValue(null);
input.setPointInputImgUrls(new ArrayList<>());
} else {
InputItem inputItem = inputItemDao.findById(action.getInputItemId()).get();
CheckInput checkInput = new CheckInput();
if (!ValidationUtil.isEmpty(requestParam)) {
List<CheckInputParam> checkItems = requestParam.getCheckItems();
for (CheckInputParam x : checkItems) {
if (x.getInputItemId() == action.getInputItemId()) {
input.setInputValue(x.getInputValue());
break;
}
}
} else {
if (XJConstant.INPUT_ITEM_SELECT.equals(inputItem.getItemType())) {
checkInput = paraseSelect(checkInput, inputItem.getDataJson(), inputItem.getIsScore());
input = JSONObject.parseObject(toJSONString(checkInput),
AppCheckInputRespone.class);
} else if (XJConstant.INPUT_ITEM_NUMBER.equals(inputItem.getItemType())) {
input.setInputValue(inputItem.getDefaultValue());
} else if (XJConstant.INPUT_ITEM_TEXT.equals(inputItem.getItemType())) {
input.setInputValue(inputItem.getDefaultValue());
}
}
if (!ObjectUtils.isEmpty(requestParam)) {
List<CheckInputParam> checkItems = requestParam.getCheckItems();
for (CheckInputParam x : checkItems) {
if (x.getInputItemId() == action.getInputItemId()) {
if (x.getCheckInputImg() != null && x.getCheckInputImg().size() > 0) {
input.setPointInputImgUrls(x.getCheckInputImg());
}else {
input.setPointInputImgUrls(new ArrayList<>());
}
}
}
}
}
input.setInputName(action.getInputName());
input.setCheckInputId(action.getCheckInputId());
input.setDefaultValue(action.getDefaultValue());
input.setDataJson(action.getDataJson());
input.setIsMultiline(action.getIsMultiline());
input.setIsMust(action.getIsMust());
input.setItemType(action.getItemType());
input.setOrderNo(action.getOrderNo());
input.setPictureJson(action.getPictureJson());
input.setClassifyId(action.getClassifyId());
input.setClassifyName(action.getClassifyName());
appCheckInputResponeList.add(input);
});
appResponeMap.put("items", appCheckInputResponeList);
return appResponeMap;
}
/**
......@@ -599,13 +666,11 @@ public class JobService implements IJobService {
public void createCheckRecord(PlanTask planTask,String userId) {
List<PlanTaskPointInputItemBo> planTaskPointInputItems = planTaskMapper.getPlanTaskPointInputItemByPlanTaskId(planTask.getId(), PlanTaskDetailStatusEnum.QUALIFIED.getValue());
Map<Long, Check> checkMap = new HashMap<>();
Set<Long> checkIds = new HashSet<Long>();
Map<String, String> deptMap = new HashMap<>();
StringBuffer deptName = new StringBuffer();
StringBuffer deptId = new StringBuffer();
StringBuffer userName = new StringBuffer();
if (planTask.getUserDept().indexOf(",") > 0) {
List<String> ids = Arrays.asList(planTask.getUserId().split(","));
List<String> depts = Arrays.asList(planTask.getUserDept().split(","));
depts.stream().forEach(dept -> {
deptMap.put(dept.split("@")[0], dept.split("@")[2]);
......@@ -631,9 +696,6 @@ public class JobService implements IJobService {
userName.append(realNames);
}
}
List<Check> checkList = new ArrayList<>();
List<Long> checkInputIdList = new ArrayList<>();
for (PlanTaskPointInputItemBo arg : planTaskPointInputItems) {
Check check = new Check();
if (checkMap.get(arg.getPointId()) == null) {
......@@ -667,9 +729,7 @@ public class JobService implements IJobService {
e.printStackTrace();
}
iCheckDao.flush();
checkList.add(check);
checkMap.put(arg.getPointId(), check);
checkIds.add(check.getId());
} else {
check = checkMap.get(arg.getPointId());
}
......@@ -695,8 +755,7 @@ public class JobService implements IJobService {
checkInput.setInputName(arg.getInputName());
checkInput.setPointClassifyId(arg.getClassifyId());
checkInput.setPointClassifyName(arg.getClassifyName());
CheckInput checkInput1 = iCheckInputDao.saveAndFlush(checkInput);
checkInputIdList.add(checkInput1.getId());
iCheckInputDao.saveAndFlush(checkInput);
}
}
......
......@@ -740,17 +740,23 @@
pii.default_value defaultValue,
pii.picture_json pictureJson,
pii.is_multiline isMultiline,
pii.order_no orderNo
pii.order_no orderNo,
prp.point_id,
prp.route_id
FROM
p_route_point_item prpi
LEFT JOIN p_point_classify ppc ON ppc.id = prpi.point_classify_id
LEFT JOIN p_route_point prp ON prp.id = prpi.route_point_id
LEFT JOIN p_point_inputitem ppii ON ppii.id = prpi.point_input_item_id
LEFT JOIN p_input_item pii ON pii.id = ppii.input_item_id
WHERE prp.point_id = #{pointId}
AND prp.route_id =#{routeId}
<where>
1=1
<if test="pointId !=null and pointId !=''">and prp.point_id = #{pointId}</if>
<if test="routeId !=null and routeId !=''">and prp.route_id =#{routeId}</if>
AND (FIND_IN_SET(prpi.point_input_item_id,prp.exclude_items) is null or FIND_IN_SET(prpi.point_input_item_id,prp.exclude_items) <![CDATA[<=]]> 0)
</where>
<!--AND NOT FIND_IN_SET(prpi.point_input_item_id,prp.exclude_items)-->
AND (FIND_IN_SET(prpi.point_input_item_id,prp.exclude_items) is null or FIND_IN_SET(prpi.point_input_item_id,prp.exclude_items) <![CDATA[<=]]> 0)
ORDER BY
prpi.order_no
......@@ -1882,4 +1888,10 @@
<select id="selectExcludeItemsByRoutId" resultType="java.util.Map">
select point_id,exclude_items from p_route_point where route_id = #{routeId}
</select>
<update id="updateStaticTableBatch">
<foreach collection="list" item="item" separator=";">
update ${item.table} set not_start = not_start - 1,risk_end = risk_end + #{item.riskEnd},no_risk_end = no_risk_end + #{item.noRiskEnd}
where org_code = #{item.orgCode} AND check_time = #{item.checkTime}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -18,4 +18,16 @@
where pp.id = #{pointId}
and pt.id = #{planTaskId}
</select>
<select id="findAllByIdInAndStatus" resultType="com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail">
select
pptd.*,
pp.name,
pp.point_no
from
"p_plan_task_detail" pptd LEFT JOIN p_point pp ON pp."id"=pptd.point_id
where
pptd.task_no in <foreach collection="planTaskIds" item="planTaskId" index="index" open="(" separator="," close=")" >#{planTaskId}</foreach>
and pptd.status = #{status}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment