|
@@ -0,0 +1,85 @@
|
|
|
+package org.springblade.meter.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+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.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/task")
|
|
|
+@Api(value = "计量任务管理相关接口", tags = "计量任务管理相关接口")
|
|
|
+public class TaskController extends BladeController {
|
|
|
+
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+ private final ContractMeterPeriodServiceImpl contractMeterPeriodService;
|
|
|
+ private final MeterPeriodServiceImpl periodService;
|
|
|
+ private final MiddleMeterApplyServiceImpl meterApplyService;
|
|
|
+
|
|
|
+ @GetMapping("/name")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "获取任务名称", notes = "传入合同段contractId、期数id、type=1(中间计量申请)、=2(材料计量单、开工预付款计量单)")
|
|
|
+ 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);
|
|
|
+ String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
+ if (("1").equals(type)) {
|
|
|
+ ContractMeterPeriod contractMeterPeriod = contractMeterPeriodService.getById(id);
|
|
|
+ if (contractInfo != null && contractMeterPeriod != null) {
|
|
|
+ name = "【" + contractInfo.getContractName() + "】" + date + " 中间计量申请【" + contractMeterPeriod.getPeriodNumber() + "】";
|
|
|
+ }
|
|
|
+ } else if (("2").equals(type)) {
|
|
|
+ MeterPeriod meterPeriod = periodService.getById(id);
|
|
|
+ if (contractInfo != null && meterPeriod != null) {
|
|
|
+ name = "【" + contractInfo.getContractName() + "】" + date + " 中间计量申请【" + meterPeriod.getPeriodNumber() + "】";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(200, name, "操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/approval")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "上报(发起审批)", notes = "传入MeterApprovalDTO")
|
|
|
+ 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()
|
|
|
+ .eq(MiddleMeterApply::getContractPeriodId, approvalDTO.getPeriodId()));
|
|
|
+
|
|
|
+ /*获取所有中间计量申请下的清单信息*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } else if (approvalDTO.getType().equals(2)) { /*材料、开工*/
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|