浏览代码

辅材收费标准增加师傅辅材关联

FengChaoYu 9 月之前
父节点
当前提交
416fbb4140

+ 19 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/base/WebsitNormChargeBean.java

@@ -0,0 +1,19 @@
+package com.gree.mall.manager.bean.material.base;
+
+import com.gree.mall.manager.plus.entity.WebsitNormCharge;
+import com.gree.mall.manager.plus.entity.WebsitNormRela;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel
+public class WebsitNormChargeBean extends WebsitNormCharge {
+
+    @ApiModelProperty(value = "收费标准编号")
+    private List<WebsitNormRela> items;
+}

+ 4 - 4
mall-server-api/src/main/java/com/gree/mall/manager/controller/material/base/NormChargeController.java

@@ -3,12 +3,12 @@ package com.gree.mall.manager.controller.material.base;
 import cn.hutool.core.lang.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.material.base.WebsitNormChargeBean;
 import com.gree.mall.manager.bean.material.base.WebsitNormChargeVO;
 import com.gree.mall.manager.enums.material.StateEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.helper.ResponseHelper;
 import com.gree.mall.manager.logic.material.base.NormChargeLogic;
-import com.gree.mall.manager.plus.entity.WebsitNormCharge;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import io.swagger.annotations.Api;
@@ -57,7 +57,7 @@ public class NormChargeController {
 
     @PostMapping("/detail")
     @ApiOperation(value = "辅材收费标准-详情")
-    public ResponseHelper<WebsitNormCharge> detail(
+    public ResponseHelper<WebsitNormChargeBean> detail(
             @ApiParam(value = "id", required = true) @RequestParam String id
     ) throws RemoteServiceException {
         return ResponseHelper.success(normChargeLogic.detail(id));
@@ -66,7 +66,7 @@ public class NormChargeController {
     @PostMapping("/add")
     @ApiOperation(value = "辅材收费标准-添加")
     public ResponseHelper add(
-            @RequestBody WebsitNormCharge bean
+            @RequestBody WebsitNormChargeBean bean
     ) throws Exception {
         normChargeLogic.add(bean);
         return ResponseHelper.success();
@@ -75,7 +75,7 @@ public class NormChargeController {
     @PostMapping("/edit")
     @ApiOperation(value = "辅材收费标准-编辑")
     public ResponseHelper edit(
-            @RequestBody WebsitNormCharge bean
+            @RequestBody WebsitNormChargeBean bean
     ) throws Exception {
         normChargeLogic.edit(bean);
         return ResponseHelper.success();

+ 35 - 4
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/base/NormChargeLogic.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
 import com.gree.mall.manager.bean.material.base.MaterialCategoryTree;
+import com.gree.mall.manager.bean.material.base.WebsitNormChargeBean;
 import com.gree.mall.manager.bean.material.base.WebsitNormChargeVO;
 import com.gree.mall.manager.commonmapper.MaterialMapper;
 import com.gree.mall.manager.enums.material.NormTypeEnum;
@@ -15,14 +16,17 @@ import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.logic.common.SysDictCompanyLogic;
 import com.gree.mall.manager.plus.entity.SysDictCompany;
 import com.gree.mall.manager.plus.entity.WebsitNormCharge;
+import com.gree.mall.manager.plus.entity.WebsitNormRela;
 import com.gree.mall.manager.plus.service.SysDictCompanyService;
 import com.gree.mall.manager.plus.service.WebsitNormChargeService;
+import com.gree.mall.manager.plus.service.WebsitNormRelaService;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
@@ -48,6 +52,7 @@ public class NormChargeLogic {
     private final SysDictCompanyService sysDictCompanyService;
     private final SysDictCompanyLogic sysDictCompanyLogic;
     private final MaterialCategoryLogic materialCategoryLogic;
+    private final WebsitNormRelaService websitNormRelaService;
 
     public IPage<WebsitNormChargeVO> page(ZfireParamBean zfireParamBean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
@@ -55,13 +60,19 @@ public class NormChargeLogic {
         return materialMapper.websitNormChargePage(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
     }
 
-    public WebsitNormCharge detail(String id) {
+    public WebsitNormChargeBean detail(String id) {
         WebsitNormCharge websitNormCharge = websitNormChargeService.getById(id);
-        return websitNormCharge;
+        WebsitNormChargeBean bean = new WebsitNormChargeBean();
+        BeanUtils.copyProperties(websitNormCharge, bean);
+        final List<WebsitNormRela> relas = websitNormRelaService.lambdaQuery()
+                .eq(WebsitNormRela::getNormId, id)
+                .list();
+        bean.setItems(relas);
+        return bean;
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public void add(WebsitNormCharge bean) {
+    public void add(WebsitNormChargeBean bean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
 
         if (StringUtils.isBlank(bean.getNormType())) {
@@ -81,6 +92,14 @@ public class NormChargeLogic {
         this.stockUnitEmptyAdd(bean);
 
         bean.insert();
+
+        if (CollectionUtil.isNotEmpty(bean.getItems())) {
+            for (WebsitNormRela item : bean.getItems()) {
+                item.setCompanyWechatId(bean.getCompanyWechatId())
+                        .setNormId(bean.getNormId());
+            }
+            websitNormRelaService.saveBatch(bean.getItems());
+        }
     }
 
     private void stockUnitEmptyAdd(WebsitNormCharge goods) {
@@ -161,7 +180,7 @@ public class NormChargeLogic {
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public void edit(WebsitNormCharge bean) {
+    public void edit(WebsitNormChargeBean bean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
 
         WebsitNormCharge oldNormCharge = websitNormChargeService.getById(bean.getNormId());
@@ -173,6 +192,18 @@ public class NormChargeLogic {
         this.stockUnitEmptyAdd(bean);
 
         bean.updateById();
+
+        if (CollectionUtil.isNotEmpty(bean.getItems())) {
+            websitNormRelaService.lambdaUpdate()
+                    .eq(WebsitNormRela::getCompanyWechatId, bean.getCompanyWechatId())
+                    .eq(WebsitNormRela::getNormId, bean.getNormId())
+                    .remove();
+            for (WebsitNormRela item : bean.getItems()) {
+                item.setCompanyWechatId(bean.getCompanyWechatId())
+                        .setNormId(bean.getNormId());
+            }
+            websitNormRelaService.saveBatch(bean.getItems());
+        }
     }
 
     @Transactional(rollbackFor = Exception.class)