|
@@ -1,5 +1,6 @@
|
|
|
package org.springblade.meter.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
@@ -19,11 +20,17 @@ import org.springblade.meter.entity.*;
|
|
|
import org.springblade.meter.service.MidPayItemContractService;
|
|
|
import org.springblade.meter.service.MidPayItemProjectService;
|
|
|
import org.springblade.meter.service.MidPayItemSystemService;
|
|
|
+import org.springblade.meter.vo.MeterMidPayItemContractVO;
|
|
|
+import org.springblade.meter.vo.MeterMidPayItemProjectVO;
|
|
|
+import org.springblade.meter.vo.MeterMidPayItemSystemVO;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@@ -32,6 +39,7 @@ import java.util.stream.Collectors;
|
|
|
@Api(value = "计量中期支付项接口", tags = "计量中期支付项接口")
|
|
|
public class MidPayItemController extends BladeController {
|
|
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
private final MidPayItemSystemService payItemSystemService;
|
|
|
private final MidPayItemProjectService payItemProjectService;
|
|
|
private final MidPayItemContractService payItemContractService;
|
|
@@ -39,8 +47,20 @@ public class MidPayItemController extends BladeController {
|
|
|
@GetMapping("/system/detail")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "系统中期支付项详情", notes = "传入id")
|
|
|
- public R<MeterMidPayItemSystem> systemDetail(@RequestParam String id) {
|
|
|
- return R.data(payItemSystemService.getById(id));
|
|
|
+ public R<MeterMidPayItemSystemVO> systemDetail(@RequestParam String id) {
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ MeterMidPayItemSystem obj = payItemSystemService.getById(id);
|
|
|
+ MeterMidPayItemSystemVO vo = new MeterMidPayItemSystemVO();
|
|
|
+ BeanUtil.copyProperties(vo, obj);
|
|
|
+ List<MeterMidPayItemRelation> recordInfos = jdbcTemplate.query("SELECT * FROM mid_pay_id_relation WHERE mid_pay_id = " + id, new BeanPropertyRowMapper<>(MeterMidPayItemRelation.class));
|
|
|
+ if (recordInfos.size() > 0) {
|
|
|
+ Set<Long> ids = recordInfos.stream().map(MeterMidPayItemRelation::getMidPayIdRelation).collect(Collectors.toSet());
|
|
|
+ List<MeterMidPayItemSystem> recordList = payItemSystemService.listByIds(ids);
|
|
|
+ vo.setSummaryItemList(recordList);
|
|
|
+ }
|
|
|
+ return R.data(vo);
|
|
|
+ }
|
|
|
+ return R.data(null);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/system/submit")
|
|
@@ -70,16 +90,33 @@ public class MidPayItemController extends BladeController {
|
|
|
|
|
|
@PostMapping("/system/list")
|
|
|
@ApiOperationSupport(order = 5)
|
|
|
- @ApiOperation(value = "系统中期支付项列表", notes = "")
|
|
|
- public R<List<MeterMidPayItemSystem>> systemList() {
|
|
|
- return R.data(payItemSystemService.getBaseMapper().selectList(Wrappers.<MeterMidPayItemSystem>lambdaQuery().eq(MeterMidPayItemSystem::getIsReferenced, 0).orderByAsc(MeterMidPayItemSystem::getCreateTime)));
|
|
|
+ @ApiOperation(value = "系统中期支付项列表", notes = "type=0(未被引用),type=1(已引用),type=空(全部)")
|
|
|
+ public R<List<MeterMidPayItemSystem>> systemList(@RequestParam String type) {
|
|
|
+ LambdaQueryWrapper<MeterMidPayItemSystem> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ if (type != null) {
|
|
|
+ queryWrapper.eq(MeterMidPayItemSystem::getIsReferenced, type);
|
|
|
+ }
|
|
|
+ queryWrapper.orderByAsc(MeterMidPayItemSystem::getCreateTime);
|
|
|
+ return R.data(payItemSystemService.getBaseMapper().selectList(queryWrapper));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/project/detail")
|
|
|
@ApiOperationSupport(order = 6)
|
|
|
@ApiOperation(value = "项目中期支付项详情", notes = "传入id")
|
|
|
- public R<MeterMidPayItemProject> projectDetail(@RequestParam String id) {
|
|
|
- return R.data(payItemProjectService.getById(id));
|
|
|
+ public R<MeterMidPayItemProjectVO> projectDetail(@RequestParam String id) {
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ MeterMidPayItemProject obj = payItemProjectService.getById(id);
|
|
|
+ MeterMidPayItemProjectVO vo = new MeterMidPayItemProjectVO();
|
|
|
+ BeanUtil.copyProperties(vo, obj);
|
|
|
+ List<MeterMidPayItemRelation> recordInfos = jdbcTemplate.query("SELECT * FROM mid_pay_id_relation WHERE mid_pay_id = " + id, new BeanPropertyRowMapper<>(MeterMidPayItemRelation.class));
|
|
|
+ if (recordInfos.size() > 0) {
|
|
|
+ Set<Long> ids = recordInfos.stream().map(MeterMidPayItemRelation::getMidPayIdRelation).collect(Collectors.toSet());
|
|
|
+ List<MeterMidPayItemProject> recordList = payItemProjectService.listByIds(ids);
|
|
|
+ vo.setSummaryItemList(recordList);
|
|
|
+ }
|
|
|
+ return R.data(vo);
|
|
|
+ }
|
|
|
+ return R.data(null);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/project/referenced")
|
|
@@ -141,16 +178,34 @@ public class MidPayItemController extends BladeController {
|
|
|
|
|
|
@PostMapping("/project/list")
|
|
|
@ApiOperationSupport(order = 11)
|
|
|
- @ApiOperation(value = "项目中期支付项列表", notes = "")
|
|
|
- public R<List<MeterMidPayItemProject>> projectList() {
|
|
|
- return R.data(payItemProjectService.getBaseMapper().selectList(Wrappers.<MeterMidPayItemProject>lambdaQuery().eq(MeterMidPayItemProject::getIsReferenced, 0).orderByAsc(MeterMidPayItemProject::getCreateTime)));
|
|
|
+ @ApiOperation(value = "系统中期支付项列表", notes = "传入type=0(未被引用),type=1(已引用),type=空(全部)、projectId")
|
|
|
+ public R<List<MeterMidPayItemProject>> projectList(@RequestParam String type, @RequestParam String projectId) {
|
|
|
+ LambdaQueryWrapper<MeterMidPayItemProject> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ if (type != null) {
|
|
|
+ queryWrapper.eq(MeterMidPayItemProject::getIsReferenced, type);
|
|
|
+ }
|
|
|
+ queryWrapper.eq(MeterMidPayItemProject::getProjectId, projectId);
|
|
|
+ queryWrapper.orderByAsc(MeterMidPayItemProject::getCreateTime);
|
|
|
+ return R.data(payItemProjectService.getBaseMapper().selectList(queryWrapper));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/contract/detail")
|
|
|
@ApiOperationSupport(order = 12)
|
|
|
@ApiOperation(value = "合同段中期支付项详情", notes = "传入id")
|
|
|
- public R<MeterMidPayItemContract> contractDetail(@RequestParam String id) {
|
|
|
- return R.data(payItemContractService.getById(id));
|
|
|
+ public R<MeterMidPayItemContractVO> contractDetail(@RequestParam String id) {
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ MeterMidPayItemContract obj = payItemContractService.getById(id);
|
|
|
+ MeterMidPayItemContractVO vo = new MeterMidPayItemContractVO();
|
|
|
+ BeanUtil.copyProperties(vo, obj);
|
|
|
+ List<MeterMidPayItemRelation> recordInfos = jdbcTemplate.query("SELECT * FROM mid_pay_id_relation WHERE mid_pay_id = " + id, new BeanPropertyRowMapper<>(MeterMidPayItemRelation.class));
|
|
|
+ if (recordInfos.size() > 0) {
|
|
|
+ Set<Long> ids = recordInfos.stream().map(MeterMidPayItemRelation::getMidPayIdRelation).collect(Collectors.toSet());
|
|
|
+ List<MeterMidPayItemContract> recordList = payItemContractService.listByIds(ids);
|
|
|
+ vo.setSummaryItemList(recordList);
|
|
|
+ }
|
|
|
+ return R.data(vo);
|
|
|
+ }
|
|
|
+ return R.data(null);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/contract/referenced")
|
|
@@ -211,4 +266,42 @@ public class MidPayItemController extends BladeController {
|
|
|
return R.data(pages.setRecords(sortResult));
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/contract/all-list")
|
|
|
+ @ApiOperationSupport(order = 17)
|
|
|
+ @ApiOperation(value = "合同段中期支付项列表(全部)", notes = "传入contractId")
|
|
|
+ public R<List<MeterMidPayItemContract>> contractAllList(@RequestParam String contractId) {
|
|
|
+ return R.data(payItemContractService.getBaseMapper().selectList(Wrappers.<MeterMidPayItemContract>lambdaQuery().eq(MeterMidPayItemContract::getContractId, contractId).orderByAsc(MeterMidPayItemContract::getCreateTime)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/bind/submit")
|
|
|
+ @ApiOperationSupport(order = 18)
|
|
|
+ @ApiOperation(value = "中期支付项添加汇总项", notes = "传入id、汇总项列表id逗号拼接成bindIds")
|
|
|
+ public R<Object> bind(@RequestParam String id, @RequestParam String bindIds) {
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ if (StringUtils.isEmpty(bindIds)) {
|
|
|
+
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_meter_mid_pay_item_relation WHERE mid_pay_id = " + id);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ for (String bindId : bindIds.split(",")) {
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_meter_mid_pay_item_relation WHERE mid_pay_id = " + id + " AND mid_pay_id_relation = " + bindId);
|
|
|
+ jdbcTemplate.execute("INSERT INTO s_meter_mid_pay_item_relation(id,mid_pay_id,mid_pay_id_relation) VALUES (" + SnowFlakeUtil.getId() + "," + id + "," + bindId + ")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/bind/remove")
|
|
|
+ @ApiOperationSupport(order = 19)
|
|
|
+ @ApiOperation(value = "中期支付项删除汇总项", notes = "传入id、汇总项列表bindId")
|
|
|
+ public R<Object> bindRemove(@RequestParam String id, @RequestParam String bindId) {
|
|
|
+ if (StringUtils.isNotEmpty(id) && StringUtils.isNotEmpty(bindId)) {
|
|
|
+ jdbcTemplate.execute("DELETE FROM s_meter_mid_pay_item_relation WHERE mid_pay_id = " + id + " AND mid_pay_id_relation = " + bindId);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
}
|