From 666e4e5ba3c84dc31ae9096b8b1b8bdd24c00c39 Mon Sep 17 00:00:00 2001 From: zhangsiqi <2825463979@qq.com> Date: Thu, 16 May 2024 19:43:15 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=EF=BC=9A=E6=8F=90=E4=BA=A4=E8=AF=B7=E8=B4=AD=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BF=A1=E6=81=AF=EF=BC=8C=E6=B8=85=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E7=9A=84=E5=AD=97=E6=AE=B5=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E5=AF=B9=E8=B1=A1=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=BE=97?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E3=80=81=E5=B2=97=E4=BD=8D=E3=80=81=E5=A7=93?= =?UTF-8?q?=E5=90=8D=E7=9A=84=E5=AD=97=E6=AE=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseRequisitioningOrderController.java | 13 ++++----- .../domain/BaseRequisitioningOrder.java | 29 +++++++++++++++++++ .../BaseRequisitioningOrderServiceImpl.java | 16 ++++++---- .../templates/system/requisitioning/add.html | 8 ++--- .../system/requisitioning/requisitioning.html | 4 +++ 5 files changed, 53 insertions(+), 17 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java index 045e0ba6..bdb32839 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java @@ -21,11 +21,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.system.service.IBaseRequisitioningOrderService; @@ -121,9 +117,10 @@ public class BaseRequisitioningOrderController extends BaseController @Log(title = "请购单", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody - public AjaxResult addSave(BaseRequisitioningOrder baseRequisitioningOrder) + public AjaxResult addSave(@RequestBody BaseRequisitioningOrder baseRequisitioningOrder) { - return toAjax(baseRequisitioningOrderService.insertBaseRequisitioningOrder(baseRequisitioningOrder)); + baseRequisitioningOrderService.insertBaseRequisitioningOrder(baseRequisitioningOrder); + return AjaxResult.success(); } /** @@ -144,7 +141,7 @@ public class BaseRequisitioningOrderController extends BaseController @Log(title = "请购单", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody - public AjaxResult editSave(BaseRequisitioningOrder baseRequisitioningOrder) + public AjaxResult editSave(@RequestBody BaseRequisitioningOrder baseRequisitioningOrder) { return toAjax(baseRequisitioningOrderService.updateBaseRequisitioningOrder(baseRequisitioningOrder)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseRequisitioningOrder.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseRequisitioningOrder.java index f2fcbb65..a21b984e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseRequisitioningOrder.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseRequisitioningOrder.java @@ -60,6 +60,35 @@ public class BaseRequisitioningOrder extends BaseEntity /** 使用状态 */ private String useStatus; + private String postName; + + private String userName; + + private String deptName; + + public String getPostName() { + return postName; + } + + public void setPostName(String postName) { + this.postName = postName; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } private List baseRequisitioningOrderChildList; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java index 4e3c0637..29435385 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java @@ -14,6 +14,7 @@ import com.ruoyi.system.mapper.BaseRequisitioningOrderMapper; import com.ruoyi.system.domain.BaseRequisitioningOrder; import com.ruoyi.system.service.IBaseRequisitioningOrderService; import com.ruoyi.common.core.text.Convert; +import org.springframework.transaction.annotation.Transactional; /** * 请购单Service业务层处理 @@ -64,6 +65,7 @@ public class BaseRequisitioningOrderServiceImpl implements IBaseRequisitioningOr * @return 结果 */ @Override + @Transactional(rollbackFor = NullPointerException.class) public int insertBaseRequisitioningOrder(BaseRequisitioningOrder baseRequisitioningOrder) { String loginName = ShiroUtils.getLoginName(); @@ -71,11 +73,14 @@ public class BaseRequisitioningOrderServiceImpl implements IBaseRequisitioningOr baseRequisitioningOrder.setCreateTime(DateUtils.getNowDate()); baseRequisitioningOrder.setRequisitioningCode(redisCache.generateBillNo("QG")); List childList = baseRequisitioningOrder.getBaseRequisitioningOrderChildList(); - for (BaseRequisitioningOrderChild child: childList) { - child.setQuoteId(baseRequisitioningOrder.getRequisitioningCode()); - child.setCreateBy(loginName); - child.setCreateTime(DateUtils.getNowDate()); - baseRequisitioningOrderChildMapper.insertBaseRequisitioningOrderChild(child); + int childSize = childList.size(); + if (childSize > 0) { + for (BaseRequisitioningOrderChild child : childList) { + child.setQuoteId(baseRequisitioningOrder.getRequisitioningCode()); + child.setCreateBy(loginName); + child.setCreateTime(DateUtils.getNowDate()); + baseRequisitioningOrderChildMapper.insertBaseRequisitioningOrderChild(child); + } } return baseRequisitioningOrderMapper.insertBaseRequisitioningOrder(baseRequisitioningOrder); } @@ -87,6 +92,7 @@ public class BaseRequisitioningOrderServiceImpl implements IBaseRequisitioningOr * @return 结果 */ @Override + @Transactional(rollbackFor = NullPointerException.class) public int updateBaseRequisitioningOrder(BaseRequisitioningOrder baseRequisitioningOrder) { String loginName = ShiroUtils.getLoginName(); diff --git a/ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html b/ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html index fd260d8d..057a1e35 100644 --- a/ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html +++ b/ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html @@ -11,13 +11,13 @@
- +
- +
@@ -236,9 +236,9 @@ dataType: "json", success: function (data) { console.log(data); - $("select[name='dept']").append($('').val(data.deptName).html(data.deptName)); + $("select[name='deptName']").append($('').val(data.deptName).html(data.deptName)); $("select[name='userName']").append($('').val(data.userName).html(data.userName)); - $("select[name='post']").append($('').val(data.postName).html(data.postName)); + $("select[name='postName']").append($('').val(data.postName).html(data.postName)); } }); diff --git a/ruoyi-admin/src/main/resources/templates/system/requisitioning/requisitioning.html b/ruoyi-admin/src/main/resources/templates/system/requisitioning/requisitioning.html index d51b71af..955babcd 100644 --- a/ruoyi-admin/src/main/resources/templates/system/requisitioning/requisitioning.html +++ b/ruoyi-admin/src/main/resources/templates/system/requisitioning/requisitioning.html @@ -2,6 +2,7 @@ +
@@ -66,6 +67,9 @@
+ + +