瀏覽代碼

添加临时库

huangfuli 4 年之前
父節點
當前提交
c835c7eeb5

+ 10 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/WarehouseBaseInfoController.java

@@ -32,6 +32,16 @@ public class WarehouseBaseInfoController {
     public String addWarehouse(@RequestBody WarehouseBaseInfo warehouseBaseInfo) {
         return warehouseBaseInfoService.addWarehouse(warehouseBaseInfo);
     }
+
+    /**
+     * 添加临时库
+     * @param warehouseBaseInfo
+     * @return
+     */
+    @PostMapping("/api/addTemporaryWarehouse")
+    public String addTemporaryWarehouse(@RequestBody WarehouseBaseInfo warehouseBaseInfo){
+        return warehouseBaseInfoService.addTemporaryWarehouse(warehouseBaseInfo);
+    }
     /**
      * 编辑仓库
      */

+ 6 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IWarehouseBaseInfoService.java

@@ -22,6 +22,12 @@ public interface IWarehouseBaseInfoService extends IService<WarehouseBaseInfo> {
      */
     String addWarehouse(WarehouseBaseInfo warehouseBaseInfo);
 
+    /**
+     * 添加临时库
+     * @param warehouseBaseInfo
+     * @return
+     */
+    String addTemporaryWarehouse(WarehouseBaseInfo warehouseBaseInfo);
 
     /**
      * 编辑仓库

+ 34 - 12
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ContractManagementInfoServiceImpl.java

@@ -8,6 +8,7 @@ import com.yh.saas.common.support.util.StringUtils;
 import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
 import com.yh.saas.plugin.yiliangyiyun.entity.ContractProcessInfo;
+import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseBaseInfo;
 import com.yh.saas.plugin.yiliangyiyun.exception.YException;
 import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
 import com.yh.saas.plugin.yiliangyiyun.mapper.ContractManagementInfoMapper;
@@ -19,6 +20,7 @@ import com.winsea.svc.base.security.util.AuthSecurityUtils;
 import com.yh.saas.plugin.yiliangyiyun.entity.ContractManagementInfo;
 import com.yh.saas.plugin.yiliangyiyun.service.IContractManagementInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.yh.saas.plugin.yiliangyiyun.service.IWarehouseBaseInfoService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.httpclient.util.DateUtil;
@@ -57,6 +59,8 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
     private ICommonBillOperateHisService billOperateHisService;
     @Autowired
     private IContractProcessInfoService contractProcessInfoService;
+    @Autowired
+    private IWarehouseBaseInfoService warehouseBaseInfoService;
     @Value("${file-root-path}")
     private String localPath;
 
@@ -77,8 +81,8 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
         List<ContractManagementInfo> contractManagementInfos =
                 contractManagementInfoService.selectList(new EntityWrapper<ContractManagementInfo>()
                         .eq("contract_no", contractManagementInfo.getContractNo())
-                        .eq("delete_flag","0"));
-        if (contractManagementInfos.size()>0){
+                        .eq("delete_flag", "0"));
+        if (contractManagementInfos.size() > 0) {
             throw new YException(YExceptionEnum.CONTRACT_NO_ERROR);
         }
         // 货物信息新增
@@ -100,6 +104,18 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
                 StatusEnum.CONTRACT_WAIT.getName(), StatusEnum.CONTRACT_WAIT.getName(), "");
         // 假如 都成功返回ok
         if (one && two && three) {
+            //自运采购合同添加临时库
+            if ("2".equals(contractManagementInfo.getContractType()) && "1".equals(contractManagementInfo.getDeliverType())) {
+                WarehouseBaseInfo warehouseBaseInfo = new WarehouseBaseInfo();
+                warehouseBaseInfo.setWarehouseName(contractManagementInfo.getContractNo());
+                warehouseBaseInfo.setPersonCharge("111");
+                warehouseBaseInfo.setPersonPhone("111");
+                warehouseBaseInfo.setWarehousePrivate(contractManagementInfo.getSourceProvince());
+                warehouseBaseInfo.setWarehouseCity(contractManagementInfo.getSourceCity());
+                warehouseBaseInfo.setWarehouseArea(contractManagementInfo.getSourceArea());
+                warehouseBaseInfo.setDetailedAddress(contractManagementInfo.getSourceGoods());
+                warehouseBaseInfoService.addTemporaryWarehouse(warehouseBaseInfo);
+            }
             return "OK";
         } else {
             return "NG";
@@ -147,6 +163,12 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
         return contractManagementInfo;
     }
 
+    /**
+     * 信息分页列表查询
+     *
+     * @param contractManagementInfo
+     * @return
+     */
     @Override
     public Page<ContractManagementInfo> selectInfo(ContractManagementInfo contractManagementInfo) {
         Map<String, Object> pageView = new HashMap<>();
@@ -227,7 +249,6 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
     }
 
 
-
     /**
      * 导出
      *
@@ -547,7 +568,7 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
                 cell.setCellValue(editString(contractManagementInfo.getStatus()));
                 cell.setCellStyle(styleDetail);
                 cell = rowx.createCell(12);
-                cell.setCellValue(DateUtil.formatDate(contractManagementInfo.getSigningDate()!=null?contractManagementInfo.getSigningDate():new Date(), DateUtils.DATE_FMT_YYYY_MM_DD));
+                cell.setCellValue(DateUtil.formatDate(contractManagementInfo.getSigningDate() != null ? contractManagementInfo.getSigningDate() : new Date(), DateUtils.DATE_FMT_YYYY_MM_DD));
                 cell.setCellStyle(styleDetail);
                 cell = rowx.createCell(13);
                 cell.setCellValue(editFloat(contractManagementInfo.getMildewGrain()));
@@ -584,38 +605,39 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
 
     /**
      * 判断字符串
+     *
      * @param example
      * @return
      */
-    private String  editString(String example){
-        String exampleOne = example !=null?example:"";
+    private String editString(String example) {
+        String exampleOne = example != null ? example : "";
         return exampleOne;
     }
 
 
     /**
      * 判断浮点数
+     *
      * @param example
      * @return
      */
-    private Float editFloat(Float example){
-        Float exampleOne = example !=null?example:0f;
+    private Float editFloat(Float example) {
+        Float exampleOne = example != null ? example : 0f;
         return exampleOne;
     }
 
     /**
      * 判断浮点数
+     *
      * @param example
      * @return
      */
-    private Double editDouble(Double example){
-        Double exampleOne = example !=null?example:0.00;
+    private Double editDouble(Double example) {
+        Double exampleOne = example != null ? example : 0.00;
         return exampleOne;
     }
 
 
-
-
     /**
      * 下载
      *

+ 50 - 28
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/WarehouseBaseInfoServiceImpl.java

@@ -52,7 +52,7 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         Wrapper<WarehouseBaseInfo> warehouseBaseInfoWrapper = new EntityWrapper<>();
         warehouseBaseInfoWrapper.eq("comp_id", compId).eq("delete_flag", "0").eq("show_flag", "1");
         if (!StringUtils.isEmpty(warehouseName)) {
-            warehouseBaseInfoWrapper.like("warehouse_name", "%"+warehouseName+"%");
+            warehouseBaseInfoWrapper.like("warehouse_name", "%" + warehouseName + "%");
         }
         // 查出所有仓库
         List<WarehouseBaseInfo> warehouseBaseInfoList = this.selectList(warehouseBaseInfoWrapper);
@@ -80,34 +80,33 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
                         List<WarehouseNumView> warehouseNumViewList = new ArrayList<>();
                         // 查询入库数量
                         List<WarehouseInOutInfo> warehouseInOutInfoList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
-                                .eq("position_id", warehousePositionInfo.getId()).eq("status_flag","3").eq("in_out_flag", "2").groupBy("goods_name_key").orderBy("goods_name_key"));
+                                .eq("position_id", warehousePositionInfo.getId()).eq("status_flag", "3").eq("in_out_flag", "2").groupBy("goods_name_key").orderBy("goods_name_key"));
                         if (!CollectionUtils.isEmpty(warehouseInOutInfoList)) {
                             for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfoList) {
                                 WarehouseNumView warehouseNumView = new WarehouseNumView();
                                 // 查询入库数量
                                 List<WarehouseInOutInfo> warehouseInOutInfoAllList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
                                         .eq("position_id", warehousePositionInfo.getId()).eq("in_out_flag", "2")
-                                        .eq("status_flag","3").eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
+                                        .eq("status_flag", "3").eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
 
                                 if (!CollectionUtils.isEmpty(warehouseInOutInfoAllList)) {
                                     Float netWeight = 0f;
                                     for (WarehouseInOutInfo warehouse : warehouseInOutInfoAllList) {
-                                            netWeight = netWeight + warehouse.getNetWeight();
+                                        netWeight = netWeight + warehouse.getNetWeight();
                                     }
                                     warehouseNumView.setGoodsName(warehouseInOutInfoAllList.get(0).getGoodsName());
                                     warehouseNumView.setInNetWeight(String.valueOf(netWeight));
-                                    if(StringUtils.isEmpty(inNetWeight)){
+                                    if (StringUtils.isEmpty(inNetWeight)) {
                                         inNetWeight = "0";
                                     }
-                                    inNetWeight = String.valueOf(Float.valueOf(inNetWeight)  + netWeight);
+                                    inNetWeight = String.valueOf(Float.valueOf(inNetWeight) + netWeight);
                                 }
                                 // 查询应余量
                                 WarehousePositionStorageInfo warehousePositionStorageInfo = warehousePositionStorageInfoService.selectOne(new EntityWrapper<WarehousePositionStorageInfo>()
                                         .eq("position_id", warehouseInOutInfo.getPositionId()).eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
-                                if (warehousePositionStorageInfo!=null) {
+                                if (warehousePositionStorageInfo != null) {
                                     storage = String.valueOf(warehousePositionStorageInfo.getStorage());
-                                }
-                                else{
+                                } else {
                                     storage = "";
                                 }
                                 warehouseNumView.setStorage(storage);
@@ -115,29 +114,29 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
                             }
 
                         }
-                                                                     
+
                         //定义出库
                         String outNetWeight = "";
                         // 查询出库数量
                         List<WarehouseInOutInfo> warehouseInOutInfos = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
-                                .eq("position_id", warehousePositionInfo.getId()).eq("status_flag","3").eq("in_out_flag", "1").groupBy("goods_name_key").orderBy("goods_name_key"));
+                                .eq("position_id", warehousePositionInfo.getId()).eq("status_flag", "3").eq("in_out_flag", "1").groupBy("goods_name_key").orderBy("goods_name_key"));
                         if (!CollectionUtils.isEmpty(warehouseInOutInfos)) {
                             for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfos) {
                                 Float netWeight = 0f;
                                 outNetWeight = "0";
                                 List<WarehouseInOutInfo> warehouseInOutInfoAllList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
-                                        .eq("status_flag","3").eq("position_id", warehousePositionInfo.getId()).eq("in_out_flag", "1").eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
+                                        .eq("status_flag", "3").eq("position_id", warehousePositionInfo.getId()).eq("in_out_flag", "1").eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
                                 if (!CollectionUtils.isEmpty(warehouseInOutInfoAllList)) {
                                     for (WarehouseInOutInfo warehouse : warehouseInOutInfoAllList) {
-                                            netWeight = netWeight + warehouse.getNetWeight();
+                                        netWeight = netWeight + warehouse.getNetWeight();
                                     }
-                                    if(StringUtils.isEmpty(outNetWeight)){
+                                    if (StringUtils.isEmpty(outNetWeight)) {
                                         outNetWeight = "0";
                                     }
-                                    outNetWeight = String.valueOf(Float.valueOf(outNetWeight)  + netWeight);
+                                    outNetWeight = String.valueOf(Float.valueOf(outNetWeight) + netWeight);
                                 }
-                                for(WarehouseNumView warehouseNumView : warehouseNumViewList){
-                                    if(warehouseNumView.getGoodsName().equals(warehouseInOutInfo.getGoodsName())){
+                                for (WarehouseNumView warehouseNumView : warehouseNumViewList) {
+                                    if (warehouseNumView.getGoodsName().equals(warehouseInOutInfo.getGoodsName())) {
                                         warehouseNumView.setOutNetWeight(outNetWeight);
                                     }
 
@@ -148,7 +147,7 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
                         // 查询入库数量
                         count = warehouseInOutInfoService.selectCount(new EntityWrapper<WarehouseInOutInfo>()
                                 .eq("position_id", warehousePositionInfo.getId())
-                                .eq("status_flag","1"));
+                                .eq("status_flag", "1"));
                         warehouseView.setNumber(count);
                         warehouseView.setWarehouseNumViewList(warehouseNumViewList);
                         warehouseViews.add(warehouseView);
@@ -180,8 +179,8 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         List<WarehouseBaseInfo> warehouseBaseInfos =
                 warehouseBaseInfoService.selectList(new EntityWrapper<WarehouseBaseInfo>()
                         .eq("warehouse_name", warehouseBaseInfo.getWarehouseName())
-                        .eq("delete_flag","0"));
-        if (warehouseBaseInfos.size()>0){
+                        .eq("delete_flag", "0"));
+        if (warehouseBaseInfos.size() > 0) {
             throw new YException(YExceptionEnum.WAREHOUSE_NAME_ERROR);
         }
         boolean one = this.insert(warehouseBaseInfo);
@@ -194,6 +193,30 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         }
     }
 
+    /**
+     * 添加临时库
+     *
+     * @param warehouseBaseInfo
+     * @return
+     */
+    @Override
+    public String addTemporaryWarehouse(WarehouseBaseInfo warehouseBaseInfo) {
+        //新增主键id
+        warehouseBaseInfo.setId(IdGenerator.generateUUID());
+        warehouseBaseInfo.setWarehouseType("2");
+        //判断仓库名称是否唯一
+        List<WarehouseBaseInfo> warehouseBaseInfos =
+                warehouseBaseInfoService.selectList(new EntityWrapper<WarehouseBaseInfo>()
+                        .eq("warehouse_name", warehouseBaseInfo.getWarehouseName())
+                        .eq("delete_flag", "0")
+                        .eq("warehouse_type", "2"));
+        if (warehouseBaseInfos.size() > 0) {
+            throw new YException(YExceptionEnum.WAREHOUSE_NAME_ERROR);
+        }
+        this.insert(warehouseBaseInfo);
+        return warehouseBaseInfo.getId();
+    }
+
     /**
      * 编辑仓库
      */
@@ -201,14 +224,13 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
     public String editWarehouse(WarehouseBaseInfo warehouseBaseInfo) {
         this.updateById(warehouseBaseInfo);
         List<WarehousePositionInfo> warehousePositionInfoList = warehouseBaseInfo.getWarehousePositionInfoList();
-        if (!CollectionUtils.isEmpty(warehousePositionInfoList)){
+        if (!CollectionUtils.isEmpty(warehousePositionInfoList)) {
             warehousePositionInfoList.forEach(warehousePositionInfo -> {
-                if(StringUtils.isEmpty(warehousePositionInfo.getId())){
+                if (StringUtils.isEmpty(warehousePositionInfo.getId())) {
                     warehousePositionInfo.setId(IdGenerator.generateUUID());
                     warehousePositionInfo.setBaseId(warehouseBaseInfo.getId());
                     warehousePositionInfoService.insert(warehousePositionInfo);
-                }
-                else{
+                } else {
                     warehousePositionInfoService.updateById(warehousePositionInfo);
                 }
             });
@@ -236,14 +258,14 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         WarehouseBaseInfo warehouseBaseInfo = this.selectById(id);
         List<WarehousePositionInfo> warehousePositionInfoList = warehousePositionInfoService.selectList(new EntityWrapper<WarehousePositionInfo>()
                 .eq("base_id", id)
-                .eq("delete_flag","0"));
+                .eq("delete_flag", "0"));
         warehousePositionInfoList.forEach(warehousePositionInfo -> {
             List<WarehousePositionStorageInfo> warehousePositionStorageInfoList = warehousePositionStorageInfoService.selectList(new EntityWrapper<WarehousePositionStorageInfo>()
-                    .eq("position_id",warehousePositionInfo.getId())
-                    .eq("delete_flag","0"));
+                    .eq("position_id", warehousePositionInfo.getId())
+                    .eq("delete_flag", "0"));
             Float storage = 0f;
             String detailStorage = "";
-            for(WarehousePositionStorageInfo warehousePositionStorageInfo : warehousePositionStorageInfoList){
+            for (WarehousePositionStorageInfo warehousePositionStorageInfo : warehousePositionStorageInfoList) {
                 storage = storage + warehousePositionStorageInfo.getStorage();
                 detailStorage = detailStorage + warehousePositionStorageInfo.getGoodsName() + "(" + warehousePositionStorageInfo.getStorage() + ")  ";
             }