瀏覽代碼

供应商

caozj 2 年之前
父節點
當前提交
0f5339aec9
共有 23 個文件被更改,包括 395 次插入32 次删除
  1. 10 0
      hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/entity/ApplyPurchase.java
  2. 1 1
      hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/entity/ApplyPurchasedetail.java
  3. 6 1
      hx-saas-project/saas-flow/src/main/java/com/fjhx/flow/mapper/FlowApplycheckMapper.xml
  4. 30 6
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchaseController.java
  5. 40 2
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchaseFlowController.java
  6. 28 1
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchasedetailController.java
  7. 20 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchaseMapper.java
  8. 30 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchaseMapper.xml
  9. 22 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchasedetailMapper.java
  10. 15 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchasedetailMapper.xml
  11. 25 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchaseService.java
  12. 19 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchasedetailService.java
  13. 2 2
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchaseFlowServiceImpl.java
  14. 59 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchaseServiceImpl.java
  15. 23 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchasedetailServiceImpl.java
  16. 1 1
      hx-saas-project/saas-storage/src/main/java/com/fjhx/supplier/service/impl/ASupplierServiceImpl.java
  17. 6 0
      hx-service-api/storage-api/src/main/java/com/fjhx/entity/supplier/Supplier.java
  18. 10 0
      hx-service/storage/src/main/java/com/fjhx/purchase/mapper/PurchaseContractMapper.java
  19. 9 0
      hx-service/storage/src/main/java/com/fjhx/purchase/mapper/PurchaseContractMapper.xml
  20. 8 0
      hx-service/storage/src/main/java/com/fjhx/purchase/service/PurchaseContractService.java
  21. 11 0
      hx-service/storage/src/main/java/com/fjhx/purchase/service/impl/PurchaseContractServiceImpl.java
  22. 6 2
      hx-service/storage/src/main/java/com/fjhx/supplier/mapper/SupplierMapper.xml
  23. 14 16
      hx-service/storage/src/main/java/com/fjhx/supplier/service/impl/SupplierServiceImpl.java

+ 10 - 0
hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/entity/ApplyPurchase.java

@@ -16,6 +16,7 @@
  */
 package com.fjhx.subscribe.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.time.LocalDateTime;
 import java.io.Serializable;
@@ -87,6 +88,15 @@ public class ApplyPurchase extends BaseStockEntity {
 	@ApiModelProperty(value = "安全库存自动生成")
 	private Boolean safetyStockCreate;
 
+	/**
+	 * 用户名
+	 */
+	@TableField(exist = false)
+	private String userName;
 
+	/**
+	 * 申购明细
+	 */
+	@TableField(exist = false)
 	private List<ApplyPurchasedetail> purchasedetailList;
 }

+ 1 - 1
hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/entity/ApplyPurchasedetail.java

@@ -49,7 +49,7 @@ public class ApplyPurchasedetail extends BaseStockEntity {
 	/**
 	* 物料Code
 	*/
-	@ApiModelProperty(value = "物料Code")
+	@ApiModelProperty(value = "物料ID")
 	private String materialId;
 	/**
 	* 申购数量

+ 6 - 1
hx-saas-project/saas-flow/src/main/java/com/fjhx/flow/mapper/FlowApplycheckMapper.xml

@@ -33,7 +33,7 @@
         LEFT JOIN blade_user t4 ON t1.check_user_id = t4.id
         <include refid="list_condition"/>
         ORDER BY t1.CreatedTime DESC
-        <include refid="Sql.sql_limit"/>
+        <include refid="sql_limit"/>
     </select>
     <select id="getTaskListCount" resultType="java.lang.Integer">
         SELECT
@@ -51,4 +51,9 @@
             t1.check_state = 1
         </where>
     </sql>
+    <sql id="sql_limit">
+        <if test="start != null and end != null">
+            LIMIT #{start},#{end}
+        </if>
+    </sql>
 </mapper>

+ 30 - 6
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchaseController.java

@@ -18,19 +18,21 @@ package com.fjhx.subscribe.controller;
 
 import com.fjhx.subscribe.entity.ApplyPurchase;
 import com.fjhx.subscribe.service.IApplyPurchaseService;
+import com.fjhx.supplier.entity.Supplier;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
-import javax.validation.Valid;
-
 import org.springblade.common.constant.ApiConstant;
+import org.springblade.common.utils.ListPageMap;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springframework.web.bind.annotation.*;
 import org.springblade.core.boot.ctrl.BladeController;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 申购单 控制器
  *
@@ -49,8 +51,8 @@ public class ApplyPurchaseController extends BladeController {
 	 * 详情
 	 */
 	@GetMapping("/detail")
-	public R<ApplyPurchase> detail(ApplyPurchase applyPurchase) {
-		ApplyPurchase detail = applyPurchaseService.getOne(Condition.getQueryWrapper(applyPurchase));
+	public R<ApplyPurchase> detail(@RequestParam("id")String id) {
+		ApplyPurchase detail = applyPurchaseService.detailApplyPurchase(id);
 		return R.data(detail);
 	}
 	
@@ -62,5 +64,27 @@ public class ApplyPurchaseController extends BladeController {
 		return R.status(applyPurchaseService.removeByIds(Func.toLongList(ids)));
 	}
 
-	
+	/**
+	 * 列表
+	 * @param condition
+	 * @return
+	 */
+	@PostMapping("/list")
+	public R list(@RequestBody Map<String, Object> condition){
+		ListPageMap.getListPageMap(condition);
+		List<ApplyPurchase> result = applyPurchaseService.getList(condition);
+		return R.success(result);
+	}
+
+	/**
+	 * 列表条数
+	 * @param condition
+	 * @return
+	 */
+	@PostMapping("/list/count")
+	public R listCount(@RequestBody Map<String, Object> condition){
+		ListPageMap.getListPageMap(condition);
+		Integer count = applyPurchaseService.getListCount(condition);
+		return R.success(count);
+	}
 }

+ 40 - 2
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchaseFlowController.java

@@ -16,7 +16,9 @@
  */
 package com.fjhx.subscribe.controller;
 
+import com.fjhx.flow.entity.FlowParam;
 import com.fjhx.subscribe.entity.ApplyPurchase;
+import com.fjhx.subscribe.service.IApplyPurchaseFlowService;
 import com.fjhx.subscribe.service.IApplyPurchaseService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiParam;
@@ -40,6 +42,42 @@ import org.springframework.web.bind.annotation.*;
 @Api(value = "申购单流程", tags = "申购单接口")
 public class ApplyPurchaseFlowController extends BladeController {
 
-	private final IApplyPurchaseService applyPurchaseService;
-	
+	private final IApplyPurchaseFlowService flowService;
+
+
+	/**
+	 * 开始流程
+	 *
+	 * @param applyPurchase
+	 * @return
+	 */
+	@PostMapping(value = "/start")
+	public R start(@RequestBody ApplyPurchase applyPurchase) {
+		flowService.start(applyPurchase);
+		return R.success();
+	}
+
+	/**
+	 * 审核
+	 *
+	 * @param condition
+	 * @return
+	 */
+	@PostMapping(value = "/examine")
+	public R examine(@RequestBody FlowParam condition) {
+		flowService.examine(condition);
+		return R.success();
+	}
+
+	/**
+	 * 回退
+	 *
+	 * @param condition
+	 * @return
+	 */
+	@PostMapping(value = "/reject")
+	public R reject(@RequestBody FlowParam condition) {
+		flowService.reject(condition);
+		return R.success();
+	}
 }

+ 28 - 1
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchasedetailController.java

@@ -16,6 +16,7 @@
  */
 package com.fjhx.subscribe.controller;
 
+import com.fjhx.subscribe.entity.ApplyPurchase;
 import com.fjhx.subscribe.entity.ApplyPurchasedetail;
 import com.fjhx.subscribe.service.IApplyPurchasedetailService;
 import io.swagger.annotations.Api;
@@ -23,12 +24,16 @@ import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
 
 import org.springblade.common.constant.ApiConstant;
+import org.springblade.common.utils.ListPageMap;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springframework.web.bind.annotation.*;
 import org.springblade.core.boot.ctrl.BladeController;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 申购单明细 控制器
  *
@@ -60,5 +65,27 @@ public class ApplyPurchasedetailController extends BladeController {
 		return R.status(applyPurchasedetailService.removeByIds(Func.toLongList(ids)));
 	}
 
-	
+	/**
+	 * 列表
+	 * @param condition
+	 * @return
+	 */
+	@PostMapping("/list")
+	public R list(@RequestBody Map<String, Object> condition){
+		ListPageMap.getListPageMap(condition);
+		List<ApplyPurchasedetail> result = applyPurchasedetailService.getList(condition);
+		return R.success(result);
+	}
+
+	/**
+	 * 列表条数
+	 * @param condition
+	 * @return
+	 */
+	@PostMapping("/list/count")
+	public R listCount(@RequestBody Map<String, Object> condition){
+		ListPageMap.getListPageMap(condition);
+		Integer count = applyPurchasedetailService.getListCount(condition);
+		return R.success(count);
+	}
 }

+ 20 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchaseMapper.java

@@ -19,7 +19,11 @@ package com.fjhx.subscribe.mapper;
 import com.fjhx.subscribe.entity.ApplyPurchase;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.fjhx.supplier.entity.Supplier;
+import org.springblade.core.tenant.annotation.TenantIgnore;
+
 import java.util.List;
+import java.util.Map;
 
 /**
  * 申购单 Mapper 接口
@@ -28,6 +32,22 @@ import java.util.List;
  * @since 2022-07-26
  */
 public interface ApplyPurchaseMapper extends BaseMapper<ApplyPurchase> {
+    /**
+     * 列表
+     *
+     * @param condition
+     * @return
+     */
+    @TenantIgnore
+    List<ApplyPurchase> getList(Map<String, Object> condition);
 
+    /**
+     * 列表-总条数
+     *
+     * @param condition
+     * @return
+     */
+    @TenantIgnore
+    Integer getListCount(Map<String, Object> condition);
 
 }

+ 30 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchaseMapper.xml

@@ -21,4 +21,34 @@
         <result column="safety_stock_create" property="safetyStockCreate"/>
     </resultMap>
 
+    <select id="getList" resultMap="applyPurchaseResultMap">
+        SELECT
+            t1.*,
+            t2.`name` AS userName
+        FROM
+            stock_apply_purchase t1
+        LEFT JOIN blade_user t2 ON t1.create_user = t2.id
+        <include refid="list_condition"/>
+        ORDER BY t1.create_time DESC
+        <include refid="com.fjhx.house.mapper.HouseMapper.sql_limit"/>
+    </select>
+    <select id="getListCount" resultType="java.lang.Integer">
+        SELECT
+            count(1)
+        FROM
+            stock_apply_purchase t1
+        LEFT JOIN blade_user t2 ON t1.create_user = t2.id
+        <include refid="list_condition"/>
+    </select>
+    <sql id="list_condition">
+        <where>
+            t1.is_delete = 0
+            <if test="search neq null and search neq '' ">
+                AND ((INSTR(t1.apply_bill_no, #{search}) > 0) OR (INSTR(t2.`name`, #{search}) > 0) )
+            </if>
+            <if test="approveBillState neq null and approveBillState neq '' ">
+                AND t1.approve_bill_state = #{approveBillState}
+            </if>
+        </where>
+    </sql>
 </mapper>

+ 22 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchasedetailMapper.java

@@ -16,9 +16,14 @@
  */
 package com.fjhx.subscribe.mapper;
 
+import com.fjhx.subscribe.entity.ApplyPurchase;
 import com.fjhx.subscribe.entity.ApplyPurchasedetail;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.core.tenant.annotation.TenantIgnore;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * 申购单明细 Mapper 接口
@@ -28,4 +33,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
  */
 public interface ApplyPurchasedetailMapper extends BaseMapper<ApplyPurchasedetail> {
 
+    /**
+     * 列表
+     *
+     * @param condition
+     * @return
+     */
+    @TenantIgnore
+    List<ApplyPurchasedetail> getList(Map<String, Object> condition);
+
+    /**
+     * 列表-总条数
+     *
+     * @param condition
+     * @return
+     */
+    @TenantIgnore
+    Integer getListCount(Map<String, Object> condition);
 }

+ 15 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchasedetailMapper.xml

@@ -16,4 +16,19 @@
         <result column="purpose" property="purpose"/>
     </resultMap>
 
+    <select id="getList" resultMap="applyPurchasedetailResultMap">
+        SELECT
+            *
+        FROM
+            stock_apply_purchasedetail
+        ORDER BY create_time DESC
+        <include refid="com.fjhx.house.mapper.HouseMapper.sql_limit"/>
+    </select>
+    <select id="getListCount" resultType="java.lang.Integer">
+        SELECT
+            count(1)
+        FROM
+            stock_apply_purchasedetail
+        ORDER BY create_time DESC
+    </select>
 </mapper>

+ 25 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchaseService.java

@@ -19,6 +19,10 @@ package com.fjhx.subscribe.service;
 import com.fjhx.subscribe.entity.ApplyPurchase;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.fjhx.supplier.entity.Supplier;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * 申购单 服务类
@@ -28,4 +32,25 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
  */
 public interface IApplyPurchaseService extends IService<ApplyPurchase> {
 
+    /**
+     * 列表
+     *
+     * @param condition
+     * @return
+     */
+    List<ApplyPurchase> getList(Map<String, Object> condition);
+
+    /**
+     * 列表-总条数
+     *
+     * @param condition
+     * @return
+     */
+    Integer getListCount(Map<String, Object> condition);
+
+    /**
+     * 明细
+     * @return
+     */
+    ApplyPurchase detailApplyPurchase(String id);
 }

+ 19 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchasedetailService.java

@@ -16,10 +16,14 @@
  */
 package com.fjhx.subscribe.service;
 
+import com.fjhx.subscribe.entity.ApplyPurchase;
 import com.fjhx.subscribe.entity.ApplyPurchasedetail;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 申购单明细 服务类
  *
@@ -28,4 +32,19 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
  */
 public interface IApplyPurchasedetailService extends IService<ApplyPurchasedetail> {
 
+    /**
+     * 列表
+     *
+     * @param condition
+     * @return
+     */
+    List<ApplyPurchasedetail> getList(Map<String, Object> condition);
+
+    /**
+     * 列表-总条数
+     *
+     * @param condition
+     * @return
+     */
+    Integer getListCount(Map<String, Object> condition);
 }

+ 2 - 2
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchaseFlowServiceImpl.java

@@ -84,14 +84,14 @@ public class ApplyPurchaseFlowServiceImpl extends ServiceImpl<ApplyPurchaseMappe
             }
         }
         //发起审批
-        String title = user.getName() + " 在" + LocalDate.now() + "日发起了 申购单审批流程(单号" + applyPurchase.getApplyBillNo() + ")";
+        String title = "caozj" + " 在" + LocalDate.now() + "日发起了 申购单审批流程(单号" + applyPurchase.getApplyBillNo() + ")";
         if (StringUtils.isBlank(applyPurchase.getId())) {
             saveApplyPurchase(applyPurchase);
         }else{
             updateApplyPurchase(applyPurchase);
         }
         //发起流程
-        FlowParam param = setValue(title,null,null,"subscribe",null);
+        FlowParam param = setValue(title,null,applyPurchase.getId(),"subscribe",null);
         try {
             flowApi.startFlow(param);
         }catch (Exception e){

+ 59 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchaseServiceImpl.java

@@ -16,12 +16,24 @@
  */
 package com.fjhx.subscribe.service.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fjhx.subscribe.entity.ApplyPurchase;
+import com.fjhx.subscribe.entity.ApplyPurchasedetail;
 import com.fjhx.subscribe.mapper.ApplyPurchaseMapper;
 import com.fjhx.subscribe.service.IApplyPurchaseService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.subscribe.service.IApplyPurchasedetailService;
+import org.apache.commons.lang3.StringUtils;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 申购单 服务实现类
  *
@@ -31,4 +43,51 @@ import org.springframework.stereotype.Service;
 @Service
 public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, ApplyPurchase> implements IApplyPurchaseService {
 
+    @Autowired
+    private IApplyPurchasedetailService iApplyPurchasedetailService;
+
+    @Autowired
+    private IUserClient iUserClient;
+    /**
+     * 列表
+     * @param condition
+     * @return
+     */
+    @Override
+    public List<ApplyPurchase> getList(Map<String, Object> condition) {
+        return baseMapper.getList(condition);
+    }
+
+    /**
+     * 列表条数
+     * @param condition
+     * @return
+     */
+    @Override
+    public Integer getListCount(Map<String, Object> condition) {
+        return baseMapper.getListCount(condition);
+    }
+
+    /**
+     * 明细
+     * @param id
+     * @return
+     */
+    @Override
+    public ApplyPurchase detailApplyPurchase(String id) {
+        if(StringUtils.isEmpty(id)){
+            throw new ServiceException("参数异常");
+        }
+        ApplyPurchase applyPurchase = getById(id);
+        if(ObjectUtil.isNotEmpty(applyPurchase)){
+            User user = iUserClient.infoUser(applyPurchase.getCreateUser());
+            if(ObjectUtil.isNotEmpty(user)){
+                applyPurchase.setUserName(user.getName());
+            }
+            List<ApplyPurchasedetail> list = iApplyPurchasedetailService.list(Wrappers.<ApplyPurchasedetail>query().lambda().
+                    eq(ApplyPurchasedetail::getApplyPurchaseId,id));
+            applyPurchase.setPurchasedetailList(list);
+        }
+        return applyPurchase;
+    }
 }

+ 23 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchasedetailServiceImpl.java

@@ -16,12 +16,16 @@
  */
 package com.fjhx.subscribe.service.impl;
 
+import com.fjhx.subscribe.entity.ApplyPurchase;
 import com.fjhx.subscribe.entity.ApplyPurchasedetail;
 import com.fjhx.subscribe.mapper.ApplyPurchasedetailMapper;
 import com.fjhx.subscribe.service.IApplyPurchasedetailService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 申购单明细 服务实现类
  *
@@ -31,4 +35,23 @@ import org.springframework.stereotype.Service;
 @Service
 public class ApplyPurchasedetailServiceImpl extends ServiceImpl<ApplyPurchasedetailMapper, ApplyPurchasedetail> implements IApplyPurchasedetailService {
 
+    /**
+     * 列表
+     * @param condition
+     * @return
+     */
+    @Override
+    public List<ApplyPurchasedetail> getList(Map<String, Object> condition) {
+        return baseMapper.getList(condition);
+    }
+
+    /**
+     * 列表条数
+     * @param condition
+     * @return
+     */
+    @Override
+    public Integer getListCount(Map<String, Object> condition) {
+        return baseMapper.getListCount(condition);
+    }
 }

+ 1 - 1
hx-saas-project/saas-storage/src/main/java/com/fjhx/supplier/service/impl/SupplierServiceImpl.java → hx-saas-project/saas-storage/src/main/java/com/fjhx/supplier/service/impl/ASupplierServiceImpl.java

@@ -52,7 +52,7 @@ import java.util.Map;
  * @since 2022-07-22
  */
 @Service
-public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> implements ISupplierService {
+public class ASupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> implements ISupplierService {
 
     @Autowired
     private StockAttachmentService stockAttachmentService;

+ 6 - 0
hx-service-api/storage-api/src/main/java/com/fjhx/entity/supplier/Supplier.java

@@ -314,4 +314,10 @@ public class Supplier extends BasicEntity {
      */
     @TableField(exist = false)
     private BigDecimal money;
+
+    /**
+     * 总额
+     */
+    @TableField(exist = false)
+    private BigDecimal totalMoney;
 }

+ 10 - 0
hx-service/storage/src/main/java/com/fjhx/purchase/mapper/PurchaseContractMapper.java

@@ -2,8 +2,10 @@ package com.fjhx.purchase.mapper;
 
 import com.fjhx.entity.purchase.PurchaseContract;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.springblade.core.tenant.annotation.TenantIgnore;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -55,4 +57,12 @@ public interface PurchaseContractMapper extends BaseMapper<PurchaseContract> {
      */
     @TenantIgnore
     List<Map<String,Object>> getPayGroupBySu(Map<String,Object> condition);
+
+    /**
+     * 获取总金额
+     * @param date
+     * @return
+     */
+    @TenantIgnore
+    BigDecimal getSumMoney(@Param("date")String date);
 }

+ 9 - 0
hx-service/storage/src/main/java/com/fjhx/purchase/mapper/PurchaseContractMapper.xml

@@ -81,6 +81,15 @@
         <include refid="pay_condition"/>
         GROUP BY t2.ID
     </select>
+    <select id="getSumMoney" resultType="java.math.BigDecimal">
+        SELECT
+            IFNULL(SUM( TotalAmount ),0) AS money
+        FROM
+            purchase_contract
+        WHERE
+            IsDelete = 0
+          AND DATE_FORMAT( CreatedTime, '%Y' ) = #{date}
+    </select>
     <sql id="pay_condition">
         <where>
             t5.ApplyPayState = 2

+ 8 - 0
hx-service/storage/src/main/java/com/fjhx/purchase/service/PurchaseContractService.java

@@ -3,6 +3,7 @@ package com.fjhx.purchase.service;
 import com.fjhx.entity.purchase.PurchaseContract;
 import com.fjhx.base.BaseService;
 
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.List;
 import java.util.Map;
@@ -57,4 +58,11 @@ public interface PurchaseContractService extends BaseService<PurchaseContract> {
      * @return
      */
     List<Map<String,Object>> getPayGroupBySu(Map<String,Object> condition);
+
+    /**
+     * 获取总金额
+     * @param date
+     * @return
+     */
+    BigDecimal getSumMoney(String date);
 }

+ 11 - 0
hx-service/storage/src/main/java/com/fjhx/purchase/service/impl/PurchaseContractServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -124,4 +125,14 @@ public class PurchaseContractServiceImpl extends ServiceImpl<PurchaseContractMap
     public List<Map<String,Object>> getPayGroupBySu(Map<String, Object> condition) {
         return baseMapper.getPayGroupBySu(condition);
     }
+
+    /**
+     * 获取总金额
+     * @param date
+     * @return
+     */
+    @Override
+    public BigDecimal getSumMoney(String date) {
+        return baseMapper.getSumMoney(date);
+    }
 }

+ 6 - 2
hx-service/storage/src/main/java/com/fjhx/supplier/mapper/SupplierMapper.xml

@@ -82,8 +82,8 @@
             t3.TechnologyType AS TechnologyType
         FROM
             supplier t1
-                LEFT JOIN supplier_price t2 ON t1.id = t2.FactoryId
-                LEFT JOIN material t3 ON t2.MaterialCode = t3.`Code`
+        LEFT JOIN supplier_price t2 ON t1.id = t2.FactoryId
+        LEFT JOIN material t3 ON t2.MaterialCode = t3.`Code`
         WHERE
             t3.TechnologyType IS NOT NULL
             AND t1.IsDelete = 0
@@ -132,6 +132,7 @@
         SELECT
             t3.`Name` AS materialName,
             t4.`Name` AS categoryName,
+            t5.totalMoney AS totalMoney,
             FORMAT( IFNULL( SUM( t2.TotalAmount ), 0 ), 2 ) AS sumMoney,
             FORMAT(IFNULL((<include refid="lastMonthMoney_filed"/> AND MaterialCode = t2.MaterialCode),0),2)AS lastMonthMoney,
             FORMAT(IFNULL((<include refid="monthMoney_filed"/> AND MaterialCode = t2.MaterialCode),0),2)AS monthMoney,
@@ -141,8 +142,10 @@
             LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
             LEFT JOIN material t3 ON t2.MaterialCode = t3.`Code`
             LEFT JOIN material_category t4 ON t1.CategoryCode = t4.`Code`
+            LEFT JOIN ( SELECT IFNULL(SUM( TotalAmount ),0) AS totalMoney, MaterialCode FROM purchase_contract WHERE IsDelete = 0 GROUP BY MaterialCode ) t5 ON t5.MaterialCode = t2.MaterialCode
         WHERE
             t1.`id` = #{id}
+            AND t2.IsDelete = 0
         GROUP BY
             t2.MaterialCode
         ORDER BY SUM( t2.TotalAmount ) DESC
@@ -222,6 +225,7 @@
         LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
         WHERE
             t1.ID = #{id}
+          AND t2.isDelete = 0
           AND DATE_FORMAT( t2.CreatedTime, '%Y' ) = #{date}
         GROUP BY
             DATE_FORMAT( t2.CreatedTime, '%Y-%m' ))AS b

+ 14 - 16
hx-service/storage/src/main/java/com/fjhx/supplier/service/impl/SupplierServiceImpl.java

@@ -1,26 +1,20 @@
 package com.fjhx.supplier.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.attachment.service.StockAttachmentService;
 import com.fjhx.entity.attachment.StockAttachment;
 import com.fjhx.entity.attachment.enums.AttachmentTypeEnum;
-import com.fjhx.entity.supplier.SupplierProblem;
+import com.fjhx.purchase.service.PurchaseContractService;
 import com.fjhx.utils.CodeUtil;
-import com.fjhx.utils.WrapperUtil;
 import com.fjhx.entity.supplier.Supplier;
-import com.fjhx.params.supplier.SupplierVo;
 import com.fjhx.supplier.mapper.SupplierMapper;
 import com.fjhx.supplier.service.SupplierService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import io.swagger.models.auth.In;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.tool.utils.CollectionUtil;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.security.SecurityProperties;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -30,7 +24,6 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -46,6 +39,9 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
 
     @Autowired
     private StockAttachmentService stockAttachmentService;
+
+    @Autowired
+    private PurchaseContractService purchaseContractService;
     /**
      * 列表
      * @param condition
@@ -211,12 +207,9 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
     @Override
     public List<Supplier> spmAnalyse(Map<String, Object> condition) {
         List<Supplier> list = baseMapper.getSuPurMaterialAnalyse(condition);
-        //统计出所有条数得总额
-        int countSum = list.stream().mapToInt(Supplier::getCount).sum();
         for(Supplier s:list){
-            BigDecimal b1 = new BigDecimal(s.getCount());
-            BigDecimal b2 = new BigDecimal(countSum);
-            s.setPurProportion(b1.divide(b2,2,BigDecimal.ROUND_HALF_UP));
+            String sumMoney = s.getSumMoney().replace(",","");
+            s.setPurProportion(new BigDecimal(sumMoney).divide(s.getTotalMoney(),2,BigDecimal.ROUND_HALF_UP));
         }
         return list;
     }
@@ -262,9 +255,10 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
     public List<Supplier> getMonthSumPurMoney(String id, String date) {
         List<Supplier> list = baseMapper.getMonthSumPurMoney(id,date);
         //统计出所有条数得总额
-        BigDecimal totalMoney = list.stream()
-                .map(Supplier::getMoney)
-                .reduce(BigDecimal.ZERO,BigDecimal::add);
+//        BigDecimal totalMoney = list.stream()
+//                .map(Supplier::getMoney)
+//                .reduce(BigDecimal.ZERO,BigDecimal::add);
+        BigDecimal totalMoney = purchaseContractService.getSumMoney(date);
         for(Supplier s:list){
             if(s.getMoney().compareTo(BigDecimal.ZERO)==0||totalMoney.compareTo(BigDecimal.ZERO)==0){
                 s.setPurProportion(BigDecimal.ZERO);
@@ -284,4 +278,8 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
     public List<Supplier> selectList(Map<String, Object> condition) {
         return baseMapper.selectList(condition);
     }
+
+    public static void main(String[] args) {
+        System.out.println(new BigDecimal("170,850.00"));
+    }
 }