Ver código fonte

加入供应商配置

wuxw 3 anos atrás
pai
commit
9c56779e1f

+ 36 - 10
java110-bean/src/main/java/com/java110/dto/supplierConfig/SupplierConfigDto.java

@@ -1,6 +1,7 @@
 package com.java110.dto.supplierConfig;
 
 import com.java110.dto.PageDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -15,9 +16,11 @@ import java.util.Date;
 public class SupplierConfigDto extends PageDto implements Serializable {
 
     private String supplierId;
-private String configId;
-private String columnValue;
-private String columnKey;
+    private String configId;
+    private String columnValue;
+    private String columnKey;
+    private String name;
+    private String remark;
 
 
     private Date createTime;
@@ -28,25 +31,32 @@ private String columnKey;
     public String getSupplierId() {
         return supplierId;
     }
-public void setSupplierId(String supplierId) {
+
+    public void setSupplierId(String supplierId) {
         this.supplierId = supplierId;
     }
-public String getConfigId() {
+
+    public String getConfigId() {
         return configId;
     }
-public void setConfigId(String configId) {
+
+    public void setConfigId(String configId) {
         this.configId = configId;
     }
-public String getColumnValue() {
+
+    public String getColumnValue() {
         return columnValue;
     }
-public void setColumnValue(String columnValue) {
+
+    public void setColumnValue(String columnValue) {
         this.columnValue = columnValue;
     }
-public String getColumnKey() {
+
+    public String getColumnKey() {
         return columnKey;
     }
-public void setColumnKey(String columnKey) {
+
+    public void setColumnKey(String columnKey) {
         this.columnKey = columnKey;
     }
 
@@ -66,4 +76,20 @@ public void setColumnKey(String columnKey) {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
 }

+ 23 - 13
java110-bean/src/main/java/com/java110/dto/supplierKey/SupplierKeyDto.java

@@ -1,6 +1,7 @@
 package com.java110.dto.supplierKey;
 
 import com.java110.dto.PageDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -15,10 +16,10 @@ import java.util.Date;
 public class SupplierKeyDto extends PageDto implements Serializable {
 
     private String name;
-private String keyId;
-private String beanName;
-private String remark;
-private String columnKey;
+    private String keyId;
+    private String beanName;
+    private String remark;
+    private String columnKey;
 
 
     private Date createTime;
@@ -29,31 +30,40 @@ private String columnKey;
     public String getName() {
         return name;
     }
-public void setName(String name) {
+
+    public void setName(String name) {
         this.name = name;
     }
-public String getKeyId() {
+
+    public String getKeyId() {
         return keyId;
     }
-public void setKeyId(String keyId) {
+
+    public void setKeyId(String keyId) {
         this.keyId = keyId;
     }
-public String getBeanName() {
+
+    public String getBeanName() {
         return beanName;
     }
-public void setBeanName(String beanName) {
+
+    public void setBeanName(String beanName) {
         this.beanName = beanName;
     }
-public String getRemark() {
+
+    public String getRemark() {
         return remark;
     }
-public void setRemark(String remark) {
+
+    public void setRemark(String remark) {
         this.remark = remark;
     }
-public String getColumnKey() {
+
+    public String getColumnKey() {
         return columnKey;
     }
-public void setColumnKey(String columnKey) {
+
+    public void setColumnKey(String columnKey) {
         this.columnKey = columnKey;
     }
 

+ 9 - 4
java110-db/src/main/resources/mapper/scm/SupplierConfigV1ServiceDaoImplMapper.xml

@@ -18,8 +18,10 @@
     <!-- 查询供应商配置信息 add by wuxw 2018-07-03 -->
     <select id="getSupplierConfigInfo" parameterType="Map" resultType="Map">
         select t.supplier_id,t.supplier_id supplierId,t.config_id,t.config_id configId,t.status_cd,t.status_cd
-        statusCd,t.column_value,t.column_value columnValue,t.column_key,t.column_key columnKey
+        statusCd,t.column_value,t.column_value columnValue,t.column_key,t.column_key columnKey,sk.name, sk.remark
         from supplier_config t
+        inner join supplier s on t.supplier_id = s.supplier_id and s.status_cd = '0'
+        inner join supplier_key sk on s.bean_name = sk.bean_name and sk.status_cd = '0'
         where 1 =1
         <if test="supplierId !=null and supplierId != ''">
             and t.supplier_id= #{supplierId}
@@ -50,9 +52,7 @@
         <if test="newBId != null and newBId != ''">
             ,t.b_id = #{newBId}
         </if>
-        <if test="supplierId !=null and supplierId != ''">
-            , t.supplier_id= #{supplierId}
-        </if>
+
         <if test="columnValue !=null and columnValue != ''">
             , t.column_value= #{columnValue}
         </if>
@@ -63,6 +63,9 @@
         <if test="configId !=null and configId != ''">
             and t.config_id= #{configId}
         </if>
+        <if test="supplierId !=null and supplierId != ''">
+            and t.supplier_id= #{supplierId}
+        </if>
 
     </update>
 
@@ -70,6 +73,8 @@
     <select id="querySupplierConfigsCount" parameterType="Map" resultType="Map">
         select count(1) count
         from supplier_config t
+        inner join supplier s on t.supplier_id = s.supplier_id and s.status_cd = '0'
+        inner join supplier_key sk on s.bean_name = sk.bean_name and sk.status_cd = '0'
         where 1 =1
         <if test="supplierId !=null and supplierId != ''">
             and t.supplier_id= #{supplierId}

+ 45 - 1
service-scm/src/main/java/com/java110/scm/cmd/supplierType/ListSupplierConfigCmd.java

@@ -22,7 +22,11 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.supplier.SupplierDto;
+import com.java110.dto.supplierKey.SupplierKeyDto;
 import com.java110.intf.scm.ISupplierConfigV1InnerServiceSMO;
+import com.java110.intf.scm.ISupplierKeyV1InnerServiceSMO;
+import com.java110.intf.scm.ISupplierV1InnerServiceSMO;
 import com.java110.po.supplierConfig.SupplierConfigPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
@@ -55,9 +59,16 @@ public class ListSupplierConfigCmd extends Cmd {
     @Autowired
     private ISupplierConfigV1InnerServiceSMO supplierConfigV1InnerServiceSMOImpl;
 
+    @Autowired
+    private ISupplierKeyV1InnerServiceSMO supplierKeyV1InnerServiceSMOImpl;
+
+    @Autowired
+    private ISupplierV1InnerServiceSMO supplierV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         super.validatePageInfo(reqJson);
+        Assert.hasKeyAndValue(reqJson,"supplierId","未包含供应商");
     }
 
     @Override
@@ -72,7 +83,7 @@ public class ListSupplierConfigCmd extends Cmd {
            if (count > 0) {
                supplierConfigDtos = supplierConfigV1InnerServiceSMOImpl.querySupplierConfigs(supplierConfigDto);
            } else {
-               supplierConfigDtos = new ArrayList<>();
+               supplierConfigDtos = getSupplierKey(supplierConfigDto);
            }
 
            ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, supplierConfigDtos);
@@ -81,4 +92,37 @@ public class ListSupplierConfigCmd extends Cmd {
 
            cmdDataFlowContext.setResponseEntity(responseEntity);
     }
+
+    /**
+     * 查询
+     * @param supplierConfigDto
+     * @return
+     */
+    private List<SupplierConfigDto> getSupplierKey(SupplierConfigDto supplierConfigDto) {
+
+        SupplierDto supplierDto = new SupplierDto();
+        supplierDto.setSupplierId(supplierConfigDto.getSupplierId());
+        List<SupplierDto> supplierDtos = supplierV1InnerServiceSMOImpl.querySuppliers(supplierDto);
+
+        Assert.listOnlyOne(supplierDtos,"未包含供应商");
+
+        SupplierKeyDto supplierKeyDto = new SupplierKeyDto();
+        supplierKeyDto.setBeanName(supplierDtos.get(0).getBeanName());
+        List<SupplierKeyDto> supplierKeyDtos = supplierKeyV1InnerServiceSMOImpl.querySupplierKeys(supplierKeyDto);
+
+        Assert.listOnlyOne(supplierDtos,"未包含供应商模板配置");
+
+        List<SupplierConfigDto> supplierConfigDtos = new ArrayList<>();
+        SupplierConfigDto supplierConfigDto1 = null;
+        for(SupplierKeyDto supplierKeyDto1:supplierKeyDtos){
+            supplierConfigDto1 = new SupplierConfigDto();
+            supplierConfigDto1.setSupplierId(supplierConfigDto.getSupplierId());
+            supplierConfigDto1.setColumnKey(supplierKeyDto1.getColumnKey());
+            supplierConfigDto1.setColumnValue("");
+            supplierConfigDto1.setName(supplierKeyDto1.getName());
+            supplierConfigDto1.setRemark(supplierKeyDto1.getRemark());
+            supplierConfigDtos.add(supplierConfigDto1);
+        }
+        return supplierConfigDtos;
+    }
 }

+ 0 - 84
service-scm/src/main/java/com/java110/scm/cmd/supplierType/ListSupplierKeyCmd.java

@@ -1,84 +0,0 @@
-/*
- * Copyright 2017-2020 吴学文 and java110 team.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.java110.scm.cmd.supplierType;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.core.annotation.Java110Cmd;
-import com.java110.core.annotation.Java110Transactional;
-import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.Cmd;
-import com.java110.core.event.cmd.CmdEvent;
-import com.java110.core.factory.GenerateCodeFactory;
-import com.java110.intf.scm.ISupplierKeyV1InnerServiceSMO;
-import com.java110.po.supplierKey.SupplierKeyPo;
-import com.java110.utils.exception.CmdException;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.vo.ResultVo;
-import org.springframework.beans.factory.annotation.Autowired;
-import com.java110.dto.supplierKey.SupplierKeyDto;
-import java.util.List;
-import java.util.ArrayList;
-import org.springframework.http.ResponseEntity;
-import org.springframework.http.HttpStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * 类表述:查询
- * 服务编码:supplierKey.listSupplierKey
- * 请求路劲:/app/supplierKey.ListSupplierKey
- * add by 吴学文 at 2022-11-17 00:16:01 mail: 928255095@qq.com
- * open source address: https://gitee.com/wuxw7/MicroCommunity
- * 官网:http://www.homecommunity.cn
- * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
- * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
- */
-@Java110Cmd(serviceCode = "supplierKey.listSupplierKey")
-public class ListSupplierKeyCmd extends Cmd {
-
-  private static Logger logger = LoggerFactory.getLogger(ListSupplierKeyCmd.class);
-    @Autowired
-    private ISupplierKeyV1InnerServiceSMO supplierKeyV1InnerServiceSMOImpl;
-
-    @Override
-    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
-        super.validatePageInfo(reqJson);
-    }
-
-    @Override
-    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
-
-           SupplierKeyDto supplierKeyDto = BeanConvertUtil.covertBean(reqJson, SupplierKeyDto.class);
-
-           int count = supplierKeyV1InnerServiceSMOImpl.querySupplierKeysCount(supplierKeyDto);
-
-           List<SupplierKeyDto> supplierKeyDtos = null;
-
-           if (count > 0) {
-               supplierKeyDtos = supplierKeyV1InnerServiceSMOImpl.querySupplierKeys(supplierKeyDto);
-           } else {
-               supplierKeyDtos = new ArrayList<>();
-           }
-
-           ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, supplierKeyDtos);
-
-           ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
-
-           cmdDataFlowContext.setResponseEntity(responseEntity);
-    }
-}

+ 8 - 1
service-scm/src/main/java/com/java110/scm/cmd/supplierType/SaveSupplierConfigCmd.java

@@ -22,6 +22,7 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.supplierConfig.SupplierConfigDto;
 import com.java110.intf.scm.ISupplierConfigV1InnerServiceSMO;
 import com.java110.po.supplierConfig.SupplierConfigPo;
 import com.java110.utils.exception.CmdException;
@@ -64,7 +65,13 @@ public class SaveSupplierConfigCmd extends Cmd {
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
-        SupplierConfigPo supplierConfigPo = BeanConvertUtil.covertBean(reqJson, SupplierConfigPo.class);
+        //删除已经存在
+        SupplierConfigPo supplierConfigPo = new SupplierConfigPo();
+        supplierConfigPo.setSupplierId(reqJson.getString("supplierId"));
+        supplierConfigV1InnerServiceSMOImpl.deleteSupplierConfig(supplierConfigPo);
+
+
+        supplierConfigPo = BeanConvertUtil.covertBean(reqJson, SupplierConfigPo.class);
         supplierConfigPo.setConfigId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
         int flag = supplierConfigV1InnerServiceSMOImpl.saveSupplierConfig(supplierConfigPo);