yzc 2 роки тому
батько
коміт
d914a68ae6

+ 3 - 3
code/src/test/java/purchaseDataSource.java

@@ -4,9 +4,9 @@ public class purchaseDataSource {
 
     public static void main(String[] args) {
         GeneratorApplication.builder()
-                .url("jdbc:mysql://36.134.91.96:17330/bytesailing_purchase?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true")
-                .username("fjhx2012mysql")
-                .password("3PN-Mzn#vnP&q6d")
+                .url("jdbc:mysql://36.134.91.96:12333/bytesailing_purchase?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true")
+                .username("root")
+                .password("Fjhx@pwd123")
                 .port(9989)
                 .module("hx-purchase")
                 .parent("com.fjhx.purchase")

+ 36 - 0
hx-purchase/src/main/java/com/fjhx/purchase/controller/purchase/PurchaseOtherFeeController.java

@@ -0,0 +1,36 @@
+package com.fjhx.purchase.controller.purchase;
+
+import com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee;
+import com.fjhx.purchase.service.purchase.PurchaseOtherFeeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 采购其他费用 前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2023-06-09
+ */
+@RestController
+@RequestMapping("/purchaseOtherFee")
+public class PurchaseOtherFeeController {
+
+    @Autowired
+    private PurchaseOtherFeeService purchaseOtherFeeService;
+
+    /**
+     * 获取采购其他费用已有列表
+     */
+    @GetMapping("/listName")
+    List<PurchaseOtherFee> listName() {
+        return purchaseOtherFeeService.listName();
+    }
+
+}

+ 17 - 0
hx-purchase/src/main/java/com/fjhx/purchase/entity/purchase/dto/PurchaseOtherFeeDto.java

@@ -0,0 +1,17 @@
+package com.fjhx.purchase.entity.purchase.dto;
+
+import com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 采购其他费用新增编辑入参实体
+ *
+ * @author
+ * @since 2023-06-09
+ */
+@Getter
+@Setter
+public class PurchaseOtherFeeDto extends PurchaseOtherFee {
+
+}

+ 17 - 0
hx-purchase/src/main/java/com/fjhx/purchase/entity/purchase/dto/PurchaseOtherFeeSelectDto.java

@@ -0,0 +1,17 @@
+package com.fjhx.purchase.entity.purchase.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 采购其他费用列表查询入参实体
+ *
+ * @author
+ * @since 2023-06-09
+ */
+@Getter
+@Setter
+public class PurchaseOtherFeeSelectDto extends BaseSelectDto {
+
+}

+ 43 - 0
hx-purchase/src/main/java/com/fjhx/purchase/entity/purchase/po/PurchaseOtherFee.java

@@ -0,0 +1,43 @@
+package com.fjhx.purchase.entity.purchase.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 采购其他费用
+ * </p>
+ *
+ * @author
+ * @since 2023-06-09
+ */
+@Getter
+@Setter
+@TableName("purchase_other_fee")
+public class PurchaseOtherFee extends BasePo {
+
+    /**
+     * 采购id
+     */
+    private Long purchaseId;
+
+    /**
+     * 费用名称
+     */
+    private String name;
+
+    /**
+     * 价格
+     */
+    private BigDecimal price;
+
+    /**
+     * 说明
+     */
+    private String remark;
+
+}

+ 17 - 0
hx-purchase/src/main/java/com/fjhx/purchase/entity/purchase/vo/PurchaseOtherFeeVo.java

@@ -0,0 +1,17 @@
+package com.fjhx.purchase.entity.purchase.vo;
+
+import com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 采购其他费用列表查询返回值实体
+ *
+ * @author
+ * @since 2023-06-09
+ */
+@Getter
+@Setter
+public class PurchaseOtherFeeVo extends PurchaseOtherFee {
+
+}

+ 6 - 0
hx-purchase/src/main/java/com/fjhx/purchase/entity/purchase/vo/PurchaseVo.java

@@ -1,6 +1,7 @@
 package com.fjhx.purchase.entity.purchase.vo;
 
 import com.fjhx.purchase.entity.purchase.po.Purchase;
+import com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -38,4 +39,9 @@ public class PurchaseVo extends Purchase {
      * 已付款金额
      */
     private BigDecimal paidAmount;
+
+    /**
+     * 其他费用列表
+     */
+    private List<PurchaseOtherFee> otherFeeList;
 }

+ 21 - 0
hx-purchase/src/main/java/com/fjhx/purchase/mapper/purchase/PurchaseOtherFeeMapper.java

@@ -0,0 +1,21 @@
+package com.fjhx.purchase.mapper.purchase;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 采购其他费用 Mapper 接口
+ * </p>
+ *
+ * @author
+ * @since 2023-06-09
+ */
+public interface PurchaseOtherFeeMapper extends BaseMapper<PurchaseOtherFee> {
+
+    List<PurchaseOtherFee> listName();
+
+}

+ 24 - 0
hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/PurchaseOtherFeeService.java

@@ -0,0 +1,24 @@
+package com.fjhx.purchase.service.purchase;
+
+import com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee;
+import com.ruoyi.common.core.service.BaseService;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 采购其他费用 服务类
+ * </p>
+ *
+ * @author
+ * @since 2023-06-09
+ */
+public interface PurchaseOtherFeeService extends BaseService<PurchaseOtherFee> {
+
+    /**
+     * 获取采购其他费用已有列表
+     */
+    List<PurchaseOtherFee> listName();
+
+}

+ 27 - 0
hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/impl/PurchaseOtherFeeServiceImpl.java

@@ -0,0 +1,27 @@
+package com.fjhx.purchase.service.purchase.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee;
+import com.fjhx.purchase.mapper.purchase.PurchaseOtherFeeMapper;
+import com.fjhx.purchase.service.purchase.PurchaseOtherFeeService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 采购其他费用 服务实现类
+ * </p>
+ *
+ * @author
+ * @since 2023-06-09
+ */
+@Service
+public class PurchaseOtherFeeServiceImpl extends ServiceImpl<PurchaseOtherFeeMapper, PurchaseOtherFee> implements PurchaseOtherFeeService {
+
+    @Override
+    public List<PurchaseOtherFee> listName() {
+        return baseMapper.listName();
+    }
+}

+ 9 - 0
hx-purchase/src/main/resources/mapper/purchase/PurchaseOtherFeeMapper.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.purchase.mapper.purchase.PurchaseOtherFeeMapper">
+    <select id="listName" resultType="com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee">
+        SELECT `name`
+        FROM purchase_other_fee
+        GROUP BY `name`
+    </select>
+</mapper>

+ 32 - 19
hx-sale/src/main/java/com/fjhx/sale/flow/PurchaseFlow.java

@@ -15,7 +15,10 @@ import com.fjhx.purchase.entity.purchase.enums.PurchaseDetailStatusEnum;
 import com.fjhx.purchase.entity.purchase.enums.PurchaseStatusEnum;
 import com.fjhx.purchase.entity.purchase.po.Purchase;
 import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
+import com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee;
+import com.fjhx.purchase.entity.purchase.vo.PurchaseVo;
 import com.fjhx.purchase.service.purchase.PurchaseDetailService;
+import com.fjhx.purchase.service.purchase.PurchaseOtherFeeService;
 import com.fjhx.purchase.service.purchase.PurchaseService;
 import com.fjhx.sale.entity.contract.po.ContractProduct;
 import com.fjhx.sale.entity.sample.po.SampleProduct;
@@ -53,6 +56,8 @@ public class PurchaseFlow extends FlowDelegate {
 
     @Autowired
     private CodingRuleService codingRuleService;
+    @Autowired
+    private PurchaseOtherFeeService purchaseOtherFeeService;
 
     @Override
     public String getFlowKey() {
@@ -61,33 +66,41 @@ public class PurchaseFlow extends FlowDelegate {
 
     /**
      * 发起流程
-     * @param flowId 流程ID
+     *
+     * @param flowId     流程ID
      * @param submitData 采购数据
      * @return
      */
     @Override
     public Long start(Long flowId, JSONObject submitData) {
         DynamicDataSourceContextHolder.push(SourceConstant.PURCHASE);
-        Purchase purchase = submitData.toJavaObject(Purchase.class);
+        PurchaseVo purchase = submitData.toJavaObject(PurchaseVo.class);
 //        purchase.setCode(CodeEnum.PURCHASE.getCode());
-        purchase.setCode(codingRuleService.createCode(CodingRuleEnum.PURCHASE.getKey(),null));
+        purchase.setCode(codingRuleService.createCode(CodingRuleEnum.PURCHASE.getKey(), null));
         purchase.setPurchaseStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
         purchase.setFlowId(flowId);
         purchaseService.save(purchase);
         List<PurchaseDetail> purchaseDetailList = purchase.getPurchaseDetailList();
-        if(CollectionUtils.isNotEmpty(purchaseDetailList)){
-            for(PurchaseDetail s : purchaseDetailList){
+        if (CollectionUtils.isNotEmpty(purchaseDetailList)) {
+            for (PurchaseDetail s : purchaseDetailList) {
                 s.setPurchaseId(purchase.getId());
             }
             purchaseDetailService.saveBatch(purchaseDetailList);
         }
+        //保存其他费用信息
+        List<PurchaseOtherFee> otherFeeList = purchase.getOtherFeeList();
+        if (ObjectUtils.isNotEmpty(otherFeeList)) {
+            otherFeeList.forEach(item -> item.setPurchaseId(purchase.getId()));
+            purchaseOtherFeeService.saveBatch(otherFeeList);
+        }
         DynamicDataSourceContextHolder.poll();
         return purchase.getId();
     }
 
     /**
      * 结束流程
-     * @param flowId 流程ID
+     *
+     * @param flowId     流程ID
      * @param businessId 业务ID
      * @param submitData 数据
      */
@@ -96,39 +109,39 @@ public class PurchaseFlow extends FlowDelegate {
     public void end(Long flowId, Long businessId, JSONObject submitData) {
         //通过业务ID查询采购数据
         Purchase purchase = purchaseService.getById(businessId);
-        if(ObjectUtils.isEmpty(purchase)){
+        if (ObjectUtils.isEmpty(purchase)) {
             throw new ServiceException("采购单不存在");
         }
         //查询采购产品
-        List<PurchaseDetail> purchaseDetailList = purchaseDetailService.list(Wrappers.<PurchaseDetail>query().lambda().eq(PurchaseDetail::getPurchaseId,businessId));
+        List<PurchaseDetail> purchaseDetailList = purchaseDetailService.list(Wrappers.<PurchaseDetail>query().lambda().eq(PurchaseDetail::getPurchaseId, businessId));
         List<ContractProduct> upContractProduct = new ArrayList<>();
         List<SampleProduct> upSampleProduct = new ArrayList<>();
-        for(PurchaseDetail p:purchaseDetailList){
-            if(ObjectUtils.isNotEmpty(p.getDataResourceId())&&
-                    p.getDataResource()== PurchaseDataResourceEnum.DATA_RESOURCE_1.getKey()){//如果采购的是外销合同
+        for (PurchaseDetail p : purchaseDetailList) {
+            if (ObjectUtils.isNotEmpty(p.getDataResourceId()) &&
+                    p.getDataResource() == PurchaseDataResourceEnum.DATA_RESOURCE_1.getKey()) {//如果采购的是外销合同
                 ContractProduct contractProduct = contractProductService.getById(p.getDataResourceId());
                 BigDecimal expendQuantity = contractProduct.getExpendQuantity().subtract(p.getCount());
-                if(expendQuantity.compareTo(BigDecimal.ZERO)< 1){//小于0不让继续执行
+                if (expendQuantity.compareTo(BigDecimal.ZERO) < 1) {//小于0不让继续执行
                     throw new ServiceException("采购数量不得大于合同剩余采购数量");
                 }
                 contractProduct.setExpendQuantity(expendQuantity);
                 upContractProduct.add(contractProduct);
             }
-            if(ObjectUtils.isNotEmpty(p.getDataResourceId())&&
-                    p.getDataResource()== PurchaseDataResourceEnum.DATA_RESOURCE_2.getKey()){//如果采购的是样品单
+            if (ObjectUtils.isNotEmpty(p.getDataResourceId()) &&
+                    p.getDataResource() == PurchaseDataResourceEnum.DATA_RESOURCE_2.getKey()) {//如果采购的是样品单
                 SampleProduct sampleProduct = sampleProductService.getById(p.getDataResourceId());
                 BigDecimal expendQuantity = sampleProduct.getExpendQuantity().subtract(p.getCount());
-                if(expendQuantity.compareTo(BigDecimal.ZERO)< 1){//小于0不让继续执行
+                if (expendQuantity.compareTo(BigDecimal.ZERO) < 1) {//小于0不让继续执行
                     throw new ServiceException("采购数量不得大于合同剩余采购数量");
                 }
                 sampleProduct.setExpendQuantity(expendQuantity);
                 upSampleProduct.add(sampleProduct);
             }
         }
-        if(CollectionUtils.isNotEmpty(upContractProduct)){//扣减销售合同数量
+        if (CollectionUtils.isNotEmpty(upContractProduct)) {//扣减销售合同数量
             contractProductService.updateBatchById(upContractProduct);
         }
-        if(CollectionUtils.isNotEmpty(upSampleProduct)){//扣减样品单数量
+        if (CollectionUtils.isNotEmpty(upSampleProduct)) {//扣减样品单数量
             sampleProductService.updateBatchById(upSampleProduct);
         }
         //修改采购状态为审批通过
@@ -138,8 +151,8 @@ public class PurchaseFlow extends FlowDelegate {
         //修改采购明细为待采购
         PurchaseDetail detail = new PurchaseDetail();
         detail.setStatus(PurchaseDetailStatusEnum.PASS.getKey());
-        purchaseDetailService.update(detail,Wrappers.<PurchaseDetail>query()
-                .lambda().eq(PurchaseDetail::getPurchaseId,purchase.getId()));
+        purchaseDetailService.update(detail, Wrappers.<PurchaseDetail>query()
+                .lambda().eq(PurchaseDetail::getPurchaseId, purchase.getId()));
     }
 
 }