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

成本分配表、计划单统计表、追溯上游账套、采购发票、销售发票调整

huxy 2 hete
szülő
commit
d91bb70bec

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

@@ -220,6 +220,14 @@ public class SyCostAllocation implements Serializable {
     //查询人
     @TableField(exist = false)
     private String queryBy;
+
+    //采购类型
+    @TableField(exist = false)
+    private String orderType;
+
+    //税率2
+    @TableField(exist = false)
+    private BigDecimal taxrate2;
     //查询时间
     @TableField(exist = false)
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")

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

@@ -413,7 +413,7 @@
         SELECT ROUND(SuM(订单数量),2) planQuantity,
         ROUND(SUM(单价*订单数量),2) salesrrdersOriginaltotal,
         ROUND(SUM(单价*订单数量*汇率),2) salesordersLocaltotal,
-        max(汇率) exchangeRate,max(客户名称) Customer
+        max(汇率) exchangeRate,max(客户名称) Customer,MAX(采购类型) orderType
         from TimeberwordFunction.dbo.sy_shipping_details_item101
         where 委外采购订单号 like '%${code}%'
 	</select>

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

@@ -206,6 +206,8 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
         syCostAllocation.setSalesordersLocaltotal(BigDecimal.valueOf((Double)orderMap.get("salesordersLocaltotal")));//美元
         syCostAllocation.setSalesrrdersOriginaltotal(new BigDecimal(orderMap.get("salesrrdersOriginaltotal").toString()));//美元*汇率=人民币
         syCostAllocation.setGarmentContractno(strs3.toString().substring(1,strs3.toString().length()-1));
+        String orderType=orderMap.get("orderType").toString();
+        syCostAllocation.setOrderType(orderType);//采购类型
         // 销售订单附件
         List<AccessorItem> accessorItemList = new ArrayList<>();
         if (org.jeecg.modules.system.util.oConvertUtils.isNotEmpty(syCostAllocation.getGarmentContractno())) {
@@ -486,39 +488,49 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
         BigDecimal notincludestaxTotal = BigDecimal.ZERO;
         //合计面料成本美元
         BigDecimal includestaxTotal = BigDecimal.ZERO;
-//        System.out.println("getFabriccostIncludestax\t"+str.getFabriccostIncludestax());
-        if(fabriccostIncludestax.size()!=0){
-//            syCostAllocation.setTaxrate(new BigDecimal(0));
-            for(SyCostAllocation str : fabriccostIncludestax){
-                for(SyCostAllocationFabric li:list3){
-                    String goodsName=li.getGoodsName();
-                    if (goodsName.indexOf("--")!=-1){
-                        goodsName=goodsName.substring(0,goodsName.indexOf("--"));
-                    }
-                    if(str.getCInvName().equals(goodsName)){
-                        BigDecimal quantity=li.getUsageQuantity();
-                        if (li.getFabrictransferQuantity()!=null){
-                            quantity=li.getUsageQuantity().subtract(li.getFabrictransferQuantity());
+        System.out.println("fabriccostIncludestaxUsd1\t"+syCostAllocation.getFabriccostIncludestaxUsd());
+        syCostAllocation.setTaxrate2(new BigDecimal("13"));
+        if(syCostAllocation.getFabriccostIncludestaxUsd()!=null){
+            syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostIncludestaxUsd().divide(new BigDecimal("1.13"),4,BigDecimal.ROUND_HALF_UP));
+        }else{
+            syCostAllocation.setTaxrate2(new BigDecimal("0"));
+        }
+        System.out.println("fabriccostIncludestaxUsd2\t"+syCostAllocation.getFabriccostIncludestaxUsd());
+        System.out.println("fabriccostIncludestax\t"+syCostAllocation.getFabriccostIncludestax());
+
+
+        if(!orderType.equals("国内加工单")||syCostAllocation.getFabriccostIncludestaxUsd()==null){
+            if(fabriccostIncludestax.size()!=0){
+                for(SyCostAllocation str : fabriccostIncludestax){
+                    for(SyCostAllocationFabric li:list3){
+                        String goodsName=li.getGoodsName();
+                        if (goodsName.indexOf("--")!=-1){
+                            goodsName=goodsName.substring(0,goodsName.indexOf("--"));
                         }
-                        //-- fabriccostincludestax=面料含税成本 fabriccostNotincludestax=面料不含税成本
+                        if(str.getCInvName().equals(goodsName)){
+                            BigDecimal quantity=li.getUsageQuantity();
+                            if (li.getFabrictransferQuantity()!=null){
+                                quantity=li.getUsageQuantity().subtract(li.getFabrictransferQuantity());
+                            }
+                            //-- fabriccostincludestax=面料含税成本 fabriccostNotincludestax=面料不含税成本
 //                        System.out.println("getFabriccostIncludestax "+str.getFabriccostIncludestax()+" getFabriccostNotincludestax "+str.getFabriccostNotincludestax()
 //                                +"getFabriccostIncludestaxUsd"+str.getFabriccostIncludestaxUsd()+" getInvoiceQuantity "+str.getInvoiceQuantity()+" quantity "+quantity);
-                        if (str.getInvoiceQuantity().compareTo(quantity)!=0){
-                            BigDecimal money = str.getFabriccostIncludestax().divide(str.getInvoiceQuantity(),2,BigDecimal.ROUND_HALF_UP);
-                            BigDecimal num = money.multiply(quantity);
-                            usageQuantityTotal = usageQuantityTotal.add(num);
-                            BigDecimal money1 = str.getFabriccostNotincludestax().divide(str.getInvoiceQuantity(),2,BigDecimal.ROUND_HALF_UP);
-                            BigDecimal num1 = money1.multiply(quantity);
-                            notincludestaxTotal = notincludestaxTotal.add(num1);
-                            BigDecimal money2 = str.getFabriccostIncludestaxUsd().divide(str.getInvoiceQuantity(),2,BigDecimal.ROUND_HALF_UP);
-                            BigDecimal num2 = money2.multiply(quantity);
-                            includestaxTotal = includestaxTotal.add(num2);
-                        }else{
-                            usageQuantityTotal = usageQuantityTotal.add(str.getFabriccostIncludestax());
-                            notincludestaxTotal = notincludestaxTotal.add(str.getFabriccostNotincludestax());
-                            includestaxTotal = includestaxTotal.add(str.getFabriccostIncludestaxUsd());
-                        }
-                        System.out.println(" getInvoiceQuantity "+str.getInvoiceQuantity()+" quantity "+quantity);
+                            if (str.getInvoiceQuantity().compareTo(quantity)!=0){
+                                BigDecimal money = str.getFabriccostIncludestax().divide(str.getInvoiceQuantity(),2,BigDecimal.ROUND_HALF_UP);
+                                BigDecimal num = money.multiply(quantity);
+                                usageQuantityTotal = usageQuantityTotal.add(num);
+                                BigDecimal money1 = str.getFabriccostNotincludestax().divide(str.getInvoiceQuantity(),2,BigDecimal.ROUND_HALF_UP);
+                                BigDecimal num1 = money1.multiply(quantity);
+                                notincludestaxTotal = notincludestaxTotal.add(num1);
+                                BigDecimal money2 = str.getFabriccostIncludestaxUsd().divide(str.getInvoiceQuantity(),2,BigDecimal.ROUND_HALF_UP);
+                                BigDecimal num2 = money2.multiply(quantity);
+                                includestaxTotal = includestaxTotal.add(num2);
+                            }else{
+                                usageQuantityTotal = usageQuantityTotal.add(str.getFabriccostIncludestax());
+                                notincludestaxTotal = notincludestaxTotal.add(str.getFabriccostNotincludestax());
+                                includestaxTotal = includestaxTotal.add(str.getFabriccostIncludestaxUsd());
+                            }
+                            System.out.println(" getInvoiceQuantity "+str.getInvoiceQuantity()+" quantity "+quantity);
 //                            BigDecimal money = str.getFabriccostIncludestax().divide(str.getInvoiceQuantity(),2,BigDecimal.ROUND_HALF_UP);
 //                            BigDecimal num = money.multiply(li.getUsageQuantity());
 //                            usageQuantityTotal = usageQuantityTotal.add(num);
@@ -529,42 +541,42 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 //                            BigDecimal money2 = str.getFabriccostIncludestaxUsd().divide(str.getInvoiceQuantity(),2,BigDecimal.ROUND_HALF_UP);
 //                            BigDecimal num2 = money2.multiply(li.getUsageQuantity());
 //                            includestaxTotal = includestaxTotal.add(num2);
-                        //(发票金额/发票数量)*使用数量
+                            //(发票金额/发票数量)*使用数量
 //                            System.out.println("面料含税成本\t"+usageQuantityTotal+"\t面料不含税成本\t"+notincludestaxTotal+"\t发票数量\t"+str.getInvoiceQuantity()+"\t使用数量\t"+li.getUsageQuantity());
+                        }
                     }
                 }
-            }
 //                System.out.println("面料含税人民币2\t"+usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP));
 //                System.out.println("实际总金额2\t"+usageQuantityTotal);
 
-            if (syCostAllocation.getFabriccostIncludestax()!=null){
-                syCostAllocation.setFabriccostIncludestax(syCostAllocation.getFabriccostIncludestax().add(usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP)));
-            }else{
-                syCostAllocation.setFabriccostIncludestax(usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP));
-            }
-            if (syCostAllocation.getFabriccostNotincludestax()!=null){
-                syCostAllocation.setFabriccostNotincludestax(syCostAllocation.getFabriccostNotincludestax().add(notincludestaxTotal));
-            }else{
-                syCostAllocation.setFabriccostNotincludestax(notincludestaxTotal);
-            }
-            System.out.println("includestaxTotal\t"+includestaxTotal+"  getFabriccostIncludestaxUsd  "+syCostAllocation.getFabriccostIncludestaxUsd());
-            if (syCostAllocation.getFabriccostIncludestaxUsd()!=null){
-                syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostIncludestaxUsd().add(includestaxTotal));
+                if (syCostAllocation.getFabriccostIncludestax()!=null){
+                    syCostAllocation.setFabriccostIncludestax(syCostAllocation.getFabriccostIncludestax().add(usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP)));
+                }else{
+                    syCostAllocation.setFabriccostIncludestax(usageQuantityTotal.setScale(2,BigDecimal.ROUND_HALF_UP));
+                }
+                if (syCostAllocation.getFabriccostNotincludestax()!=null){
+                    syCostAllocation.setFabriccostNotincludestax(syCostAllocation.getFabriccostNotincludestax().add(notincludestaxTotal));
+                }else{
+                    syCostAllocation.setFabriccostNotincludestax(notincludestaxTotal);
+                }
+                System.out.println("includestaxTotal\t"+includestaxTotal+"  getFabriccostIncludestaxUsd  "+syCostAllocation.getFabriccostIncludestaxUsd());
+                if (syCostAllocation.getFabriccostIncludestaxUsd()!=null){
+                    syCostAllocation.setFabriccostIncludestaxUsd(syCostAllocation.getFabriccostIncludestaxUsd().add(includestaxTotal));
+                }else{
+                    syCostAllocation.setFabriccostIncludestaxUsd(includestaxTotal);
+                }
             }else{
-                syCostAllocation.setFabriccostIncludestaxUsd(includestaxTotal);
-            }
-        }else{
-            if (syCostAllocation.getFabriccostIncludestax()==null){
-                syCostAllocation.setFabriccostIncludestax(BigDecimal.ZERO);
-            }
-            if (syCostAllocation.getFabriccostNotincludestax()==null){
-                syCostAllocation.setFabriccostNotincludestax(BigDecimal.ZERO);
-            }
-            if (syCostAllocation.getFabriccostIncludestaxUsd()==null){
-                syCostAllocation.setFabriccostIncludestaxUsd(BigDecimal.ZERO);
+                if (syCostAllocation.getFabriccostIncludestax()==null){
+                    syCostAllocation.setFabriccostIncludestax(BigDecimal.ZERO);
+                }
+                if (syCostAllocation.getFabriccostNotincludestax()==null){
+                    syCostAllocation.setFabriccostNotincludestax(BigDecimal.ZERO);
+                }
+                if (syCostAllocation.getFabriccostIncludestaxUsd()==null){
+                    syCostAllocation.setFabriccostIncludestaxUsd(BigDecimal.ZERO);
+                }
             }
         }
-
 //        }
 
         long startTime3 = System.currentTimeMillis();

+ 10 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/costLossReview/mapper/xml/SyCostLossReviewMapper.xml

@@ -684,20 +684,23 @@ GROUP BY planNo;
         </if>
         <if test='e.msPlanMan !="" and e.msPlanMan != null'>
             and plan_code in(select plan_no from sy_approval_history
-            where processed_by like CONCAT('%',#{e.msPlanMan},'%')and stuta='审批通过')
+            where assigned_by like CONCAT('%',#{e.msPlanMan},'%')and stuta='指派')
         </if>
 
     </select>
     <select id="queryCodeBycstatus" resultType="String">
         select plan_num as cCode
         from sy_cost_json
-        where status in
-        <foreach collection="status" item="value" index="index" open="(" separator="," close=")">
-        #{value}
-        </foreach>
+        where 1=1
+        <if test='status !="" and status != null '>
+            and status in
+            <foreach collection="status" item="value" index="index" open="(" separator="," close=")">
+                #{value}
+            </foreach>
+        </if>
         <if test='e.cbPlanMan !="" and e.cbPlanMan != null'>
-            and plan_code in(select plan_no from sy_cost_approval_history
-            where processed_by like CONCAT('%',#{e.cbPlanMan},'%')and stuta='审批通过')
+            and plan_num in(select plan_no from sy_cost_approval_history
+            where assigned_by like CONCAT('%',#{e.cbPlanMan},'%')and stuta='指派')
         </if>
     </select>
     <select id="queryCodeByPlanTable" resultType="String">

+ 7 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splfi/service/impl/SyPackingListFabricServiceImpl.java

@@ -3062,7 +3062,7 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 		//删除入库单号记录
 		String account="101";
 		List<String> codes=getList3(listFabrics);//获取入库单号
-//		System.out.println("面辅料查看入库单号  "+codes);
+		System.out.println("面辅料查看入库单号  "+codes);
 		listFabrics.forEach(f->{
 			//这里用来推送结算单
 //			System.out.println("单据号   "+f.getDocumentNo()+"  Rdrecord32Code  "+f.getRdrecord32Code());
@@ -3447,6 +3447,9 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 			if(account.equals("102")&&(syPackingListFabric.getSaleInvoiceCode()==null||syPackingListFabric.getSaleInvoiceCode().indexOf(account1+"采购发票")==-1)){
 				ids.add(syPackingListFabric.getDocumentNo().substring(3));
 				String rdrecord01Code=syPackingListTailoringItemMapper.getRdrecord01Code(syPackingListFabric.getDocumentNo().substring(3),"0000000002");
+				if (oConvertUtils.isEmpty(rdrecord01Code)){
+					throw new JeecgBootException(account+"销售出库单号"+rdrecord01Code+",找不到对应101的入库单");
+				}
 				syPackingListFabric.setRdrecord32Code(rdrecord01Code);
 				String cdepCode=syPackingListTailoringItemMapper.getRdrecord01(rdrecord01Code);
 				syPackingListFabric.setCdepCode(cdepCode);
@@ -3454,6 +3457,9 @@ public class SyPackingListFabricServiceImpl extends ServiceImpl<SyPackingListFab
 			if(account.equals("103")&&(syPackingListFabric.getSaleInvoiceCode()==null||syPackingListFabric.getSaleInvoiceCode().indexOf(account1+"采购发票")==-1)){
 				ids.add(syPackingListFabric.getDocumentNo().substring(3));
 				String rdrecord01Code=syPackingListTailoringItemMapper.getRdrecord01Code(syPackingListFabric.getDocumentNo().substring(3),"0000000001");
+				if (oConvertUtils.isEmpty(rdrecord01Code)){
+					throw new JeecgBootException(account+"销售出库单号"+rdrecord01Code+",找不到对应101的入库单");
+				}
 				System.out.println("rdrecord01Code     "+rdrecord01Code);
 				syPackingListFabric.setRdrecord32Code(rdrecord01Code);
 				String cdepCode=syPackingListTailoringItemMapper.getRdrecord01(rdrecord01Code);

+ 7 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/controller/SyPackingListTailoringController.java

@@ -1826,11 +1826,11 @@ public class SyPackingListTailoringController implements Job {
 				map.put("poid","one");//销售订单id
 				for (int x=0;x<3;x++){//最多循环3次
 					try {
-						if (map.get("account").equals("103")){
+						if (map.get("account").equals("103") && !map.containsKey("errorMessage")){
 							message+=syPackingListTailoringService.three(main,map);
-						}else if(map.get("account").equals("102")){
+						}else if(map.get("account").equals("102")&& !map.containsKey("errorMessage")){
 							message+=syPackingListTailoringService.two(main,map);
-						}else if(map.get("account").equals("101")){
+						}else if(map.get("account").equals("101")&& !map.containsKey("errorMessage")){
 							message+=syPackingListTailoringService.one(main,map);
 						}else{
 							break;
@@ -1840,6 +1840,10 @@ public class SyPackingListTailoringController implements Job {
 						message+=e.getMessage();
 					}
 				}
+				if (map.containsKey("errorMessage")){
+					message+=map.get("errorMessage");
+				}
+				System.out.println("errorMessage\n"+message);
 				if (map.containsKey("error")&&map.get("error").toString().indexOf("10")>-1){
 					String error =map.get("error").toString();
 					log.info("成衣推送报错error\t"+error);

+ 10 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/impl/SyPackingListTailoringServiceImpl.java

@@ -1376,6 +1376,7 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 					if(mapt.get("orderNumber").equals("one")){
 						orderData=syPackingListTailoringMapper.getOmOrPo("PO_POMAIN","cPOID='"+mapt.get("mpOrder")+"'","POID");//委外订单号判断
 					}else{
+						System.out.println("orderNumber\t"+mapt.get("orderNumber"));
 						orderData=syPackingListTailoringMapper.getOmOrPo("PO_POMAIN","cPOID='"+mapt.get("orderNumber")+"'","POID");//根据采购订单号判断
 					}
 					map.put("CRDCODE","11");//入库类别(采购入库/委外入库)
@@ -1618,10 +1619,14 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 					String params5=mapSort.get(item.getId());//当前数据库行号
 					Map<String,Object> ivouchrownos =syPackingListTailoringMapper.getIvouchrowno(params1,params2,params3,params4,params5);
 					if(ivouchrownos==null||ivouchrownos.get("iorderdid")==null){
-						return "推送失败:未找到上游订单数据";
+//						return mapt.get("account")+"账套推送失败:销售订单"+params3+"未找到上游订单数据";
+						String account=oConvertUtils.getString(mapt.get("account"));
+						account=org.jeecg.modules.system.util.oConvertUtils.subtractOne(account);
+						mapt.put("errorMessage",account+"账套推送失败:"+mapt.get("account")+"销售订单"+params3+"未找到上游订单数据");
+					}else{
+						mapSort.put(item.getId(),ivouchrownos.get("iorderdid").toString());
+						mapSort.put(item.getId()+"2",ivouchrownos.get("ivouchrowno").toString());
 					}
-					mapSort.put(item.getId(),ivouchrownos.get("iorderdid").toString());
-					mapSort.put(item.getId()+"2",ivouchrownos.get("ivouchrowno").toString());
 				}
 
 				//测试新区域
@@ -2291,7 +2296,7 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 						u8Money=u8Money.add(u8Price.multiply(item.getTotal()).setScale(2, RoundingMode.HALF_UP));//单证合计
 						jsonObject.put("IORIMONEY",item.getTotal().multiply(u8Price).setScale(2, RoundingMode.HALF_UP));//改成使用报关单价*成衣参考单价
 						getcFree(jsonObject,map);
-						jsonObject.put("CDEFINE28",item.getSmallPo());//小po
+//						jsonObject.put("CDEFINE28",item.getSmallPo());//小po
 						break;
 					}
 				}
@@ -2468,7 +2473,7 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 						autoIds.add(map.get("AutoID"));
 						jsonObject.put("AUTOID_DIS",map.get("AutoID"));
 						getcFree(jsonObject,map);
-						jsonObject.put("CDEFINE28",item.getSmallPo());
+//						jsonObject.put("CDEFINE28",item.getSmallPo());
 						if(item.getAcSetNo().equals("102")&&account.equals("102")){
 							jsonObject.put("ITAXUNITPRICE",item.getCustomsDeclarationUnitPrice());//改成使用报关单价
 						}

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/oConvertUtils.java

@@ -594,6 +594,7 @@ public class oConvertUtils {
         return code;
 
     }
+
     /**
      * 字符串+1方法,该方法将其结尾的整数+1,适用于任何以整数结尾的字符串,不限格式,不限分隔符。
      * @author 隔壁老赵
@@ -616,6 +617,28 @@ public class oConvertUtils {
         }
     }
 
+    /**
+     * 字符串+1方法,该方法将其结尾的整数+1,适用于任何以整数结尾的字符串,不限格式,不限分隔符。
+     * @author 隔壁老赵
+     * @param testStr 要+1的字符串
+     * @return +1后的字符串
+     * @exception NumberFormatException
+     */
+    public static String subtractOne(String testStr) {
+        String[] strs = testStr.split("[^0-9]");//根据不是数字的字符拆分字符串
+        String numStr = strs[strs.length - 1];//取出最后一组数字
+        if (numStr != null && numStr.length() > 0) {//如果最后一组没有数字(也就是不以数字结尾),抛NumberFormatException异常
+            int n = numStr.length();//取出字符串的长度
+            BigDecimal num=new BigDecimal(numStr).add(new BigDecimal(-1));//将该数字加一
+            String added = String.valueOf(num);
+            n = Math.min(n, added.length());
+            //拼接字符串
+            return testStr.subSequence(0, testStr.length() - n) + added;
+        } else {
+            throw new NumberFormatException();
+        }
+    }
+
     /**
      * 获取流水号最大值去除单号中的前缀0
      * @param testStr