|
@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -48,6 +51,8 @@ import java.lang.reflect.InvocationTargetException;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.Month;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
@@ -419,6 +424,7 @@ public class TaskController extends BladeController {
|
|
|
.eq(AttachmentForm::getProjectId, approvalDTO.getProjectId()));
|
|
|
List<AttachmentFormTask> attachmentFormTasks = BeanUtil.copyProperties(attachmentForms, AttachmentFormTask.class);
|
|
|
for (AttachmentFormTask attachmentFormTask : attachmentFormTasks) {
|
|
|
+ attachmentFormTask.setId(SnowFlakeUtil.getId());
|
|
|
attachmentFormTask.setTaskId(taskId);
|
|
|
}
|
|
|
/*复制变更令的附件信息VO*/
|
|
@@ -612,14 +618,14 @@ public class TaskController extends BladeController {
|
|
|
@ApiOperationSupport(order = 3)
|
|
|
@ApiOperation(value = "任务废除(任务撤销、驳回审批)", notes = "按一期废除,即按整条任务废除(中期计量申请、材料计量单、开工预付款计量单、变更令、任务查看-废除任务)")
|
|
|
@PushMessage(clientId = ClientIdConstant.METER_CLIENT_ID)
|
|
|
- public R<Object> repeal(@RequestBody TaskRepealDTO taskRepealDTO) {
|
|
|
+ public R<Object> repeal(@RequestBody TaskRepealDTO taskRepealDTO) throws JsonProcessingException {
|
|
|
/*加锁*/
|
|
|
String redisValue = bladeRedis.get("meter:repeal:user:" + SecureUtil.getUserId());
|
|
|
if (StringUtils.isNotEmpty(redisValue) && redisValue.equals("1")) {
|
|
|
- return R.fail(400, "请勿重复提交,30秒后再尝试");
|
|
|
+ return R.fail(400, "请勿重复提交,10秒后再尝试");
|
|
|
}
|
|
|
bladeRedis.set("meter:repeal:user:" + SecureUtil.getUserId(), "1");
|
|
|
- bladeRedis.expire("meter:repeal:user:" + SecureUtil.getUserId(), 30);
|
|
|
+ bladeRedis.expire("meter:repeal:user:" + SecureUtil.getUserId(), 10);
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(taskRepealDTO) && ObjectUtil.isNotEmpty(taskRepealDTO.getTaskId())) {
|
|
|
if (ObjectUtil.isNotEmpty(taskRepealDTO.getMeterTaskRepealDesc()) && taskRepealDTO.getMeterTaskRepealDesc().length() > 1000) {
|
|
@@ -684,6 +690,41 @@ public class TaskController extends BladeController {
|
|
|
jdbcTemplate.execute("DELETE FROM s_middle_meter_apply_task WHERE contract_period_id = '" + periodId + "' AND task_id = " + taskRepealDTO.getTaskId());
|
|
|
jdbcTemplate.execute("DELETE FROM s_inventory_form_apply_task WHERE contract_period_id = '" + periodId + "' AND task_id = " + taskRepealDTO.getTaskId());
|
|
|
|
|
|
+ /*还原修改过的清单信息*/
|
|
|
+ List<InventoryFormApply> restoreInventoryFormApplyList = new ArrayList<>();
|
|
|
+ for (Long middleMeterAppliesId : middleMeterAppliesIds) {
|
|
|
+ List<TaskDataUpdateRecord> query = jdbcTemplate.query("SELECT * FROM s_task_data_update_record WHERE data_id = " + middleMeterAppliesId, new BeanPropertyRowMapper<>(TaskDataUpdateRecord.class));
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ for (TaskDataUpdateRecord taskDataUpdateRecord : query) {
|
|
|
+ String rawFormDataJson = taskDataUpdateRecord.getRawFormDataJson();
|
|
|
+ Map<String, Object> jsonMap = objectMapper.readValue(rawFormDataJson, new TypeReference<Map<String, Object>>() {
|
|
|
+ });
|
|
|
+ Map<String, Object> businessDateMap = (Map<String, Object>) jsonMap.get("businessDate");
|
|
|
+ Map<String, Object> modifiedJsonMap = new HashMap<>(jsonMap);
|
|
|
+ if (businessDateMap != null) {
|
|
|
+ modifiedJsonMap.remove("businessDate");
|
|
|
+ }
|
|
|
+ InventoryFormApplyTask inventoryFormApplyTask = objectMapper.convertValue(modifiedJsonMap, InventoryFormApplyTask.class);
|
|
|
+ InventoryFormApply inventoryFormApply = BeanUtil.copyProperties(inventoryFormApplyTask, InventoryFormApply.class);
|
|
|
+ if (inventoryFormApply != null) {
|
|
|
+ inventoryFormApply.setApproveStatus(0);
|
|
|
+ if (businessDateMap != null) {
|
|
|
+ int year = (int) businessDateMap.get("year");
|
|
|
+ String month = (String) businessDateMap.get("month");
|
|
|
+ LocalDate businessDate = LocalDate.of(year, Month.valueOf(month), 1);
|
|
|
+ inventoryFormApplyTask.setBusinessDate(businessDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ restoreInventoryFormApplyList.add(inventoryFormApply);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (restoreInventoryFormApplyList.size() > 0) {
|
|
|
+ if (inventoryFormApplyService.updateBatchById(restoreInventoryFormApplyList)) {
|
|
|
+ /*删除修改的操作记录信息*/
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_task_data_update_record WHERE data_id in(" + StringUtils.join(middleMeterAppliesIds, ",") + ")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} else if (task.getMeterTaskType().equals(2)) {
|
|
|
/*==================== 材料计量单 ====================*/
|
|
|
/*获取原始的材料数量*/
|
|
@@ -743,6 +784,10 @@ public class TaskController extends BladeController {
|
|
|
jdbcTemplate.execute("DELETE FROM s_change_token_form_task WHERE id = '" + dataId + "' AND task_id = " + taskRepealDTO.getTaskId());
|
|
|
jdbcTemplate.execute("DELETE FROM s_change_token_meter_task WHERE change_token_id = '" + dataId + "' AND task_id = " + taskRepealDTO.getTaskId());
|
|
|
jdbcTemplate.execute("DELETE FROM s_change_token_inventory_task WHERE change_token_id = '" + dataId + "' AND task_id = " + taskRepealDTO.getTaskId());
|
|
|
+
|
|
|
+ /*删除单条废除的历史记录*/
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_task_data_update_record WHERE data_id = " + taskRepealDTO.getTaskId());
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -952,7 +997,7 @@ public class TaskController extends BladeController {
|
|
|
@GetMapping("/detail")
|
|
|
@ApiOperationSupport(order = 5)
|
|
|
@ApiOperation(value = "任务详情", notes = "传入任务id")
|
|
|
- public R<TaskDetailVO> detail(@RequestParam String id) {
|
|
|
+ public R<TaskDetailVO> detail(@RequestParam String id) throws JsonProcessingException {
|
|
|
if (ObjectUtil.isEmpty(id) || ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
|
throw new ServiceException("任务id、用户信息不能为空");
|
|
|
}
|
|
@@ -990,7 +1035,7 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
vo.setTaskProcessInfo(taskProcessInfo);
|
|
|
|
|
|
- /*中间业务taskVO复制数据(只有待审批、已审批任务才能查看到具体的taskVO复制数据,因为废除任务时taskVO被删除)*/
|
|
|
+ /*中间业务taskVO复制数据(只有待审批、已审批任务才能查看到具体的taskVO复制数据,因为废除任务时taskVO被删除,但是单条驳回时有记录单条数据的历史信息,所以通过的任务还是能查看到)*/
|
|
|
if (ObjectUtil.isNotEmpty(task.getFormDataId()) && Arrays.asList(1, 2).contains(task.getStatus())) {
|
|
|
/*获取当条任务所有批注信息*/
|
|
|
Map<String, TaskComment> taskCommentMap = jdbcTemplate.query("SELECT * FROM s_task_comment WHERE task_id = " + id, new BeanPropertyRowMapper<>(TaskComment.class))
|
|
@@ -1054,9 +1099,17 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
} else if (task.getMeterTaskType().equals(4)) {
|
|
|
/*==================== 变更令 ====================*/
|
|
|
+ /*变更令有两种情况*/
|
|
|
+ //1.单条通过显示
|
|
|
List<Long> longs = Func.toLongList(periodId);
|
|
|
- List<ChangeTokenFormTask> changeTokenFormTasks = changeTokenFormServiceTask.getBaseMapper().selectBatchIds(longs);
|
|
|
+ List<ChangeTokenFormTask> changeTokenFormTasks = changeTokenFormServiceTask.getBaseMapper()
|
|
|
+ .selectList(Wrappers.<ChangeTokenFormTask>lambdaQuery()
|
|
|
+ .eq(ChangeTokenFormTask::getTaskId, id)
|
|
|
+ .in(ChangeTokenFormTask::getId, longs));
|
|
|
List<ChangeTokenFormTaskVO> changeTokenFormTaskVOS = BeanUtil.copyProperties(changeTokenFormTasks, ChangeTokenFormTaskVO.class);
|
|
|
+ if (ObjectUtil.isEmpty(changeTokenFormTaskVOS)) {
|
|
|
+ changeTokenFormTaskVOS = new ArrayList<>();
|
|
|
+ }
|
|
|
for (ChangeTokenFormTaskVO changeTokenFormTaskVO : changeTokenFormTaskVOS) {
|
|
|
String key = SecureUtil.getUserId() + ":" + changeTokenFormTaskVO.getId();
|
|
|
TaskComment orDefault = taskCommentMap.getOrDefault(key, null);
|
|
@@ -1066,23 +1119,68 @@ public class TaskController extends BladeController {
|
|
|
changeTokenFormTaskVO.setIsComment(0);
|
|
|
}
|
|
|
}
|
|
|
- vo.setTaskCenterDataInfo(changeTokenFormTaskVOS);
|
|
|
|
|
|
+ /*已审批的任务才会去追加查看,单条驳回的历史记录信息*/
|
|
|
+ if (task.getStatus().equals(2)) {
|
|
|
+ //2.单条驳回显示(历史记录)data_id=id=taskId
|
|
|
+ List<TaskDataUpdateRecord> query = jdbcTemplate.query("SELECT * FROM s_task_data_update_record WHERE data_id = " + id, new BeanPropertyRowMapper<>(TaskDataUpdateRecord.class));
|
|
|
+ if (query.size() > 0) {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ for (TaskDataUpdateRecord taskDataUpdateRecord : query) {
|
|
|
+ String rawChangCenterDataJson = taskDataUpdateRecord.getRawChangCenterDataJson();
|
|
|
+ Map<String, Object> jsonMap = objectMapper.readValue(rawChangCenterDataJson, new TypeReference<Map<String, Object>>() {
|
|
|
+ });
|
|
|
+ Map<String, Object> businessDateMap = (Map<String, Object>) jsonMap.get("businessDate");
|
|
|
+ Map<String, Object> designDateMap = (Map<String, Object>) jsonMap.get("designDate");
|
|
|
+ Map<String, Object> changeApprovalDateMap = (Map<String, Object>) jsonMap.get("changeApprovalDate");
|
|
|
+ Map<String, Object> modifiedJsonMap = new HashMap<>(jsonMap);
|
|
|
+ if (businessDateMap != null || designDateMap != null || changeApprovalDateMap != null) {
|
|
|
+ modifiedJsonMap.remove("businessDate");
|
|
|
+ modifiedJsonMap.remove("designDate");
|
|
|
+ modifiedJsonMap.remove("changeApprovalDate");
|
|
|
+ }
|
|
|
+ ChangeTokenFormTaskVO changeTokenFormTaskVO = objectMapper.convertValue(modifiedJsonMap, ChangeTokenFormTaskVO.class);
|
|
|
+ if (changeTokenFormTaskVO != null) {
|
|
|
+ if (businessDateMap != null) {
|
|
|
+ int year = (int) businessDateMap.get("year");
|
|
|
+ String month = (String) businessDateMap.get("month");
|
|
|
+ LocalDate businessDate = LocalDate.of(year, Month.valueOf(month), 1);
|
|
|
+ changeTokenFormTaskVO.setBusinessDate(businessDate);
|
|
|
+ }
|
|
|
+ if (designDateMap != null) {
|
|
|
+ int year = (int) designDateMap.get("year");
|
|
|
+ String month = (String) designDateMap.get("month");
|
|
|
+ LocalDate designDate = LocalDate.of(year, Month.valueOf(month), 1);
|
|
|
+ changeTokenFormTaskVO.setDesignDate(designDate);
|
|
|
+ }
|
|
|
+ if (changeApprovalDateMap != null) {
|
|
|
+ int year = (int) changeApprovalDateMap.get("year");
|
|
|
+ String month = (String) changeApprovalDateMap.get("month");
|
|
|
+ LocalDate changeApprovalDate = LocalDate.of(year, Month.valueOf(month), 1);
|
|
|
+ changeTokenFormTaskVO.setChangeApprovalDate(changeApprovalDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ changeTokenFormTaskVOS.add(changeTokenFormTaskVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setTaskCenterDataInfo(changeTokenFormTaskVOS);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return R.data(200, vo, "操作成功");
|
|
|
}
|
|
|
|
|
|
@GetMapping("/data/detail")
|
|
|
@ApiOperationSupport(order = 6)
|
|
|
@ApiOperation(value = "任务数据信息详情", notes = "传入任务id,数据dataId")
|
|
|
- public R<TaskDataDetailVO> dataDetail(@RequestParam String id, @RequestParam String dataId) {
|
|
|
+ public R<TaskDataDetailVO> dataDetail(@RequestParam String id, @RequestParam String dataId) throws JsonProcessingException {
|
|
|
if (ObjectUtil.isEmpty(id) || ObjectUtil.isEmpty(dataId)) {
|
|
|
throw new ServiceException("任务id、数据id不能为空");
|
|
|
}
|
|
|
TaskDataDetailVO vo = new TaskDataDetailVO();
|
|
|
- Task task = jdbcTemplate.query("SELECT meter_task_type,form_data_id FROM u_task WHERE id = " + id, new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
+ Task task = jdbcTemplate.query("SELECT meter_task_type,form_data_id,status FROM u_task WHERE id = " + id, new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
if (task != null) {
|
|
|
if (task.getMeterTaskType().equals(1)) {
|
|
|
MiddleMeterApplyTask middleMeterApplyTask = middleMeterApplyServiceTask.getById(dataId);
|
|
@@ -1113,25 +1211,111 @@ public class TaskController extends BladeController {
|
|
|
vo.setBasicsInfo(startPayMeterFormTask);
|
|
|
|
|
|
} else if (task.getMeterTaskType().equals(4)) {
|
|
|
- ChangeTokenFormVO2 changeTokenFormVO = changeTokenFormService.getBaseMapper().detailCopy(Long.parseLong(dataId));
|
|
|
- if (changeTokenFormVO != null) {
|
|
|
- List<ChangeNodeVO> nodeListCopy = changeTokenFormService.getBaseMapper().getNodeListCopy(changeTokenFormVO.getContractId(), changeTokenFormVO.getId());
|
|
|
- if (nodeListCopy.size() > 0) {
|
|
|
- List<ChangeFormVO2> formListCopy = changeTokenFormService.getBaseMapper().getFormListCopy(changeTokenFormVO.getContractId(), changeTokenFormVO.getId());
|
|
|
- if (formListCopy.size() > 0) {
|
|
|
- Map<Long, List<ChangeFormVO2>> map = formListCopy.stream().collect(Collectors.groupingBy(ChangeFormVO2::getContractMeterId));
|
|
|
- for (ChangeNodeVO nodeVO : nodeListCopy) {
|
|
|
- List<ChangeFormVO2> vo2s = map.get(nodeVO.getId());
|
|
|
- nodeVO.setFormList(vo2s);
|
|
|
+ /*待审批任务正常显示*/
|
|
|
+ if (new Integer(1).equals(task.getStatus())) {
|
|
|
+ ChangeTokenFormVO2 changeTokenFormVO = changeTokenFormService.getBaseMapper().detailCopy(Long.parseLong(dataId));
|
|
|
+ if (changeTokenFormVO != null) {
|
|
|
+ List<ChangeNodeVO> nodeListCopy = changeTokenFormService.getBaseMapper().getNodeListCopy(changeTokenFormVO.getContractId(), changeTokenFormVO.getId());
|
|
|
+ if (nodeListCopy.size() > 0) {
|
|
|
+ List<ChangeFormVO2> formListCopy = changeTokenFormService.getBaseMapper().getFormListCopy(changeTokenFormVO.getContractId(), changeTokenFormVO.getId());
|
|
|
+ if (formListCopy.size() > 0) {
|
|
|
+ Map<Long, List<ChangeFormVO2>> map = formListCopy.stream().collect(Collectors.groupingBy(ChangeFormVO2::getContractMeterId));
|
|
|
+ for (ChangeNodeVO nodeVO : nodeListCopy) {
|
|
|
+ List<ChangeFormVO2> vo2s = map.get(nodeVO.getId());
|
|
|
+ nodeVO.setFormList(vo2s);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (ChangeNodeVO nodeVO : nodeListCopy) {
|
|
|
+ nodeVO.setNodeUrl(middleMeterApplyService.getNodeDivide(nodeVO.getId()));
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- for (ChangeNodeVO nodeVO : nodeListCopy) {
|
|
|
- nodeVO.setNodeUrl(middleMeterApplyService.getNodeDivide(nodeVO.getId()));
|
|
|
+ changeTokenFormVO.setNodeList(nodeListCopy);
|
|
|
+ vo.setChangeTokenFormVO(changeTokenFormVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*已审批、已废除任务,需要判断显示*/
|
|
|
+ if (Arrays.asList(2, 3).contains(task.getStatus())) {
|
|
|
+ //2.单条驳回显示(历史记录)data_id=入参的id=taskId;form_id=入参的dataId=变更令id
|
|
|
+ List<TaskDataUpdateRecord> query = jdbcTemplate.query("SELECT * FROM s_task_data_update_record WHERE data_id = " + id + " AND form_id = " + dataId, new BeanPropertyRowMapper<>(TaskDataUpdateRecord.class));
|
|
|
+ if (query.size() == 1) {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ TaskDataDetailVO taskDataDetailVO = new TaskDataDetailVO();
|
|
|
+ TaskDataUpdateRecord taskDataUpdateRecord = query.get(0);
|
|
|
+ String rawChangRightDataJson = taskDataUpdateRecord.getRawChangRightDataJson();
|
|
|
+ Map<String, Object> jsonMap = objectMapper.readValue(rawChangRightDataJson, new TypeReference<Map<String, Object>>() {
|
|
|
+ });
|
|
|
+
|
|
|
+ /*部位、清单信息*/
|
|
|
+ Map<String, Object> changeTokenFormVOMap = (Map<String, Object>) jsonMap.get("changeTokenFormVO");
|
|
|
+ Map<String, Object> designDateMap = (Map<String, Object>) changeTokenFormVOMap.get("designDate");
|
|
|
+ Map<String, Object> businessDateMap = (Map<String, Object>) changeTokenFormVOMap.get("businessDate");
|
|
|
+ Map<String, Object> changeApprovalDateMap = (Map<String, Object>) changeTokenFormVOMap.get("changeApprovalDate");
|
|
|
+ Map<String, Object> modifiedChangeTokenFormVOMap = new HashMap<>(changeTokenFormVOMap);
|
|
|
+ if (businessDateMap != null || designDateMap != null || changeApprovalDateMap != null) {
|
|
|
+ modifiedChangeTokenFormVOMap.remove("businessDate");
|
|
|
+ modifiedChangeTokenFormVOMap.remove("designDate");
|
|
|
+ modifiedChangeTokenFormVOMap.remove("changeApprovalDate");
|
|
|
+ }
|
|
|
+ ChangeTokenFormVO2 changeTokenFormVO2 = objectMapper.convertValue(modifiedChangeTokenFormVOMap, ChangeTokenFormVO2.class);
|
|
|
+ if (changeTokenFormVO2 != null) {
|
|
|
+ if (businessDateMap != null) {
|
|
|
+ int year = (int) businessDateMap.get("year");
|
|
|
+ String month = (String) businessDateMap.get("month");
|
|
|
+ LocalDate businessDate = LocalDate.of(year, Month.valueOf(month), 1);
|
|
|
+ changeTokenFormVO2.setBusinessDate(businessDate);
|
|
|
+ }
|
|
|
+ if (designDateMap != null) {
|
|
|
+ int year = (int) designDateMap.get("year");
|
|
|
+ String month = (String) designDateMap.get("month");
|
|
|
+ LocalDate designDate = LocalDate.of(year, Month.valueOf(month), 1);
|
|
|
+ changeTokenFormVO2.setDesignDate(designDate);
|
|
|
+ }
|
|
|
+ if (changeApprovalDateMap != null) {
|
|
|
+ int year = (int) changeApprovalDateMap.get("year");
|
|
|
+ String month = (String) changeApprovalDateMap.get("month");
|
|
|
+ LocalDate changeApprovalDate = LocalDate.of(year, Month.valueOf(month), 1);
|
|
|
+ changeTokenFormVO2.setChangeApprovalDate(changeApprovalDate);
|
|
|
+ }
|
|
|
+ taskDataDetailVO.setChangeTokenFormVO(changeTokenFormVO2);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*附件*/
|
|
|
+ List<Object> attachmentFormTaskList = (List<Object>) jsonMap.get("attachmentFormTask");
|
|
|
+ List<AttachmentFormTask> attachmentFormTaskListResult = new ArrayList<>();
|
|
|
+ for (Object item : attachmentFormTaskList) {
|
|
|
+ AttachmentFormTask attachmentFormTask = objectMapper.convertValue(item, AttachmentFormTask.class);
|
|
|
+ attachmentFormTaskListResult.add(attachmentFormTask);
|
|
|
+ }
|
|
|
+ taskDataDetailVO.setAttachmentFormTask(attachmentFormTaskListResult);
|
|
|
+
|
|
|
+ /*单条驳回数据,直接返回*/
|
|
|
+ return R.data(200, taskDataDetailVO, "操作成功");
|
|
|
+
|
|
|
+ } else if (query.size() == 0) {
|
|
|
+ /*没有历史记录说明当前任务全是通过的数据,没有单条驳回的*/
|
|
|
+ ChangeTokenFormVO2 changeTokenFormVO = changeTokenFormService.getBaseMapper().detailCopy(Long.parseLong(dataId));
|
|
|
+ if (changeTokenFormVO != null) {
|
|
|
+ List<ChangeNodeVO> nodeListCopy = changeTokenFormService.getBaseMapper().getNodeListCopy(changeTokenFormVO.getContractId(), changeTokenFormVO.getId());
|
|
|
+ if (nodeListCopy.size() > 0) {
|
|
|
+ List<ChangeFormVO2> formListCopy = changeTokenFormService.getBaseMapper().getFormListCopy(changeTokenFormVO.getContractId(), changeTokenFormVO.getId());
|
|
|
+ if (formListCopy.size() > 0) {
|
|
|
+ Map<Long, List<ChangeFormVO2>> map = formListCopy.stream().collect(Collectors.groupingBy(ChangeFormVO2::getContractMeterId));
|
|
|
+ for (ChangeNodeVO nodeVO : nodeListCopy) {
|
|
|
+ List<ChangeFormVO2> vo2s = map.get(nodeVO.getId());
|
|
|
+ nodeVO.setFormList(vo2s);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (ChangeNodeVO nodeVO : nodeListCopy) {
|
|
|
+ nodeVO.setNodeUrl(middleMeterApplyService.getNodeDivide(nodeVO.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ changeTokenFormVO.setNodeList(nodeListCopy);
|
|
|
+ vo.setChangeTokenFormVO(changeTokenFormVO);
|
|
|
}
|
|
|
}
|
|
|
- changeTokenFormVO.setNodeList(nodeListCopy);
|
|
|
}
|
|
|
- vo.setChangeTokenFormVO(changeTokenFormVO);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1286,11 +1470,11 @@ public class TaskController extends BladeController {
|
|
|
@PostMapping("/data/inventoryFormApplyTask/update")
|
|
|
@ApiOperationSupport(order = 8)
|
|
|
@ApiOperation(value = "清单数据修改", notes = "传入InventoryFormApplyTaskDTO")
|
|
|
- public R<Object> dataInventoryFormApplyTaskUpdate(@RequestBody InventoryFormApplyTaskDTO dto) {
|
|
|
+ public R<Object> dataInventoryFormApplyTaskUpdate(@RequestBody InventoryFormApplyTaskDTO dto) throws JsonProcessingException {
|
|
|
if (ObjectUtil.isEmpty(dto.getTaskId())) {
|
|
|
throw new ServiceException("未获取到taskId");
|
|
|
}
|
|
|
- Task task = jdbcTemplate.query("SELECT meter_task_type,process_instance_id,contract_id,project_id FROM u_task WHERE id = " + dto.getTaskId(), new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
+ Task task = jdbcTemplate.query("SELECT meter_task_type,process_instance_id,contract_id,project_id,form_data_id FROM u_task WHERE id = " + dto.getTaskId(), new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
if (task != null) {
|
|
|
check(task);
|
|
|
|
|
@@ -1298,7 +1482,9 @@ public class TaskController extends BladeController {
|
|
|
if (ObjectUtil.isEmpty(obj)) {
|
|
|
throw new ServiceException("操作异常");
|
|
|
}
|
|
|
+
|
|
|
obj.setId(dto.getTaskDetailId());
|
|
|
+
|
|
|
InventoryFormApplyTask inventoryFormApplyTask = inventoryFormApplyServiceTask.getById(obj.getId());
|
|
|
if (ObjectUtil.isEmpty(inventoryFormApplyTask)) {
|
|
|
throw new ServiceException("未获取到清单数据");
|
|
@@ -1307,6 +1493,18 @@ public class TaskController extends BladeController {
|
|
|
obj.setProjectId(Long.parseLong(task.getProjectId()));
|
|
|
obj.setContractId(Long.parseLong(task.getContractId()));
|
|
|
|
|
|
+ /*获取原始计量清单数据(任务整体驳回时需要恢复,因为下面逻辑去修改了原始数据,/data/detail接口又必须用原始数据查询)*/
|
|
|
+ String sql = "SELECT * FROM s_task_data_update_record WHERE data_id = ? AND form_id = ?";
|
|
|
+ List<TaskDataUpdateRecord> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskDataUpdateRecord.class),
|
|
|
+ inventoryFormApplyTask.getMiddleMeterId(), inventoryFormApplyTask.getId());
|
|
|
+ if (query.size() == 0) {
|
|
|
+ /*存储原始计量清单数据*/
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ String jsonString = objectMapper.writeValueAsString(inventoryFormApplyTask);
|
|
|
+ jdbcTemplate.update("INSERT INTO s_task_data_update_record (id, data_id, form_id, raw_form_data_json) VALUES (?, ?, ?, ?)",
|
|
|
+ SnowFlakeUtil.getId(), inventoryFormApplyTask.getMiddleMeterId(), inventoryFormApplyTask.getId(), jsonString);
|
|
|
+ }
|
|
|
+
|
|
|
/*需要修改原始数据(统计累计计量量的时候需要查原始表数据)*/
|
|
|
InventoryFormApply inventoryFormApply = BeanUtil.copyProperties(obj, InventoryFormApply.class);
|
|
|
|
|
@@ -1446,8 +1644,8 @@ public class TaskController extends BladeController {
|
|
|
@ApiOperationSupport(order = 10)
|
|
|
@ApiOperation(value = "材料数据修改", notes = "传入MaterialMeterFormTask")
|
|
|
public R<Object> dataMaterialMeterFormServiceTaskUpdate(@RequestBody MaterialMeterFormTask obj) {
|
|
|
- if (ObjectUtil.isEmpty(obj.getTaskId())) {
|
|
|
- throw new ServiceException("未获取到taskId");
|
|
|
+ if (ObjectUtil.isEmpty(obj.getTaskId()) || ObjectUtil.isEmpty(obj.getId())) {
|
|
|
+ throw new ServiceException("未获取到taskId、id");
|
|
|
}
|
|
|
Task task = jdbcTemplate.query("SELECT meter_task_type,process_instance_id,contract_id,project_id FROM u_task WHERE id = " + obj.getTaskId(), new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
if (task != null) {
|
|
@@ -1479,8 +1677,8 @@ public class TaskController extends BladeController {
|
|
|
@ApiOperationSupport(order = 11)
|
|
|
@ApiOperation(value = "开工预付款数据修改", notes = "传入StartPayMeterFormTask")
|
|
|
public R<Object> dataStartPayMeterFormServiceTaskUpdate(@RequestBody StartPayMeterFormTask obj) {
|
|
|
- if (ObjectUtil.isEmpty(obj.getTaskId())) {
|
|
|
- throw new ServiceException("未获取到taskId");
|
|
|
+ if (ObjectUtil.isEmpty(obj.getTaskId()) || ObjectUtil.isEmpty(obj.getId())) {
|
|
|
+ throw new ServiceException("未获取到taskId、id");
|
|
|
}
|
|
|
Task task = jdbcTemplate.query("SELECT meter_task_type,process_instance_id,contract_id,project_id FROM u_task WHERE id = " + obj.getTaskId(), new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
if (task != null) {
|
|
@@ -1499,8 +1697,8 @@ public class TaskController extends BladeController {
|
|
|
@ApiOperationSupport(order = 12)
|
|
|
@ApiOperation(value = "变更令-基础信息修改", notes = "传入ChangeTokenFormTask")
|
|
|
public R<Object> dataChangeTokenFromUpdate(@RequestBody ChangeTokenFormTask obj) {
|
|
|
- if (ObjectUtil.isEmpty(obj.getTaskId())) {
|
|
|
- throw new ServiceException("未获取到taskId");
|
|
|
+ if (ObjectUtil.isEmpty(obj.getTaskId()) || ObjectUtil.isEmpty(obj.getId())) {
|
|
|
+ throw new ServiceException("未获取到taskId、id");
|
|
|
}
|
|
|
Task task = jdbcTemplate.query("SELECT meter_task_type,process_instance_id,contract_id,project_id FROM u_task WHERE id = " + obj.getTaskId(), new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
if (task != null) {
|
|
@@ -1718,7 +1916,7 @@ public class TaskController extends BladeController {
|
|
|
@PostMapping("/data/audit")
|
|
|
@ApiOperationSupport(order = 18)
|
|
|
@ApiOperation(value = "单条数据同意或驳回", notes = "传入TaskAuditDTO")
|
|
|
- public R<Object> dataAudit(@RequestBody TaskAuditDTO dto) {
|
|
|
+ public R<Object> dataAudit(@RequestBody TaskAuditDTO dto) throws JsonProcessingException {
|
|
|
if (ObjectUtil.isEmpty(dto.getDataId()) || ObjectUtil.isEmpty(dto.getTaskId())) {
|
|
|
throw new ServiceException("任务id、数据id不能为空");
|
|
|
}
|
|
@@ -1751,6 +1949,33 @@ public class TaskController extends BladeController {
|
|
|
.set(ChangeTokenFormTask::getRepealDesc, ObjectUtil.isNotEmpty(dto.getRepealDesc()) ? dto.getRepealDesc() : null)
|
|
|
.eq(ChangeTokenFormTask::getId, dto.getDataId()));
|
|
|
|
|
|
+ /*变更令单条驳回后,会存在重新上报情况,需要保留驳回前的记录信息显示在旧任务中,那么需要存储历史记录*/
|
|
|
+ if (dto.getAuditStatus().equals("2")) {
|
|
|
+ /*获取变更令*/
|
|
|
+ TaskDetailVO data = this.detail(dto.getTaskId()).getData();
|
|
|
+ Object taskCenterDataInfo = data.getTaskCenterDataInfo();
|
|
|
+ List<ChangeTokenFormTaskVO> changeTokenFormTaskVOS = (List<ChangeTokenFormTaskVO>) taskCenterDataInfo;
|
|
|
+ ChangeTokenFormTaskVO changeTokenFormTaskVO = changeTokenFormTaskVOS.stream().filter(f -> f.getId().equals(Long.parseLong(dto.getDataId()))).findAny().orElse(null);
|
|
|
+ if (changeTokenFormTaskVO != null) {
|
|
|
+ /*获取部位、清单信息*/
|
|
|
+ TaskDataDetailVO formAndBW = this.dataDetail(dto.getTaskId(), dto.getDataId()).getData();
|
|
|
+ if (formAndBW != null) {
|
|
|
+ /*存储历史记录*/
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ String jsonStringChangeTokenFormTaskVO = objectMapper.writeValueAsString(changeTokenFormTaskVO);
|
|
|
+ String jsonStringFormAndBW = objectMapper.writeValueAsString(formAndBW);
|
|
|
+
|
|
|
+ /*此处data_id=taskId,form_id=变更令id*/
|
|
|
+ String sql = "SELECT * FROM s_task_data_update_record WHERE data_id = ? AND form_id = ?";
|
|
|
+ List<TaskDataUpdateRecord> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskDataUpdateRecord.class),
|
|
|
+ dto.getTaskId(), changeTokenFormTaskVO.getId());
|
|
|
+ if (query.size() == 0) {
|
|
|
+ jdbcTemplate.update("INSERT INTO s_task_data_update_record (id, data_id, form_id, raw_chang_center_data_json, raw_chang_right_data_json) VALUES (?, ?, ?, ?, ?)",
|
|
|
+ SnowFlakeUtil.getId(), dto.getTaskId(), changeTokenFormTaskVO.getId(), jsonStringChangeTokenFormTaskVO, jsonStringFormAndBW);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
@@ -1770,10 +1995,10 @@ public class TaskController extends BladeController {
|
|
|
/*加锁*/
|
|
|
String redisValue = bladeRedis.get("meter:approve:user:" + SecureUtil.getUserId());
|
|
|
if (StringUtils.isNotEmpty(redisValue) && redisValue.equals("1")) {
|
|
|
- return R.fail(400, "请勿重复提交,30秒后再尝试");
|
|
|
+ return R.fail(400, "请勿重复提交,10秒后再尝试");
|
|
|
}
|
|
|
bladeRedis.set("meter:approve:user:" + SecureUtil.getUserId(), "1");
|
|
|
- bladeRedis.expire("meter:approve:user:" + SecureUtil.getUserId(), 30);
|
|
|
+ bladeRedis.expire("meter:approve:user:" + SecureUtil.getUserId(), 10);
|
|
|
|
|
|
String sql_1 = "SELECT * FROM u_task WHERE id = ?";
|
|
|
Task task = jdbcTemplate.query(sql_1, new Object[]{dto.getTaskId()}, new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
@@ -1899,9 +2124,9 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
} else if (task.getMeterTaskType().equals(4)) {
|
|
|
List<ChangeTokenFormTask> query = jdbcTemplate.query("SELECT id FROM s_change_token_form_task WHERE status != 2 AND id IN(" + formDataId + ")", new BeanPropertyRowMapper<>(ChangeTokenFormTask.class));
|
|
|
- List<Long> collect = query.stream().map(ChangeTokenFormTask::getId).collect(Collectors.toList());
|
|
|
- if (collect.size() > 0) {
|
|
|
- jdbcTemplate.execute("UPDATE s_change_token_form_task SET status = 1 WHERE id IN(" + StringUtils.join(collect, ",") + ")");
|
|
|
+ List<Long> ids = query.stream().map(ChangeTokenFormTask::getId).collect(Collectors.toList());
|
|
|
+ if (ids.size() > 0) {
|
|
|
+ jdbcTemplate.execute("UPDATE s_change_token_form_task SET status = 1 WHERE id IN(" + StringUtils.join(ids, ",") + ")");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1968,16 +2193,37 @@ public class TaskController extends BladeController {
|
|
|
} else if (task.getMeterTaskType().equals(4)) {
|
|
|
List<String> formDataIds = Func.toStrList(formDataId);
|
|
|
List<ChangeTokenFormTask> changeTokenFormTasks = changeTokenFormServiceTask.getBaseMapper().selectList(Wrappers.<ChangeTokenFormTask>lambdaQuery()
|
|
|
- .in(ChangeTokenFormTask::getId, formDataIds)
|
|
|
- .eq(ChangeTokenFormTask::getStatus, 1));
|
|
|
- List<Long> ids = changeTokenFormTasks.stream().map(ChangeTokenFormTask::getId).collect(Collectors.toList());
|
|
|
- if (ids.size() > 0) {
|
|
|
+ .eq(ChangeTokenFormTask::getTaskId, dto.getTaskId())
|
|
|
+ .in(ChangeTokenFormTask::getId, formDataIds));
|
|
|
+
|
|
|
+ /*修改status=1的通过的变更令数据的审批状态=已审批*/
|
|
|
+ List<Long> ids_1 = changeTokenFormTasks.stream().filter(f -> f.getStatus().equals(1)).map(ChangeTokenFormTask::getId).collect(Collectors.toList());
|
|
|
+ if (ids_1.size() > 0) {
|
|
|
UpdateWrapper<ChangeTokenFormTask> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.in("id", ids);
|
|
|
+ updateWrapper.eq("task_id", dto.getTaskId());
|
|
|
+ updateWrapper.in("id", ids_1);
|
|
|
ChangeTokenFormTask updateEntity = new ChangeTokenFormTask();
|
|
|
updateEntity.setApproveStatus(2);
|
|
|
changeTokenFormServiceTask.update(updateEntity, updateWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ /*删除status=2的单条驳回的变更令、部位、清单数据taskVO,并修改原始变更令数据的审批状态=未上报,status=未选中*/
|
|
|
+ List<Long> ids_2 = changeTokenFormTasks.stream().filter(f -> f.getStatus().equals(2)).map(ChangeTokenFormTask::getId).collect(Collectors.toList());
|
|
|
+ if (ids_2.size() > 0) {
|
|
|
+ /*原始变更令审批状态修改为=0未上报,单条驳回状态=0未选中,可重复上报*/
|
|
|
+ UpdateWrapper<ChangeTokenForm> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("id", ids_2);
|
|
|
+ ChangeTokenForm updateEntity = new ChangeTokenForm();
|
|
|
+ updateEntity.setApproveStatus(0);
|
|
|
+ updateEntity.setStatus(0);
|
|
|
+ changeTokenFormService.update(updateEntity, updateWrapper);
|
|
|
+
|
|
|
+ /*删除*/
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_change_token_form_task WHERE task_id = " + dto.getTaskId() + " AND id IN(" + StringUtils.join(ids_2, ",") + ")");
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_change_token_meter_task WHERE task_id = " + dto.getTaskId() + " AND change_token_id IN(" + StringUtils.join(ids_2, ",") + ")");
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_change_token_inventory_task WHERE task_id = " + dto.getTaskId() + " AND change_token_id IN(" + StringUtils.join(ids_2, ",") + ")");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return this;
|
|
|
}
|