From 538876b6ab77736bfbf9fe15c1fbbd2b22c24ff4 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期五, 25 十一月 2022 16:28:39 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/crm/manager/controller/PlanController.java | 90 +++++++++++++++++++++++++++++++--------------
1 files changed, 62 insertions(+), 28 deletions(-)
diff --git a/src/main/java/com/zy/crm/manager/controller/PlanController.java b/src/main/java/com/zy/crm/manager/controller/PlanController.java
index 3e4bb07..01bf282 100644
--- a/src/main/java/com/zy/crm/manager/controller/PlanController.java
+++ b/src/main/java/com/zy/crm/manager/controller/PlanController.java
@@ -21,6 +21,7 @@
import com.zy.crm.manager.service.PlanService;
import com.zy.crm.manager.service.PlanTypeService;
import com.zy.crm.system.entity.User;
+import com.zy.crm.system.service.DeptService;
import com.zy.crm.system.service.UserService;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.DataFormatter;
@@ -44,6 +45,8 @@
private PlanService planService;
@Autowired
private PlanTypeService planTypeService;
+ @Autowired
+ private DeptService deptService;
@GetMapping(value = "/plan/{id}/auth")
@ManagerAuth
@@ -61,7 +64,7 @@
}
resultObj.put("formHtml", planType.getHtml());
// 姝ラ鏉$浉鍏�
- resultObj.put("step", this.getStepOfSettle(plan.getSettle()));
+ resultObj.put("step", plan.getSettle() == 5 ? 0 : plan.getSettle() + 1);
return R.ok().add(resultObj);
}
@@ -91,6 +94,7 @@
@RequestMapping(value = "/plan/add/auth")
@ManagerAuth
+ @Transactional
public R add(@RequestParam Map<String, Object> param) {
// pre
Plan plan = JSON.parseObject(JSON.toJSONString(param), Plan.class);
@@ -119,11 +123,21 @@
plan.setForm(JSON.toJSONString(param)); // 鑷畾涔夎〃鍗曞唴瀹�
plan.setSettle(1); // 1.寮�濮�
- plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan)));
+ User manager = userService.getDeptManager(hostId, getUser().getDeptId()); // 鑾峰彇閮ㄩ棬棰嗗
+ plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan, manager)));
if (!planService.insert(plan)) {
throw new CoolException("淇濇寔澶辫触锛岃閲嶈瘯");
}
+
+ // 鑷姩娣诲姞璺熻繘浜�
+ PlanFoll planFoll = new PlanFoll();
+ planFoll.setPlanId(plan.getId());
+ planFoll.setUserId(manager.getId());
+ if (!planFollService.insert(planFoll)) {
+ throw new CoolException("淇濇寔澶辫触锛岃閲嶈瘯");
+ }
+
return R.ok();
}
@@ -140,7 +154,6 @@
plan.setUpdateTime(new Date());
plan.setForm(JSON.toJSONString(param)); // 鑷畾涔夎〃鍗曞唴瀹�
- plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan)));
if (!planService.updateById(plan)) {
throw new CoolException("淇濇寔澶辫触锛岃閲嶈瘯");
@@ -154,6 +167,52 @@
for (Long id : ids){
planService.deleteById(id);
}
+ return R.ok();
+ }
+
+ @PostMapping(value = "/plan/approval/auth")
+ @ManagerAuth
+ public R approval(@RequestParam Long planId){
+ Plan plan = planService.selectById(planId);
+ assert plan != null;
+
+ switch (plan.getSettle()) {
+ case 1:
+ break;
+ case 2:
+ // 鏈粍缁勯暱瀹℃牳
+ User user = userService.selectById(plan.getUserId());
+ User manager = userService.getDeptManager(getHostId(), user.getDeptId());
+ if (manager.getId().equals(getUserId())) {
+
+ // 鏌ユ壘瑙勫垝缁勯暱
+ plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan, manager)));
+ // 淇敼 settle 姝ラ鏁版嵁
+
+ // 淇敼瑙勫垝鍗曠姸鎬�
+ plan.setSettle(3); // 瑙勫垝缁勯暱寰呭
+ plan.setUpdateBy(getUserId());
+ plan.setUpdateTime(new Date());
+
+ if (!planService.updateById(plan)) {
+ throw new CoolException("瀹℃牳澶辫触锛岃鑱旂郴绠$悊鍛�");
+ }
+
+ // 娣诲姞瑙勫垝缁勯暱璺熻繘浜�
+
+ } else {
+ return R.error("鎶辨瓑锛屾偍娌℃湁瀹℃牳鐨勬潈闄�");
+ }
+ break;
+ case 3:
+ break;
+ case 4:
+ break;
+ default:
+ return R.error();
+ }
+
+
return R.ok();
}
@@ -289,31 +348,6 @@
throw new CoolException("鍒犻櫎澶辫触锛岃鑱旂郴绠$悊鍛�");
}
return R.ok("鍒犻櫎鎴愬姛");
- }
-
-
-
-
-
-
-
-
- /*************************************** 姝ラ鏉$浉鍏� **********************************************/
- private Integer getStepOfSettle(int settle){
- switch (settle){
- case 1:
- return 2;
- case 2:
- return 3;
- case 3:
- return 4;
- case 4:
- return 5;
- case 5:
- return 0;
- default:
- return 1;
- }
}
}
--
Gitblit v1.9.1