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 @@
+ + +