|
@@ -0,0 +1,307 @@
|
|
|
|
+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;
|
|
|
|
+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.common.utils.SnowFlakeUtil;
|
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
|
+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
|
|
|
|
+@AllArgsConstructor
|
|
|
|
+@RequestMapping("/mid/pay/item")
|
|
|
|
+@Api(value = "计量中期支付项接口", tags = "计量中期支付项接口")
|
|
|
|
+public class MidPayItemController extends BladeController {
|
|
|
|
+
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
|
+ private final MidPayItemSystemService payItemSystemService;
|
|
|
|
+ private final MidPayItemProjectService payItemProjectService;
|
|
|
|
+ private final MidPayItemContractService payItemContractService;
|
|
|
|
+
|
|
|
|
+ @GetMapping("/system/detail")
|
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
|
+ @ApiOperation(value = "系统中期支付项详情", notes = "传入id")
|
|
|
|
+ public R<MeterMidPayItemSystemVO> systemDetail(@RequestParam String id) {
|
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
|
+ MeterMidPayItemSystem obj = payItemSystemService.getById(id);
|
|
|
|
+ MeterMidPayItemSystemVO vo = new MeterMidPayItemSystemVO();
|
|
|
|
+ BeanUtil.copyProperties(obj, vo);
|
|
|
|
+ List<MeterMidPayItemRelation> recordInfos = jdbcTemplate.query("SELECT * FROM s_meter_mid_pay_item_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")
|
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
|
+ @ApiOperation(value = "系统中期支付项新增或修改", notes = "传入MeterMidPayItemSystem对象")
|
|
|
|
+ public R<Object> systemSubmit(@RequestBody MeterMidPayItemSystem obj) {
|
|
|
|
+ return R.data(payItemSystemService.saveOrUpdate(obj));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/system/remove")
|
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
|
+ @ApiOperation(value = "系统中期支付项删除", notes = "传入id")
|
|
|
|
+ public R<Object> systemRemove(@RequestParam String id) {
|
|
|
|
+ return R.data(payItemSystemService.removeById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/system/page")
|
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
|
+ @ApiOperation(value = "系统中期支付项分页", notes = "传入MeterMidPayItemSystem、Query")
|
|
|
|
+ public R<IPage<MeterMidPayItemSystem>> systemPage(@RequestBody MeterMidPayItemSystem meterMidPayItemSystem, @RequestBody Query query) {
|
|
|
|
+ IPage<MeterMidPayItemSystem> pages = payItemSystemService.page(Condition.getPage(query), Condition.getQueryWrapper(meterMidPayItemSystem));
|
|
|
|
+ List<MeterMidPayItemSystem> sortResult = pages.getRecords().stream()
|
|
|
|
+ .sorted(Comparator.comparing(MeterMidPayItemSystem::getCreateTime))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ return R.data(pages.setRecords(sortResult));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/system/list")
|
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
|
+ @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<MeterMidPayItemProjectVO> projectDetail(@RequestParam String id) {
|
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
|
+ MeterMidPayItemProject obj = payItemProjectService.getById(id);
|
|
|
|
+ MeterMidPayItemProjectVO vo = new MeterMidPayItemProjectVO();
|
|
|
|
+ BeanUtil.copyProperties(obj, vo);
|
|
|
|
+ List<MeterMidPayItemRelation> recordInfos = jdbcTemplate.query("SELECT * FROM s_meter_mid_pay_item_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")
|
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
|
+ @ApiOperation(value = "项目中期支付项引用系统级数据", notes = "传入数据id逗号拼接ids、projectId")
|
|
|
|
+ public R<Object> projectReferenced(@RequestParam String ids, @RequestParam Long projectId) {
|
|
|
|
+ if (StringUtils.isNotEmpty(ids)) {
|
|
|
|
+ List<Long> systemIds = Func.toLongList(ids);
|
|
|
|
+ List<MeterMidPayItemSystem> meterMidPayItemSystems = payItemSystemService.getBaseMapper().selectList(Wrappers.<MeterMidPayItemSystem>lambdaQuery().in(MeterMidPayItemSystem::getId, systemIds).orderByAsc(MeterMidPayItemSystem::getCreateTime));
|
|
|
|
+ List<MeterMidPayItemProject> meterMidPayItemProjects = new ArrayList<>();
|
|
|
|
+ for (MeterMidPayItemSystem systemPay : meterMidPayItemSystems) {
|
|
|
|
+ MeterMidPayItemProject projectPay = BeanUtil.copyProperties(systemPay, MeterMidPayItemProject.class);
|
|
|
|
+ if (projectPay != null) {
|
|
|
|
+ projectPay.setId(SnowFlakeUtil.getId());
|
|
|
|
+ projectPay.setProjectId(projectId);
|
|
|
|
+ meterMidPayItemProjects.add(projectPay);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (meterMidPayItemProjects.size() > 0) {
|
|
|
|
+ /*批量修改状态为被引用*/
|
|
|
|
+ UpdateWrapper<MeterMidPayItemSystem> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.in("id", systemIds);
|
|
|
|
+ MeterMidPayItemSystem updateEntity = new MeterMidPayItemSystem();
|
|
|
|
+ updateEntity.setIsReferenced(1);
|
|
|
|
+ boolean b1 = payItemSystemService.update(updateEntity, updateWrapper);
|
|
|
|
+ boolean b2 = payItemProjectService.saveBatch(meterMidPayItemProjects, 1000);
|
|
|
|
+ if (b1 && b2) {
|
|
|
|
+ return R.success("操作成功");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.fail("操作失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/project/update")
|
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
|
+ @ApiOperation(value = "项目中期支付项修改", notes = "传入MeterMidPayItemProject对象")
|
|
|
|
+ public R<Object> projectUpdate(@RequestBody MeterMidPayItemProject obj) {
|
|
|
|
+ return R.data(payItemProjectService.updateById(obj));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/project/remove")
|
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
|
+ @ApiOperation(value = "项目中期支付项删除", notes = "传入id")
|
|
|
|
+ public R<Object> projectRemove(@RequestParam String id) {
|
|
|
|
+ return R.data(payItemProjectService.removeById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/project/page")
|
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
|
|
+ @ApiOperation(value = "项目中期支付项分页", notes = "传入MeterMidPayItemProject、Query")
|
|
|
|
+ public R<IPage<MeterMidPayItemProject>> projectPage(@RequestBody MeterMidPayItemProject meterMidPayItemProject, @RequestBody Query query) {
|
|
|
|
+ IPage<MeterMidPayItemProject> pages = payItemProjectService.page(Condition.getPage(query), Condition.getQueryWrapper(meterMidPayItemProject));
|
|
|
|
+ List<MeterMidPayItemProject> sortResult = pages.getRecords().stream()
|
|
|
|
+ .sorted(Comparator.comparing(MeterMidPayItemProject::getCreateTime))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ return R.data(pages.setRecords(sortResult));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/project/list")
|
|
|
|
+ @ApiOperationSupport(order = 11)
|
|
|
|
+ @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<MeterMidPayItemContractVO> contractDetail(@RequestParam String id) {
|
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
|
+ MeterMidPayItemContract obj = payItemContractService.getById(id);
|
|
|
|
+ MeterMidPayItemContractVO vo = new MeterMidPayItemContractVO();
|
|
|
|
+ BeanUtil.copyProperties(obj, vo);
|
|
|
|
+ List<MeterMidPayItemRelation> recordInfos = jdbcTemplate.query("SELECT * FROM s_meter_mid_pay_item_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")
|
|
|
|
+ @ApiOperationSupport(order = 13)
|
|
|
|
+ @ApiOperation(value = "合同段中期支付项引用项目级数据", notes = "传入数据id逗号拼接ids、projectId、contractId")
|
|
|
|
+ public R<Object> contractReferenced(@RequestParam String ids, @RequestParam Long projectId, @RequestParam Long contractId) {
|
|
|
|
+ if (StringUtils.isNotEmpty(ids)) {
|
|
|
|
+ List<Long> projectIds = Func.toLongList(ids);
|
|
|
|
+ List<MeterMidPayItemProject> meterMidPayItemProjects = payItemProjectService.getBaseMapper().selectList(Wrappers.<MeterMidPayItemProject>lambdaQuery().in(MeterMidPayItemProject::getId, projectIds).orderByAsc(MeterMidPayItemProject::getCreateTime));
|
|
|
|
+ List<MeterMidPayItemContract> meterMidPayItemContracts = new ArrayList<>();
|
|
|
|
+ for (MeterMidPayItemProject projectPay : meterMidPayItemProjects) {
|
|
|
|
+ MeterMidPayItemContract contractPay = BeanUtil.copyProperties(projectPay, MeterMidPayItemContract.class);
|
|
|
|
+ if (contractPay != null) {
|
|
|
|
+ contractPay.setId(SnowFlakeUtil.getId());
|
|
|
|
+ contractPay.setProjectId(projectId);
|
|
|
|
+ contractPay.setContractId(contractId);
|
|
|
|
+ meterMidPayItemContracts.add(contractPay);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (meterMidPayItemContracts.size() > 0) {
|
|
|
|
+ /*批量修改状态为被引用*/
|
|
|
|
+ UpdateWrapper<MeterMidPayItemProject> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.in("id", projectIds);
|
|
|
|
+ MeterMidPayItemProject updateEntity = new MeterMidPayItemProject();
|
|
|
|
+ updateEntity.setIsReferenced(1);
|
|
|
|
+ boolean b1 = payItemProjectService.update(updateEntity, updateWrapper);
|
|
|
|
+ boolean b2 = payItemContractService.saveBatch(meterMidPayItemContracts, 1000);
|
|
|
|
+ if (b1 && b2) {
|
|
|
|
+ return R.success("操作成功");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.fail("操作失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/contract/update")
|
|
|
|
+ @ApiOperationSupport(order = 14)
|
|
|
|
+ @ApiOperation(value = "合同段中期支付项修改", notes = "传入MeterMidPayItemContract对象")
|
|
|
|
+ public R<Object> contractUpdate(@RequestBody MeterMidPayItemContract obj) {
|
|
|
|
+ return R.data(payItemContractService.updateById(obj));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/contract/remove")
|
|
|
|
+ @ApiOperationSupport(order = 15)
|
|
|
|
+ @ApiOperation(value = "合同段中期支付项删除", notes = "传入id")
|
|
|
|
+ public R<Object> contractRemove(@RequestParam String id) {
|
|
|
|
+ return R.data(payItemContractService.removeById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/contract/page")
|
|
|
|
+ @ApiOperationSupport(order = 16)
|
|
|
|
+ @ApiOperation(value = "合同段中期支付项分页", notes = "传入MeterMidPayItemContract、Query")
|
|
|
|
+ public R<IPage<MeterMidPayItemContract>> contractPage(@RequestBody MeterMidPayItemContract meterMidPayItemContract, @RequestBody Query query) {
|
|
|
|
+ IPage<MeterMidPayItemContract> pages = payItemContractService.page(Condition.getPage(query), Condition.getQueryWrapper(meterMidPayItemContract));
|
|
|
|
+ List<MeterMidPayItemContract> sortResult = pages.getRecords().stream()
|
|
|
|
+ .sorted(Comparator.comparing(MeterMidPayItemContract::getCreateTime))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ 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("操作失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|