Browse Source

成本分配表bug修复

huxy 1 month ago
parent
commit
420b8b1a9a

+ 16 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/controller/SyCostAllocationController.java

@@ -23,6 +23,7 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
@@ -38,6 +39,7 @@ import org.jeecg.modules.report.service.IFabricLossService;
 import org.jeecg.modules.report.service.ISyFabricLossReportService;
 import org.jeecg.modules.scas.entity.SyCostAllocationSummary;
 import org.jeecg.modules.system.controller.CommonController;
+import org.jeecg.modules.system.service.impl.SysDictServiceImpl;
 import org.jeecgframework.poi.excel.ExcelExportUtil;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -93,6 +95,8 @@ public class SyCostAllocationController {
     private IFabricLossService fabricLossService;
     @Autowired
     private FabricLossMapper fabricLossMapper;
+    @Autowired
+    private SysDictServiceImpl sysDictService;
 
     /**
      * 分页列表查询
@@ -131,6 +135,16 @@ public class SyCostAllocationController {
         if (oConvertUtils.isEmpty(plannum)) {
             throw new JeecgBootException("计划号不能为空!");
         }
+
+
+        List<DictModel> dictModels=sysDictService.queryDictItemsByCode("Related_units");
+        List<String> strings=new ArrayList<>();
+        for (DictModel model : dictModels){
+            String account= model.getValue().split("-")[0];
+            String ccuscode= model.getValue().split("-")[1];
+            strings.add(ccuscode);
+        }
+
         if(type.equals("query")){
             // 销售订单附件
             List<AccessorItem> accessorItemList = new ArrayList<>();
@@ -165,13 +179,13 @@ public class SyCostAllocationController {
                 syCostAllocation.setAccessorItemList(accessorItemList);
                 Result.OK(syCostAllocation);
             }else {
-                syCostAllocation=syCostAllocationService.queryByPlanNum(plannum,type);
+                syCostAllocation=syCostAllocationService.queryByPlanNum(plannum,type,strings);
                 if(syCostAllocation==null){
                     return result.error500("找不到对应计划单号!!!");
                 }
             }
         }else if(type.equals("queryNew")){
-            syCostAllocation=syCostAllocationService.queryByPlanNum(plannum,type);
+            syCostAllocation=syCostAllocationService.queryByPlanNum(plannum,type,strings);
             if(syCostAllocation==null){
                 return result.error500("找不到对应计划单号!!!");
             }

+ 27 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/entity/GarmentContract.java

@@ -0,0 +1,27 @@
+package org.jeecg.modules.cost.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class GarmentContract {
+
+    /**订单号*/
+    @ApiModelProperty(value = "订单号")
+    private String ccode;
+    /**成衣合同号*/
+    @ApiModelProperty(value = "成衣合同号")
+    private String contractno;
+    /**款号*/
+    @ApiModelProperty(value = "款号")
+    private String cdefine22;
+    /**制单人*/
+    @ApiModelProperty(value = "制单人")
+    private String cpersonName;
+    /**客户*/
+    @ApiModelProperty(value = "客户")
+    private String ccuscode;
+    /**"账套*/
+    @ApiModelProperty(value = "账套")
+    private String account;
+}

+ 5 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/SyCostAllocationMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.cost.entity.GarmentContract;
 import org.jeecg.modules.cost.entity.SyCostAllocation;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.cost.entity.SyCostJson;
@@ -21,7 +22,10 @@ public interface SyCostAllocationMapper extends BaseMapper<SyCostAllocation> {
     List<SyCostAllocation> queryByCostHead(@Param("code") String planCode);
 
     @DS("multi-three")
-    List<String> queryByCostHead2(@Param("code") String planCode);
+    List<GarmentContract> queryByCostHead2(@Param("code") String planCode,@Param("csocode") List csocode);
+
+    @DS("multi-three")
+    List<String> queryByCostHead3(@Param("code") String planCode);
 
     List<SyCostJson> queryByCostJson(@Param("planNum")String planNum,
                              @Param("pageStart")Integer pageStart,@Param("pageEnd")Integer pageEnd);

+ 11 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationMapper.xml

@@ -392,8 +392,17 @@
 
 
     <!-- 获取 头信息 主要是成衣委外及源头订单信息 -->
-    <select id="queryByCostHead2" resultType="java.lang.String">
-		select distinct contractno from VIEW_FabricLoss_Head_Clothes where (trim(cCode) like '%${code}%' and cCode not like '%样%')
+    <select id="queryByCostHead2" resultType="org.jeecg.modules.cost.entity.GarmentContract">
+		select * from VIEW_FabricLoss_Head_Clothes2 where (trim(cCode) like '%${code}%' and cCode not like '%样%')
+	</select>
+
+    <!-- 获取 头信息 主要是成衣委外及源头订单信息 -->
+    <select id="queryByCostHead3" resultType="java.lang.String">
+		select distinct 销售订单号 contractno from VIEW_FabricLoss_Head_Clothes2 a
+        left join TimeberwordFunction.dbo.sy_shipping_details_item101 b
+        on a.contractno=b.销售订单号
+        where (trim(cCode) like '%${code}%' and cCode not like '%样%')
+        and 销售订单号 is not null
 	</select>
 
     <!--<select id="queryByCostHead2" resultType="java.lang.String">

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/ISyCostAllocationService.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 成本分配主表
@@ -40,7 +41,7 @@ public interface ISyCostAllocationService extends IService<SyCostAllocation> {
     public void delBatchMain(Collection<? extends Serializable> idList);
 
     //根据单据号查询
-    public SyCostAllocation queryByPlanNum(String plannum,String type);
+    public SyCostAllocation queryByPlanNum(String plannum,String type,List<String> strings);
 
     //查询面损数据
     List<String> queryByFabric(String planCode);

+ 30 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/impl/SyCostAllocationServiceImpl.java

@@ -173,7 +173,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 
     //查询森宇u8数据
     @Override
-    public SyCostAllocation queryByPlanNum(String plannum, String type) {
+    public SyCostAllocation queryByPlanNum(String plannum, String type,List<String> strings) {
         //返回数据 garmentContractno
         SyCostAllocation syCostAllocation=new SyCostAllocation();
 
@@ -191,13 +191,37 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
             return null;
         }
         syCostAllocation = list.get(0);
-        List<String> strs3=Arrays.asList(syCostAllocation.getGarmentContractno().split(",")).stream().distinct().collect(Collectors.toList());
-        List<String> strs= syCostAllocationMapper.queryByCostHead2(plannum);
-        syCostAllocation.setGarmentContractno(strs.toString().substring(1,strs.toString().length()-1));
+//        List<String> strs3=Arrays.asList(syCostAllocation.getGarmentContractno().split(",")).stream().distinct().collect(Collectors.toList());
+//        List<String> strs3=new ArrayList<>();
+        List<String> strs3= syCostAllocationMapper.queryByCostHead3(plannum);
+//        List<GarmentContract> garmentContractList= syCostAllocationMapper.queryByCostHead2(plannum);
+//        System.out.println("garmentContractList\t"+garmentContractList);
+//        garmentContractList.forEach(g->{
+//            strs3.add(g.getContractno());
+//        });
+////        String strs="";
+//
+//        System.out.println("maps\t"+maps.get("maps"));
+//
+//        System.out.println("strs3前\t"+strs3);
+//        Map<String,List<String>> map1=(HashMap) maps.get("maps");
+//        for (String str : map1.keySet()){
+//            List<String> list1=map1.get(str);
+//            garmentContractList.forEach(g->{
+//                if (g.getAccount().equals(str)&&list1.contains(g.getCcuscode())){
+//                    strs3.remove(g.getContractno());
+//                }
+//            });
+//        }
+//
+//        System.out.println("strs3后\t"+strs3);
+
+        syCostAllocation.setGarmentContractno(strs3.toString().substring(1,strs3.toString().length()-1));
+
         // 销售订单附件
         List<AccessorItem> accessorItemList = new ArrayList<>();
         if (org.jeecg.modules.system.util.oConvertUtils.isNotEmpty(syCostAllocation.getGarmentContractno())) {
-            accessorItemList = fabricLossMapper.getSoAccList(strs);
+            accessorItemList = fabricLossMapper.getSoAccList(strs3);
 //            accessorItemList = fabricLossMapper.getSoAccList(Arrays.asList(syCostAllocation.getGarmentContractno().split(",")));
             accessorItemList.forEach(e -> e.setFileurl("/report/FabricLoss/getFile?fileId=" + e.getCFileId() + "&filename=" + e.getFilename()));
         }
@@ -801,7 +825,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
         //费用支出
         List<SyCostAllocationCostpay> syCostAllocationCostpays = syCostAllocationCostpayMapper.queryByCostPay(plannum);
         //查询销售订单总数量(用来计算占比),有一个销售订单关联多个委外订单的情况,使用占比算金额
-        SyCostAllocation entity = syCostAllocationMapper.querySalerIauantity(strs);
+        SyCostAllocation entity = syCostAllocationMapper.querySalerIauantity(strs3);
         //计算占比
         BigDecimal zhanBi = syCostAllocation.getPlanQuantity().divide(entity.getSalerIquantity(),2);