Commit ac8d5ed5 authored by litengwei's avatar litengwei

双规小程序接口

parent 6ec982ef
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
public class AppPointCheckRespone { public class AppPointCheckRespone {
private long pointId; private long pointId;
...@@ -13,16 +14,48 @@ public class AppPointCheckRespone { ...@@ -13,16 +14,48 @@ public class AppPointCheckRespone {
private String pointNo; private String pointNo;
public String getTaskStatus() {
return taskStatus;
}
public void setTaskStatus(String taskStatus) {
this.taskStatus = taskStatus;
}
private Date checkTime;
private Date beginTime;
private Date endTime;
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
private String pointStatus; private String pointStatus;
private String planName; private String planName;
private String taskStatus;
private String departmentName; private String departmentName;
private String username; private String username;
private Date checkTime;
private String strCheckTime; private String strCheckTime;
private long checkId; private long checkId;
......
...@@ -67,11 +67,25 @@ public class PlanTask extends BasicEntity { ...@@ -67,11 +67,25 @@ public class PlanTask extends BasicEntity {
*/ */
@Column(name="route_id") @Column(name="route_id")
private long routeId; private long routeId;
/** /**
* 状态:0-有效;1-无效 * 状态:0-有效;1-无效
*/ */
private int status; private int status;
/**
* 状态:0-有效;1-无效
*/
@Column(name="risk_status")
private int riskStatus;
public int getRiskStatus() {
return riskStatus;
}
public void setRiskStatus(int riskStatus) {
this.riskStatus = riskStatus;
}
/** /**
* 可执行人,一个或多个,多个用,隔开 * 可执行人,一个或多个,多个用,隔开
*/ */
......
...@@ -368,6 +368,13 @@ public class XJConstant { ...@@ -368,6 +368,13 @@ public class XJConstant {
public static final String YES = "是"; public static final String YES = "是";
public static final String NOT = "否"; public static final String NOT = "否";
public static final String RISK = "有风险";
public static final String NORISK = "无风险";
public static final String NOUSE = "不涉及";
public static final int RISK_NUM = 1;
public static final int NORISK_NUM = 2;
public static final String INPUT_ITEM_OK_SCORE = "OkScore"; public static final String INPUT_ITEM_OK_SCORE = "OkScore";
public static final String INPUT_ITEM_NOT_SCORE = "NoScore"; public static final String INPUT_ITEM_NOT_SCORE = "NoScore";
......
...@@ -48,6 +48,8 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -48,6 +48,8 @@ import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.*; import java.util.*;
...@@ -679,8 +681,8 @@ public class InputItemController extends AbstractBaseController { ...@@ -679,8 +681,8 @@ public class InputItemController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取检查分类", notes = "获取检查分类") @ApiOperation(value = "获取检查分类", notes = "获取检查分类")
@GetMapping(value = "/checkClassify") @GetMapping(value = "/checkClassify")
public CommonResponse getCheckClassify() { public ResponseModel<Object> getCheckClassify() {
return CommonResponseUtil.success(inputItemService.getCheckClassify(getToken(), getProduct(), getAppKey(), DictTypeEnum.CHECK_CLASSIFY.getCode())); return ResponseHelper.buildResponse(inputItemService.getCheckClassify(getToken(), getProduct(), getAppKey(), DictTypeEnum.CHECK_CLASSIFY.getCode()));
} }
/*******新增接口************/ /*******新增接口************/
......
...@@ -47,6 +47,8 @@ public interface CheckMapper extends BaseMapper { ...@@ -47,6 +47,8 @@ public interface CheckMapper extends BaseMapper {
*/ */
List<Map<String,Object>> calendarData(CheckRecordParam param); List<Map<String,Object>> calendarData(CheckRecordParam param);
List<Map<String,Object>> planCount(String checkTime, String orgCode,String type,String userId);
List<Map<String, Object>> queryRecordByPointId(HashMap<String, Object> req); List<Map<String, Object>> queryRecordByPointId(HashMap<String, Object> req);
Map<String, Object> queryCheckById(@Param(value="checkId") int checkId); Map<String, Object> queryCheckById(@Param(value="checkId") int checkId);
......
package com.yeejoin.amos.patrol.business.dao.repository; package com.yeejoin.amos.patrol.business.dao.repository;
import com.yeejoin.amos.patrol.dao.entity.Plan; import com.yeejoin.amos.patrol.dao.entity.Plan;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Optional;
@Repository("planDao") @Repository("planDao")
public interface IPlanDao extends BaseDao<Plan, Long> { public interface IPlanDao extends BaseDao<Plan, Long> {
...@@ -36,4 +38,7 @@ public interface IPlanDao extends BaseDao<Plan, Long> { ...@@ -36,4 +38,7 @@ public interface IPlanDao extends BaseDao<Plan, Long> {
List<Plan> findByOriginalIds(List<String> originalIds); List<Plan> findByOriginalIds(List<String> originalIds);
@Transactional
@Query(value = "select * from p_plan where id = (?1) and is_delete = 0", nativeQuery = true)
Optional<Plan> findById(Long id);
} }
\ No newline at end of file
...@@ -9,8 +9,10 @@ public class PointCheckDetailBo { ...@@ -9,8 +9,10 @@ public class PointCheckDetailBo {
private String pointName; private String pointName;
private String pointNo; private String pointNo;
private String pointStatus; private String pointStatus;
private String taskStatus;
private String planName; private String planName;
...@@ -19,8 +21,28 @@ public class PointCheckDetailBo { ...@@ -19,8 +21,28 @@ public class PointCheckDetailBo {
private String departmentName; private String departmentName;
private String username; private String username;
private Date checkTime; private Date checkTime;
private Date beginTime;
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
private Date endTime;
private long checkId; private long checkId;
...@@ -60,6 +82,14 @@ public class PointCheckDetailBo { ...@@ -60,6 +82,14 @@ public class PointCheckDetailBo {
private String planTaskId; private String planTaskId;
public String getTaskStatus() {
return taskStatus;
}
public void setTaskStatus(String taskStatus) {
this.taskStatus = taskStatus;
}
public String getPlanTaskId() { public String getPlanTaskId() {
return planTaskId; return planTaskId;
} }
......
...@@ -313,6 +313,9 @@ public class CheckServiceImpl implements ICheckService { ...@@ -313,6 +313,9 @@ public class CheckServiceImpl implements ICheckService {
} else if (XJConstant.INPUT_ITEM_TEXT.equals(inputItem.getItemType())) { } else if (XJConstant.INPUT_ITEM_TEXT.equals(inputItem.getItemType())) {
checkInput = paraseText(checkInput, inputItem.getDataJson(), item, inputItem.getIsScore()); checkInput = paraseText(checkInput, inputItem.getDataJson(), item, inputItem.getIsScore());
} }
if(XJConstant.RISK.equals(checkInput.getInputValue())) {
planTask.setRiskStatus(XJConstant.RISK_NUM);
}
if (XJConstant.NO.equals(checkInput.getIsOk())) { if (XJConstant.NO.equals(checkInput.getIsOk())) {
String classifyName = pointClassifyName != null ? pointClassifyName + "-" : ""; String classifyName = pointClassifyName != null ? pointClassifyName + "-" : "";
error += (classifyName + inputItem.getName() + "=" + (ObjectUtils.isEmpty(item.getInputValue()) ? "" : item.getInputValue()) + ";"); error += (classifyName + inputItem.getName() + "=" + (ObjectUtils.isEmpty(item.getInputValue()) ? "" : item.getInputValue()) + ";");
...@@ -345,6 +348,11 @@ public class CheckServiceImpl implements ICheckService { ...@@ -345,6 +348,11 @@ public class CheckServiceImpl implements ICheckService {
equipmentInputItemRoList.add(equipmentInputItemRo); equipmentInputItemRoList.add(equipmentInputItemRo);
} }
} }
if(ObjectUtils.isEmpty(planTask.getRiskStatus())) {
planTask.setRiskStatus(XJConstant.NORISK_NUM);
}
planTaskDao.saveAndFlush(planTask);
if (!ObjectUtils.isEmpty(error) && error.endsWith(";")) { if (!ObjectUtils.isEmpty(error) && error.endsWith(";")) {
error.substring(0, error.length() - 1); error.substring(0, error.length() - 1);
check.setIsOk(CheckStatusEnum.UNQUALIFIED.getCode()); check.setIsOk(CheckStatusEnum.UNQUALIFIED.getCode());
...@@ -659,52 +667,52 @@ public class CheckServiceImpl implements ICheckService { ...@@ -659,52 +667,52 @@ public class CheckServiceImpl implements ICheckService {
checkInputList.add(checkInput); checkInputList.add(checkInput);
} }
//规则请求结果 //规则请求结果
checkInputList.forEach(checkInput -> { // checkInputList.forEach(checkInput -> {
InputItem inputItem = inputItemDao.findById(checkInput.getInputId()).get(); // InputItem inputItem = inputItemDao.findById(checkInput.getInputId()).get();
for (int i = 0; i < equipmentInputItemRoList.size(); i++) { // for (int i = 0; i < equipmentInputItemRoList.size(); i++) {
if (inputItem.getItemNo().equals(equipmentInputItemRoList.get(i).getCheckContent())) { // if (inputItem.getItemNo().equals(equipmentInputItemRoList.get(i).getCheckContent())) {
equipmentInputItemRoList.get(i).setCheckInputId(Long.valueOf(checkInput.getId()).toString()); // equipmentInputItemRoList.get(i).setCheckInputId(Long.valueOf(checkInput.getId()).toString());
} // }
} // }
}); // });
equipmentHandlerService.getRulesCheckResult(equipmentInputItemRoList, token); // equipmentHandlerService.getRulesCheckResult(equipmentInputItemRoList, token);
if (imgList.size() > 0) { if (imgList.size() > 0) {
checkService.saveCheckImg(imgList); checkService.saveCheckImg(imgList);
} }
if (check.getPlanTaskId() > 0) { if (check.getPlanTaskId() > 0) {
planTaskDetailMapper.finishTaskDetail(Long.parseLong(detail.get("planTaskDetailId").toString()), requestParam.getPointId(), requestParam.getPlanTaskId(), requestParam.getUserId()); // planTaskDetailMapper.finishTaskDetail(Long.parseLong(detail.get("planTaskDetailId").toString()), requestParam.getPointId(), requestParam.getPlanTaskId(), requestParam.getUserId());
} else { } else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
planTaskMapper.reformStatistics(requestParam.getUserId(), sdf.format(new Date()), requestParam.getOrgCode()); planTaskMapper.reformStatistics(requestParam.getUserId(), sdf.format(new Date()), requestParam.getOrgCode());
} }
if(check.getPlanId()!=0) { // if(check.getPlanId()!=0) {
// 任务完成、同步修改待办任务状态 // // 任务完成、同步修改待办任务状态
Plan plan = planService.queryPlanById(check.getPlanId()); // Plan plan = planService.queryPlanById(check.getPlanId());
if (!ObjectUtils.isEmpty(plan) && plan.getIsSingleExecution()) { // if (!ObjectUtils.isEmpty(plan) && plan.getIsSingleExecution()) {
// 单人执行 // // 单人执行
updateTaskStatus(plan.getId(), requestParam.getUserId()); // updateTaskStatus(plan.getId(), requestParam.getUserId());
} else { // } else {
// 多人执行 // // 多人执行
updateTaskStatus(plan.getId(), null); // updateTaskStatus(plan.getId(), null);
} // }
} // }
CheckDto checkDto= new CheckDto(check.getId(), unqualifiedcheckItemList); CheckDto checkDto= new CheckDto(check.getId(), unqualifiedcheckItemList);
// 巡检站端与中心级数据同步 // 巡检站端与中心级数据同步
Check finalCheck = check; // Check finalCheck = check;
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { // TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override // @Override
public void afterCommit() { // public void afterCommit() {
// 事物提交后业务逻辑 // // 事物提交后业务逻辑
patrolDataSyncService.checkDataSync(finalCheck); // patrolDataSyncService.checkDataSync(finalCheck);
patrolDataSyncService.checkInputDataSync(checkInputList); // patrolDataSyncService.checkInputDataSync(checkInputList);
//
Map<String, Object> map = new HashMap<>(); // Map<String, Object> map = new HashMap<>();
map.put("idList", checkInputList.stream().map(CheckInput::getId).collect(Collectors.toList())); // map.put("idList", checkInputList.stream().map(CheckInput::getId).collect(Collectors.toList()));
List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map); // List<CheckInputSyncBo> checkInputSyncBoList = checkInputMapper.getCheckInputSyncBoList(map);
patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList); // patrolDataSyncService.checkInputBoDataSync(checkInputSyncBoList);
} // }
}); // });
return checkDto; return checkDto;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -834,10 +842,10 @@ public class CheckServiceImpl implements ICheckService { ...@@ -834,10 +842,10 @@ public class CheckServiceImpl implements ICheckService {
if (validateName.equals(item.getInputValue())) { if (validateName.equals(item.getInputValue())) {
if (validateIsOk.equals(XJConstant.YES) || validateIsOk.equals(XJConstant.OK)) { if (validateIsOk.equals(XJConstant.YES) || validateIsOk.equals(XJConstant.OK)) {
checkInput.setIsOk(XJConstant.OK); checkInput.setIsOk(XJConstant.OK);
checkInput.setInputValue(XJConstant.YES); checkInput.setInputValue(item.getInputValue());
} else { } else {
checkInput.setIsOk(XJConstant.NO); checkInput.setIsOk(XJConstant.NO);
checkInput.setInputValue(XJConstant.NOT); checkInput.setInputValue(item.getInputValue());
} }
score = OkScore; score = OkScore;
break; break;
...@@ -1229,6 +1237,14 @@ public class CheckServiceImpl implements ICheckService { ...@@ -1229,6 +1237,14 @@ public class CheckServiceImpl implements ICheckService {
} }
@Override @Override
public Map<String, Object> checkCalendarNew(String checkTime, String orgCode,String type,String userId) {
Map<String, Object> result = new HashMap<>();
List<Map<String, Object>> list = checkMapper.planCount(checkTime, orgCode, type, userId);
result.put("calendarData", list);
return result;
}
@Override
public List<CheckInfoVo> getCheckInfoList(String toke,String product,String appKey,CheckInfoPageParam param) { public List<CheckInfoVo> getCheckInfoList(String toke,String product,String appKey,CheckInfoPageParam param) {
List<CheckInfoVo> list= checkMapper.getCheckInfo(param); List<CheckInfoVo> list= checkMapper.getCheckInfo(param);
......
...@@ -34,6 +34,8 @@ import com.yeejoin.amos.patrol.business.util.Toke; ...@@ -34,6 +34,8 @@ import com.yeejoin.amos.patrol.business.util.Toke;
import com.yeejoin.amos.patrol.business.util.WordTemplateUtils; import com.yeejoin.amos.patrol.business.util.WordTemplateUtils;
import com.yeejoin.amos.patrol.business.vo.*; import com.yeejoin.amos.patrol.business.vo.*;
import com.yeejoin.amos.patrol.common.enums.NotifyBusinessTypeEum; import com.yeejoin.amos.patrol.common.enums.NotifyBusinessTypeEum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailIsFinishEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailStatusEnum;
import com.yeejoin.amos.patrol.core.common.request.CommonPageable; import com.yeejoin.amos.patrol.core.common.request.CommonPageable;
import com.yeejoin.amos.patrol.core.common.response.AppCheckInputRespone; import com.yeejoin.amos.patrol.core.common.response.AppCheckInputRespone;
import com.yeejoin.amos.patrol.core.common.response.AppPointCheckRespone; import com.yeejoin.amos.patrol.core.common.response.AppPointCheckRespone;
...@@ -95,6 +97,8 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -95,6 +97,8 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Autowired @Autowired
IPlanDao iplanDao; IPlanDao iplanDao;
@Autowired @Autowired
IPlanTaskDetailDao iPlanTaskDetailDao;
@Autowired
private ICheckDao checkDao; private ICheckDao checkDao;
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
...@@ -1131,6 +1135,32 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -1131,6 +1135,32 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
} }
@Override @Override
public void handleAll(String id) {
Optional<Plan> byId = iplanDao.findById(Long.valueOf(id));
Plan plan = byId.get();
List<PlanTask> planTaskList = iplanTaskDao.findByPlanId(plan.getId());
for (PlanTask p : planTaskList
) {
p.setFinishStatus(XJConstant.TASK_STATUS_FINISH);
p.setRiskStatus(XJConstant.NORISK_NUM);
iplanTaskDao.saveAndFlush(p);
List<PlanTaskDetail> planTaskDetails = iPlanTaskDetailDao.findAllByTaskNoAndStatus(p.getId(), PlanTaskDetailStatusEnum.NOTSTARTED.getValue());
if (!planTaskDetails.isEmpty()) {
planTaskDetails.stream().forEach(action -> {
action.setIsFinish(PlanTaskDetailIsFinishEnum.FINISHED.getValue());
action.setStatus(PlanTaskDetailStatusEnum.QUALIFIED.getValue());
iPlanTaskDetailDao.saveAndFlush(action);
});
}
// 生成巡检记录
jobService.createCheckRecord(p);
}
}
@Override
public List getPlanTaskInfo(HashMap<String, Object> param) { public List getPlanTaskInfo(HashMap<String, Object> param) {
return planTaskMapper.getPlanTaskByPointId(param); return planTaskMapper.getPlanTaskByPointId(param);
} }
...@@ -1422,62 +1452,47 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -1422,62 +1452,47 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Override @Override
public AppPointCheckRespone queryPointPlanTaskDetail(String toke, String product, String appKey, Long planTaskId, Long pointId) { public AppPointCheckRespone queryPointPlanTaskDetail(String toke, String product, String appKey, Long planTaskId, Long pointId) {
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone(); AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
Check check = checkDao.findByPlanTaskIdAndPointId(planTaskId, pointId); Check check = checkDao.findByPlanTaskIdAndPointId(planTaskId, pointId);
if (check != null) {
pointCheckRespone = checkService.queryCheckPointDetail(toke, product, appKey, check.getId()); PointCheckDetailBo planPointInfo = planTaskMapper.getPointPlanTaskInfo(planTaskId, pointId);
} else { pointCheckRespone.setTaskStatus(planPointInfo.getTaskStatus());
PointCheckDetailBo planPointInfo = planTaskMapper.getPointPlanTaskInfo(planTaskId, pointId); if (planPointInfo != null) {
pointCheckRespone.setPointId(pointId);
if (planPointInfo != null) { pointCheckRespone.setPointName(planPointInfo.getPointName());
List<String> userIds = Arrays.asList(planPointInfo.getUsername().split(",")); pointCheckRespone.setPointNo(planPointInfo.getPointNo());
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey, planPointInfo.getUsername()); pointCheckRespone.setPointStatus("0");
Map<String, String> userModelMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2)); pointCheckRespone.setPlanName(planPointInfo.getPlanName());
if (userModelMap != null) { List<PointCheckDetailBo> pointInputs = planTaskMapper.getPointInputByRouteIdAndPointId(planPointInfo.getRouteId(), planPointInfo.getPointId());
List<String> userNameList = new ArrayList<>(); JSONObject appResponeMap = new JSONObject();
for (String userId : userIds) { pointInputs.forEach(action -> {
userNameList.add(userModelMap.get(userId)); AppCheckInputRespone input = new AppCheckInputRespone();
input.setInputName(action.getInputName());
input.setCheckInputId(action.getCheckInputId());
input.setDataJson(action.getDataJson());
input.setIsMultiline(action.getIsMultiline());
input.setIsMust(action.getIsMust());
for (CheckInput ck :check.getCheckInput()
) {
if(ck.getInputId().toString().equals(String.valueOf(action.getCheckInputId()))) {
input.setInputValue(ck.getInputValue());
} }
userNameList.remove("");
userNameList.remove(null);
pointCheckRespone.setUsername(Joiner.on(",").join(userNameList));
} }
DepartmentModel departmentBo = remoteSecurityService.getDepartmentByDeptId(toke, product, appKey, planPointInfo.getUsername()); input.setItemType(action.getItemType());
if (departmentBo != null) { input.setOrderNo(action.getOrderNo());
pointCheckRespone.setDepartmentName(departmentBo.getDepartmentName()); input.setPictureJson(action.getPictureJson());
input.setClassifyId(action.getClassifyId());
input.setClassifyName(action.getClassifyName());
String key = ObjectUtils.isEmpty(action.getClassifyName()) ? "其他" : action.getClassifyName();
if (appResponeMap.containsKey(key)) {
appResponeMap.getJSONArray(key).add(input);
} else {
List<AppCheckInputRespone> appCheckInputResponeList = new ArrayList<AppCheckInputRespone>();
appCheckInputResponeList.add(input);
appResponeMap.put(key, appCheckInputResponeList);
} }
pointCheckRespone.setPointId(pointId); });
pointCheckRespone.setPointName(planPointInfo.getPointName()); pointCheckRespone.setAppCheckInput(appResponeMap);
pointCheckRespone.setPointNo(planPointInfo.getPointNo());
pointCheckRespone.setPointStatus("0");
pointCheckRespone.setPlanName(planPointInfo.getPlanName());
List<PointCheckDetailBo> pointInputs = planTaskMapper.getPointInputByRouteIdAndPointId(planPointInfo.getRouteId(), planPointInfo.getPointId());
JSONObject appResponeMap = new JSONObject();
pointInputs.forEach(action -> {
AppCheckInputRespone input = new AppCheckInputRespone();
input.setInputName(action.getInputName());
input.setCheckInputId(action.getCheckInputId());
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());
String key = ObjectUtils.isEmpty(action.getClassifyName()) ? "其他" : action.getClassifyName();
if (appResponeMap.containsKey(key)) {
appResponeMap.getJSONArray(key).add(input);
} else {
List<AppCheckInputRespone> appCheckInputResponeList = new ArrayList<AppCheckInputRespone>();
appCheckInputResponeList.add(input);
appResponeMap.put(key, appCheckInputResponeList);
}
});
pointCheckRespone.setAppCheckInput(appResponeMap);
} else {
return null;
}
} }
return pointCheckRespone; return pointCheckRespone;
......
...@@ -80,6 +80,14 @@ public interface ICheckService { ...@@ -80,6 +80,14 @@ public interface ICheckService {
Map<String, Object> checkCalendar(CheckRecordParam requestParam); Map<String, Object> checkCalendar(CheckRecordParam requestParam);
/** /**
* 巡检统计
*
* @param requestParam
* @return
*/
Map<String, Object> checkCalendarNew(String time, String orgCode,String type,String userId);
/**
* 根据点ID查询点巡检记录 手机APP * 根据点ID查询点巡检记录 手机APP
* *
* @param req * @param req
......
...@@ -89,6 +89,13 @@ public interface IPlanTaskService { ...@@ -89,6 +89,13 @@ public interface IPlanTaskService {
void disablePlanTask(Long[] routeIds); void disablePlanTask(Long[] routeIds);
/** /**
* 任务列表一键提交
*
* @param id
*/
void handleAll(String id);
/**
* app 根据条件查询用户权限内所有当前巡检计划任务 * app 根据条件查询用户权限内所有当前巡检计划任务
* @param params * @param params
* @return * @return
......
package com.yeejoin.amos.patrol.business.util;
import org.springframework.http.HttpStatus;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
public class ResponseHelperUtil {
public ResponseHelperUtil() {
}
public static <T> ResponseModel<T> buildErrorResponse(T t) {
ResponseModel<T> response = new ResponseModel();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
response.setResult(t);
response.setDevMessage("ERROR");
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
response.setTraceId(RequestContext.getTraceId());
response.setPath(request.getServletPath());
return response;
}
}
...@@ -61,7 +61,7 @@ public interface IJobService { ...@@ -61,7 +61,7 @@ public interface IJobService {
* @param jobName * @param jobName
*/ */
public void msgJobPerform(long msgId,String jobType,String jobName); public void msgJobPerform(long msgId,String jobType,String jobName);
public void createCheckRecord(PlanTask planTask);
} }
...@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yeejoin.amos.component.feign.config.InnerInvokException; import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.MessageModel; import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo; import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo;
...@@ -411,6 +413,149 @@ public class JobService implements IJobService { ...@@ -411,6 +413,149 @@ public class JobService implements IJobService {
}); });
} }
/**
* 创建检查记录
*
* @param planTask
*/
public void createCheckRecord(PlanTask planTask) {
List<PlanTaskPointInputItemBo> planTaskPointInputItems = planTaskMapper.getPlanTaskPointInputItemByPlanTaskId(planTask.getId(), PlanTaskDetailStatusEnum.OMISSION.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.substring(0, dept.indexOf("@")), dept.substring(dept.indexOf("@") + 1));
deptId.append(dept.substring(dept.indexOf("@") + 1)).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 = "";
FeignClientResult<AgencyUserModel> agencyUserModelsDate = Privilege.agencyUserClient.queryByUserId(planTask.getUserId());
AgencyUserModel agencyUserModel = agencyUserModelsDate.getResult();
// FeignClientResult<List<Map<String, Object>>> departmentModeldate = jcsFeignClient.selectByIdDeptList(deptIds.toString().substring(0, deptIds.toString().length() - 1));
// List<Map<String, Object>> departmentModels = departmentModeldate.getResult();
if (agencyUserModel != null) {
realNames = agencyUserModel.getRealName().join(",");
userName.append(realNames);
}
// if (!departmentModels.isEmpty()) {
//// String departmentName = departmentModels.stream().map(map -> map.get("bizOrgName").toString()).collect(Collectors.joining(","));
//// deptName.append(departmentName);
// }
} else {
String realNames = "";
deptId.append(planTask.getUserDept().substring(planTask.getUserDept().indexOf("@") + 1)).append(",");
deptMap.put(planTask.getUserDept().substring(0, planTask.getUserDept().indexOf("@")), planTask.getUserDept().substring(planTask.getUserDept().indexOf("@") + 1));
// FeignClientResult<List<Map<String, Object>>> departmentModeldate = jcsFeignClient.selectByIdDeptList(deptMap.get(planTask.getUserId()));
// List<Map<String, Object>> departmentModel = departmentModeldate.getResult();
//
// if (departmentModel.size() > 0) {
// departmentModel.stream().forEach(model -> {
// deptName.append(model.get("bizOrgName").toString());
// });
// } else {
// deptName.append("其他").append(",");
// }
FeignClientResult<AgencyUserModel> agencyUserModelsDate = Privilege.agencyUserClient.queryByUserId(planTask.getUserId());
AgencyUserModel agencyUserModel = agencyUserModelsDate.getResult();
if (agencyUserModel != null) {
realNames = agencyUserModel.getRealName().join(",");
userName.append(realNames);
}
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) {
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.setDepId(deptId.toString().substring(0, deptId.length() - 1));
// 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());
try {
check = iCheckDao.save(check);
} catch (InnerInvokException e) {
e.printStackTrace();
}
iCheckDao.flush();
checkList.add(check);
checkMap.put(arg.getPointId(), check);
checkIds.add(check.getId());
} else {
check = checkMap.get(arg.getPointId());
}
if (arg.getInputItemId() != null) {
CheckInput checkInput = new CheckInput();
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());
CheckInput checkInput1 = iCheckInputDao.saveAndFlush(checkInput);
checkInputIdList.add(checkInput1.getId());
}
}
// String usrIds = planTask.getUserId();
// if (!ObjectUtils.isEmpty(usrIds)) {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// String[] ids = usrIds.split(",");
// for (String userId : usrIds.split(",")) {
// if (ObjectUtils.isEmpty(userId)) {
// continue;
// }
// planTaskMapper.reformStatistics(userId, sdf.format(new Date()), planTask.getOrgCode());
// }
// }
}
private void removeJob(String jobName) { private void removeJob(String jobName) {
log.debug("removeJob==jobName==" + jobName); log.debug("removeJob==jobName==" + jobName);
QuartzManager.removeJob(jobName); QuartzManager.removeJob(jobName);
......
...@@ -545,12 +545,38 @@ ...@@ -545,12 +545,38 @@
DATE_FORMAT(check_time, '%Y-%m') = #{checkTime} DATE_FORMAT(check_time, '%Y-%m') = #{checkTime}
<if test="userId!=null and userId!=0">AND FIND_IN_SET(#{userId}, user_id)>0</if> <if test="userId!=null and userId!=0">AND FIND_IN_SET(#{userId}, user_id)>0</if>
<if test="routeId!=null and routeId!=0">AND route_id = #{routeId}</if> <if test="routeId!=null and routeId!=0">AND route_id = #{routeId}</if>
<!-- <if test="orgCode!=null">AND org_code LIKE #{orgCode}</if>--> <!-- <if test="orgCode!=null">AND org_code LIKE #{orgCode}</if>-->
<if test="orgCode!=null">AND org_code LIKE concat(#{orgCode},'%') </if> <if test="orgCode!=null">AND org_code LIKE concat(#{orgCode},'%') </if>
GROUP BY is_ok,time GROUP BY is_ok,time
ORDER BY time ORDER BY time
</select> </select>
<select id="planCount" resultType="Map">
SELECT
SUM ( CASE WHEN pt.finish_status = '0' THEN ( CASE WHEN pl.plan_type = #{type} THEN 1 ELSE 0 END) ELSE 0 END ) notStart,
SUM ( CASE WHEN pt.finish_status = '2' THEN ( CASE WHEN pl.plan_type = #{type} THEN ( CASE WHEN pt.risk_status = '1' THEN 1 ELSE 0 END) ELSE 0 END) ELSE 0 END ) riskEnd,
SUM ( CASE WHEN pt.finish_status = '2' THEN ( CASE WHEN pl.plan_type = #{type} THEN ( CASE WHEN pt.risk_status = '2' THEN 1 ELSE 0 END) ELSE 0 END) ELSE 0 END ) noRiskEnd,
SUM ( CASE WHEN pt.finish_status = '3' THEN ( CASE WHEN pl.plan_type = #{type} THEN 1 ELSE 0 END) ELSE 0 END ) timeOut,
(
CASE
WHEN '2' = #{type} THEN date_part('week',pt.check_date) ELSE ( DATE_FORMAT ( pt.check_date, ( CASE WHEN '1' = #{type} THEN '%Y-%m-%d' ELSE '%Y-%m' END ) ) )
END
) stime,
pl.plan_type as type
FROM
p_plan_task pt left join p_plan pl on pt.plan_id = pl.id
WHERE
pl.plan_type = #{type}
<if test="type!=null and type==1">AND DATE_FORMAT(pt.check_date, '%Y-%m') = left(#{checkTime}, 7) </if>
<if test="type!=null and type==2">AND DATE_FORMAT(pt.check_date, '%Y-%m') = left(#{checkTime}, 7)</if>
<if test="type!=null and type==3">DATE_FORMAT(pt.check_date, '%Y') = left(#{checkTime}, 4)</if>
<if test="userId!=null and userId!=0">AND FIND_IN_SET(#{userId}, pt.user_id)>0</if>
<!-- <if test="orgCode!=null">AND org_code LIKE #{orgCode}</if>-->
<if test="orgCode!=null">AND pt.org_code LIKE concat(#{orgCode}::text,'%') </if>
GROUP BY stime
order by stime desc
</select>
<select id="queryRecordByPointId" resultType="Map" parameterType="Map"> <select id="queryRecordByPointId" resultType="Map" parameterType="Map">
SELECT SELECT
......
...@@ -230,7 +230,8 @@ ...@@ -230,7 +230,8 @@
pt.point_num taskPlanNum, pt.point_num taskPlanNum,
pt.finish_num finshNum, pt.finish_num finshNum,
pt.user_name userName, pt.user_name userName,
pt.user_dept userDept pt.user_dept userDept,
p.plan_type
FROM FROM
p_plan_task pt p_plan_task pt
...@@ -268,7 +269,8 @@ ...@@ -268,7 +269,8 @@
pt.point_num taskPlanNum, pt.point_num taskPlanNum,
pt.finish_num finshNum, pt.finish_num finshNum,
pt.user_name userName, pt.user_name userName,
pt.user_dept userDept pt.user_dept userDept,
p.plan_type
FROM FROM
p_plan_task pt p_plan_task pt
INNER JOIN p_plan p ON pt.plan_id = p.id INNER JOIN p_plan p ON pt.plan_id = p.id
...@@ -278,11 +280,12 @@ ...@@ -278,11 +280,12 @@
<sql id="plan-task-app-where"> <sql id="plan-task-app-where">
<where> <where>
<if test="userId != null and userId > 0 "> and find_in_set(#{userId},a.userId)>0</if> <if test="userId != null and userId > 0 "> and find_in_set(#{userId},a.userId)>0</if>
<if test="type != null and type !='' "> and a.plan_type = #{type}</if>
<if test="routeId != null and routeId > 0 "> and a.route_id = #{routeId} </if> <if test="routeId != null and routeId > 0 "> and a.route_id = #{routeId} </if>
<if test="checkDate != null and checkDate != '' "> and a.beginTime <![CDATA[<=]]> #{checkDate} and a.endTime <![CDATA[>=]]> #{checkDate} </if> <if test="checkDate != null and checkDate != '' "> and a.beginTime <![CDATA[<=]]> #{checkDate} and a.endTime <![CDATA[>=]]> #{checkDate} </if>
<if test="finishStatus != null"> and a.finishStatus = #{finishStatus}</if> <if test="finishStatus != null"> and a.finishStatus = #{finishStatus}</if>
<if test="orgCode != null and orgCode !=''" > <if test="orgCode != null and orgCode !=''" >
and a.OrgCode LIKE CONCAT( #{orgCode}, '%' ) and a.OrgCode LIKE CONCAT( #{orgCode}::text, '%' )
</if> </if>
<!-- <if test="departmentId != null and departmentId != 0 ">and a.userDept like concat('%', #{departmentId}, '%')</if>--> <!-- <if test="departmentId != null and departmentId != 0 ">and a.userDept like concat('%', #{departmentId}, '%')</if>-->
<if test="startTime != null and startTime != '' and endTime != null and endTime != '' "> <if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
...@@ -667,7 +670,8 @@ ...@@ -667,7 +670,8 @@
ppl.dept_id checkDepartmentId, ppl.dept_id checkDepartmentId,
ppt.user_id userId, ppt.user_id userId,
ppt.user_name userName, ppt.user_name userName,
pptd.status pointStatus pptd.status pointStatus,
pptd.is_finish taskStatus
FROM FROM
p_plan_task_detail pptd p_plan_task_detail pptd
LEFT JOIN p_plan_task ppt ON pptd.task_no = ppt.id LEFT JOIN p_plan_task ppt ON pptd.task_no = ppt.id
......
...@@ -5,25 +5,25 @@ ...@@ -5,25 +5,25 @@
<!-- 根据ID获取路线点的项信息 --> <!-- 根据ID获取路线点的项信息 -->
<select id="getInputItemById" resultType="com.yeejoin.amos.patrol.business.vo.PointInputItemVo"> <select id="getInputItemById" resultType="com.yeejoin.amos.patrol.business.vo.PointInputItemVo">
SELECT SELECT
ii.*, prpi.point_classify_id as 'classifyIds',prpi.id routePointItemId ii.*, prpi.point_classify_id classifyIds,prpi.id routePointItemId
FROM FROM
p_input_item ii p_input_item ii
LEFT JOIN p_point_inputitem pii ON pii.input_item_id = ii.id LEFT JOIN p_point_inputitem pii ON pii.input_item_id = ii.id
LEFT JOIN p_route_point_item prpi ON prpi.point_input_item_id = pii.id, LEFT JOIN p_route_point_item prpi ON prpi.point_input_item_id = pii.id,
( (
SELECT SELECT
id AS route_point_id, id AS route_point_id,
exclude_items exclude_items
FROM FROM
p_route_point rp p_route_point rp
<where> <where>
<if test="routeId != null">route_id = #{routeId}</if> <if test="routeId != null">route_id = #{routeId}</if>
<if test="pointId != null">and point_id = #{pointId}</if> <if test="pointId != null">and point_id = #{pointId}</if>
</where> </where>
) prp ) prp
WHERE WHERE
prp.route_point_id = prpi.route_point_id prp.route_point_id = prpi.route_point_id
and !FIND_IN_SET(pii.id, ifnull(prp.exclude_items, 0)) and FIND_IN_SET(pii.id, ifnull(prp.exclude_items, 0)) = 0
</select> </select>
<resultMap id="routePointInputItemMap" type="com.yeejoin.amos.patrol.dao.entity.PointInputItem"> <resultMap id="routePointInputItemMap" type="com.yeejoin.amos.patrol.dao.entity.PointInputItem">
......
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