From 959e5318189e66ad58d07c5bb94789c815b4d2e9 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期六, 16 八月 2025 11:42:37 +0800
Subject: [PATCH] art: WebService服务端相关代码修改
---
src/main/java/org/jeecg/modules/qms/controller/InspectionPlanController.java | 107 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 98 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/jeecg/modules/qms/controller/InspectionPlanController.java b/src/main/java/org/jeecg/modules/qms/controller/InspectionPlanController.java
index 764eac7..99bbb3b 100644
--- a/src/main/java/org/jeecg/modules/qms/controller/InspectionPlanController.java
+++ b/src/main/java/org/jeecg/modules/qms/controller/InspectionPlanController.java
@@ -1,20 +1,28 @@
package org.jeecg.modules.qms.controller;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.util.*;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.qms.entity.Defect;
+import org.jeecg.modules.qms.entity.InspectionItem;
import org.jeecg.modules.qms.entity.InspectionPlan;
+import org.jeecg.modules.qms.entity.InspectionPlanItem;
+import org.jeecg.modules.qms.service.IInspectionPlanItemService;
import org.jeecg.modules.qms.service.IInspectionPlanService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -51,6 +59,9 @@
public class InspectionPlanController extends JeecgController<InspectionPlan, IInspectionPlanService> {
@Autowired
private IInspectionPlanService inspectionPlanService;
+
+ @Autowired
+ private IInspectionPlanItemService inspectionPlanItemService;
/**
* 鍒嗛〉鍒楄〃鏌ヨ
@@ -77,31 +88,57 @@
/**
* 娣诲姞
*
- * @param inspectionPlan
+ * @param jSONObject
* @return
*/
@AutoLog(value = "妫�楠屾柟妗�-娣诲姞")
@ApiOperation(value="妫�楠屾柟妗�-娣诲姞", notes="妫�楠屾柟妗�-娣诲姞")
- //@RequiresPermissions("org.jeecg.modules:qms_inspection_plan:add")
@PostMapping(value = "/add")
- public Result<String> add(@RequestBody InspectionPlan inspectionPlan) {
+ public Result<?> add(@RequestBody JSONObject jSONObject) {
+ InspectionPlan inspectionPlan = jSONObject.toJavaObject(InspectionPlan.class);
inspectionPlan.setPlanStatus(CommonConstant.STATUS_1);
+ inspectionPlan.setPublishStatus(CommonConstant.STATUS_0);
+ inspectionPlan.setIsNewVersion("1");
+ inspectionPlan.setVersion("V1");
inspectionPlanService.save(inspectionPlan);
+ //淇濆瓨妫�楠屾柟妗堟楠岄」鐩叧鑱斿叧绯�
+ JSONArray jsonArray = jSONObject.getJSONArray("detailData");
+ List<InspectionPlanItem> inspectionPlanItemList = jsonArray.toJavaList(InspectionPlanItem.class);
+ for(int i = 0;i<inspectionPlanItemList.size();i++){
+ InspectionPlanItem inspectionPlanItem = inspectionPlanItemList.get(i);
+ inspectionPlanItem.setItemId(inspectionPlanItem.getId());
+ inspectionPlanItem.setId(null);
+ inspectionPlanItem.setPlanId(inspectionPlan.getId());
+ }
+ inspectionPlanItemService.saveBatch(inspectionPlanItemList);
return Result.OK("娣诲姞鎴愬姛锛�");
}
/**
* 缂栬緫
*
- * @param inspectionPlan
+ * @param jSONObject
* @return
*/
@AutoLog(value = "妫�楠屾柟妗�-缂栬緫")
@ApiOperation(value="妫�楠屾柟妗�-缂栬緫", notes="妫�楠屾柟妗�-缂栬緫")
- //@RequiresPermissions("org.jeecg.modules:qms_inspection_plan:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
- public Result<String> edit(@RequestBody InspectionPlan inspectionPlan) {
+ public Result<?> edit(@RequestBody JSONObject jSONObject) {
+ InspectionPlan inspectionPlan = jSONObject.toJavaObject(InspectionPlan.class);
+ inspectionPlan.setPlanStatus(CommonConstant.STATUS_1);
inspectionPlanService.updateById(inspectionPlan);
+ //鍒犻櫎鍘熷叧鑱斿叧绯�
+ inspectionPlanItemService.removeBatchByIds(inspectionPlanItemService.lambdaQuery().eq(InspectionPlanItem::getPlanId,inspectionPlan.getId()).list());
+ //淇濆瓨妫�楠屾柟妗堟楠岄」鐩叧鑱斿叧绯�
+ JSONArray jsonArray = jSONObject.getJSONArray("detailData");
+ List<InspectionPlanItem> inspectionPlanItemList = jsonArray.toJavaList(InspectionPlanItem.class);
+ for(int i = 0;i<inspectionPlanItemList.size();i++){
+ InspectionPlanItem inspectionPlanItem = inspectionPlanItemList.get(i);
+ inspectionPlanItem.setPlanId(inspectionPlan.getId());
+ inspectionPlanItem.setItemId(inspectionPlanItem.getId());
+ inspectionPlanItem.setId(null);
+ }
+ inspectionPlanItemService.saveBatch(inspectionPlanItemList);
return Result.OK("缂栬緫鎴愬姛!");
}
@@ -117,6 +154,8 @@
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
inspectionPlanService.removeById(id);
+ //鍒犻櫎鍏宠仈鍏崇郴
+ inspectionPlanItemService.removeBatchByIds(inspectionPlanItemService.lambdaQuery().eq(InspectionPlanItem::getPlanId,id).list());
return Result.OK("鍒犻櫎鎴愬姛!");
}
@@ -191,4 +230,54 @@
return Result.ok("鎿嶄綔鎴愬姛锛�");
}
+ @AutoLog(value = "妫�楠屾柟妗�-鍙戝竷")
+ @ApiOperation(value = "妫�楠屾柟妗�-鍙戝竷", notes = "妫�楠屾柟妗�-鍙戝竷")
+ @PutMapping(value = "/publish")
+ public Result<?> publish(@RequestParam(name = "id", required = true) String id) {
+ InspectionPlan inspectionPlan = inspectionPlanService.getById(id);
+ if (CommonConstant.STATUS_1.equals(inspectionPlan.getPublishStatus())) {
+ inspectionPlan.setPublishStatus(CommonConstant.STATUS_0);
+ } else {
+ inspectionPlan.setPublishStatus(CommonConstant.STATUS_1);
+ }
+ inspectionPlanService.updateById(inspectionPlan);
+ return Result.ok("鎿嶄綔鎴愬姛锛�");
+ }
+
+ @AutoLog(value = "妫�楠屾柟妗�-鍗囩増")
+ @ApiOperation(value = "妫�楠屾柟妗�-鍗囩増", notes = "妫�楠屾柟妗�-鍗囩増")
+ @PutMapping(value = "/version")
+ public Result<?> version(@RequestParam(name = "id", required = true) String id) {
+ InspectionPlan inspectionPlan = inspectionPlanService.getById(id);
+ //澶嶅埗褰撳墠妫�楠屾柟妗�
+ InspectionPlan newInspectionPlan = new InspectionPlan();
+ BeanUtil.copyProperties(inspectionPlan,newInspectionPlan);
+ newInspectionPlan.setId(null);
+ newInspectionPlan.setPlanStatus(CommonConstant.STATUS_1);
+ newInspectionPlan.setPublishStatus(CommonConstant.STATUS_0);
+ newInspectionPlan.setCreateTime(new Date());
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+ newInspectionPlan.setCreateBy(user.getUsername());
+ //璁$畻鐗堟湰锛岀増鏈�+1
+ String number = inspectionPlan.getVersion().substring(1);
+ BigDecimal newNumber = new BigDecimal(number).add(BigDecimal.ONE);
+ newInspectionPlan.setVersion("V"+newNumber);
+ newInspectionPlan.setIsNewVersion("1");
+ inspectionPlanService.save(newInspectionPlan);
+ //澶嶅埗妫�楠屾柟妗堟楠岄」鐩�
+ List<InspectionPlanItem> inspectionPlanItemList = inspectionPlanItemService.lambdaQuery().eq(InspectionPlanItem::getPlanId,inspectionPlan.getId()).list();
+ List<InspectionPlanItem> newInspectionPlanItemList = new ArrayList<>();
+ newInspectionPlanItemList.addAll(inspectionPlanItemList);
+ for(InspectionPlanItem inspectionPlanItem : inspectionPlanItemList){
+ inspectionPlanItem.setId(null);
+ inspectionPlanItem.setPlanId(newInspectionPlan.getId());
+ }
+ inspectionPlanItemService.saveBatch(newInspectionPlanItemList);
+ //鏇存柊鍘熸楠屾柟妗堜负绂佺敤
+ inspectionPlan.setPlanStatus(CommonConstant.STATUS_0);
+ inspectionPlan.setIsNewVersion("0");
+ inspectionPlanService.updateById(inspectionPlan);
+ return Result.ok("鍗囩増鎴愬姛锛�");
+ }
+
}
--
Gitblit v1.9.3