Quellcode durchsuchen

面料损耗更新

fenghaifu vor 2 Jahren
Ursprung
Commit
01f6f5574d

+ 36 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/entity/FabricInventoryOut.java

@@ -0,0 +1,36 @@
+package org.jeecg.modules.report.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * @author fenghaifu
+ * @version V1.0
+ * @Copyright: 上海萃颠信息科技有限公司. All rights reserved.
+ * @Title:FabricInventoryOut
+ * @projectName jeecg-boot-parent
+ * @Description:物料出库
+ * @date: 2022-10-08 11:34
+ * @updatehistory: 2022-10-08 11:34 新增
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="面料损耗-基础-物料出库", description="面料损耗-基础-物料出库")
+public class FabricInventoryOut {
+	@ApiModelProperty(value = "批号")
+	String cBatch;
+	@ApiModelProperty(value = "数量")
+	Double iQuantity;
+	@ApiModelProperty(value = "物料名称")
+	String cInvName;
+	@ApiModelProperty(value = "物料编码")
+	String cInvCode;
+	@ApiModelProperty(value = "颜色")
+	String cColor;
+	@ApiModelProperty(value = "物料分类编号")
+	String cInvCCode;
+}

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/entity/FabricPoOrderIn.java

@@ -33,6 +33,9 @@ public class FabricPoOrderIn {
 	//颜色
 	@ApiModelProperty(value = "颜色")
 	private String cColor;
+	//批号
+	@ApiModelProperty(value = "批号")
+	private String cBatch;
 	//入库数量
 	@ApiModelProperty(value = "入库数量")
 	private Double iQuantity;

+ 36 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/mapper/xml/FabricLossMapper.xml

@@ -37,6 +37,10 @@
 	<select id="getSaleOutSum" resultType="java.lang.String">
 		select sum(isnull(iQuantity,0)) as 'iQuantity' from VIEW_FabricLoss_Head_Clothes_SaleOut_Sum where csocode in (
 			select cSoOrdercode from VIEW_OM_MOMain_ALL_Clothes where ccode like CONCAT(#{code},'%')
+		) and cinvcode in (
+			select cinvcode from VIEW_OM_MOMain_ALL_Clothes where ccode like CONCAT(#{code},'%')
+		) and cfree1 in (
+			select cfree1 from VIEW_OM_MOMain_ALL_Clothes where ccode like CONCAT(#{code},'%')
 		)
 	</select>
 	<select id="getPrice" resultType="java.lang.String">
@@ -63,12 +67,12 @@
 
 	<!--获取采购订单,物料名为物料名+颜色-->
 	<select id="getPurchaseList" resultType="org.jeecg.modules.report.entity.FabricPoOrder">
-		select cVenName,cVenAbbName,cInvCode,cInvName,cColor,cBatch,sum(iQuantity) as iQuantity,
+		select cVenName,cVenAbbName,cPOID,cInvCode,cInvName,cColor,<!--isnull(cBatch,'') as cBatch,-->sum(iQuantity) as iQuantity,
 		isnull(sum(iQuantityIn),0) as iQuantityIn
 		 from (
 		select a.cPOID ,d.cVenName,d.cVenAbbName ,c.cInvCode,c.cInvName + ' ' + isnull(b.cFree1,'') as cInvName,isnull(b.cFree1,'') as cColor,b.iQuantity,
-		(select sum(iquantity) from RdRecords01 x where x.iposid=b.id) as iQuantityIn,
-		stuff((SELECT ',' + cbatch FROM RdRecords01 x where x.iposid=b.id FOR XML path('') ), 1, 1, '') as cBatch
+		(select sum(iquantity) from RdRecords01 x where x.iposid=b.id) as iQuantityIn<!--,
+		stuff((SELECT ',' + cbatch FROM RdRecords01 x where x.iposid=b.id FOR XML path('') ), 1, 1, '') as cBatch-->
 		from PO_Pomain a
 		inner join PO_Podetails b on a.POID  =b.POID
 		inner join Inventory c on b.cInvCode=c.cInvCode
@@ -78,7 +82,7 @@
 		or c.cInvCCode LIKE '02%'
 		or c.cInvCCode LIKE '03%'
 		or c.cInvCCode LIKE '04%')
-		) as t1 group by cVenName,cVenAbbName,cInvCode,cInvName,cColor,cBatch
+		) as t1 group by cVenName,cVenAbbName,cPOID,cInvCode,cInvName,cColor<!--,cBatch-->
 	</select>
 	<!-- 其他入库纱,找委外订单的材料出库单,获取物料号+批号,物料号+批号再其他入库单 -->
 	<select id="getPurchaseListOtherInList" resultType="org.jeecg.modules.report.entity.FabricPoOrderOut">
@@ -90,7 +94,7 @@
 			rdrecords11 a
 			INNER JOIN Inventory d ON a.cinvcode = d.cinvcode
 		WHERE
-		a.cbatch is not null and a.cbatch &lt;&gt;'期初' and
+		(a.cbatch is null or a.cbatch='' or a.cbatch &lt;&gt; '期初') and
 		(d.cInvCCode LIKE '01%'
 			or d.cInvCCode LIKE '02%'
 			or d.cInvCCode LIKE '03%'
@@ -114,7 +118,7 @@
 				WHERE
 					a.cbustype = '其他入库'
 				)
-			)
+			) or d.cinvname='杂纱'
 			)
 		) as t1 group by cCode
 	</select>
@@ -221,7 +225,7 @@
 		order by cVCName,cVenName,cInvCode,cInvName,cComUnitCode,cColor
 
 	</select>
-	<!--获取委外材料出库单,已核销的取核销数量-->
+	<!--获取本次采购入库的委外材料出库单,已核销的取核销数量-->
 	<select id="getOmOutList" resultType="map">
 		SELECT
 			g.cVenName,
@@ -277,7 +281,7 @@
 	</select>
 	<!--获取本次采购入库单,含发票和结算数据-->
 	<select id="getPurchaseInList" resultType="org.jeecg.modules.report.entity.FabricPoOrderIn">
-		select a.cCode,a.cBusType,b.cInvCode,b.cFree1 as cColor,b.iQuantity,
+		select a.cCode,a.cBusType,b.cInvCode,b.cFree1 as cColor,b.cBatch,b.iQuantity,
 		isnull((select sum(iPBVQuantity ) from PurBillVouchs x where x.RdsId =b.autoid),0) as iQuantityInvoice,
 		isnull((select sum(iSum)/sum(iPBVQuantity ) from PurBillVouchs  x where x.RdsId =b.autoid),0) as iPrice,
 		isnull((select sum(iSVQuantity) from PurSettleVouchs  x where x.iRdsID=b.autoid),0) as iQuantitySettle
@@ -415,7 +419,9 @@
 	</select>
 	<!--获取采购入库物料被其他委外订单使用明细 -->
 	<select id="getPoOrderInToOther" resultType="org.jeecg.modules.report.entity.FabricPoOrderOut">
-		select cCode,cInvCode,cColor,sum(iQuantity*iPrice)/sum(iQuantity) as iPrice, sum(iQuantity) as iQuantity from
+		select cCode,cInvCode,cColor,
+			case when sum( iQuantity ) = 0 then 0 else sum(iQuantity*iPrice)/sum(iQuantity) end as iPrice,
+			sum(iQuantity) as iQuantity from
 		(
 		select cInvCode,isnull(cFree1,'') as cColor,comcode as cCode,isnull(iSQuantity,iquantity) as iQuantity,iUnitCost as iPrice
 		from rdrecords11 where
@@ -482,4 +488,25 @@
 		AND a.cCode LIKE CONCAT(#{code},'%')
 
 	</select>
+	<!-- 获取委外出库的纱数量 -->
+	<select id="getOmOutList01" resultType="org.jeecg.modules.report.entity.FabricInventoryOut">
+		SELECT
+			b.cInvName,
+			isnull( a.cFree1, '' ) AS cColor,
+			b.cInvCode,
+			sum(isnull( a.iSQuantity, a.iQuantity )) AS iQuantity,
+			a.cBatch
+		FROM
+			rdrecords11 a
+			INNER JOIN Inventory b ON a.cInvCode = b.cInvCode
+			INNER JOIN OM_MODetails d ON d.MODetailsID = a.iOMoDID
+			INNER JOIN om_momain e ON e.moid = d.moid
+		WHERE
+			b.cInvCCode NOT LIKE '19%'
+			AND e.cCode LIKE CONCAT(#{code},'%')
+			and b.cInvCCode like '01%'
+			group by b.cinvname,a.cFree1,b.cinvcode,a.cbatch
+
+	</select>
+
 </mapper>

+ 48 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/service/impl/FabricLossServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CacheConstant;
 import org.jeecg.common.constant.CommonConstant;
@@ -101,10 +102,13 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 				ret.setCPersonName(String.join(",",lstCpersonName));
 			}
 			//制单人
+			LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+			ret.setMakingPeople(sysUser.getRealname());
+			/*
 			List<String> makingPeople = fabricLossMapper.getMakingPeople(code);
 			if (oConvertUtils.listIsNotEmpty(makingPeople)){
 				ret.setMakingPeople(String.join(",", makingPeople));
-			}
+			}*/
 			//计划员
 			List<String> planner = fabricLossMapper.getPlanner(code);
 			if (oConvertUtils.listIsNotEmpty(planner)){
@@ -115,9 +119,33 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 			// 排单数量
 			ret.setNumber(oConvertUtils.getDouble(fabricLossMapper.getNumber(code),0));
 			// 销售出库数量
-			ret.setOutboundNumber(oConvertUtils.getDouble(fabricLossMapper.getSaleOutSum(code),0));
+			Double dOutSum = oConvertUtils.getDouble(fabricLossMapper.getSaleOutSum(code),0);
+			if (dOutSum>ret.getNumber()) {
+				dOutSum = ret.getNumber();
+			}
+			ret.setOutboundNumber(dOutSum);
 			// 采购入库数据
-			List<FabricPoOrder> fabricPoOrderList = fabricLossMapper.getPurchaseList(code);
+			List<FabricPoOrder> fabricPoOrderListTmp = fabricLossMapper.getPurchaseList(code);
+			//采购数据把不同订单合并
+			List<FabricPoOrder> fabricPoOrderList= new ArrayList<>();
+			for (FabricPoOrder fabricPoOrder: fabricPoOrderListTmp){
+				String cInvName = fabricPoOrder.getCInvName();
+				Optional<FabricPoOrder> findItemOpt = fabricPoOrderList.stream().filter(e->e.getCInvName().equals(cInvName)).findFirst();
+				if (findItemOpt.isPresent()){
+					FabricPoOrder findItem = findItemOpt.get();
+					findItem.setIQuantityIn(findItem.getIQuantityIn()+fabricPoOrder.getIQuantityIn());
+					findItem.setIQuantity(findItem.getIQuantity()+fabricPoOrder.getIQuantity());
+					findItem.setCPOID(findItem.getCPOID()+","+fabricPoOrder.getCPOID());
+					if (findItem.getCVenAbbName().indexOf(fabricPoOrder.getCVenAbbName()) == -1){
+						findItem.setCVenAbbName(findItem.getCVenAbbName()+","+fabricPoOrder.getCVenAbbName());
+					}
+					if (findItem.getCVenName().indexOf(fabricPoOrder.getCVenName()) == -1){
+						findItem.setCVenName(findItem.getCVenName()+","+fabricPoOrder.getCVenName());
+					}
+				}else{
+					fabricPoOrderList.add(fabricPoOrder);
+				}
+			}
 			// 获取委外材料出库单,已核销的取核销数量
 			List<Map<String,Object>> fabricOmOutList = fabricLossMapper.getOmOutList(code);
 			// 获取本次采购入库的形态转换
@@ -129,6 +157,8 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 				fabricPoOrderIn.setIQuantityNInvoice(bNum.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
 				bNum = new BigDecimal(fabricPoOrderIn.getIQuantity()-fabricPoOrderIn.getIQuantitySettle());
 				fabricPoOrderIn.setIQuantityNSettle(bNum.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
+				bNum = new BigDecimal(fabricPoOrderIn.getIPrice());
+				fabricPoOrderIn.setIPrice(bNum.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue());
 			}
 			// 采购入库被其他委外订单使用的信息
 			List<FabricPoOrderOut> fabricPoOrderOutList = fabricLossMapper.getPoOrderInToOther(code);
@@ -137,22 +167,25 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 				// 获取采购形态转换物料
 				List<Map<String, Object>> tmpAssemVouchList = fabricAssemVouchList.stream().filter(e->
 						oConvertUtils.getString(e.get("cInvCode")).equals(fabricPoOrder.getCInvCode()) &&
-						oConvertUtils.getString(e.get("cColor")).equals(fabricPoOrder.getCColor())&&
-								oConvertUtils.getString(e.get("cAVBatch")).equals(fabricPoOrder.getCBatch())).collect(Collectors.toList());
+						oConvertUtils.getString(e.get("cColor")).equals(fabricPoOrder.getCColor())).collect(Collectors.toList());
+				//&&
+				//								fabricPoOrder.getCBatch().indexOf(oConvertUtils.getString(e.get("cAVBatch")))>-1
 				// 未形态转换物料
 				List<Map<String, Object>> tmpOmOutList1 = fabricOmOutList.stream().filter(e->
 						oConvertUtils.getString(e.get("cInvCode")).equals(fabricPoOrder.getCInvCode()) &&
-						oConvertUtils.getString(e.get("cColor")).equals(fabricPoOrder.getCColor()) &&
-						oConvertUtils.getString(e.get("cBatch")).equals(fabricPoOrder.getCBatch())).collect(Collectors.toList());
+						oConvertUtils.getString(e.get("cColor")).equals(fabricPoOrder.getCColor())).collect(Collectors.toList());
+				// &&
+				//								fabricPoOrder.getCBatch().indexOf(oConvertUtils.getString(e.get("cBatch")))>-1
 
 				// 形态转换物料
 				List<Map<String, Object>> tmpOmOutList2 = fabricOmOutList.stream().filter(out->{
 				return tmpAssemVouchList.stream().filter(e ->
 						oConvertUtils.getString(e.get("cInvCode2")).equals(oConvertUtils.getString(out.get("cInvCode"))) &&
-						oConvertUtils.getString(e.get("cColor2")).equals(oConvertUtils.getString(out.get("cColor"))) &&
-								oConvertUtils.getString(e.get("cAVBatch2")).equals(oConvertUtils.getString(out.get("cBatch")))
+						oConvertUtils.getString(e.get("cColor2")).equals(oConvertUtils.getString(out.get("cColor")))
 				).count() > 0;
 				}).collect(Collectors.toList());
+				// &&
+				//								oConvertUtils.getString(e.get("cAVBatch2")).equals(oConvertUtils.getString(out.get("cBatch")))
 
 				tmpOmOutList1.addAll(tmpOmOutList2);
 
@@ -456,6 +489,12 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 				BigDecimal bdValue = new BigDecimal(fabricCostCloth.getINatSum());
 				fabricCostCloth.setINatSum(bdValue.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
 			}
+			Collections.sort(fabricCostClothGroupList, new Comparator<FabricCostCloth>() {
+				@Override
+				public int compare(FabricCostCloth o1, FabricCostCloth o2) {
+					return DateUtils.str2Date(o1.getCShipTime(), DateUtils.date_sdf.get()).compareTo(DateUtils.str2Date(o2.getCShipTime(), DateUtils.date_sdf.get()));
+				}
+			});
 			ret.setFabricCostClothList(fabricCostClothGroupList);
 
 			return  ret;