From 1894777d560dd5bd8c68aba38493b3f39c7d4a2f Mon Sep 17 00:00:00 2001 From: dearlin <1261008090@qq.com> Date: Tue, 26 Dec 2023 11:41:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=89=BF=E8=AF=BA=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/bus/CorpPromiseController.java | 50 ++++++- .../controller/bus/PromiseController.java | 127 +++++++++++------- 2 files changed, 123 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/zcloud/controller/bus/CorpPromiseController.java b/src/main/java/com/zcloud/controller/bus/CorpPromiseController.java index f6cf9306..6804d04c 100644 --- a/src/main/java/com/zcloud/controller/bus/CorpPromiseController.java +++ b/src/main/java/com/zcloud/controller/bus/CorpPromiseController.java @@ -2,6 +2,7 @@ package com.zcloud.controller.bus; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.zcloud.aspect.DockAnnotation; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; @@ -11,6 +12,7 @@ import com.zcloud.service.bus.CorpPromiseService; import com.zcloud.service.bus.ImgFilesService; import com.zcloud.util.DateUtil; import com.zcloud.util.Jurisdiction; +import com.zcloud.util.ReturnMap; import com.zcloud.util.Tools; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -46,7 +48,13 @@ public class CorpPromiseController extends BaseController { */ @RequestMapping(value = "/add") @ResponseBody + @DockAnnotation public Object add() throws Exception { + PageData dockData = new PageData(); + ArrayList corpPromiseDetails = new ArrayList<>(); + ArrayList corpPromisePeoples = new ArrayList<>(); + ArrayList coverPeoples = new ArrayList<>(); + Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); @@ -63,6 +71,7 @@ public class CorpPromiseController extends BaseController { pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //创建时间 pd.put("RELEASE_PLATFORM", "1");//企业端发布 corpPromiseService.save(pd); + dockData.put("corpPromiseSave",JSON.toJSONString(pd)); List list = (List) JSON.parse(pd.getString("DETAIL")); //副文内容 if (list.size() > 0) { for (int i = 0; i < list.size(); i++) { @@ -72,7 +81,9 @@ public class CorpPromiseController extends BaseController { promise.put("COLLATERAL", list.get(i).get("value")); promise.put("SORTINDEX", list.get(i).get("index")); corpPromiseDetailsService.save(promise); + corpPromiseDetails.add(promise); } + dockData.put("corpPromiseDetailsSave",JSON.toJSONString(corpPromiseDetails)); } if (people.size() > 0) { //承诺人数据 int num = 0; @@ -90,12 +101,15 @@ public class CorpPromiseController extends BaseController { promise.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); promise.put("ISPROMISE_PEOPLE", "0"); corpPromisePeopleService.save(promise); + corpPromisePeoples.add(promise); num++; } + dockData.put("corpPromisePeopleSave",JSON.toJSONString(corpPromisePeoples)); } } pd.put("PEOPLENUM_INVOLVED", num); corpPromiseService.editpeople(pd); + dockData.put("editPeople",JSON.toJSONString(pd)); } List coverpeople = (List) JSON.parse(pd.getString("coverpeople")); if (coverpeople.size() > 0) { //被承诺人数据 @@ -113,12 +127,14 @@ public class CorpPromiseController extends BaseController { promise.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); promise.put("ISPROMISE_PEOPLE", "1"); corpPromisePeopleService.save(promise); + coverPeoples.add(promise); } + dockData.put("coverPeopleList",JSON.toJSONString(coverPeoples)); } } } - map.put("result", errInfo); + map.put("dockData", JSON.toJSONString(dockData)); return map; } @@ -169,13 +185,22 @@ public class CorpPromiseController extends BaseController { */ @RequestMapping(value = "/editdelete") @ResponseBody + @DockAnnotation public Object editdelete() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); + if (Tools.notEmpty(pd.getString("dockData"))) { + // 咱们的对接流程 如有异常 使用 throw new BizException(); + PageData dockData = JSON.parseObject(pd.getString("dockData"), PageData.class); + corpPromiseService.editdelete(dockData); + // 正常返回 + return ReturnMap.ok(); + } corpPromiseService.editdelete(pd); map.put("result", errInfo); + map.put("dockData", JSON.toJSONString(pd)); return map; } @@ -244,12 +269,17 @@ public class CorpPromiseController extends BaseController { */ @RequestMapping(value = "/edit") @ResponseBody + @DockAnnotation public Object edit() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //创建时间 + PageData dockData = new PageData(); + ArrayList corpPromiseDetails = new ArrayList<>(); + ArrayList corpPromisePeoples = new ArrayList<>(); + ArrayList coverPeoples = new ArrayList<>(); corpPromiseService.edit(pd); corpPromiseDetailsService.deletePromiseId(pd); List list = (List) JSON.parse(pd.getString("DETAIL")); @@ -261,9 +291,12 @@ public class CorpPromiseController extends BaseController { promise.put("COLLATERAL", list.get(i).get("value")); promise.put("SORTINDEX", list.get(i).get("index")); corpPromiseDetailsService.save(promise); + corpPromiseDetails.add(promise); } + dockData.put("corpPromiseDetails",JSON.toJSONString(corpPromiseDetails)); } corpPromisePeopleService.deletePromiseId(pd); //先删除承诺人数据,再新增 + dockData.put("baseData",JSON.toJSONString(pd)); List people = (List) JSON.parse(pd.getString("people")); if (people.size() > 0) { //承诺人数据 int num = 0; @@ -282,11 +315,15 @@ public class CorpPromiseController extends BaseController { promise.put("ISPROMISE_PEOPLE", "0"); corpPromisePeopleService.save(promise); num++; + corpPromisePeoples.add(promise); } + dockData.put("corpPromisePeoples",JSON.toJSONString(corpPromisePeoples)); } } pd.put("PEOPLENUM_INVOLVED", num); corpPromiseService.editpeople(pd); + dockData.put("editData",JSON.toJSONString(pd)); + } List coverpeople = (List) JSON.parse(pd.getString("coverpeople")); if (coverpeople.size() > 0) { //被承诺人数据 @@ -304,11 +341,14 @@ public class CorpPromiseController extends BaseController { promise.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); promise.put("ISPROMISE_PEOPLE", "1"); corpPromisePeopleService.save(promise); + coverPeoples.add(promise); } + dockData.put("coverPeoples",JSON.toJSONString(coverPeoples)); } } } map.put("result", errInfo); + map.put("dockData", JSON.toJSONString(dockData)); return map; } @@ -432,18 +472,24 @@ public class CorpPromiseController extends BaseController { */ @RequestMapping(value = "/delete") @ResponseBody + @DockAnnotation public Object delete() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); + PageData dockData = new PageData(); + List corpPromisePeopleList = new ArrayList<>(); List promiseList = corpPromisePeopleService.getListAllByPromiseId(pd); for (PageData pageData : promiseList) { corpPromisePeopleService.delete(pageData); + corpPromisePeopleList.add(pageData); } - corpPromiseService.delete(pd); + dockData.put("removeData",JSON.toJSONString(pd)); + dockData.put("corpPromisePeopleList",JSON.toJSONString(corpPromisePeopleList)); map.put("result", errInfo); + map.put("dockData", JSON.toJSONString(dockData)); return map; } } diff --git a/src/main/java/com/zcloud/controller/bus/PromiseController.java b/src/main/java/com/zcloud/controller/bus/PromiseController.java index aa84702d..0cc23ccb 100644 --- a/src/main/java/com/zcloud/controller/bus/PromiseController.java +++ b/src/main/java/com/zcloud/controller/bus/PromiseController.java @@ -1,10 +1,8 @@ package com.zcloud.controller.bus; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import com.zcloud.aspect.DockAnnotation; import com.zcloud.util.Jurisdiction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -38,150 +36,175 @@ public class PromiseController extends BaseController { @Autowired private CorpPromisePeopleService corpPromisePeopleService; - /**新增 + /** + * 新增 + * * @param * @throws Exception */ - @RequestMapping(value="/add") + @RequestMapping(value = "/add") @ResponseBody - public Object add() throws Exception{ - Map map = new HashMap(); + @DockAnnotation + public Object add() throws Exception { + Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); - pd.put("PROMISE_ID", this.get32UUID()); //主键 - pd.put("ISDELETE",0); - pd.put("CREATOR", "admin"); //创建人 - pd.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 - pd.put("OPERATOR", "admin"); //创建人 - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //创建时间 + pd.put("PROMISE_ID", this.get32UUID()); //主键 + pd.put("ISDELETE", 0); + pd.put("CREATOR", "admin"); //创建人 + pd.put("CREATTIME", DateUtil.date2Str(new Date())); //创建时间 + pd.put("OPERATOR", "admin"); //创建人 + pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //创建时间 pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); promiseService.save(pd); + ArrayList promiseDetailList = new ArrayList<>(); List list = (List) JSON.parse(pd.getString("DETAIL")); - if(list.size()>0){ - for (int i=0;i 0) { + for (int i = 0; i < list.size(); i++) { PageData promise = new PageData(); promise.put("PROMISEDETAIL_ID", this.get32UUID()); //主键 promise.put("PROMISE_ID", pd.getString("PROMISE_ID")); //外键ID - promise.put("COLLATERAL",list.get(i).get("value")); - promise.put("SORTINDEX",list.get(i).get("index")); + promise.put("COLLATERAL", list.get(i).get("value")); + promise.put("SORTINDEX", list.get(i).get("index")); promiseDetailsService.save(promise); + promiseDetailList.add(promise); } + pd.put("promiseDetailList", JSON.toJSONString(promiseDetailList)); } map.put("result", errInfo); + map.put("dockData", JSON.toJSONString(pd)); return map; } - /**列表 + /** + * 列表 + * * @param page * @throws Exception */ - @RequestMapping(value="/list") + @RequestMapping(value = "/list") @ResponseBody - public Object list(Page page) throws Exception{ - Map map = new HashMap(); + public Object list(Page page) throws Exception { + Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); - String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 - if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); + String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 + if (Tools.notEmpty(KEYWORDS)) pd.put("KEYWORDS", KEYWORDS.trim()); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); page.setPd(pd); - List varList = promiseService.list(page); //列出Notice列表 + List varList = promiseService.list(page); //列出Notice列表 map.put("varList", varList); map.put("page", page); map.put("result", errInfo); return map; } - /**启用禁用 + /** + * 启用禁用 + * * @param * @throws Exception */ - @RequestMapping(value="/editdelete") + @RequestMapping(value = "/editdelete") @ResponseBody - public Object editdelete() throws Exception{ - Map map = new HashMap(); + @DockAnnotation + public Object editdelete() throws Exception { + Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); promiseService.editdelete(pd); map.put("result", errInfo); + map.put("dockData", JSON.toJSONString(pd)); return map; } - /**查看 + /** + * 查看 + * * @param * @throws Exception */ - @RequestMapping(value="/goEdit") + @RequestMapping(value = "/goEdit") @ResponseBody - public Object goEdit() throws Exception{ - Map map = new HashMap(); + public Object goEdit() throws Exception { + Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); - PageData promise = promiseService.findById(pd); + PageData promise = promiseService.findById(pd); List promistDetail = promiseDetailsService.findByPromiseId(pd); - map.put("promistDetail",promistDetail); + map.put("promistDetail", promistDetail); map.put("varList", promise); map.put("result", errInfo); return map; } - /**查看 + /** + * 查看 + * * @param * @throws Exception */ - @RequestMapping(value="/edit") + @RequestMapping(value = "/edit") @ResponseBody - public Object edit() throws Exception{ - Map map = new HashMap(); + @DockAnnotation + public Object edit() throws Exception { + Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); - pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //创建时间 + pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //创建时间 promiseService.edit(pd); promiseDetailsService.deletePromiseId(pd); + ArrayList promiseDetailList = new ArrayList<>(); List list = (List) JSON.parse(pd.getString("DETAIL")); - if(list.size()>0){ - for (int i=0;i 0) { + for (int i = 0; i < list.size(); i++) { PageData promise = new PageData(); promise.put("PROMISEDETAIL_ID", this.get32UUID()); //主键 promise.put("PROMISE_ID", pd.getString("PROMISE_ID")); //外键ID - promise.put("COLLATERAL",list.get(i).get("value")); - promise.put("SORTINDEX",list.get(i).get("index")); + promise.put("COLLATERAL", list.get(i).get("value")); + promise.put("SORTINDEX", list.get(i).get("index")); promiseDetailsService.save(promise); + promiseDetailList.add(promise); } } + pd.put("promiseDetailList",JSON.toJSONString(promiseDetailList)); map.put("result", errInfo); + map.put("dockData", JSON.toJSONString(pd)); return map; } - /**启用禁用 + + /** + * 启用禁用 + * * @param * @throws Exception */ - @RequestMapping(value="/delete") + @RequestMapping(value = "/delete") @ResponseBody - public Object delete() throws Exception{ - Map map = new HashMap(); + public Object delete() throws Exception { + Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); // b3f6c82e51774b4b82e2a87363c8f1cf List coverpeople = corpPromisePeopleService.findByCoverPromiseId(pd); //被承诺人 List people = corpPromisePeopleService.findByPromiseId(pd);//承诺人 - if(coverpeople.size()>0){ + if (coverpeople.size() > 0) { map.put("result", "fail"); map.put("msg", "该承诺书有被承诺人,删除失败!"); return map; - }else if(people.size()>0){ + } else if (people.size() > 0) { map.put("result", "fail"); map.put("msg", "该承诺书有承诺人,删除失败!"); return map; - }else{ - promiseService.delete(pd); // 删除 + } else { + promiseService.delete(pd); // 删除 } map.put("result", errInfo); return map;