|
@@ -1,29 +1,54 @@
|
|
|
package org.springblade.meter.controller;
|
|
|
|
|
|
|
|
|
+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.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.commons.lang.time.DateUtils;
|
|
|
+import org.springblade.business.entity.FixedFlowLink;
|
|
|
+import org.springblade.business.entity.Task;
|
|
|
+import org.springblade.business.entity.TaskParallel;
|
|
|
+import org.springblade.business.feign.TaskClient;
|
|
|
+import org.springblade.common.constant.ClientIdConstant;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.base.BaseService;
|
|
|
+import org.springblade.core.redis.cache.BladeRedis;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.feign.ArchiveFileTaskClient;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
|
-import org.springblade.meter.dto.MeterApprovalDTO;
|
|
|
-import org.springblade.meter.entity.ContractMeterPeriod;
|
|
|
-import org.springblade.meter.entity.MeterPeriod;
|
|
|
-import org.springblade.meter.entity.MiddleMeterApply;
|
|
|
-import org.springblade.meter.service.impl.ContractMeterPeriodServiceImpl;
|
|
|
-import org.springblade.meter.service.impl.MeterPeriodServiceImpl;
|
|
|
-import org.springblade.meter.service.impl.MiddleMeterApplyServiceImpl;
|
|
|
+import org.springblade.meter.dto.*;
|
|
|
+import org.springblade.meter.entity.*;
|
|
|
+import org.springblade.meter.service.impl.*;
|
|
|
+import org.springblade.meter.vo.TaskDataDetailVO;
|
|
|
+import org.springblade.meter.vo.TaskDetailVO;
|
|
|
+import org.springblade.meter.vo.TaskPageVO;
|
|
|
+import org.springblade.producer.bean.PushMessage;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.lang.reflect.InvocationTargetException;
|
|
|
+import java.lang.reflect.Method;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
@@ -32,17 +57,30 @@ import java.util.List;
|
|
|
public class TaskController extends BladeController {
|
|
|
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
+ private final BladeRedis bladeRedis;
|
|
|
+ private final ArchiveFileTaskClient archiveFileTaskClient;
|
|
|
+ private final TaskClient taskClient;
|
|
|
private final ContractMeterPeriodServiceImpl contractMeterPeriodService;
|
|
|
private final MeterPeriodServiceImpl periodService;
|
|
|
- private final MiddleMeterApplyServiceImpl meterApplyService;
|
|
|
+ private final MiddleMeterApplyServiceImpl middleMeterApplyService;
|
|
|
+ private final InventoryFormApplyServiceImpl inventoryFormApplyService;
|
|
|
+ private final MiddleMeterApplyServiceTaskImpl middleMeterApplyServiceTask;
|
|
|
+ private final InventoryFormApplyServiceTaskImpl inventoryFormApplyServiceTask;
|
|
|
+ private final MaterialMeterFormServiceImpl materialMeterFormService;
|
|
|
+ private final MaterialMeterFormServiceTaskImpl materialMeterFormServiceTask;
|
|
|
+ private final StartPayMeterFormServiceImpl startPayMeterFormService;
|
|
|
+ private final StartPayMeterFormServiceTaskImpl startPayMeterFormServiceTask;
|
|
|
+ private final AttachmentFormServiceImpl attachmentFormService;
|
|
|
+ private final AttachmentFormServiceTaskImpl attachmentFormServiceTask;
|
|
|
|
|
|
@GetMapping("/name")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
- @ApiOperation(value = "获取任务名称", notes = "传入合同段contractId、期数id、type=1(中间计量申请)、=2(材料计量单、开工预付款计量单)")
|
|
|
+ @ApiOperation(value = "获取任务名称", notes = "传入合同段contractId、期数id、type=1(中间计量申请)、=2(材料计量单、开工预付款计量单)、=3(变更令)")
|
|
|
public R<Object> name(@RequestParam String contractId, @RequestParam String id, @RequestParam String type) {
|
|
|
String name = null;
|
|
|
if (ObjectUtil.isNotEmpty(contractId) && ObjectUtil.isNotEmpty(id)) {
|
|
|
- ContractInfo contractInfo = jdbcTemplate.query("SELECT contract_name FROM m_contract_info WHERE id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
+ ContractInfo contractInfo = jdbcTemplate.query("SELECT contract_name FROM m_contract_info WHERE id = " + contractId,
|
|
|
+ new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
if (("1").equals(type)) {
|
|
|
ContractMeterPeriod contractMeterPeriod = contractMeterPeriodService.getById(id);
|
|
@@ -54,32 +92,1269 @@ public class TaskController extends BladeController {
|
|
|
if (contractInfo != null && meterPeriod != null) {
|
|
|
name = "【" + contractInfo.getContractName() + "】" + date + " 中间计量申请【" + meterPeriod.getPeriodNumber() + "】";
|
|
|
}
|
|
|
+ } else if (("3").equals(type)) {
|
|
|
+ //TODO 变更令
|
|
|
}
|
|
|
}
|
|
|
return R.data(200, name, "操作成功");
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/approval")
|
|
|
+ @PostMapping("/report")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
- @ApiOperation(value = "上报(发起审批)", notes = "传入MeterApprovalDTO")
|
|
|
+ @ApiOperation(value = "任务上报", notes = "(中期计量申请、材料计量单、开工预付款计量单)传入MeterApprovalDTO")
|
|
|
+ @PushMessage(clientId = ClientIdConstant.METER_CLIENT_ID)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public R<Object> approval(@RequestBody MeterApprovalDTO approvalDTO) {
|
|
|
- if (ObjectUtil.isNotEmpty(approvalDTO.getType()) && (approvalDTO.getType().equals(1) || approvalDTO.getType().equals(2))) {
|
|
|
- if (approvalDTO.getType().equals(1)) { /*中间计量申请*/
|
|
|
- /*获取所有中间计量申请*/
|
|
|
- List<MiddleMeterApply> middleMeterApplies = meterApplyService.getBaseMapper().selectList(Wrappers.<MiddleMeterApply>lambdaQuery()
|
|
|
+ if (ObjectUtil.isEmpty(approvalDTO.getBatch())
|
|
|
+ || ObjectUtil.isEmpty(approvalDTO.getPeriodId())
|
|
|
+ || ObjectUtil.isEmpty(approvalDTO.getProjectId())
|
|
|
+ || ObjectUtil.isEmpty(approvalDTO.getContractId())
|
|
|
+ || ObjectUtil.isEmpty(approvalDTO.getTaskName())
|
|
|
+ || ObjectUtil.isEmpty(approvalDTO.getRestrictDay())) {
|
|
|
+ throw new ServiceException("请求入参数据异常,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(approvalDTO.getTaskUserIds()) && ObjectUtil.isEmpty(approvalDTO.getFixedFlowId())) {
|
|
|
+ throw new ServiceException("未获取到任务人信息,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(approvalDTO.getType()) && (approvalDTO.getType().equals(1) || approvalDTO.getType().equals(2) || approvalDTO.getType().equals(3))) {
|
|
|
+ if (approvalDTO.getType().equals(1)) {
|
|
|
+ /*==================== 中间计量申请 ====================*/
|
|
|
+ Long taskId = SnowFlakeUtil.getId();
|
|
|
+ /*获取当前期数下的所有中间计量申请*/
|
|
|
+ List<MiddleMeterApply> middleMeterApplies = middleMeterApplyService.getBaseMapper().selectList(Wrappers.<MiddleMeterApply>lambdaQuery()
|
|
|
.eq(MiddleMeterApply::getContractPeriodId, approvalDTO.getPeriodId()));
|
|
|
|
|
|
+ /*判断是否都是未上报、或已废除*/
|
|
|
+ long countMiddleMeterApplies = middleMeterApplies.stream().filter(f -> !Arrays.asList(0, 3).contains(f.getApproveStatus())).count();
|
|
|
+ if (countMiddleMeterApplies > 0) {
|
|
|
+ throw new ServiceException("当前期数的数据中存在已上报的任务,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
/*获取所有中间计量申请下的清单信息*/
|
|
|
+ List<Long> middleMeterAppliesIds = middleMeterApplies.stream().map(MiddleMeterApply::getId).collect(Collectors.toList());
|
|
|
+ List<InventoryFormApply> inventoryFormApplies = inventoryFormApplyService.getBaseMapper().selectList(Wrappers.<InventoryFormApply>lambdaQuery()
|
|
|
+ .in(InventoryFormApply::getMiddleMeterId, middleMeterAppliesIds)
|
|
|
+ .eq(InventoryFormApply::getContractPeriodId, approvalDTO.getPeriodId()));
|
|
|
+ List<Long> inventoryFormAppliesIds = inventoryFormApplies.stream().map(InventoryFormApply::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ /*判断是否都是未上报、或已废除*/
|
|
|
+ long countInventoryFormApplies = inventoryFormApplies.stream().filter(f -> !Arrays.asList(0, 3).contains(f.getApproveStatus())).count();
|
|
|
+ if (countInventoryFormApplies > 0) {
|
|
|
+ throw new ServiceException("当前期数的清单数据中存在已上报的任务,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*复制中间计量申请数据任务VO*/
|
|
|
+ List<MiddleMeterApplyTask> copyMiddleMeterApplies = BeanUtil.copyProperties(middleMeterApplies, MiddleMeterApplyTask.class);
|
|
|
+ for (MiddleMeterApplyTask copyMiddleMeterApply : copyMiddleMeterApplies) {
|
|
|
+ copyMiddleMeterApply.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ boolean b_1 = middleMeterApplyServiceTask.saveBatch(copyMiddleMeterApplies, 1000);
|
|
|
+
|
|
|
+ /*复制清单信息数据任务VO*/
|
|
|
+ List<InventoryFormApplyTask> inventoryFormApplyTasks = BeanUtil.copyProperties(inventoryFormApplies, InventoryFormApplyTask.class);
|
|
|
+ for (InventoryFormApplyTask inventoryFormApplyTask : inventoryFormApplyTasks) {
|
|
|
+ inventoryFormApplyTask.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ boolean b_2 = inventoryFormApplyServiceTask.saveBatch(inventoryFormApplyTasks, 1000);
|
|
|
+
|
|
|
+ if (b_1 && b_2) {
|
|
|
+ /*获取计量中间件的附件信息*/
|
|
|
+ List<AttachmentForm> attachmentForms = attachmentFormService.getBaseMapper().selectList(Wrappers.<AttachmentForm>lambdaQuery()
|
|
|
+ .in(AttachmentForm::getMasterId, middleMeterAppliesIds)
|
|
|
+ .eq(AttachmentForm::getContractId, approvalDTO.getContractId())
|
|
|
+ .eq(AttachmentForm::getProjectId, approvalDTO.getProjectId()));
|
|
|
+ List<AttachmentFormTask> attachmentFormTasks = BeanUtil.copyProperties(attachmentForms, AttachmentFormTask.class);
|
|
|
+ for (AttachmentFormTask attachmentFormTask : attachmentFormTasks) {
|
|
|
+ attachmentFormTask.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ /*复制计量中间件的附件信息VO*/
|
|
|
+ attachmentFormServiceTask.saveBatch(attachmentFormTasks, 1000);
|
|
|
+
|
|
|
+ /*构造创建审批任务*/
|
|
|
+ Set<String> aopParamsSet = new HashSet<>();
|
|
|
+ try {
|
|
|
+ this.buildTaskInfo(taskId, approvalDTO, aopParamsSet, 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("创建审批任务异常,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*修改数据源状态为=待审批*/
|
|
|
+ List<BaseService<?>> baseServiceList_1 = new ArrayList<>();
|
|
|
+ baseServiceList_1.add(middleMeterApplyService);
|
|
|
+ baseServiceList_1.add(middleMeterApplyServiceTask);
|
|
|
+
|
|
|
+ List<BaseService<?>> baseServiceList_2 = new ArrayList<>();
|
|
|
+ baseServiceList_2.add(inventoryFormApplyService);
|
|
|
+ baseServiceList_2.add(inventoryFormApplyServiceTask);
|
|
|
+
|
|
|
+ Map<List<Long>, List<BaseService<?>>> serviceMap = new HashMap<>();
|
|
|
+ serviceMap.put(middleMeterAppliesIds, baseServiceList_1);
|
|
|
+ serviceMap.put(inventoryFormAppliesIds, baseServiceList_2);
|
|
|
+
|
|
|
+ this.updateApproveStatus(serviceMap, 1); //待审批
|
|
|
+
|
|
|
+ return R.data(200, aopParamsSet, "操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (approvalDTO.getType().equals(2)) {
|
|
|
+ /*==================== 材料计量单 ====================*/
|
|
|
+ Long taskId = SnowFlakeUtil.getId();
|
|
|
+ /*获取当前期数下的所有材料*/
|
|
|
+ List<MaterialMeterForm> materialMeterForms = materialMeterFormService.getBaseMapper().selectList(Wrappers.<MaterialMeterForm>lambdaQuery()
|
|
|
+ .eq(MaterialMeterForm::getMeterPeriodId, approvalDTO.getPeriodId()));
|
|
|
+
|
|
|
+ /*判断是否都是未上报、或已废除*/
|
|
|
+ long countMaterialMeterForms = materialMeterForms.stream().filter(f -> !Arrays.asList(0, 3).contains(f.getApproveStatus())).count();
|
|
|
+ if (countMaterialMeterForms > 0) {
|
|
|
+ throw new ServiceException("当前期数的数据中存在已上报的任务,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> materialMeterFormsIds = materialMeterForms.stream().map(MaterialMeterForm::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ /*复制材料计量单数据任务VO*/
|
|
|
+ List<MaterialMeterFormTask> materialMeterFormTasks = BeanUtil.copyProperties(materialMeterForms, MaterialMeterFormTask.class);
|
|
|
+ for (MaterialMeterFormTask materialMeterFormTask : materialMeterFormTasks) {
|
|
|
+ materialMeterFormTask.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ boolean b = materialMeterFormServiceTask.saveBatch(materialMeterFormTasks, 1000);
|
|
|
+
|
|
|
+ if (b) {
|
|
|
+ /*获取材料的附件信息*/
|
|
|
+ List<AttachmentForm> attachmentForms = attachmentFormService.getBaseMapper().selectList(Wrappers.<AttachmentForm>lambdaQuery()
|
|
|
+ .in(AttachmentForm::getMasterId, materialMeterFormsIds)
|
|
|
+ .eq(AttachmentForm::getContractId, approvalDTO.getContractId())
|
|
|
+ .eq(AttachmentForm::getProjectId, approvalDTO.getProjectId()));
|
|
|
+ List<AttachmentFormTask> attachmentFormTasks = BeanUtil.copyProperties(attachmentForms, AttachmentFormTask.class);
|
|
|
+ for (AttachmentFormTask attachmentFormTask : attachmentFormTasks) {
|
|
|
+ attachmentFormTask.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ /*复制材料的附件信息VO*/
|
|
|
+ attachmentFormServiceTask.saveBatch(attachmentFormTasks, 1000);
|
|
|
+
|
|
|
+ /*构造创建审批任务*/
|
|
|
+ Set<String> aopParamsSet = new HashSet<>();
|
|
|
+ try {
|
|
|
+ this.buildTaskInfo(taskId, approvalDTO, aopParamsSet, 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("创建审批任务异常,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*修改数据源状态为=待审批*/
|
|
|
+ List<BaseService<?>> baseServiceList_1 = new ArrayList<>();
|
|
|
+ baseServiceList_1.add(materialMeterFormService);
|
|
|
+ baseServiceList_1.add(materialMeterFormServiceTask);
|
|
|
+
|
|
|
+ Map<List<Long>, List<BaseService<?>>> serviceMap = new HashMap<>();
|
|
|
+ serviceMap.put(materialMeterFormsIds, baseServiceList_1);
|
|
|
+
|
|
|
+ this.updateApproveStatus(serviceMap, 1); //待审批
|
|
|
+
|
|
|
+ return R.data(200, aopParamsSet, "操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (approvalDTO.getType().equals(3)) {
|
|
|
+ /*==================== 开工预付款计量单 ====================*/
|
|
|
+ Long taskId = SnowFlakeUtil.getId();
|
|
|
+ /*获取当前期数下的所有开工预付款计量单*/
|
|
|
+ List<StartPayMeterForm> startPayMeterForms = startPayMeterFormService.getBaseMapper().selectList(Wrappers.<StartPayMeterForm>lambdaQuery()
|
|
|
+ .eq(StartPayMeterForm::getMeterPeriodId, approvalDTO.getPeriodId()));
|
|
|
+
|
|
|
+ /*判断是否都是未上报、或已废除*/
|
|
|
+ long countStartPayMeterForms = startPayMeterForms.stream().filter(f -> !Arrays.asList(0, 3).contains(f.getApproveStatus())).count();
|
|
|
+ if (countStartPayMeterForms > 0) {
|
|
|
+ throw new ServiceException("当前期数的数据中存在已上报的任务,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> startPayMeterFormsIds = startPayMeterForms.stream().map(StartPayMeterForm::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ /*复制开工预付款计量单数据任务VO*/
|
|
|
+ List<StartPayMeterFormTask> startPayMeterFormTasks = BeanUtil.copyProperties(startPayMeterForms, StartPayMeterFormTask.class);
|
|
|
+ for (StartPayMeterFormTask startPayMeterFormTask : startPayMeterFormTasks) {
|
|
|
+ startPayMeterFormTask.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ boolean b = startPayMeterFormServiceTask.saveBatch(startPayMeterFormTasks, 1000);
|
|
|
+
|
|
|
+ if (b) {
|
|
|
+ /*获取开工预付款的附件信息*/
|
|
|
+ List<AttachmentForm> attachmentForms = attachmentFormService.getBaseMapper().selectList(Wrappers.<AttachmentForm>lambdaQuery()
|
|
|
+ .in(AttachmentForm::getMasterId, startPayMeterFormsIds)
|
|
|
+ .eq(AttachmentForm::getContractId, approvalDTO.getContractId())
|
|
|
+ .eq(AttachmentForm::getProjectId, approvalDTO.getProjectId()));
|
|
|
+ List<AttachmentFormTask> attachmentFormTasks = BeanUtil.copyProperties(attachmentForms, AttachmentFormTask.class);
|
|
|
+ for (AttachmentFormTask attachmentFormTask : attachmentFormTasks) {
|
|
|
+ attachmentFormTask.setTaskId(taskId);
|
|
|
+ }
|
|
|
+ /*复制开工预付款的附件信息VO*/
|
|
|
+ attachmentFormServiceTask.saveBatch(attachmentFormTasks, 1000);
|
|
|
+
|
|
|
+ /*构造创建审批任务*/
|
|
|
+ Set<String> aopParamsSet = new HashSet<>();
|
|
|
+ try {
|
|
|
+ this.buildTaskInfo(taskId, approvalDTO, aopParamsSet, 3);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("创建审批任务异常,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*修改数据源状态为=待审批*/
|
|
|
+ List<BaseService<?>> baseServiceList_1 = new ArrayList<>();
|
|
|
+ baseServiceList_1.add(startPayMeterFormService);
|
|
|
+ baseServiceList_1.add(startPayMeterFormServiceTask);
|
|
|
+
|
|
|
+ Map<List<Long>, List<BaseService<?>>> serviceMap = new HashMap<>();
|
|
|
+ serviceMap.put(startPayMeterFormsIds, baseServiceList_1);
|
|
|
+
|
|
|
+ this.updateApproveStatus(serviceMap, 1); //待审批
|
|
|
+
|
|
|
+ return R.data(200, aopParamsSet, "操作成功");
|
|
|
+ }
|
|
|
+ } else if (approvalDTO.getType().equals(4)) {
|
|
|
+ /*==================== 变更令 ====================*/
|
|
|
+ //TODO
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构造创建审批任务
|
|
|
+ *
|
|
|
+ * @param taskId
|
|
|
+ * @param approvalDTO
|
|
|
+ * @param aopParamsSet
|
|
|
+ * @param meterTaskType
|
|
|
+ */
|
|
|
+ private void buildTaskInfo(Long taskId, MeterApprovalDTO approvalDTO, Set<String> aopParamsSet, Integer meterTaskType) {
|
|
|
+ /*预设流程,获取对应任务人id*/
|
|
|
+ String resultString = "";
|
|
|
+ if (ObjectUtil.isNotEmpty(approvalDTO.getFixedFlowId())) {
|
|
|
+ List<FixedFlowLink> fixedFlowLinks = jdbcTemplate.query("select fixed_flow_link_user,fixed_flow_link_sort from u_fixed_flow_link " +
|
|
|
+ "where fixed_flow_id = " + approvalDTO.getFixedFlowId(), new BeanPropertyRowMapper<>(FixedFlowLink.class));
|
|
|
+ if (fixedFlowLinks.size() > 0) {
|
|
|
+ fixedFlowLinks.sort(Comparator.comparingInt(FixedFlowLink::getFixedFlowLinkSort));
|
|
|
+ StringBuilder sortStr = new StringBuilder();
|
|
|
+ for (FixedFlowLink link : fixedFlowLinks) {
|
|
|
+ sortStr.append(link.getFixedFlowLinkUser()).append(",");
|
|
|
+ }
|
|
|
+ if (sortStr.length() > 0) {
|
|
|
+ sortStr.deleteCharAt(sortStr.length() - 1);
|
|
|
+ }
|
|
|
+ resultString = sortStr.toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*如果是预设流程,重新赋值任务人id*/
|
|
|
+ if (ObjectUtil.isNotEmpty(resultString)) {
|
|
|
+ /*检查预设任务流程的任务人是否存在签字证书信息*/
|
|
|
+ R<Object> objectR = archiveFileTaskClient.checkTaskUserCertificateInfo(resultString);
|
|
|
+ if (objectR.isSuccess()) {
|
|
|
+ approvalDTO.setTaskUserIds(resultString);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("未获取到预设任务流程的任务人的签字证书信息,操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isEmpty(approvalDTO.getTaskUserIds())) {
|
|
|
+ throw new ServiceException("未获取到任务人信息,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*主任务*/
|
|
|
+ Long processInstanceId = SnowFlakeUtil.getId();
|
|
|
+ Task task = new Task();
|
|
|
+ task.setId(taskId);
|
|
|
+ Date nowTime = new Date();
|
|
|
+ task.setStartTime(DateUtil.format(nowTime, "yyyy-MM-dd"));
|
|
|
+ task.setEndTime(DateUtil.format(DateUtils.addDays(nowTime, approvalDTO.getRestrictDay()), "yyyy-MM-dd"));
|
|
|
+ task.setProcessDefinitionId(SnowFlakeUtil.getId().toString());
|
|
|
+ task.setProcessInstanceId(processInstanceId.toString()); //实例id
|
|
|
+ task.setReportUser(AuthUtil.getUserId().toString());
|
|
|
+ task.setReportUserName(AuthUtil.getNickName());
|
|
|
+ task.setCreateUser(AuthUtil.getUserId());
|
|
|
+ task.setCreateTime(nowTime);
|
|
|
+ task.setUpdateTime(nowTime);
|
|
|
+ task.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ task.setCreateDept(null);
|
|
|
+ task.setTaskContent(ObjectUtil.isNotEmpty(approvalDTO.getTaskDesc()) ? approvalDTO.getTaskDesc() : null);
|
|
|
+ task.setTaskUser(null);
|
|
|
+ task.setFormDataId(approvalDTO.getPeriodId().toString()); //数据指向,指向期数id
|
|
|
+ task.setTaskName(approvalDTO.getTaskName());
|
|
|
+ task.setContractId(approvalDTO.getContractId().toString());
|
|
|
+ task.setProjectId(approvalDTO.getProjectId().toString());
|
|
|
+ task.setBatch(approvalDTO.getBatch());
|
|
|
+ task.setMeterTaskType(meterTaskType); //计量任务类型 1=中间计量申请,2=材料计量单,3=开工预付款计量单
|
|
|
+
|
|
|
+ task.setType(1);
|
|
|
+ task.setApprovalType(5); //计量
|
|
|
+ task.setFixedFlowId(0L);
|
|
|
+ task.setStatus(1); //待审批
|
|
|
+ task.setIsDeleted(0);
|
|
|
+ taskClient.saveTask(task);
|
|
|
+
|
|
|
+ Map<Long, String> nameMap = jdbcTemplate.query("select id,name from blade_user where is_deleted = 0"
|
|
|
+ , new BeanPropertyRowMapper<>(User.class)).stream().collect(Collectors.toMap(User::getId, User::getName, (key1, key2) -> key1));
|
|
|
+
|
|
|
+ /*副任务(approvalDTO.getTaskUserIds()是按顺序构造,所以创建的任务也是按照顺序构造)*/
|
|
|
+ String[] userIds = approvalDTO.getTaskUserIds().split(",");
|
|
|
+ int sort = 1;
|
|
|
+ for (String userId : userIds) {
|
|
|
+ TaskParallel taskParallel = new TaskParallel();
|
|
|
+ taskParallel.setId(SnowFlakeUtil.getId());
|
|
|
+ taskParallel.setProcessInstanceId(processInstanceId.toString());
|
|
|
+ taskParallel.setParallelProcessInstanceId(SnowFlakeUtil.getId().toString());
|
|
|
+ taskParallel.setTaskUser(userId);
|
|
|
+ if (nameMap.get(Long.parseLong(userId)) != null) {
|
|
|
+ taskParallel.setTaskUserName(nameMap.get(Long.parseLong(userId)));
|
|
|
+ }
|
|
|
+ taskParallel.setInitiative(1);
|
|
|
+ taskParallel.setCreateUser(AuthUtil.getUserId());
|
|
|
+ taskParallel.setCreateTime(nowTime);
|
|
|
+ taskParallel.setUpdateTime(nowTime);
|
|
|
+ taskParallel.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ taskParallel.setCreateDept(null);
|
|
|
+ taskParallel.setStatus(1); //待审批
|
|
|
+ taskParallel.setIsDeleted(0);
|
|
|
+ taskParallel.setSort(sort++);
|
|
|
+ taskClient.saveTaskParallel(taskParallel);
|
|
|
+
|
|
|
+ String param = userId + "," + approvalDTO.getProjectId() + "," + approvalDTO.getContractId();
|
|
|
+ aopParamsSet.add(param);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改审批任务业务数据状态
|
|
|
+ *
|
|
|
+ * @param serviceMap
|
|
|
+ * @param approveStatus
|
|
|
+ */
|
|
|
+ private void updateApproveStatus(Map<List<Long>, List<BaseService<?>>> serviceMap, int approveStatus) {
|
|
|
+ for (Map.Entry<List<Long>, List<BaseService<?>>> entry : serviceMap.entrySet()) {
|
|
|
+ List<Long> ids = entry.getKey();
|
|
|
+ List<BaseService<?>> services = entry.getValue();
|
|
|
+ for (BaseService<?> service : services) {
|
|
|
+ updateEntityStatus(service, ids, approveStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private <T, U extends BaseService<T>> void updateEntityStatus(U service, List<Long> ids, int approveStatus) {
|
|
|
+ UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("id", ids);
|
|
|
+ T updateEntity = createUpdateEntity(service.getEntityClass());
|
|
|
+ setApproveStatus(updateEntity, approveStatus);
|
|
|
+ service.update(updateEntity, updateWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ private <T> T createUpdateEntity(Class<T> entityClass) {
|
|
|
+ try {
|
|
|
+ return entityClass.newInstance();
|
|
|
+ } catch (InstantiationException | IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new ServiceException("createUpdateEntity构造失败,msg:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private <T> void setApproveStatus(T entity, int approveStatus) {
|
|
|
+ try {
|
|
|
+ Method setApproveStatusMethod = entity.getClass().getMethod("setApproveStatus", Integer.TYPE);
|
|
|
+ setApproveStatusMethod.invoke(entity, approveStatus);
|
|
|
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new ServiceException("修改业务数据审批状态失败,msg:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/repeal")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "任务废除(任务撤销、驳回审批)", notes = "按一期废除,即按整条任务废除(中期计量申请、材料计量单、开工预付款计量单、任务查看-废除任务)")
|
|
|
+ @PushMessage(clientId = ClientIdConstant.METER_CLIENT_ID)
|
|
|
+ public R<Object> repeal(@RequestBody TaskRepealDTO taskRepealDTO) {
|
|
|
+ if (ObjectUtil.isNotEmpty(taskRepealDTO) && ObjectUtil.isNotEmpty(taskRepealDTO.getTaskId())) {
|
|
|
+ if (ObjectUtil.isNotEmpty(taskRepealDTO.getMeterTaskRepealDesc()) && taskRepealDTO.getMeterTaskRepealDesc().length() > 1000) {
|
|
|
+ throw new ServiceException("任务废除原因过长,请重新输入");
|
|
|
+ }
|
|
|
+ Task task = jdbcTemplate.query("SELECT * FROM u_task WHERE id = " + taskRepealDTO.getTaskId(), new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
+ if (task != null) {
|
|
|
+ /*校验当前用户是否为当前轮次审批人*/
|
|
|
+ String processInstanceId = task.getProcessInstanceId();
|
|
|
+ List<TaskParallel> taskParallels = jdbcTemplate.query("SELECT * FROM u_task_parallel WHERE process_instance_id = '" + processInstanceId + "' ORDER BY sort", new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
+ List<String> taskParallelsUserIds = taskParallels.stream().map(TaskParallel::getTaskUser).collect(Collectors.toList());
|
|
|
+ boolean previousUsersApproved = true;
|
|
|
+ List<String> name = new ArrayList<>();
|
|
|
+ for (TaskParallel parallel : taskParallels) {
|
|
|
+ //判断是否有人未审批
|
|
|
+ if (parallel.getStatus() != 2) {
|
|
|
+ previousUsersApproved = false;
|
|
|
+ name.add(parallel.getTaskUserName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //判断是否是当前用户之前的用户
|
|
|
+ if (parallel.getTaskUser().equals(AuthUtil.getUserId().toString())) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!previousUsersApproved) {
|
|
|
+ throw new ServiceException("当前任务还有【" + StringUtils.join(name, "、") + "】未完成审批,请您稍后再试");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*修改主任务、副任务状态*/
|
|
|
+ jdbcTemplate.execute("UPDATE u_task SET status = 3,meter_task_repeal_desc = '" + taskRepealDTO.getMeterTaskRepealDesc() + "' WHERE id = " + taskRepealDTO.getTaskId());
|
|
|
+ jdbcTemplate.execute("UPDATE u_task_parallel SET status = 3 WHERE process_instance_id = '" + processInstanceId + "'");
|
|
|
+
|
|
|
+ /*修改业务状态=未上报,业务复制数据taskVO全部删除(存在重新上报的情况,那么如果历史复制数据存在,会导致主键冲突,因为关联数据是copy的)*/
|
|
|
+ if (ObjectUtil.isNotEmpty(task.getFormDataId())) {
|
|
|
+ String periodId = task.getFormDataId();
|
|
|
+ if (task.getMeterTaskType().equals(1)) {
|
|
|
+ /*==================== 中间计量申请 ====================*/
|
|
|
+ /*获取原始中间计量申请数据*/
|
|
|
+ List<MiddleMeterApply> middleMeterApplies = middleMeterApplyService.getBaseMapper().selectList(Wrappers.<MiddleMeterApply>lambdaQuery()
|
|
|
+ .eq(MiddleMeterApply::getContractPeriodId, periodId));
|
|
|
+ List<Long> middleMeterAppliesIds = middleMeterApplies.stream().map(MiddleMeterApply::getId).collect(Collectors.toList());
|
|
|
+ /*中间计量申请下的清单信息*/
|
|
|
+ List<InventoryFormApply> inventoryFormApplies = inventoryFormApplyService.getBaseMapper().selectList(Wrappers.<InventoryFormApply>lambdaQuery()
|
|
|
+ .in(InventoryFormApply::getMiddleMeterId, middleMeterAppliesIds)
|
|
|
+ .eq(InventoryFormApply::getContractPeriodId, periodId));
|
|
|
+ List<Long> inventoryFormAppliesIds = inventoryFormApplies.stream().map(InventoryFormApply::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ /*修改数据源状态为=未上报*/
|
|
|
+ List<BaseService<?>> baseServiceList_1 = new ArrayList<>();
|
|
|
+ baseServiceList_1.add(middleMeterApplyService);
|
|
|
+ List<BaseService<?>> baseServiceList_2 = new ArrayList<>();
|
|
|
+ baseServiceList_2.add(inventoryFormApplyService);
|
|
|
+
|
|
|
+ Map<List<Long>, List<BaseService<?>>> serviceMap = new HashMap<>();
|
|
|
+ serviceMap.put(middleMeterAppliesIds, baseServiceList_1);
|
|
|
+ serviceMap.put(inventoryFormAppliesIds, baseServiceList_2);
|
|
|
+
|
|
|
+ this.updateApproveStatus(serviceMap, 0); //未上报
|
|
|
+
|
|
|
+ /*删除业务复制数据taskVO*/
|
|
|
+ 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());
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_attachment_form_task WHERE task_id = " + taskRepealDTO.getTaskId());
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(2)) {
|
|
|
+ /*==================== 材料计量单 ====================*/
|
|
|
+ /*获取原始的材料数量*/
|
|
|
+ List<MaterialMeterForm> materialMeterForms = materialMeterFormService.getBaseMapper().selectList(Wrappers.<MaterialMeterForm>lambdaQuery()
|
|
|
+ .eq(MaterialMeterForm::getMeterPeriodId, periodId));
|
|
|
+ List<Long> materialMeterFormsIds = materialMeterForms.stream().map(MaterialMeterForm::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ /*修改数据源状态为=未上报*/
|
|
|
+ List<BaseService<?>> baseServiceList_1 = new ArrayList<>();
|
|
|
+ baseServiceList_1.add(materialMeterFormService);
|
|
|
+
|
|
|
+ Map<List<Long>, List<BaseService<?>>> serviceMap = new HashMap<>();
|
|
|
+ serviceMap.put(materialMeterFormsIds, baseServiceList_1);
|
|
|
+
|
|
|
+ this.updateApproveStatus(serviceMap, 0); //未上报
|
|
|
+
|
|
|
+ /*删除业务复制数据taskVO*/
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_material_meter_form_task WHERE meter_period_id = '" + periodId + "' AND task_id = " + taskRepealDTO.getTaskId());
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_attachment_form_task WHERE task_id = " + taskRepealDTO.getTaskId());
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(3)) {
|
|
|
+ /*==================== 开工预付款计量单 ====================*/
|
|
|
+ /*获取当前期数下的所有材料*/
|
|
|
+ List<StartPayMeterForm> startPayMeterForms = startPayMeterFormService.getBaseMapper().selectList(Wrappers.<StartPayMeterForm>lambdaQuery()
|
|
|
+ .eq(StartPayMeterForm::getMeterPeriodId, periodId));
|
|
|
+ List<Long> startPayMeterFormsIds = startPayMeterForms.stream().map(StartPayMeterForm::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ /*修改数据源状态为=未上报*/
|
|
|
+ List<BaseService<?>> baseServiceList_1 = new ArrayList<>();
|
|
|
+ baseServiceList_1.add(startPayMeterFormService);
|
|
|
+
|
|
|
+ Map<List<Long>, List<BaseService<?>>> serviceMap = new HashMap<>();
|
|
|
+ serviceMap.put(startPayMeterFormsIds, baseServiceList_1);
|
|
|
+
|
|
|
+ this.updateApproveStatus(serviceMap, 0); //未上报
|
|
|
+
|
|
|
+ /*删除业务复制数据taskVO*/
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_start_pay_meter_form_task WHERE meter_period_id = '" + periodId + "' AND task_id = " + taskRepealDTO.getTaskId());
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_attachment_form_task WHERE task_id = " + taskRepealDTO.getTaskId());
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(4)) {
|
|
|
+ //TODO 变更令
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> aopParamsSet = new HashSet<>();
|
|
|
+ for (String userId : taskParallelsUserIds) {
|
|
|
+ String param = userId + "," + taskRepealDTO.getProjectId() + "," + taskRepealDTO.getContractId();
|
|
|
+ aopParamsSet.add(param);
|
|
|
+ }
|
|
|
+ return R.data(200, aopParamsSet, "操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("未获取到任务信息,操作失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询
|
|
|
+ */
|
|
|
+ @PostMapping("/page")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "分页查询", notes = "传入TaskPageDTO")
|
|
|
+ public R<IPage<TaskPageVO>> page(@RequestBody TaskPageDTO dto) throws IOException {
|
|
|
+ if (ObjectUtil.isEmpty(dto.getProjectId()) || ObjectUtil.isEmpty(dto.getContractId())) {
|
|
|
+ throw new ServiceException("未获取到当前项目或合同段信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ //封装入参SQL
|
|
|
+ int current = dto.getCurrent();
|
|
|
+ int size = dto.getSize();
|
|
|
+ List<Object> params = new ArrayList<>();
|
|
|
+ StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type = 5"); //approval_type = 5 计量任务
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getProjectId()) && ObjectUtil.isNotEmpty(dto.getContractId())) {
|
|
|
+ sqlString.append(" AND project_id = ? AND contract_id = ?");
|
|
|
+ params.add(dto.getProjectId());
|
|
|
+ params.add(dto.getContractId());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getTypeValue())) {
|
|
|
+ sqlString.append(" AND type = ?");
|
|
|
+ params.add(dto.getTypeValue());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getStatusValue())) {
|
|
|
+ sqlString.append(" AND status = ?");
|
|
|
+ params.add(dto.getStatusValue());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getBatchValue())) {
|
|
|
+ sqlString.append(" AND batch = ?");
|
|
|
+ params.add(dto.getBatchValue());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getStartTimeValue()) && StringUtils.isNotBlank(dto.getEndTimeValue())) {
|
|
|
+ sqlString.append(" AND start_time >= ?")
|
|
|
+ .append(" AND end_time <= ?");
|
|
|
+ params.add(dto.getStartTimeValue());
|
|
|
+ params.add(dto.getEndTimeValue());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getQueryValue())) {
|
|
|
+ sqlString.append(" AND task_name LIKE ?");
|
|
|
+ params.add("%" + dto.getQueryValue() + "%");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getSelectedType())) {
|
|
|
+ sqlString.append(" AND (");
|
|
|
+ if (dto.getSelectedType().equals(1)) { //待办页面
|
|
|
+
|
|
|
+ //如果是待办页面,且 任务状态下拉框 选择的是 待审批状态 的任务,那么才查询数据
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && dto.getStatusValue().equals(1)) {
|
|
|
+ sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status = ? AND u_task_parallel.task_user = ?)");
|
|
|
+ params.add(1);
|
|
|
+ params.add(SecureUtil.getUserId());
|
|
|
+
|
|
|
+ //如果是待办页面,且 任务状态下拉框 选择的不是 待审批状态 的任务,那么直接返回null
|
|
|
+ } else if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && !dto.getStatusValue().equals(1)) {
|
|
|
+ return null;
|
|
|
+
|
|
|
+ //如果是待办页面,没选择 任务状态下拉框,那么就默认查询 待审批状态 任务
|
|
|
+ } else if (ObjectUtil.isEmpty(dto.getStatusValue())) {
|
|
|
+ sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status = ? AND u_task_parallel.task_user = ?)");
|
|
|
+ params.add(1);
|
|
|
+ params.add(SecureUtil.getUserId());
|
|
|
+ sqlString.append(" AND status = 1");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (dto.getSelectedType().equals(2)) { //已办页面
|
|
|
+ sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status in(2,3) AND u_task_parallel.task_user = ?)");
|
|
|
+ //当前自己的任务必须是已审批、已废除 status = 2,3 ,才视为已办
|
|
|
+ params.add(SecureUtil.getUserId());
|
|
|
+
|
|
|
+ } else if (dto.getSelectedType().equals(3)) { //我发起页面
|
|
|
+ sqlString.append("report_user = ?");
|
|
|
+ params.add(SecureUtil.getUserId());
|
|
|
+ }
|
|
|
+ sqlString.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ //总数量
|
|
|
+ String sqlCount = sqlString.toString().replace("*", "count(1)");
|
|
|
+ Optional<Integer> totalCountOptional = Optional.ofNullable(jdbcTemplate.queryForObject(sqlCount, Integer.class, params.toArray()));
|
|
|
+ int totalCount = totalCountOptional.orElse(0);
|
|
|
+
|
|
|
+ //分页
|
|
|
+ sqlString.append(" ORDER BY create_time ASC LIMIT ? OFFSET ?;");
|
|
|
+ params.add(size);
|
|
|
+ params.add((current - 1) * size);
|
|
|
+
|
|
|
+ //执行SQL获取数据
|
|
|
+ String sqlPage = sqlString.toString();
|
|
|
+ List<Task> resultList = jdbcTemplate.query(
|
|
|
+ sqlPage,
|
|
|
+ new BeanPropertyRowMapper<>(Task.class),
|
|
|
+ params.toArray()
|
|
|
+ );
|
|
|
+
|
|
|
+ //获取任务详情信息Map
|
|
|
+ Set<String> processInstanceIds = resultList.stream().map(Task::getProcessInstanceId).collect(Collectors.toSet());
|
|
|
+ Map<String, List<TaskParallel>> taskParallelGroupMap = new HashMap<>();
|
|
|
+ if (processInstanceIds.size() > 0) {
|
|
|
+ String resultIds = processInstanceIds.stream()
|
|
|
+ .map(id -> "'" + id + "'")
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ taskParallelGroupMap = jdbcTemplate.query("select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,status,sort from u_task_parallel where process_instance_id in(" + resultIds + ") order by id", new BeanPropertyRowMapper<>(TaskParallel.class)).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+ }
|
|
|
+ Map<String, List<TaskParallel>> finalTaskParallelGroupMap = taskParallelGroupMap;
|
|
|
+
|
|
|
+ //获取用户信息Map
|
|
|
+ Map<Long, String> nameMap = jdbcTemplate.query("select id,name from blade_user where is_deleted = 0", new BeanPropertyRowMapper<>(User.class)).stream().collect(Collectors.toMap(User::getId, User::getName, (key1, key2) -> key1));
|
|
|
+
|
|
|
+ //解析page分页数据
|
|
|
+ IPage<TaskPageVO> page = new Page<>(current, size);
|
|
|
+ List<TaskPageVO> pageList = resultList.stream()
|
|
|
+ .map(task -> {
|
|
|
+ TaskPageVO vo = new TaskPageVO();
|
|
|
+ vo.setId(task.getId());
|
|
|
+ vo.setTaskName(task.getTaskName());
|
|
|
+ vo.setTaskTypeName(task.getType().equals(1) ? "普通任务" : task.getType().equals(2) ? "验收任务" : "移交任务");
|
|
|
+ vo.setTaskStatusName(task.getStatus().equals(1) ? "待审批" : task.getStatus().equals(2) ? "已审批" : "已废除");
|
|
|
+ vo.setStartTime(task.getStartTime());
|
|
|
+ vo.setEndTime(task.getEndTime());
|
|
|
+ vo.setType(task.getType());
|
|
|
+ vo.setTaskDesc(task.getTaskContent());
|
|
|
+ vo.setTaskReportUserName(nameMap.get(Long.parseLong(task.getReportUser())));
|
|
|
+ List<TaskParallel> taskParallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
+ if (taskParallelList != null && taskParallelList.size() > 0) {
|
|
|
+ List<String> names = taskParallelList.stream().map(TaskParallel::getTaskUserName).collect(Collectors.toList());
|
|
|
+ if (names.size() > 0) {
|
|
|
+ vo.setTaskApproveUserNames(StringUtils.join(names, ","));
|
|
|
+ }
|
|
|
+
|
|
|
+ //电签状态(始终只获取自己的电签任务状态信息)
|
|
|
+ TaskParallel taskParallel = taskParallelList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getTaskUser()) && f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
|
|
|
+ if (taskParallel != null) {
|
|
|
+ vo.setEVisaStatus(taskParallel.getEVisaContent() != null ? taskParallel.getEVisaContent() : "");
|
|
|
+ }
|
|
|
+ if (vo.getTaskStatusName().equals("已废除")) {
|
|
|
+ vo.setEVisaStatus("废除成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断签字人的验证 2=绿色 3=黄色 999=红色 其他代表=灰色
|
|
|
+ List<TaskParallel> statList = new ArrayList<>();
|
|
|
+ for (TaskParallel taskPa : taskParallelList) {
|
|
|
+ if (taskPa.getStatus() == 2 && ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 1) {
|
|
|
+ taskPa.setEVisaStatus(2);
|
|
|
+ } else if (taskPa.getStatus() == 3 && taskPa.getTaskUser().equals(SecureUtil.getUserId().toString())) {
|
|
|
+ taskPa.setEVisaStatus(3);
|
|
|
+ } else if (ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 99) {
|
|
|
+ taskPa.setEVisaStatus(999);
|
|
|
+ } else {
|
|
|
+ taskPa.setEVisaStatus(1);
|
|
|
+ }
|
|
|
+ statList.add(taskPa);
|
|
|
+ }
|
|
|
+ if (statList.size() > 0) {
|
|
|
+ List<Object> objectList = statList.stream()
|
|
|
+ .map(taskPa -> (Object) taskPa)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setTaskApproveUserNamesList(objectList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ page.setRecords(pageList);
|
|
|
+ page.setTotal(totalCount);
|
|
|
+ return R.data(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 任务详情
|
|
|
+ */
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "任务详情", notes = "传入任务id")
|
|
|
+ public R<TaskDetailVO> detail(@RequestParam String id) {
|
|
|
+ if (ObjectUtil.isEmpty(id)) {
|
|
|
+ throw new ServiceException("任务id不能为空");
|
|
|
+ }
|
|
|
+ TaskDetailVO vo = new TaskDetailVO();
|
|
|
+ Task task = jdbcTemplate.query("SELECT * FROM u_task WHERE id = " + id, new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
+ if (task != null) {
|
|
|
+ /*任务流程信息*/
|
|
|
+ List<TaskParallel> taskParallels = jdbcTemplate.query("select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,status,sort from u_task_parallel where process_instance_id = " + task.getProcessInstanceId() + " order by sort", new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
+ List<Map<String, String>> taskProcessInfo = new LinkedList<>();
|
|
|
+ for (TaskParallel taskParallel : taskParallels) {
|
|
|
+ Map<String, String> taskUserMap = new LinkedHashMap<>();
|
|
|
+ taskUserMap.put("name", taskParallel.getTaskUserName());
|
|
|
+ taskUserMap.put("date", taskParallel.getCreateTime().toString());
|
|
|
+ taskUserMap.put("status", taskParallel.getStatus().toString());
|
|
|
+ taskProcessInfo.add(taskUserMap);
|
|
|
+ }
|
|
|
+ vo.setTaskProcessInfo(taskProcessInfo);
|
|
|
+
|
|
|
+ /*中间业务taskVO数据*/
|
|
|
+ if (ObjectUtil.isNotEmpty(task.getFormDataId())) {
|
|
|
+ String periodId = task.getFormDataId();
|
|
|
+ if (task.getMeterTaskType().equals(1)) {
|
|
|
+ /*==================== 中间计量申请 ====================*/
|
|
|
+ List<MiddleMeterApplyTask> middleMeterApplyTasks = middleMeterApplyServiceTask.getBaseMapper().selectList(Wrappers.<MiddleMeterApplyTask>lambdaQuery()
|
|
|
+ .eq(MiddleMeterApplyTask::getContractPeriodId, periodId)
|
|
|
+ .eq(MiddleMeterApplyTask::getTaskId, task.getId())
|
|
|
+ );
|
|
|
+ vo.setTaskCenterDataInfo(Collections.singletonList(middleMeterApplyTasks));
|
|
|
|
|
|
+ } else if (task.getMeterTaskType().equals(2)) {
|
|
|
+ /*==================== 材料计量单 ====================*/
|
|
|
+ List<MaterialMeterFormTask> materialMeterFormTasks = materialMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<MaterialMeterFormTask>lambdaQuery()
|
|
|
+ .eq(MaterialMeterFormTask::getMeterPeriodId, periodId)
|
|
|
+ .eq(MaterialMeterFormTask::getTaskId, task.getId())
|
|
|
+ );
|
|
|
+ vo.setTaskCenterDataInfo(Collections.singletonList(materialMeterFormTasks));
|
|
|
|
|
|
+ } else if (task.getMeterTaskType().equals(3)) {
|
|
|
+ /*==================== 开工预付款计量单 ====================*/
|
|
|
+ List<StartPayMeterFormTask> startPayMeterFormTasks = startPayMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<StartPayMeterFormTask>lambdaQuery()
|
|
|
+ .eq(StartPayMeterFormTask::getMeterPeriodId, periodId)
|
|
|
+ .eq(StartPayMeterFormTask::getTaskId, task.getId())
|
|
|
+ );
|
|
|
+ vo.setTaskCenterDataInfo(Collections.singletonList(startPayMeterFormTasks));
|
|
|
|
|
|
- } else if (approvalDTO.getType().equals(2)) { /*材料、开工*/
|
|
|
+ } else if (task.getMeterTaskType().equals(4)) {
|
|
|
+ /*==================== 变更令 ====================*/
|
|
|
+ //TODO 变更令
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ if (ObjectUtil.isEmpty(id) || ObjectUtil.isEmpty(dataId)) {
|
|
|
+ throw new ServiceException("任务、数据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);
|
|
|
+ if (task != null) {
|
|
|
+ if (task.getMeterTaskType().equals(1)) {
|
|
|
+ MiddleMeterApplyTask middleMeterApplyTask = middleMeterApplyServiceTask.getById(dataId);
|
|
|
+ vo.setBasicsInfo(middleMeterApplyTask);
|
|
|
+ List<InventoryFormApplyTask> inventoryFormApplyTasks = inventoryFormApplyServiceTask.getBaseMapper().selectList(Wrappers.<InventoryFormApplyTask>lambdaQuery()
|
|
|
+ .eq(InventoryFormApplyTask::getTaskId, id)
|
|
|
+ .eq(InventoryFormApplyTask::getContractPeriodId, task.getFormDataId())
|
|
|
+ .eq(InventoryFormApplyTask::getMiddleMeterId, dataId));
|
|
|
+ vo.setAssociatedDataInfoList(Collections.singletonList(inventoryFormApplyTasks));
|
|
|
|
|
|
+ } else if (task.getMeterTaskType().equals(2)) {
|
|
|
+ MaterialMeterFormTask materialMeterFormTask = materialMeterFormServiceTask.getById(dataId);
|
|
|
+ vo.setBasicsInfo(materialMeterFormTask);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(3)) {
|
|
|
+ StartPayMeterFormTask startPayMeterFormTask = startPayMeterFormServiceTask.getById(dataId);
|
|
|
+ vo.setBasicsInfo(startPayMeterFormTask);
|
|
|
+ } else if (task.getMeterTaskType().equals(4)) {
|
|
|
+ //TODO 变更令
|
|
|
}
|
|
|
+
|
|
|
+ /*附件文件信息*/
|
|
|
+ List<AttachmentFormTask> attachmentFormTasks = attachmentFormServiceTask.getBaseMapper().selectList(Wrappers.<AttachmentFormTask>lambdaQuery()
|
|
|
+ .eq(AttachmentFormTask::getTaskId, id)
|
|
|
+ .eq(AttachmentFormTask::getMasterId, dataId));
|
|
|
+ vo.setAttachmentFormTask(attachmentFormTasks);
|
|
|
+ }
|
|
|
+ return R.data(200, vo, "操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/data/remove")
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
+ @ApiOperation(value = "任务关联的数据删除(清单、变更令删除)", notes = "传入任务id,数据dataId")
|
|
|
+ public R<Object> dataRemove(@RequestParam String id, @RequestParam String dataId) {
|
|
|
+ if (ObjectUtil.isEmpty(id) || ObjectUtil.isEmpty(dataId)) {
|
|
|
+ throw new ServiceException("任务、数据id不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ if (task != null) {
|
|
|
+ if (task.getMeterTaskType().equals(1)) {
|
|
|
+ /*清单*/
|
|
|
+ InventoryFormApplyTask inventoryFormApplyTask = inventoryFormApplyServiceTask.getById(dataId);
|
|
|
+ if (inventoryFormApplyTask != null) {
|
|
|
+ MiddleMeterApplyTask middleMeterApplyTask = middleMeterApplyServiceTask.getById(inventoryFormApplyTask.getMiddleMeterId());
|
|
|
+ if (middleMeterApplyTask != null && inventoryFormApplyServiceTask.removeById(inventoryFormApplyTask.getId())) {
|
|
|
+ BigDecimal currentMeterMoney = inventoryFormApplyTask.getCurrentMeterMoney();
|
|
|
+ BigDecimal currentMeterTotal = inventoryFormApplyTask.getCurrentMeterTotal();
|
|
|
+ BigDecimal result = currentMeterMoney.multiply(currentMeterTotal);
|
|
|
+
|
|
|
+ BigDecimal meterMoney = middleMeterApplyTask.getMeterMoney();
|
|
|
+ BigDecimal updatedMeterMoney = meterMoney.subtract(result); //相减
|
|
|
+
|
|
|
+ String updateSql = "UPDATE s_middle_meter_apply_task SET meter_money = ? WHERE id = ?";
|
|
|
+ Object[] params = {updatedMeterMoney, inventoryFormApplyTask.getMiddleMeterId()};
|
|
|
+ jdbcTemplate.update(updateSql, params);
|
|
|
+
|
|
|
+ return R.data(200, null, "操作成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(4)) {
|
|
|
+ /*变更令*/
|
|
|
+ //TODO
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return R.fail("操作失败");
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/data/inventoryFormApplyTask/update")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "清单数据修改", notes = "传入InventoryFormApplyTask")
|
|
|
+ public R<Object> dataInventoryFormApplyTaskUpdate(@RequestBody InventoryFormApplyTask obj) {
|
|
|
+ InventoryFormApplyTask inventoryFormApplyTask = inventoryFormApplyServiceTask.getById(obj.getId());
|
|
|
+
|
|
|
+ /*更新前数量*/
|
|
|
+ BigDecimal old = inventoryFormApplyTask.getCurrentMeterTotal();
|
|
|
+ /*更新后数量*/
|
|
|
+ BigDecimal update = obj.getCurrentMeterTotal();
|
|
|
+
|
|
|
+ /*如果更新前<更新后,相加*/
|
|
|
+ if (old.compareTo(update) < 0) {
|
|
|
+ BigDecimal total = update.subtract(old); //差值
|
|
|
+ BigDecimal currentMeterMoney = inventoryFormApplyTask.getCurrentMeterMoney();
|
|
|
+ BigDecimal result = currentMeterMoney.multiply(total);
|
|
|
+
|
|
|
+ if (inventoryFormApplyServiceTask.updateById(obj)) {
|
|
|
+
|
|
|
+ MiddleMeterApplyTask middleMeterApplyTask = middleMeterApplyServiceTask.getById(inventoryFormApplyTask.getMiddleMeterId());
|
|
|
+ if (middleMeterApplyTask != null) {
|
|
|
+ BigDecimal meterMoney = middleMeterApplyTask.getMeterMoney();
|
|
|
+ BigDecimal updatedMeterMoney = meterMoney.add(result); //相加
|
|
|
+
|
|
|
+ String updateSql = "UPDATE s_middle_meter_apply_task SET meter_money = ? WHERE id = ?";
|
|
|
+ Object[] params = {updatedMeterMoney, inventoryFormApplyTask.getMiddleMeterId()};
|
|
|
+ jdbcTemplate.update(updateSql, params);
|
|
|
+
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*如果更新前>更新后,相减*/
|
|
|
+ } else if (old.compareTo(update) > 0) {
|
|
|
+ BigDecimal total = old.subtract(update); //差值
|
|
|
+ BigDecimal currentMeterMoney = inventoryFormApplyTask.getCurrentMeterMoney();
|
|
|
+ BigDecimal result = currentMeterMoney.multiply(total);
|
|
|
+
|
|
|
+ if (inventoryFormApplyServiceTask.updateById(obj)) {
|
|
|
+
|
|
|
+ MiddleMeterApplyTask middleMeterApplyTask = middleMeterApplyServiceTask.getById(inventoryFormApplyTask.getMiddleMeterId());
|
|
|
+ if (middleMeterApplyTask != null) {
|
|
|
+ BigDecimal meterMoney = middleMeterApplyTask.getMeterMoney();
|
|
|
+ BigDecimal updatedMeterMoney = meterMoney.subtract(result); //相减
|
|
|
+
|
|
|
+ String updateSql = "UPDATE s_middle_meter_apply_task SET meter_money = ? WHERE id = ?";
|
|
|
+ Object[] params = {updatedMeterMoney, inventoryFormApplyTask.getMiddleMeterId()};
|
|
|
+ jdbcTemplate.update(updateSql, params);
|
|
|
+
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/data/inventoryFormApplyTask/save")
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
+ @ApiOperation(value = "清单数据新增(添加清单)", notes = "查询获取数据接口还是调/middleMeterApply/addFormList,传入InventoryFormApplyTask")
|
|
|
+ public R<Object> dataInventoryFormApplyTaskSave(@RequestBody InventoryFormApplyTask obj) {
|
|
|
+ if (ObjectUtil.isEmpty(obj.getCurrentMeterTotal()) && ObjectUtil.isEmpty(obj.getCurrentPrice())) {
|
|
|
+ throw new ServiceException("计量金额和计量数量不能为空");
|
|
|
+ }
|
|
|
+ /*重新计算金额*/
|
|
|
+ obj.setCurrentMeterMoney(obj.getCurrentPrice().multiply(obj.getCurrentMeterTotal()));
|
|
|
+ if (inventoryFormApplyServiceTask.save(obj)) {
|
|
|
+ /*申请单金额相加*/
|
|
|
+ BigDecimal currentMeterMoney = obj.getCurrentMeterMoney();
|
|
|
+ MiddleMeterApplyTask middleMeterApplyTask = middleMeterApplyServiceTask.getById(obj.getMiddleMeterId());
|
|
|
+ if (middleMeterApplyTask != null) {
|
|
|
+ BigDecimal meterMoney = middleMeterApplyTask.getMeterMoney();
|
|
|
+ BigDecimal add = meterMoney.add(currentMeterMoney); //相加
|
|
|
+
|
|
|
+ String updateSql = "UPDATE s_middle_meter_apply_task SET meter_money = ? WHERE id = ?";
|
|
|
+ Object[] params = {add, middleMeterApplyTask.getId()};
|
|
|
+ jdbcTemplate.update(updateSql, params);
|
|
|
+
|
|
|
+ return R.data(200, null, "操作成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/data/materialMeterFormServiceTask/update")
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
|
+ @ApiOperation(value = "材料数据修改", notes = "传入MaterialMeterFormTask")
|
|
|
+ public R<Object> dataMaterialMeterFormServiceTaskUpdate(@RequestBody MaterialMeterFormTask obj) {
|
|
|
+ if (materialMeterFormServiceTask.updateById(obj)) {
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/data/startPayMeterFormServiceTask/update")
|
|
|
+ @ApiOperationSupport(order = 11)
|
|
|
+ @ApiOperation(value = "开工预付款数据修改", notes = "传入StartPayMeterFormTask")
|
|
|
+ public R<Object> dataStartPayMeterFormServiceTaskUpdate(@RequestBody StartPayMeterFormTask obj) {
|
|
|
+ if (startPayMeterFormServiceTask.updateById(obj)) {
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/data/uploadFile")
|
|
|
+ @ApiOperationSupport(order = 12)
|
|
|
+ @ApiOperation(value = "附件文件上传", notes = "传入TaskDataUploadFileDTO")
|
|
|
+ public R<Object> dataUploadFile(@RequestBody TaskDataUploadFileDTO dto) {
|
|
|
+ List<AttachmentFormTask> fileList = dto.getFileList();
|
|
|
+ if (fileList != null && fileList.size() != 0) {
|
|
|
+ for (AttachmentFormTask file : fileList) {
|
|
|
+ file.setProjectId(dto.getProjectId());
|
|
|
+ file.setContractId(dto.getContractId());
|
|
|
+ file.setMasterId(dto.getDataId());
|
|
|
+ }
|
|
|
+ attachmentFormServiceTask.saveBatch(fileList);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/data/removeFile")
|
|
|
+ @ApiOperationSupport(order = 13)
|
|
|
+ @ApiOperation(value = "附件文件删除", notes = "传入文件id")
|
|
|
+ public R<Object> dataRemoveFile(@RequestParam String id) {
|
|
|
+ AttachmentFormTask attachmentFormTask = attachmentFormServiceTask.getById(id);
|
|
|
+ if (attachmentFormTask != null) {
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_attachment_form_task WHERE id = " + id);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/data/audit")
|
|
|
+ @ApiOperationSupport(order = 14)
|
|
|
+ @ApiOperation(value = "单条数据同意或驳回", notes = "传入TaskAuditDTO")
|
|
|
+ public R<Object> updateStatus(@RequestBody TaskAuditDTO dto) {
|
|
|
+ if (ObjectUtil.isEmpty(dto.getDataId()) || ObjectUtil.isEmpty(dto.getTaskId())) {
|
|
|
+ throw new ServiceException("任务、数据id不能为空");
|
|
|
+ }
|
|
|
+ if (Arrays.asList("1", "2").contains(dto.getAuditStatus())) {
|
|
|
+ Task task = jdbcTemplate.query("SELECT meter_task_type FROM u_task WHERE id = " + dto.getTaskId(), new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
+ if (task != null) {
|
|
|
+ if (task.getMeterTaskType().equals(1)) {
|
|
|
+ middleMeterApplyServiceTask.update(Wrappers.<MiddleMeterApplyTask>lambdaUpdate()
|
|
|
+ .set(MiddleMeterApplyTask::getStatus, dto.getAuditStatus())
|
|
|
+ .set(MiddleMeterApplyTask::getRepealDesc, ObjectUtil.isNotEmpty(dto.getRepealDesc()) ? dto.getRepealDesc() : null)
|
|
|
+ .eq(MiddleMeterApplyTask::getId, dto.getDataId()));
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(2)) {
|
|
|
+ materialMeterFormServiceTask.update(Wrappers.<MaterialMeterFormTask>lambdaUpdate()
|
|
|
+ .set(MaterialMeterFormTask::getStatus, dto.getAuditStatus())
|
|
|
+ .set(MaterialMeterFormTask::getRepealDesc, ObjectUtil.isNotEmpty(dto.getRepealDesc()) ? dto.getRepealDesc() : null)
|
|
|
+ .eq(MaterialMeterFormTask::getId, dto.getDataId()));
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(3)) {
|
|
|
+ startPayMeterFormServiceTask.update(Wrappers.<StartPayMeterFormTask>lambdaUpdate()
|
|
|
+ .set(StartPayMeterFormTask::getStatus, dto.getAuditStatus())
|
|
|
+ .set(StartPayMeterFormTask::getRepealDesc, ObjectUtil.isNotEmpty(dto.getRepealDesc()) ? dto.getRepealDesc() : null)
|
|
|
+ .eq(StartPayMeterFormTask::getId, dto.getDataId()));
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(4)) {
|
|
|
+ //TODO 变更令
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/approve")
|
|
|
+ @ApiOperationSupport(order = 15)
|
|
|
+ @ApiOperation(value = "同意审批", notes = "传入TaskApproveDTO")
|
|
|
+ public R<Object> approve(@RequestBody TaskApproveDTO dto) {
|
|
|
+ if (ObjectUtil.isEmpty(dto.getTaskId()) || ObjectUtil.isEmpty(dto.getProjectId()) || ObjectUtil.isEmpty(dto.getContractId()) || ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
|
+ throw new ServiceException("入参数据异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*加锁*/
|
|
|
+ String redisValue = bladeRedis.get("meter:approve:" + dto.getTaskId());
|
|
|
+ if (StringUtils.isNotEmpty(redisValue) && redisValue.equals("1")) {
|
|
|
+ return R.fail(400, "当前任务已提交审批,请勿重复提交,60秒后再尝试");
|
|
|
+ }
|
|
|
+ bladeRedis.set("meter:approve:" + dto.getTaskId(), "1");
|
|
|
+ bladeRedis.expire("meter:approve:" + dto.getTaskId(), 60);
|
|
|
+
|
|
|
+ Task task = jdbcTemplate.query("SELECT * FROM u_task WHERE id = " + dto.getTaskId(), new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
|
|
|
+ if (task != null) {
|
|
|
+ if (ObjectUtil.isEmpty(task.getFormDataId()) || ObjectUtil.isEmpty(task.getProcessInstanceId())) {
|
|
|
+ throw new ServiceException("未获取到任务关联的业务数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*校验当前用户审批顺序*/
|
|
|
+ boolean isCurrentUserLastApprove = checkTheTaskPersonSort(task);
|
|
|
+
|
|
|
+ /*修改复制数据状态,未选择时,默认为正确(即同意)*/
|
|
|
+ updateCopyDataStatus(task, dto);
|
|
|
+
|
|
|
+ /*最后审批人员*/
|
|
|
+ if (isCurrentUserLastApprove) {
|
|
|
+
|
|
|
+ //TODO 重新生成报表,执行电签(电签失败直接return或抛出异常,不修改下方状态)
|
|
|
+
|
|
|
+ /*修改主任务对应的业务状态为已审批*/
|
|
|
+ updateTaskDataStatus(task, dto);
|
|
|
+
|
|
|
+ /*修改主任务状态为已审批*/
|
|
|
+ updateTaskStatus(task);
|
|
|
+
|
|
|
+ /*替换数据*/
|
|
|
+ displace(task, dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*修改副任务状态为已审批*/
|
|
|
+ updateTaskParallelStatus(task);
|
|
|
+
|
|
|
+ return R.data(200, null, "操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean checkTheTaskPersonSort(Task task) {
|
|
|
+ List<TaskParallel> taskParallels = jdbcTemplate.query("SELECT * FROM u_task_parallel WHERE process_instance_id = '" + task.getProcessInstanceId() + "' ORDER BY sort", new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
+ List<String> name = new ArrayList<>();
|
|
|
+ boolean previousUsersApproved = true;
|
|
|
+ boolean isCurrentUserLastApprover = true;
|
|
|
+ for (TaskParallel parallel : taskParallels) {
|
|
|
+ //判断是否有人未审批
|
|
|
+ if (parallel.getStatus() != 2) {
|
|
|
+ previousUsersApproved = false;
|
|
|
+ name.add(parallel.getTaskUserName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //判断是否是当前用户之前的用户
|
|
|
+ if (parallel.getTaskUser().equals(SecureUtil.getUserId().toString())) {
|
|
|
+ isCurrentUserLastApprover = false; //当前用户不是最后一个审批人
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!previousUsersApproved) {
|
|
|
+ throw new ServiceException("当前任务还有【" + StringUtils.join(name, "、") + "】未完成审批,请您稍后再试");
|
|
|
+ }
|
|
|
+
|
|
|
+ return isCurrentUserLastApprover;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateCopyDataStatus(Task task, TaskApproveDTO dto) {
|
|
|
+ String formDataId = task.getFormDataId();
|
|
|
+ if (task.getMeterTaskType().equals(1)) {
|
|
|
+ List<MiddleMeterApplyTask> middleMeterApplyTasks = middleMeterApplyServiceTask.getBaseMapper().selectList(Wrappers.<MiddleMeterApplyTask>lambdaQuery()
|
|
|
+ .eq(MiddleMeterApplyTask::getContractPeriodId, formDataId)
|
|
|
+ .eq(MiddleMeterApplyTask::getTaskId, dto.getTaskId())
|
|
|
+ .isNull(MiddleMeterApplyTask::getStatus) //表示用户未选择,那么默认同意
|
|
|
+ );
|
|
|
+ List<Long> ids = middleMeterApplyTasks.stream().map(MiddleMeterApplyTask::getId).collect(Collectors.toList());
|
|
|
+ UpdateWrapper<MiddleMeterApplyTask> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("id", ids);
|
|
|
+ MiddleMeterApplyTask updateEntity = new MiddleMeterApplyTask();
|
|
|
+ updateEntity.setStatus(1);
|
|
|
+ middleMeterApplyServiceTask.update(updateEntity, updateWrapper);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(2)) {
|
|
|
+ List<MaterialMeterFormTask> materialMeterFormTasks = materialMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<MaterialMeterFormTask>lambdaQuery()
|
|
|
+ .eq(MaterialMeterFormTask::getMeterPeriodId, formDataId)
|
|
|
+ .eq(MaterialMeterFormTask::getTaskId, dto.getTaskId())
|
|
|
+ .isNull(MaterialMeterFormTask::getStatus) //表示用户未选择,那么默认同意
|
|
|
+ );
|
|
|
+ List<Long> ids = materialMeterFormTasks.stream().map(MaterialMeterFormTask::getId).collect(Collectors.toList());
|
|
|
+ UpdateWrapper<MaterialMeterFormTask> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("id", ids);
|
|
|
+ MaterialMeterFormTask updateEntity = new MaterialMeterFormTask();
|
|
|
+ updateEntity.setStatus(1);
|
|
|
+ materialMeterFormServiceTask.update(updateEntity, updateWrapper);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(3)) {
|
|
|
+ List<StartPayMeterFormTask> startPayMeterFormTasks = startPayMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<StartPayMeterFormTask>lambdaQuery()
|
|
|
+ .eq(StartPayMeterFormTask::getMeterPeriodId, formDataId)
|
|
|
+ .eq(StartPayMeterFormTask::getTaskId, dto.getTaskId())
|
|
|
+ .isNull(StartPayMeterFormTask::getStatus) //表示用户未选择,那么默认同意
|
|
|
+ );
|
|
|
+ List<Long> ids = startPayMeterFormTasks.stream().map(StartPayMeterFormTask::getId).collect(Collectors.toList());
|
|
|
+ UpdateWrapper<StartPayMeterFormTask> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("id", ids);
|
|
|
+ StartPayMeterFormTask updateEntity = new StartPayMeterFormTask();
|
|
|
+ updateEntity.setStatus(1);
|
|
|
+ startPayMeterFormServiceTask.update(updateEntity, updateWrapper);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(4)) {
|
|
|
+ //TODO 变更令
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateTaskDataStatus(Task task, TaskApproveDTO dto) {
|
|
|
+ String formDataId = task.getFormDataId();
|
|
|
+ if (task.getMeterTaskType().equals(1)) {
|
|
|
+ List<MiddleMeterApplyTask> middleMeterApplyTasks = middleMeterApplyServiceTask.getBaseMapper().selectList(Wrappers.<MiddleMeterApplyTask>lambdaQuery()
|
|
|
+ .eq(MiddleMeterApplyTask::getContractPeriodId, formDataId)
|
|
|
+ .eq(MiddleMeterApplyTask::getTaskId, dto.getTaskId())
|
|
|
+ );
|
|
|
+ List<Long> middleMeterApplyTasksIds = middleMeterApplyTasks.stream().map(MiddleMeterApplyTask::getId).collect(Collectors.toList());
|
|
|
+ UpdateWrapper<MiddleMeterApplyTask> updateWrapper_1 = new UpdateWrapper<>();
|
|
|
+ updateWrapper_1.in("id", middleMeterApplyTasksIds);
|
|
|
+ MiddleMeterApplyTask updateEntity_1 = new MiddleMeterApplyTask();
|
|
|
+ updateEntity_1.setApproveStatus(2);
|
|
|
+ middleMeterApplyServiceTask.update(updateEntity_1, updateWrapper_1);
|
|
|
+
|
|
|
+ List<InventoryFormApplyTask> inventoryFormAppliesTasks = inventoryFormApplyServiceTask.getBaseMapper().selectList(Wrappers.<InventoryFormApplyTask>lambdaQuery()
|
|
|
+ .eq(InventoryFormApplyTask::getContractPeriodId, formDataId)
|
|
|
+ .eq(InventoryFormApplyTask::getTaskId, dto.getTaskId())
|
|
|
+ );
|
|
|
+ List<Long> inventoryFormAppliesTasksIds = inventoryFormAppliesTasks.stream().map(InventoryFormApplyTask::getId).collect(Collectors.toList());
|
|
|
+ UpdateWrapper<InventoryFormApplyTask> updateWrapper_2 = new UpdateWrapper<>();
|
|
|
+ updateWrapper_2.in("id", inventoryFormAppliesTasksIds);
|
|
|
+ InventoryFormApplyTask updateEntity_2 = new InventoryFormApplyTask();
|
|
|
+ updateEntity_2.setApproveStatus(2);
|
|
|
+ inventoryFormApplyServiceTask.update(updateEntity_2, updateWrapper_2);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(2)) {
|
|
|
+ List<MaterialMeterFormTask> materialMeterFormTasks = materialMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<MaterialMeterFormTask>lambdaQuery()
|
|
|
+ .eq(MaterialMeterFormTask::getMeterPeriodId, formDataId)
|
|
|
+ .eq(MaterialMeterFormTask::getTaskId, dto.getTaskId())
|
|
|
+ );
|
|
|
+ List<Long> ids = materialMeterFormTasks.stream().map(MaterialMeterFormTask::getId).collect(Collectors.toList());
|
|
|
+ UpdateWrapper<MaterialMeterFormTask> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("id", ids);
|
|
|
+ MaterialMeterFormTask updateEntity = new MaterialMeterFormTask();
|
|
|
+ updateEntity.setApproveStatus(2);
|
|
|
+ materialMeterFormServiceTask.update(updateEntity, updateWrapper);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(3)) {
|
|
|
+ List<StartPayMeterFormTask> startPayMeterFormTasks = startPayMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<StartPayMeterFormTask>lambdaQuery()
|
|
|
+ .eq(StartPayMeterFormTask::getMeterPeriodId, formDataId)
|
|
|
+ .eq(StartPayMeterFormTask::getTaskId, dto.getTaskId())
|
|
|
+ );
|
|
|
+ List<Long> ids = startPayMeterFormTasks.stream().map(StartPayMeterFormTask::getId).collect(Collectors.toList());
|
|
|
+ UpdateWrapper<StartPayMeterFormTask> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("id", ids);
|
|
|
+ StartPayMeterFormTask updateEntity = new StartPayMeterFormTask();
|
|
|
+ updateEntity.setApproveStatus(2);
|
|
|
+ startPayMeterFormServiceTask.update(updateEntity, updateWrapper);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(4)) {
|
|
|
+ //TODO 变更令
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateTaskStatus(Task task) {
|
|
|
+ jdbcTemplate.execute("UPDATE u_task SET status = 2 WHERE id = " + task.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateTaskParallelStatus(Task task) {
|
|
|
+ TaskParallel taskParallelOne = jdbcTemplate.query("SELECT * FROM u_task_parallel WHERE process_instance_id = '" + task.getProcessInstanceId() + "' AND task_user = " + SecureUtil.getUserId(), new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
|
|
|
+ if (taskParallelOne != null && taskParallelOne.getStatus().equals(1)) {
|
|
|
+ jdbcTemplate.execute("UPDATE u_task_parallel SET status = 2 WHERE id = " + taskParallelOne.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void displace(Task task, TaskApproveDTO dto) {
|
|
|
+ if (task.getMeterTaskType().equals(1)) {
|
|
|
+ List<MiddleMeterApplyTask> middleMeterApplyTasks = middleMeterApplyServiceTask.getBaseMapper().selectList(Wrappers.<MiddleMeterApplyTask>lambdaQuery()
|
|
|
+ .eq(MiddleMeterApplyTask::getContractPeriodId, task.getFormDataId())
|
|
|
+ .eq(MiddleMeterApplyTask::getTaskId, dto.getTaskId()));
|
|
|
+ List<InventoryFormApplyTask> inventoryFormApplyTasks = inventoryFormApplyServiceTask.getBaseMapper().selectList(Wrappers.<InventoryFormApplyTask>lambdaQuery()
|
|
|
+ .eq(InventoryFormApplyTask::getTaskId, dto.getTaskId())
|
|
|
+ .eq(InventoryFormApplyTask::getContractPeriodId, task.getFormDataId()));
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_middle_meter_apply WHERE contract_period_id = " + task.getFormDataId());
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_inventory_form_apply WHERE contract_period_id = " + task.getFormDataId());
|
|
|
+
|
|
|
+ List<MiddleMeterApply> middleMeterApplies = BeanUtil.copyProperties(middleMeterApplyTasks, MiddleMeterApply.class);
|
|
|
+ List<InventoryFormApply> inventoryFormApplies = BeanUtil.copyProperties(inventoryFormApplyTasks, InventoryFormApply.class);
|
|
|
+ middleMeterApplyService.saveBatch(middleMeterApplies, 1000);
|
|
|
+ inventoryFormApplyService.saveBatch(inventoryFormApplies, 1000);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(2)) {
|
|
|
+ List<MaterialMeterFormTask> materialMeterFormTasks = materialMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<MaterialMeterFormTask>lambdaQuery()
|
|
|
+ .eq(MaterialMeterFormTask::getMeterPeriodId, task.getFormDataId())
|
|
|
+ .eq(MaterialMeterFormTask::getTaskId, dto.getTaskId()));
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_material_meter_form WHERE meter_period_id = " + task.getFormDataId());
|
|
|
+
|
|
|
+ List<MaterialMeterForm> materialMeterForms = BeanUtil.copyProperties(materialMeterFormTasks, MaterialMeterForm.class);
|
|
|
+ materialMeterFormService.saveBatch(materialMeterForms, 1000);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(3)) {
|
|
|
+ List<StartPayMeterFormTask> startPayMeterFormTasks = startPayMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<StartPayMeterFormTask>lambdaQuery()
|
|
|
+ .eq(StartPayMeterFormTask::getMeterPeriodId, task.getFormDataId())
|
|
|
+ .eq(StartPayMeterFormTask::getTaskId, dto.getTaskId()));
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_start_pay_meter_form WHERE meter_period_id = " + task.getFormDataId());
|
|
|
+
|
|
|
+ List<StartPayMeterForm> startPayMeterForms = BeanUtil.copyProperties(startPayMeterFormTasks, StartPayMeterForm.class);
|
|
|
+ startPayMeterFormService.saveBatch(startPayMeterForms, 1000);
|
|
|
+
|
|
|
+ } else if (task.getMeterTaskType().equals(4)) {
|
|
|
+ //TODO 变更令
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/comment/list")
|
|
|
+ @ApiOperationSupport(order = 16)
|
|
|
+ @ApiOperation(value = "批注信息列表", notes = "传入任务taskId,数据dataId")
|
|
|
+ public R<List<TaskComment>> commentList(@RequestParam String taskId, @RequestParam String dataId) {
|
|
|
+ if (StringUtils.isNotEmpty(taskId) && StringUtils.isNotEmpty(dataId)) {
|
|
|
+ String sql = "SELECT * FROM s_task_comment WHERE task_id = ? AND data_id = ?";
|
|
|
+ List<TaskComment> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskComment.class), taskId, dataId);
|
|
|
+ return R.data(200, query, "操作成功");
|
|
|
+ }
|
|
|
+ return R.data(200, null, "未查询到信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/comment/submit")
|
|
|
+ @ApiOperationSupport(order = 17)
|
|
|
+ @ApiOperation(value = "批注信息新增或修改", notes = "传入TaskComment")
|
|
|
+ @Transactional
|
|
|
+ public R<Object> commentSave(@RequestBody TaskComment taskComment) {
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
|
+ throw new ServiceException("未获取到当前用户信息");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(taskComment.getComment()) && taskComment.getComment().length() > 1000) {
|
|
|
+ throw new ServiceException("批注信息最长1000个字符");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String querySql = "SELECT COUNT(*) FROM s_task_comment WHERE task_id = ? AND data_id = ? AND user_id = ?";
|
|
|
+ Object[] queryParams = {
|
|
|
+ taskComment.getTaskId(),
|
|
|
+ taskComment.getDataId(),
|
|
|
+ SecureUtil.getUserId()
|
|
|
+ };
|
|
|
+ Integer count = jdbcTemplate.queryForObject(querySql, Integer.class, queryParams);
|
|
|
+ int rowCount = (count != null) ? count : 0;
|
|
|
+ if (rowCount == 0) {
|
|
|
+ String insertSql = "INSERT INTO s_task_comment(id, task_id, data_id, user_id, user_name, comment, create_time) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
|
|
+ Object[] insertParams = {
|
|
|
+ SnowFlakeUtil.getId(),
|
|
|
+ taskComment.getTaskId(),
|
|
|
+ taskComment.getDataId(),
|
|
|
+ SecureUtil.getUserId(),
|
|
|
+ SecureUtil.getNickName(),
|
|
|
+ taskComment.getComment(),
|
|
|
+ new java.sql.Timestamp(System.currentTimeMillis())
|
|
|
+ };
|
|
|
+ jdbcTemplate.update(insertSql, insertParams);
|
|
|
+ } else {
|
|
|
+ String updateSql = "UPDATE s_task_comment SET comment = ?, create_time = ? WHERE task_id = ? AND data_id = ? AND user_id = ?";
|
|
|
+ Object[] updateParams = {
|
|
|
+ taskComment.getComment(),
|
|
|
+ new java.sql.Timestamp(System.currentTimeMillis()),
|
|
|
+ taskComment.getTaskId(),
|
|
|
+ taskComment.getDataId(),
|
|
|
+ SecureUtil.getUserId()
|
|
|
+ };
|
|
|
+ jdbcTemplate.update(updateSql, updateParams);
|
|
|
+ }
|
|
|
+ return R.data(200, null, "操作成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.fail("操作失败" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-}
|
|
|
+}
|