From 6f9623981926d78ce8ccd80bce55ad631bd2c76b Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期四, 27 三月 2025 17:16:13 +0800
Subject: [PATCH] fix: 计划合并提交
---
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandPlanController.java | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 108 insertions(+), 4 deletions(-)
diff --git a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandPlanController.java b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandPlanController.java
index 03ff167..f67a136 100644
--- a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandPlanController.java
+++ b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandPlanController.java
@@ -3,14 +3,19 @@
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.by4cloud.platformx.common.core.util.R;
import com.by4cloud.platformx.common.log.annotation.SysLog;
+import com.by4cloud.platformx.common.security.util.SecurityUtils;
import com.by4cloud.platformx.device.constant.MaxSizeContant;
+import com.by4cloud.platformx.device.entity.Device;
import com.by4cloud.platformx.device.entity.DeviceDemandPlan;
-import com.by4cloud.platformx.device.service.DeviceDemandPlanService;
-import com.by4cloud.platformx.device.service.JcMaxSizeService;
+import com.by4cloud.platformx.device.entity.DeviceDemandSub;
+import com.by4cloud.platformx.device.service.*;
+import com.by4cloud.platformx.device.util.NumUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -21,8 +26,8 @@
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* 璁惧闇�姹傝鍒掍富琛�
@@ -38,7 +43,10 @@
public class DeviceDemandPlanController {
private final DeviceDemandPlanService deviceDemandPlanService;
+ private final DeviceDemandTotalService deviceDemandTotalService;
+ private final DeviceDemandSubService deviceDemandSubService;
private final JcMaxSizeService maxSizeService;
+ private final DeviceService deviceService;
/**
* 鍒嗛〉鏌ヨ
@@ -55,6 +63,23 @@
wrapper.eq(deviceDemandPlan.getYear() !=null,DeviceDemandPlan::getYear,deviceDemandPlan.getYear());
return R.ok(deviceDemandPlanService.pageByScope(page, wrapper));
}
+
+ /**
+ * 鍒嗛〉鏌ヨ2
+ * @param page 鍒嗛〉瀵硅薄
+ * @param deviceDemandPlan 璁惧闇�姹傝鍒掍富琛�
+ * @return
+ */
+ @Operation(summary = "鏈崟浣嶅垎椤垫煡璇�" , description = "鏈崟浣嶅垎椤垫煡璇�" )
+ @GetMapping("/page2" )
+ public R page2(@ParameterObject Page page, @ParameterObject DeviceDemandPlan deviceDemandPlan) {
+ LambdaQueryWrapper<DeviceDemandPlan> wrapper = Wrappers.lambdaQuery();
+ wrapper.eq(deviceDemandPlan.getDeclareCompId() !=null,DeviceDemandPlan::getDeclareCompId,deviceDemandPlan.getDeclareCompId());
+ wrapper.eq(deviceDemandPlan.getReleasePerson() !=null,DeviceDemandPlan::getReleasePerson,deviceDemandPlan.getReleasePerson());
+ wrapper.eq(deviceDemandPlan.getYear() !=null,DeviceDemandPlan::getYear,deviceDemandPlan.getYear());
+ wrapper.eq(DeviceDemandPlan::getType2,1);
+ return R.ok(deviceDemandPlanService.page(page, wrapper));
+ }
/**
@@ -80,9 +105,88 @@
@PreAuthorize("@pms.hasPermission('platformx_deviceDemandPlan_add')" )
public R save(@RequestBody DeviceDemandPlan deviceDemandPlan) {
deviceDemandPlan.setNumber(maxSizeService.nextNo(MaxSizeContant.PLAN_NUM));
+ deviceDemandPlan.setType2(0);
return R.ok(deviceDemandPlanService.save(deviceDemandPlan));
}
+ @Operation(summary = "鍚堝苟璁″垝鎻愪氦" , description = "鍚堝苟璁″垝鎻愪氦" )
+ @GetMapping("/mergePlan" )
+ public R mergePlan(String ids) {
+ List<DeviceDemandSub> subs = new ArrayList<>();
+ DeviceDemandPlan plan = new DeviceDemandPlan();
+ deviceDemandPlanService.save(plan);
+ Double aa = 0d;
+ String name = SecurityUtils.getUser().getName();
+ if(StringUtils.isNotBlank(ids)){
+ String[] split = ids.split(",");
+ for (String s : split) {
+ long l = Long.parseLong(s);
+ DeviceDemandPlan byId = deviceDemandPlanService.getById(l);
+ byId.setPlanId(plan.getId());
+ byId.setSendDate(new Date());
+ deviceDemandPlanService.updateById(byId);
+ plan.setYear(byId.getYear());
+ plan.setType(byId.getType());
+ aa= NumUtils.addDoubles(aa,byId.getAmount());
+ //鍚堝苟瀛愰」
+ List<DeviceDemandSub> byPlanId = deviceDemandSubService.getByPlanId(l);
+ subs.addAll(byPlanId);
+ }
+ }
+ plan.setAmount(aa);
+ plan.setReleasePerson(name);
+ plan.setStatus(3);
+ plan.setType2(1);
+ if(subs.size()>0){
+ deviceDemandPlanService.updateById(plan);
+ return R.ok("鎻愪氦鎴愬姛");
+ }else {
+ return R.failed("璇烽�夋嫨璁″垝鎻愪氦");
+ }
+ }
+
+ @Operation(summary = "鏌ョ湅瀛愰」璇︽儏" , description = "鏌ョ湅瀛愰」璇︽儏" )
+ @GetMapping("/getByMergePlanId/{id}" )
+ public R getByMergePlanId(@PathVariable("id" ) Long id) {
+ List<DeviceDemandSub> subs = new ArrayList<>();
+ QueryWrapper<DeviceDemandPlan> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .eq(DeviceDemandPlan::getPlanId,id);
+ List<DeviceDemandPlan> list = deviceDemandPlanService.list(wrapper);
+ List<Long> collect = list.stream().map(DeviceDemandPlan::getId).collect(Collectors.toList());
+ for (Long l : collect) {
+ //鍚堝苟瀛愰」
+ List<DeviceDemandSub> byPlanId = deviceDemandSubService.getByPlanId(l);
+ subs.addAll(byPlanId);
+ }
+ List<Map<String,Object>> resultList = new ArrayList<>();
+ for (Map.Entry<Integer, List<DeviceDemandSub>> integerListEntry : subs.stream().collect(Collectors.groupingBy(item -> item.getMonth())).entrySet()) {
+ Integer month = integerListEntry.getKey();
+ List<Map<String,Object>> mapList = new ArrayList<>();
+ for (Map.Entry<Long, List<DeviceDemandSub>> entry : integerListEntry.getValue().stream().collect(Collectors.groupingBy(item -> item.getDeviceId())).entrySet()) {
+ Long key = entry.getKey();
+ int size = entry.getValue().size();
+ Device device = deviceService.getById(key);
+ Map<String,Object> map = new HashMap<>();
+ map.put("deviceNumber",device.getNumber());
+ map.put("name",device.getName());
+ map.put("count",size);
+ map.put("manu",device.getManu());
+ map.put("beforeDate",device.getBeforeDate());
+ map.put("depreciation",device.getDepreciation());
+ map.put("remindDate",device.getRemindDate());
+ mapList.add(map);
+ }
+ Map<String,Object> map = new HashMap<>();
+ map.put("month",month);
+ map.put("deviceList",mapList);
+ resultList.add(map);
+
+ }
+ return R.ok(resultList);
+
+ }
+
/**
* 淇敼璁惧闇�姹傝鍒掍富琛�
* @param deviceDemandPlan 璁惧闇�姹傝鍒掍富琛�
--
Gitblit v1.9.1