|
@@ -29,6 +29,7 @@ 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.manager.entity.ContractRelationJlyz;
|
|
|
import org.springblade.meter.dto.*;
|
|
|
import org.springblade.meter.entity.*;
|
|
|
import org.springblade.meter.mapper.MiddleMeterApplyMapper;
|
|
@@ -77,7 +78,7 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
@GetMapping("/name")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
- @ApiOperation(value = "获取任务名称", notes = "传入合同段contractId、期数id、type=1(中间计量申请)、=2(材料计量单、开工预付款计量单)、=3(变更令)")
|
|
|
+ @ApiOperation(value = "获取任务名称", notes = "传入合同段contractId、期数id、type=1(中间计量申请)、=2(材料计量单)、3=(开工预付款计量单)、=4(变更令)")
|
|
|
public R<Object> name(@RequestParam String contractId, @RequestParam String id, @RequestParam String type) {
|
|
|
String name = null;
|
|
|
if (ObjectUtil.isNotEmpty(contractId) && ObjectUtil.isNotEmpty(id)) {
|
|
@@ -92,13 +93,14 @@ public class TaskController extends BladeController {
|
|
|
} else if (("2").equals(type)) {
|
|
|
MeterPeriod meterPeriod = periodService.getById(id);
|
|
|
if (contractInfo != null && meterPeriod != null) {
|
|
|
- if (meterPeriod.getType().equals(1)) {
|
|
|
- name = "【" + contractInfo.getContractName() + "】" + date + " 材料计量单【" + meterPeriod.getPeriodNumber() + "】";
|
|
|
- } else if (meterPeriod.getType().equals(2)) {
|
|
|
- name = "【" + contractInfo.getContractName() + "】" + date + " 开工预付款计量单【" + meterPeriod.getPeriodNumber() + "】";
|
|
|
- }
|
|
|
+ name = "【" + contractInfo.getContractName() + "】" + date + " 材料计量单【" + meterPeriod.getPeriodNumber() + "】";
|
|
|
}
|
|
|
} else if (("3").equals(type)) {
|
|
|
+ MeterPeriod meterPeriod = periodService.getById(id);
|
|
|
+ if (contractInfo != null && meterPeriod != null) {
|
|
|
+ name = "【" + contractInfo.getContractName() + "】" + date + " 开工预付款计量单【" + meterPeriod.getPeriodNumber() + "】";
|
|
|
+ }
|
|
|
+ } else if (("4").equals(type)) {
|
|
|
//TODO 变更令
|
|
|
}
|
|
|
}
|
|
@@ -209,6 +211,11 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
this.updateApproveStatus(serviceMap, 1); //待审批
|
|
|
|
|
|
+ /*修改计量期的审批状态=待审批*/
|
|
|
+ contractMeterPeriodService.update(Wrappers.<ContractMeterPeriod>lambdaUpdate()
|
|
|
+ .set(ContractMeterPeriod::getApproveStatus, 1)
|
|
|
+ .eq(ContractMeterPeriod::getId, approvalDTO.getPeriodId()));
|
|
|
+
|
|
|
return R.data(200, aopParamsSet, "操作成功");
|
|
|
}
|
|
|
|
|
@@ -265,6 +272,11 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
this.updateApproveStatus(serviceMap, 1); //待审批
|
|
|
|
|
|
+ /*修改计量期的审批状态=待审批*/
|
|
|
+ periodService.update(Wrappers.<MeterPeriod>lambdaUpdate()
|
|
|
+ .set(MeterPeriod::getApproveStatus, 1)
|
|
|
+ .eq(MeterPeriod::getId, approvalDTO.getPeriodId()));
|
|
|
+
|
|
|
return R.data(200, aopParamsSet, "操作成功");
|
|
|
}
|
|
|
|
|
@@ -321,6 +333,11 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
this.updateApproveStatus(serviceMap, 1); //待审批
|
|
|
|
|
|
+ /*修改计量期的审批状态=待审批*/
|
|
|
+ periodService.update(Wrappers.<MeterPeriod>lambdaUpdate()
|
|
|
+ .set(MeterPeriod::getApproveStatus, 1)
|
|
|
+ .eq(MeterPeriod::getId, approvalDTO.getPeriodId()));
|
|
|
+
|
|
|
return R.data(200, aopParamsSet, "操作成功");
|
|
|
}
|
|
|
} else if (approvalDTO.getType().equals(4)) {
|
|
@@ -547,10 +564,14 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
this.updateApproveStatus(serviceMap, 0); //未上报
|
|
|
|
|
|
+ /*修改计量期的审批状态=未上报*/
|
|
|
+ contractMeterPeriodService.update(Wrappers.<ContractMeterPeriod>lambdaUpdate()
|
|
|
+ .set(ContractMeterPeriod::getApproveStatus, 0)
|
|
|
+ .eq(ContractMeterPeriod::getId, periodId));
|
|
|
+
|
|
|
/*删除业务复制数据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)) {
|
|
|
/*==================== 材料计量单 ====================*/
|
|
@@ -568,9 +589,13 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
this.updateApproveStatus(serviceMap, 0); //未上报
|
|
|
|
|
|
+ /*修改计量期的审批状态=未上报*/
|
|
|
+ periodService.update(Wrappers.<MeterPeriod>lambdaUpdate()
|
|
|
+ .set(MeterPeriod::getApproveStatus, 0)
|
|
|
+ .eq(MeterPeriod::getId, periodId));
|
|
|
+
|
|
|
/*删除业务复制数据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)) {
|
|
|
/*==================== 开工预付款计量单 ====================*/
|
|
@@ -588,14 +613,22 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
this.updateApproveStatus(serviceMap, 0); //未上报
|
|
|
|
|
|
+ /*修改计量期的审批状态=未上报*/
|
|
|
+ periodService.update(Wrappers.<MeterPeriod>lambdaUpdate()
|
|
|
+ .set(MeterPeriod::getApproveStatus, 0)
|
|
|
+ .eq(MeterPeriod::getId, periodId));
|
|
|
+
|
|
|
/*删除业务复制数据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 变更令
|
|
|
}
|
|
|
|
|
|
+ /*删除文件附件、任务批注信息*/
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_attachment_form_task WHERE task_id = " + taskRepealDTO.getTaskId());
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_task_comment WHERE task_id = " + taskRepealDTO.getTaskId());
|
|
|
+
|
|
|
Set<String> aopParamsSet = new HashSet<>();
|
|
|
for (String userId : taskParallelsUserIds) {
|
|
|
String param = userId + "," + taskRepealDTO.getProjectId() + "," + taskRepealDTO.getContractId();
|
|
@@ -622,16 +655,29 @@ public class TaskController extends BladeController {
|
|
|
throw new ServiceException("未获取到当前项目或合同段信息");
|
|
|
}
|
|
|
|
|
|
- //封装入参SQL
|
|
|
+ /*封装入参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());
|
|
|
+
|
|
|
+ ContractInfo contractInfo = jdbcTemplate.queryForObject("select contract_type from m_contract_info where id = " + dto.getContractId(), new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
+ if (contractInfo != null && Arrays.asList(1, 4).contains(contractInfo.getContractType())) {
|
|
|
+ /*施工、计量合同段(总承包合同段)按照项目id、合同段id正常查询*/
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (contractInfo != null && Arrays.asList(2, 3).contains(contractInfo.getContractType())) {
|
|
|
+ /*监理、业主(指挥部)合同段,默认查询当前项目下所有关联的合同段*/
|
|
|
+ List<ContractRelationJlyz> contractRelationJLYZ = jdbcTemplate.query("select contract_id_sg from m_contract_relation_jlyz where contract_id_jlyz = " + dto.getContractId(), new BeanPropertyRowMapper<>(ContractRelationJlyz.class));
|
|
|
+ Set<Long> ids = contractRelationJLYZ.stream().map(ContractRelationJlyz::getContractIdSg).collect(Collectors.toSet());
|
|
|
+ ids.add(Long.parseLong(dto.getContractId())); //把本身合同段也加入查询
|
|
|
+ sqlString.append(" AND contract_id in(").append(StringUtils.join(ids, ",")).append(")");
|
|
|
}
|
|
|
+
|
|
|
if (ObjectUtil.isNotEmpty(dto.getTypeValue())) {
|
|
|
sqlString.append(" AND type = ?");
|
|
|
params.add(dto.getTypeValue());
|
|
@@ -658,17 +704,17 @@ public class TaskController extends BladeController {
|
|
|
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
|
|
|
+ /*如果是待办页面,且 任务状态下拉框 选择的不是 待审批状态 的任务,那么直接返回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);
|
|
@@ -678,7 +724,7 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
} 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 ,才视为已办
|
|
|
+ /*当前自己的任务必须是已审批、已废除 status = 2,3 ,才视为已办*/
|
|
|
params.add(SecureUtil.getUserId());
|
|
|
|
|
|
} else if (dto.getSelectedType().equals(3)) { //我发起页面
|
|
@@ -688,17 +734,17 @@ public class TaskController extends BladeController {
|
|
|
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获取数据
|
|
|
+ /*执行SQL获取数据*/
|
|
|
String sqlPage = sqlString.toString();
|
|
|
List<Task> resultList = jdbcTemplate.query(
|
|
|
sqlPage,
|
|
@@ -706,7 +752,7 @@ public class TaskController extends BladeController {
|
|
|
params.toArray()
|
|
|
);
|
|
|
|
|
|
- //获取任务详情信息Map
|
|
|
+ /*获取任务详情信息Map*/
|
|
|
Set<String> processInstanceIds = resultList.stream().map(Task::getProcessInstanceId).collect(Collectors.toSet());
|
|
|
Map<String, List<TaskParallel>> taskParallelGroupMap = new HashMap<>();
|
|
|
if (processInstanceIds.size() > 0) {
|
|
@@ -717,10 +763,10 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
Map<String, List<TaskParallel>> finalTaskParallelGroupMap = taskParallelGroupMap;
|
|
|
|
|
|
- //获取用户信息Map
|
|
|
+ /*获取用户信息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分页数据
|
|
|
+ /*解析page分页数据*/
|
|
|
IPage<TaskPageVO> page = new Page<>(current, size);
|
|
|
List<TaskPageVO> pageList = resultList.stream()
|
|
|
.map(task -> {
|
|
@@ -742,7 +788,7 @@ public class TaskController extends BladeController {
|
|
|
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() : "");
|
|
@@ -751,7 +797,7 @@ public class TaskController extends BladeController {
|
|
|
vo.setEVisaStatus("废除成功");
|
|
|
}
|
|
|
|
|
|
- //判断签字人的验证 2=绿色 3=黄色 999=红色 其他代表=灰色
|
|
|
+ /*判断签字人的验证 2=绿色 3=黄色 999=红色 其他代表=灰色*/
|
|
|
List<TaskParallel> statList = new ArrayList<>();
|
|
|
for (TaskParallel taskPa : taskParallelList) {
|
|
|
if (taskPa.getStatus() == 2 && ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 1) {
|
|
@@ -793,32 +839,38 @@ public class TaskController extends BladeController {
|
|
|
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,create_time from u_task_parallel where process_instance_id = " + task.getProcessInstanceId() + " order by sort", new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
+ List<TaskParallel> taskParallels = jdbcTemplate.query("select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,status,sort,update_time from u_task_parallel where process_instance_id = " + task.getProcessInstanceId() + " order by sort", new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
List<Map<String, String>> taskProcessInfo = new LinkedList<>();
|
|
|
+
|
|
|
+ /*上报人*/
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
Map<String, String> taskUserOne = new LinkedHashMap<>();
|
|
|
taskUserOne.put("name", task.getReportUserName());
|
|
|
- taskUserOne.put("date", task.getCreateTime().toString());
|
|
|
- taskUserOne.put("status", task.getStatus().toString());
|
|
|
+ taskUserOne.put("date", sdf.format(task.getCreateTime()));
|
|
|
+ taskUserOne.put("status", "2");
|
|
|
taskUserOne.put("flowValue", "上报");
|
|
|
taskProcessInfo.add(0, taskUserOne);
|
|
|
|
|
|
+ /*流程人*/
|
|
|
for (int i = 0; i < taskParallels.size(); i++) {
|
|
|
TaskParallel taskParallel = taskParallels.get(i);
|
|
|
- Map<String, String> taskUserMap = new LinkedHashMap<>();
|
|
|
- taskUserMap.put("name", taskParallel.getTaskUserName());
|
|
|
- taskUserMap.put("date", taskParallel.getCreateTime().toString());
|
|
|
- taskUserMap.put("status", taskParallel.getStatus().toString());
|
|
|
+ Map<String, String> taskUserOther = new LinkedHashMap<>();
|
|
|
+ taskUserOther.put("name", taskParallel.getTaskUserName());
|
|
|
+ if (taskParallel.getStatus().equals(2)) {
|
|
|
+ taskUserOther.put("date", sdf.format(task.getUpdateTime()));
|
|
|
+ }
|
|
|
+ taskUserOther.put("status", taskParallel.getStatus().toString());
|
|
|
if (i == taskParallels.size() - 1) {
|
|
|
- taskUserOne.put("flowValue", "结束流程</br>同意");
|
|
|
+ taskUserOther.put("flowValue", (taskParallel.getStatus().equals(2) ? "同意" : "待审批") + "</br></br>结束流程");
|
|
|
} else {
|
|
|
- taskUserOne.put("flowValue", taskParallel.getStatus().equals(2) ? "同意" : "待审批");
|
|
|
+ taskUserOther.put("flowValue", taskParallel.getStatus().equals(2) ? "同意" : "待审批");
|
|
|
}
|
|
|
- taskProcessInfo.add(taskUserMap);
|
|
|
+ taskProcessInfo.add(taskUserOther);
|
|
|
}
|
|
|
vo.setTaskProcessInfo(taskProcessInfo);
|
|
|
|
|
|
- /*中间业务taskVO数据*/
|
|
|
- if (ObjectUtil.isNotEmpty(task.getFormDataId())) {
|
|
|
+ /*中间业务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))
|
|
|
.stream()
|
|
@@ -902,7 +954,7 @@ public class TaskController extends BladeController {
|
|
|
MiddleMeterApplyTask middleMeterApplyTask = middleMeterApplyServiceTask.getById(dataId);
|
|
|
vo.setBasicsInfo(middleMeterApplyTask);
|
|
|
|
|
|
- /*清单信息*/
|
|
|
+ /*清单信息(查询原始表数据,因为包含表中数据的计算统计,复制表中的数据不全)*/
|
|
|
List<MeterInventoryVO> formToTask = middleMeterApplyMapper.getForm(Long.parseLong(dataId), middleMeterApplyTask.getContractId(), middleMeterApplyTask.getContractUnitId());
|
|
|
vo.setAssociatedDataInfoList(formToTask);
|
|
|
|
|
@@ -1024,32 +1076,83 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
@PostMapping("/data/inventoryFormApplyTask/save")
|
|
|
@ApiOperationSupport(order = 9)
|
|
|
- @ApiOperation(value = "清单数据新增(添加清单)", notes = "查询获取数据接口还是调/middleMeterApply/addFormList,传入InventoryFormApplyTaskBatchDTO")
|
|
|
+ @ApiOperation(value = "清单数据新增(添加清单)", notes = "查询获取数据接口还是调/middleMeterApply/addFormList;入参传入InventoryFormApplyTaskBatchDTO")
|
|
|
public R<Object> dataInventoryFormApplyTaskSave(@RequestBody InventoryFormApplyTaskBatchDTO dto) {
|
|
|
- BigDecimal currentMeterMoneyTotal = BigDecimal.ZERO;
|
|
|
- Long middleMeterId = null;
|
|
|
- for (InventoryFormApplyTask obj : dto.getDtoList()) {
|
|
|
- if (ObjectUtil.isEmpty(obj.getCurrentMeterTotal()) && ObjectUtil.isEmpty(obj.getCurrentPrice())) {
|
|
|
- throw new ServiceException("计量金额和计量数量不能为空");
|
|
|
- }
|
|
|
- if (ObjectUtil.isEmpty(middleMeterId)) {
|
|
|
- middleMeterId = obj.getMiddleMeterId();
|
|
|
- }
|
|
|
- obj.setCurrentMeterMoney(obj.getCurrentPrice().multiply(obj.getCurrentMeterTotal()));
|
|
|
- currentMeterMoneyTotal = currentMeterMoneyTotal.add(obj.getCurrentMeterMoney());
|
|
|
- inventoryFormApplyServiceTask.save(obj);
|
|
|
+ /*获取中间计量单信息*/
|
|
|
+ MiddleMeterApplyTask middleMeterApplyTask = middleMeterApplyServiceTask.getById(dto.getDataId());
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(middleMeterApplyTask)) {
|
|
|
+ throw new ServiceException("未获取到中间计量单信息");
|
|
|
}
|
|
|
|
|
|
- /*申请单金额相加*/
|
|
|
- MiddleMeterApplyTask middleMeterApplyTask = middleMeterApplyServiceTask.getById(middleMeterId);
|
|
|
- if (middleMeterApplyTask != null) {
|
|
|
- BigDecimal meterMoney = middleMeterApplyTask.getMeterMoney();
|
|
|
- BigDecimal resultMoney = meterMoney.add(currentMeterMoneyTotal); //相加
|
|
|
+ /*获取数据源分解清单*/
|
|
|
+ List<MeterInventoryVO> formList = middleMeterApplyService.addResolveForm(dto.getContractId(), dto.getNodeId(), dto.getIds());
|
|
|
+
|
|
|
+ if (formList.size() != 0) {
|
|
|
+ /*原始表数据(为了/data/detail接口回显,因为详情接口查询的是原始数据)*/
|
|
|
+ List<InventoryFormApply> formApplies = formList.stream().map(l -> {
|
|
|
+ InventoryFormApply formApply = new InventoryFormApply();
|
|
|
+ formApply.setBusinessDate(middleMeterApplyTask.getBusinessDate());
|
|
|
+ formApply.setProjectId(dto.getProjectId());
|
|
|
+ formApply.setContractId(dto.getContractId());
|
|
|
+ formApply.setContractFormId(l.getId());
|
|
|
+ formApply.setMiddleMeterId(dto.getDataId());
|
|
|
+ formApply.setContractPeriodId(dto.getContractPeriodId());
|
|
|
+ formApply.setMeterNumber(middleMeterApplyTask.getMeterNumber());
|
|
|
+ formApply.setContractMeterId(dto.getNodeId());
|
|
|
+ formApply.setFormNumber(l.getFormNumber());
|
|
|
+ formApply.setFormName(l.getFormName());
|
|
|
+ formApply.setCurrentPrice(l.getCurrentPrice());
|
|
|
+ formApply.setBuildPictureTotal(l.getResolveTotal());
|
|
|
+ formApply.setChangeBuildPictureTotal(l.getChangeTotal());
|
|
|
+ if (l.getCurrentMeterTotal() != null && l.getCurrentPrice() != null) {
|
|
|
+ formApply.setCurrentMeterTotal(l.getCurrentMeterTotal());
|
|
|
+ formApply.setCurrentMeterMoney(l.getCurrentPrice().multiply(l.getCurrentMeterTotal()));
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("计量金额和计量数量不能为空");
|
|
|
+ }
|
|
|
+ return formApply;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ inventoryFormApplyService.saveBatch(formApplies);
|
|
|
+
|
|
|
+ /*复制表taskVO数据*/
|
|
|
+ BigDecimal currentMeterMoneyTotal = BigDecimal.ZERO;
|
|
|
+ List<InventoryFormApplyTask> formAppliesTask = formList.stream().map(l -> {
|
|
|
+ InventoryFormApplyTask formApplyTask = new InventoryFormApplyTask();
|
|
|
+ formApplyTask.setTaskId(dto.getTaskId());
|
|
|
+ formApplyTask.setBusinessDate(middleMeterApplyTask.getBusinessDate());
|
|
|
+ formApplyTask.setProjectId(dto.getProjectId());
|
|
|
+ formApplyTask.setContractId(dto.getContractId());
|
|
|
+ formApplyTask.setContractFormId(l.getId());
|
|
|
+ formApplyTask.setMiddleMeterId(dto.getDataId());
|
|
|
+ formApplyTask.setContractPeriodId(dto.getContractPeriodId());
|
|
|
+ formApplyTask.setMeterNumber(middleMeterApplyTask.getMeterNumber());
|
|
|
+ formApplyTask.setContractMeterId(dto.getNodeId());
|
|
|
+ formApplyTask.setFormNumber(l.getFormNumber());
|
|
|
+ formApplyTask.setFormName(l.getFormName());
|
|
|
+ formApplyTask.setCurrentPrice(l.getCurrentPrice());
|
|
|
+ formApplyTask.setBuildPictureTotal(l.getResolveTotal());
|
|
|
+ formApplyTask.setChangeBuildPictureTotal(l.getChangeTotal());
|
|
|
+ formApplyTask.setApproveStatus(1); //待审批
|
|
|
+ if (l.getCurrentMeterTotal() != null && l.getCurrentPrice() != null) {
|
|
|
+ formApplyTask.setCurrentMeterTotal(l.getCurrentMeterTotal());
|
|
|
+ formApplyTask.setCurrentMeterMoney(l.getCurrentPrice().multiply(l.getCurrentMeterTotal()));
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("计量金额和计量数量不能为空");
|
|
|
+ }
|
|
|
+ return formApplyTask;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ for (InventoryFormApplyTask formApplyTask : formAppliesTask) {
|
|
|
+ currentMeterMoneyTotal = currentMeterMoneyTotal.add(formApplyTask.getCurrentMeterMoney());
|
|
|
+ }
|
|
|
+ inventoryFormApplyServiceTask.saveBatch(formAppliesTask);
|
|
|
+
|
|
|
+ /*修改计量单当前总金额*/
|
|
|
String updateSql = "UPDATE s_middle_meter_apply_task SET meter_money = ? WHERE id = ?";
|
|
|
- Object[] params = {resultMoney, middleMeterApplyTask.getId()};
|
|
|
+ Object[] params = {currentMeterMoneyTotal, middleMeterApplyTask.getId()};
|
|
|
jdbcTemplate.update(updateSql, params);
|
|
|
|
|
|
- return R.data(200, resultMoney, "操作成功");
|
|
|
+ return R.data(200, formList, "操作成功");
|
|
|
}
|
|
|
|
|
|
return R.fail("操作失败");
|
|
@@ -1144,7 +1247,8 @@ public class TaskController extends BladeController {
|
|
|
|
|
|
@PostMapping("/approve")
|
|
|
@ApiOperationSupport(order = 15)
|
|
|
- @ApiOperation(value = "同意审批", notes = "传入TaskApproveDTO")
|
|
|
+ @ApiOperation(value = "同意审批(批量审批)", notes = "传入TaskApproveDTO")
|
|
|
+ @PushMessage(clientId = ClientIdConstant.METER_CLIENT_ID)
|
|
|
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("入参数据异常");
|
|
@@ -1158,44 +1262,49 @@ public class TaskController extends BladeController {
|
|
|
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);
|
|
|
+ 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);
|
|
|
if (task != null) {
|
|
|
if (ObjectUtil.isEmpty(task.getFormDataId()) || ObjectUtil.isEmpty(task.getProcessInstanceId())) {
|
|
|
throw new ServiceException("未获取到任务关联的业务数据");
|
|
|
}
|
|
|
+ /*存在监理合同段查看任务,监理默认查看当前项目下所有任务,
|
|
|
+ 那么默认选择任务对应的项目id、合同段id,而不是前端入参dto*/
|
|
|
+ dto.setProjectId(task.getProjectId());
|
|
|
+ dto.setContractId(task.getContractId());
|
|
|
|
|
|
- /*校验当前用户审批顺序*/
|
|
|
- boolean isCurrentUserLastApprove = checkTheTaskPersonSort(task);
|
|
|
+ /*当前审批轮次*/
|
|
|
+ String sql_2 = "SELECT * FROM u_task_parallel WHERE process_instance_id = ? ORDER BY sort";
|
|
|
+ List<TaskParallel> taskParallels = jdbcTemplate.query(sql_2, new Object[]{task.getProcessInstanceId()}, new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
+ boolean isCurrentUserLastApprove = checkTheTaskPersonSort(task, taskParallels);
|
|
|
|
|
|
- /*修改复制数据状态,单条数据的状态,未选择时,默认为正确(即同意)(此状态为数据状态,不是任务状态)*/
|
|
|
+ /*单条业务数据状态*/
|
|
|
updateCopyDataStatus(task, dto);
|
|
|
|
|
|
- /*最后审批人员*/
|
|
|
+ /*最终审批轮次*/
|
|
|
if (isCurrentUserLastApprove) {
|
|
|
|
|
|
//TODO 重新生成报表,执行电签(电签失败直接return或抛出异常,不修改下方状态)
|
|
|
|
|
|
- /*修改主任务对应的复制业务数据状态为已审批*/
|
|
|
- updateCopyDataApproveStatus(task, dto);
|
|
|
-
|
|
|
- /*修改主任务状态为已审批*/
|
|
|
- updateTaskStatus(task);
|
|
|
-
|
|
|
- /*替换数据*/
|
|
|
- displace(task, dto);
|
|
|
+ /*复制业务数据状态>主任务状态>替换数据*/
|
|
|
+ updateCopyDataApproveStatus(task, dto).updateTaskStatus(task).displace(task, dto);
|
|
|
}
|
|
|
|
|
|
- /*修改副任务状态为已审批*/
|
|
|
+ /*副任务状态*/
|
|
|
updateTaskParallelStatus(task);
|
|
|
|
|
|
- return R.data(200, null, "操作成功");
|
|
|
+ Set<String> aopParamsSet = new HashSet<>();
|
|
|
+ for (TaskParallel taskParallel : taskParallels) {
|
|
|
+ String param = taskParallel.getTaskUser() + "," + dto.getProjectId() + "," + dto.getContractId();
|
|
|
+ aopParamsSet.add(param);
|
|
|
+ }
|
|
|
+ return R.data(200, aopParamsSet, "操作成功");
|
|
|
}
|
|
|
|
|
|
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));
|
|
|
+ private boolean checkTheTaskPersonSort(Task task, List<TaskParallel> taskParallels) {
|
|
|
List<String> name = new ArrayList<>();
|
|
|
boolean previousUsersApproved = true;
|
|
|
boolean isCurrentUserLastApprover = true;
|
|
@@ -1265,7 +1374,7 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void updateCopyDataApproveStatus(Task task, TaskApproveDTO dto) {
|
|
|
+ private TaskController updateCopyDataApproveStatus(Task task, TaskApproveDTO dto) {
|
|
|
String formDataId = task.getFormDataId();
|
|
|
if (task.getMeterTaskType().equals(1)) {
|
|
|
List<MiddleMeterApplyTask> middleMeterApplyTasks = middleMeterApplyServiceTask.getBaseMapper().selectList(Wrappers.<MiddleMeterApplyTask>lambdaQuery()
|
|
@@ -1317,10 +1426,12 @@ public class TaskController extends BladeController {
|
|
|
} else if (task.getMeterTaskType().equals(4)) {
|
|
|
//TODO 变更令
|
|
|
}
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
- private void updateTaskStatus(Task task) {
|
|
|
+ private TaskController updateTaskStatus(Task task) {
|
|
|
jdbcTemplate.execute("UPDATE u_task SET status = 2 WHERE id = " + task.getId());
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
private void updateTaskParallelStatus(Task task) {
|
|
@@ -1330,7 +1441,7 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void displace(Task task, TaskApproveDTO dto) {
|
|
|
+ private TaskController displace(Task task, TaskApproveDTO dto) {
|
|
|
if (task.getMeterTaskType().equals(1)) {
|
|
|
List<MiddleMeterApplyTask> middleMeterApplyTasks = middleMeterApplyServiceTask.getBaseMapper().selectList(Wrappers.<MiddleMeterApplyTask>lambdaQuery()
|
|
|
.eq(MiddleMeterApplyTask::getContractPeriodId, task.getFormDataId())
|
|
@@ -1367,6 +1478,7 @@ public class TaskController extends BladeController {
|
|
|
} else if (task.getMeterTaskType().equals(4)) {
|
|
|
//TODO 变更令
|
|
|
}
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
@GetMapping("/comment/list")
|
|
@@ -1374,7 +1486,7 @@ public class TaskController extends BladeController {
|
|
|
@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 = ?";
|
|
|
+ String sql = "SELECT * FROM s_task_comment WHERE task_id = ? AND data_id = ? ORDER BY create_time";
|
|
|
List<TaskComment> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskComment.class), taskId, dataId);
|
|
|
return R.data(200, query, "操作成功");
|
|
|
}
|
|
@@ -1385,7 +1497,7 @@ public class TaskController extends BladeController {
|
|
|
@ApiOperationSupport(order = 17)
|
|
|
@ApiOperation(value = "批注信息新增或修改", notes = "传入TaskComment")
|
|
|
@Transactional
|
|
|
- public R<Object> commentSave(@RequestBody TaskComment taskComment) {
|
|
|
+ public R<Object> commentSubmit(@RequestBody TaskComment taskComment) {
|
|
|
if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
|
throw new ServiceException("未获取到当前用户信息");
|
|
|
}
|