Forráskód Böngészése

销售合同修改

yzc 1 éve
szülő
commit
4e929ec239

+ 9 - 50
hx-common/src/main/java/com/fjhx/common/controller/FileServiceController.java

@@ -1,50 +1,28 @@
 package com.fjhx.common.controller;
 
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson2.JSONObject;
-import com.fjhx.common.utils.Utils;
-import com.ruoyi.common.exception.ServiceException;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.message.BasicNameValuePair;
+import com.fjhx.common.service.file.FtpFileService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * FTP文件服务控制器
  */
 @RestController
 @RequestMapping("/fileService")
 public class FileServiceController {
+
+    @Autowired
+    private FtpFileService ftpFileService;
+
     /**
      * 创建临时文件夹
      */
     @PostMapping("/createTempFolder")
-    public JSONObject createTempFolder(String folderName) {
-        try {
-            String fileServiceUrl = SpringUtil.getProperty("hx.fileServiceUrl");
-            if (ObjectUtil.isEmpty(fileServiceUrl)) {
-                throw new ServiceException("未配置文件服务控制程序!!!");
-            }
-            HttpPost httpPost = new HttpPost(fileServiceUrl + "/fileService/createFolder");
-            List<BasicNameValuePair> params = new ArrayList<>();
-            params.add(new BasicNameValuePair("folderPath", File.separator + "temp" + File.separator + folderName));
-            httpPost.setEntity(new UrlEncodedFormEntity(params));
-            JSONObject responseJson = Utils.getJSON(httpPost);
-            if (responseJson.getInteger("code") != 200) {
-                throw new ServiceException(responseJson.getString("msg"));
-            }
-            return responseJson.getJSONObject("data");
-        } catch (IOException e) {
-            throw new ServiceException("操作失败:" + e.getMessage());
-        }
+    public JSONObject createTempFolder() {
+        return ftpFileService.createTempFolder();
     }
 
     /**
@@ -52,25 +30,6 @@ public class FileServiceController {
      */
     @PostMapping("/moveTempFolderToPermanent")
     public void moveFolder(String sourceFolderPath, String targetFolderPath) {
-        try {
-            String fileServiceUrl = SpringUtil.getProperty("hx.fileServiceUrl");
-            if (ObjectUtil.isEmpty(fileServiceUrl)) {
-                throw new ServiceException("未配置文件服务控制程序!!!");
-            }
-            HttpPost httpPost = new HttpPost(fileServiceUrl + "/fileService/moveTempFolderToPermanent");
-
-            List<BasicNameValuePair> params = new ArrayList<>();
-            params.add(new BasicNameValuePair("sourceFolderPath", sourceFolderPath));
-            params.add(new BasicNameValuePair("targetFolderPath", File.separator + "permanent" + File.separator + targetFolderPath));
-            httpPost.setEntity(new UrlEncodedFormEntity(params));
-
-            JSONObject responseJson = Utils.getJSON(httpPost);
-
-            if (responseJson.getInteger("code") != 200) {
-                throw new ServiceException(responseJson.getString("msg"));
-            }
-        } catch (IOException e) {
-            throw new ServiceException("操作失败:" + e.getMessage());
-        }
+        ftpFileService.moveFolder(sourceFolderPath, targetFolderPath);
     }
 }

+ 17 - 0
hx-common/src/main/java/com/fjhx/common/service/file/FtpFileService.java

@@ -0,0 +1,17 @@
+package com.fjhx.common.service.file;
+
+import com.alibaba.fastjson2.JSONObject;
+import org.springframework.stereotype.Service;
+
+@Service
+public interface FtpFileService {
+    /**
+     * 创建临时文件夹
+     */
+    JSONObject createTempFolder();
+
+    /**
+     * 将临时文件移动到永久文件夹
+     */
+    void moveFolder(String sourceFolderPath, String targetFolderPath);
+}

+ 75 - 0
hx-common/src/main/java/com/fjhx/common/service/file/impl/FtpFileServiceImpl.java

@@ -0,0 +1,75 @@
+package com.fjhx.common.service.file.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.alibaba.fastjson2.JSONObject;
+import com.fjhx.common.service.file.FtpFileService;
+import com.fjhx.common.utils.Utils;
+import com.ruoyi.common.exception.ServiceException;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.message.BasicNameValuePair;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class FtpFileServiceImpl implements FtpFileService {
+    /**
+     * 创建临时文件夹
+     */
+    @Override
+    public JSONObject createTempFolder() {
+        try {
+            String fileServiceUrl = SpringUtil.getProperty("hx.fileServiceUrl");
+            if (ObjectUtil.isEmpty(fileServiceUrl)) {
+                throw new ServiceException("未配置文件服务控制程序!!!");
+            }
+
+            String tempFolderPath = String.format("/temp/%s", new Date().getTime());
+
+            HttpPost httpPost = new HttpPost(fileServiceUrl + "/fileService/createFolder");
+            List<BasicNameValuePair> params = new ArrayList<>();
+            params.add(new BasicNameValuePair("folderPath", tempFolderPath));
+            httpPost.setEntity(new UrlEncodedFormEntity(params));
+            JSONObject responseJson = Utils.getJSON(httpPost);
+            if (responseJson.getInteger("code") != 200) {
+                throw new ServiceException(responseJson.getString("msg"));
+            }
+            return responseJson.getJSONObject("data");
+        } catch (IOException e) {
+            throw new ServiceException("操作失败:" + e.getMessage());
+        }
+    }
+
+    /**
+     * 将临时文件移动到永久文件夹
+     */
+    @Override
+    public void moveFolder(String sourceFolderPath, String targetFolderPath) {
+        targetFolderPath = String.format("/permanent/%s", targetFolderPath);
+
+        try {
+            String fileServiceUrl = SpringUtil.getProperty("hx.fileServiceUrl");
+            if (ObjectUtil.isEmpty(fileServiceUrl)) {
+                throw new ServiceException("未配置文件服务控制程序!!!");
+            }
+            HttpPost httpPost = new HttpPost(fileServiceUrl + "/fileService/moveTempFolderToPermanent");
+
+
+            List<BasicNameValuePair> params = new ArrayList<>();
+            params.add(new BasicNameValuePair("sourceFolderPath", sourceFolderPath));
+            params.add(new BasicNameValuePair("targetFolderPath", targetFolderPath));
+            httpPost.setEntity(new UrlEncodedFormEntity(params));
+
+            JSONObject responseJson = Utils.getJSON(httpPost);
+
+            if (responseJson.getInteger("code") != 200) {
+                throw new ServiceException(responseJson.getString("msg"));
+            }
+        } catch (IOException e) {
+            throw new ServiceException("操作失败:" + e.getMessage());
+        }
+    }
+}

+ 13 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/po/Contract.java

@@ -279,6 +279,19 @@ public class Contract extends BasePo {
     private String beneficiaryAccountNumber;
 
     /**
+     * 户名
+     */
+    private String accountName;
+    /**
+     * 账号
+     */
+    private String accountOpening;
+    /**
+     * 开户银行
+     */
+    private String openingBank;
+
+    /**
      * 利润预算表金额
      */
     private String budgetMoney;

+ 12 - 2
hx-sale/src/main/java/com/fjhx/sale/entity/contract/po/ContractProduct.java

@@ -69,9 +69,19 @@ public class ContractProduct extends BasePo {
     private BigDecimal expendQuantity;
 
     /**
-     * 尔弘时代JSON扩展字段
+     * 包装方式
      */
-    private String ehsdJson;
+    private String packMethod;
+    /**
+     * 贸易方式
+     */
+    private String tradeMethod;
+
+
+    /**
+     * 生产源文件地址
+     */
+    private String prodFilePath;
 
     /**
      * 附件列表

+ 35 - 42
hx-sale/src/main/java/com/fjhx/sale/flow/ContractFlow.java

@@ -1,14 +1,15 @@
 package com.fjhx.sale.flow;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fjhx.area.utils.CustomizeAreaUtil;
-import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.common.enums.CodingRuleEnum;
 import com.fjhx.common.enums.FlowStatusEnum1;
 import com.fjhx.common.service.coding.CodingRuleService;
+import com.fjhx.common.service.file.FtpFileService;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.core.FlowDelegate;
 import com.fjhx.flow.enums.FlowStatusEnum;
@@ -16,7 +17,6 @@ import com.fjhx.sale.entity.contract.dto.ContractDto;
 import com.fjhx.sale.entity.contract.po.Contract;
 import com.fjhx.sale.entity.contract.po.ContractProduct;
 import com.fjhx.sale.entity.contract.po.ContractProject;
-import com.fjhx.sale.entity.contract.po.ContractShipment;
 import com.fjhx.sale.service.contract.ContractProductService;
 import com.fjhx.sale.service.contract.ContractProjectService;
 import com.fjhx.sale.service.contract.ContractService;
@@ -30,6 +30,7 @@ import com.ruoyi.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -57,6 +58,8 @@ public class ContractFlow extends FlowDelegate {
 
     @Autowired
     private ContractShipmentService contractShipmentService;
+    @Autowired
+    private FtpFileService ftpFileService;
 
     @Override
     public String getFlowKey() {
@@ -76,7 +79,7 @@ public class ContractFlow extends FlowDelegate {
 
         contract.setFlowId(flowId);
 
-        if(StringUtils.isEmpty(contract.getCurrency())){
+        if (StringUtils.isEmpty(contract.getCurrency())) {
             throw new ServiceException("币种不能为空");
         }
         contract.setCode(codingRuleService.createCode(CodingRuleEnum.CONTRACT.getKey(), contract.getBuyCorporationId()));
@@ -123,53 +126,42 @@ public class ContractFlow extends FlowDelegate {
         contract.setBuyCountryId(contract.getCountryId());
         contract.setBuyProvinceId(contract.getProvinceId());
         contract.setStatus(FlowStatusEnum1.UNDER_REVIEW.getKey());
-//        contract.setRate(ExchangeRateUtil.getCnyToCodeRate(contract.getCurrency()));
         contractService.saveOrUpdate(contract);
 
         // 保存合同产品
         List<ContractProduct> contractProductList = contract.getContractProductList();
-        //重新发起删除被删掉的产品
-        contractProductService.editLinked(contractProductList, ContractProduct::getContractId, contract.getId());
-        if (CollectionUtils.isNotEmpty(contractProductList)) {
-            for (ContractProduct c : contractProductList) {
-                c.setContractId(contract.getId());
+        contractProductList = ObjectUtil.isEmpty(contractProductList) ? new ArrayList<>() : contractProductList;
+        for (ContractProduct c : contractProductList) {
+            //对新数据创建id
+            c.setId(ObjectUtil.isEmpty(c.getId()) ? IdWorker.getId() : c.getId());
+            //赋值合同Id
+            c.setContractId(contract.getId());
+            //保存设计稿图
+            ObsFileUtil.editFile(c.getFileList(), c.getId());
+            //保存生产源文件
+            String prodFilePath = c.getProdFilePath();
+            if (ObjectUtil.isNotEmpty(prodFilePath) && prodFilePath.startsWith("/temp")) {
+                String targetFolderPath = String.format("/contractProduct/%s", c.getId());
+                ftpFileService.moveFolder(prodFilePath, targetFolderPath);
+                c.setProdFilePath(targetFolderPath);
             }
-            contractProductService.saveOrUpdateBatch(contractProductList);
         }
+        contractProductService.editLinked(contractProductList, ContractProduct::getContractId, contract.getId());
 
         // 保存收费项目
         List<ContractProject> contractProjectList = contract.getContractProjectList();
-        //重新发起删除被删掉的收费项目
-        contractProjectService.editLinked(contractProjectList, ContractProject::getContractId, contract.getId());
-        if (CollectionUtils.isNotEmpty(contractProjectList)) {
-            for (ContractProject c : contractProjectList) {
-                c.setContractId(contract.getId());
-            }
-            contractProjectService.saveOrUpdateBatch(contractProjectList);
-        }
-
-        // 保存自定义出货
-        List<ContractShipment> contractShipmentList = contract.getContractShipmentList();
-        //重新发起删除被删掉的出货计划
-        contractShipmentService.editLinked(contractShipmentList, ContractShipment::getContractId, contract.getId());
-        if (CollectionUtils.isNotEmpty(contractShipmentList)) {
-            for (ContractShipment c : contractShipmentList) {
-                c.setContractId(contract.getId());
-            }
-            contractShipmentService.saveOrUpdateBatch(contractShipmentList);
+        contractProjectList = ObjectUtil.isEmpty(contractProjectList) ? new ArrayList<>() : contractProjectList;
+        for (ContractProject c : contractProjectList) {
+            c.setContractId(contract.getId());
         }
-
-        // 交接单附件列表
-        ObsFileUtil.editFile(contract.getFileList(), contract.getId(), 1);
-
-        // 包装指示附件列表
-        ObsFileUtil.editFile(contract.getPackageFileList(), contract.getId(), 2);
+        contractProjectService.editLinked(contractProjectList, ContractProject::getContractId, contract.getId());
 
         return contract.getId();
     }
 
     /**
      * 重新发起
+     *
      * @param flowId
      * @param businessId
      * @param flowStatus
@@ -180,7 +172,7 @@ public class ContractFlow extends FlowDelegate {
     public void relaunch(Long flowId, Long businessId, FlowStatusEnum flowStatus, JSONObject submitData) {
         //删除采购合同
         ContractDto contractDto = submitData.toJavaObject(ContractDto.class);
-        if(ObjectUtils.isEmpty(contractDto)){
+        if (ObjectUtils.isEmpty(contractDto)) {
             throw new ServiceException("合同数据不能为空");
         }
         start(contractDto);
@@ -188,18 +180,19 @@ public class ContractFlow extends FlowDelegate {
 
     /**
      * 驳回
+     *
      * @param flowId
      * @param businessId
      * @param flowStatus
      */
     @Override
     public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
-            contractService.update(q -> q
-                    .eq(Contract::getId, businessId)
-                    .set(Contract::getStatus, 20)//20为驳回
-                    .set(Contract::getUpdateTime, new Date())
-                    .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
-            );
+        contractService.update(q -> q
+                .eq(Contract::getId, businessId)
+                .set(Contract::getStatus, 20)//20为驳回
+                .set(Contract::getUpdateTime, new Date())
+                .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+        );
 
     }
 

+ 4 - 4
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -1963,10 +1963,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
 
             productIndo.setProductModel(item.getProductModel());
 
-            JSONObject ehsdJson = JSONObject.parseObject(item.getEhsdJson());
-            if (ObjectUtil.isNotEmpty(ehsdJson)) {
-                productIndo.setPackMethod(ehsdJson.getString("packMethod"));
-            }
+//            JSONObject ehsdJson = JSONObject.parseObject(item.getEhsdJson());
+//            if (ObjectUtil.isNotEmpty(ehsdJson)) {
+//                productIndo.setPackMethod(ehsdJson.getString("packMethod"));
+//            }
 
             if (ObjectUtil.isNotEmpty(productInfo)) {
                 productIndo.setProductRemark(productInfo.getRemark());