LiGuang пре 3 година
родитељ
комит
6dabe29eca

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

@@ -33,6 +33,8 @@ public class FabricLoss {
     private  String price;
     //成衣合同号
     private  String contractNo;
+    //采购订单号
+    private String orderCode;
     //查询日期
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
     @DateTimeFormat(pattern = "yyyy-MM-dd")

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

@@ -29,14 +29,23 @@ public interface FabricLossMapper extends BaseMapper<FabricLoss> {
 	FabricLoss getFabricLossData(@Param("code")String code);
 
 	//查询103委外制单人=计划员
+	@DS("multi-three")
 	List<String>getPlanner(@Param("code")String code);
 
 	//查询103的委外发票制单人=制单人
+	@DS("multi-three")
 	List<String>getMakingPeople(@Param("code")String code);
 
 	//查询103委外订单数量=排单量
+	@DS("multi-three")
 	String getNumber(@Param("code")String code);
 
 	//查询103委外订单 单价成本
+	@DS("multi-three")
 	String getPrice(@Param("code")String code);
+
+	//查询102采购订单号(只获取供应商为马菲羊的)
+	@DS("multi-two")
+	String getOrderCode(@Param("code")String code);
+
 }

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

@@ -5,14 +5,20 @@
 
 	<select id="getFabricLossData" resultType="org.jeecg.modules.report.entity.FabricLoss">
 		select distinct   a.csocode as 'csoCode',b.cdefine22 as 'cDefine22',c.cPersonName as 'cPersonName',d.iQuantity as 'number',e.iQuantity as 'outboundNumber',
-				f.dj as 'price',CONVERT(varchar,GETDATE(),120) as 'dateTime',a.csocode as 'csoCode',f.dj as 'actualPrice'
+		f.price as 'price',CONVERT(varchar,GETDATE(),120) as 'dateTime',a.csocode as 'csoCode',f.price as 'actualPrice',ta.cPOID as 'orderCode'
 		from SO_SOMain a left join SO_SODetails b on a.csocode=b.csocode
-						 left join Person c on a.cPersonCode=c.cPersonCode
-						 left join (select sum(a.iQuantity)as 'iQuantity' ,b.csocode  from OM_MODetails a left join SO_SODetails b on a.isosid =b.isosid																			  left join OM_MOMain c on a.moid=c.moid GROUP BY b.csocode) d on a.csocode=d.csocode
-						 left join (select sum(iQuantity) as 'iQuantity',csocode from rdrecords32  GROUP BY csocode) e on a.csocode=e.csocode
-						 left join (select (b.iProcessFee+b.iMaterialFee)/b.iQuantity as 'dj',b.csocode  from (
-							select sum(b.iMaterialFee) as 'iMaterialFee',sum(b.iProcessFee) as 'iProcessFee',sum(b.iQuantity) as 'iQuantity',bc.csocode  from rdrecord01 a left join rdrecords01 b on a.id=b.id
-							GROUP BY bc.csocode)  b  ) f on a.csocode=f.csocode
+		left join Person c on a.cPersonCode=c.cPersonCode
+		left join (select sum(isnull(a.iQuantity,0))as 'iQuantity' ,b.csocode  from OM_MODetails a left join SO_SODetails b on a.isosid =b.isosid																			  left join OM_MOMain c on a.moid=c.moid GROUP BY b.csocode) d on a.csocode=d.csocode
+		left join (select sum(isnull(iQuantity,0)) as 'iQuantity',csocode from rdrecords32  GROUP BY csocode) e on a.csocode=e.csocode
+		left join (select isnull(sum(a.count)/sum(b.iquantity),0) as 'price',b.csoordercode from (
+		select sum((isnull(c.iQuantity,0)*isnull(b.iunitcost,0))+(isnull(c.iQuantity,0)*isnull(b.iprocesscost,0))) as 'count' ,a.cordercode as 'cordercode'     from rdrecord01 a left join rdrecords01 b on a.id=b.id
+		left join (select sum(b.iquantity)as 'iquantity',b.cbatch,b.iorderdid,cmpocode  from rdrecord11 a  left join rdrecords11 b on a.id=b.id
+		where   b.cbatch is not null GROUP BY b.iorderdid,cbatch,cmpocode)  c on b.iorderdid=c.iorderdid and a.cordercode=c.cmpocode AND c.cbatch=b.cbatch
+		GROUP BY a.cordercode) a
+		left join (select sum(isnull(b.iquantity,0)) as 'iquantity',a.ccode,b.csoordercode from OM_MOMain  a left join OM_MODetails b  on a.moid=b.moid
+		GROUP BY a.ccode,b.csoordercode) b on a.cordercode=b.ccode
+		where   a.count !='0'  GROUP BY b.csoordercode) f on a.csocode=f.csoordercode
+		left join (select a.cpoid as 'cpoid',b.csoordercode as 'csoordercode' from PO_Pomain a left join PO_Podetails b on a.POID=b.POID) ta on a.csocode=ta.csoordercode
 		where 1=1
 		<if test="code!=null and ''!=code">
 			a.csocode=#{code}
@@ -20,7 +26,9 @@
 	</select>
 	<select id="getPlanner" resultType="java.lang.String">
 		select distinct c.cMaker   from OM_MODetails a
-		left join OM_MOMain c on a.moid=c.moid where 1=1
+		left join OM_MOMain c on a.moid=c.moid
+		left join Vendor b on c.cvencode=b.cvencode
+		where b.cvccode='0105'
 		<if test="code!=null and ''!=code">
 			a.csocode=#{code}
 		</if>
@@ -33,20 +41,32 @@
 		</if>
 	</select>
 	<select id="getNumber" resultType="java.lang.String">
-		select sum(a.iQuantity)as 'iQuantity'  from OM_MODetails a left join SO_SODetails b on a.isosid =b.isosid
+		select sum(isnull(a.iQuantity,0))as 'iQuantity'  from OM_MODetails a left join SO_SODetails b on a.isosid =b.isosid
 																   left join OM_MOMain c on a.moid=c.moid where 1=1
 		<if test="code!=null and ''!=code">
 			b.csocode=#{code}
 		</if>
 	</select>
 	<select id="getPrice" resultType="java.lang.String">
-		select (b.iProcessFee+b.iMaterialFee)/b.iQuantity as 'dj'  from (
-		select sum(b.iMaterialFee) as 'iMaterialFee',sum(b.iProcessFee) as 'iProcessFee',sum(b.iQuantity) as 'iQuantity',bc.csocode  from rdrecord01 a left join rdrecords01 b on a.id=b.id
-		left join OM_MOMain c on c.moid=a.ipurorderid
-		left join  OM_MODetails bc on c.moid=bc.moid
-		GROUP BY bc.csocode)  b where 1=1
+		select isnull(sum(a.count)/sum(b.iquantity),0) as 'price' from (
+		select sum((isnull(c.iQuantity,0)*isnull(b.iunitcost,0))+(isnull(c.iQuantity,0)*isnull(b.iprocesscost,0))) as 'count' ,a.cordercode as 'cordercode'     from rdrecord01 a left join rdrecords01 b on a.id=b.id
+		left join (select sum(b.iquantity)as 'iquantity',b.cbatch,b.iorderdid,cmpocode  from rdrecord11 a  left join rdrecords11 b on a.id=b.id
+		where   b.cbatch is not null GROUP BY b.iorderdid,cbatch,cmpocode)  c on b.iorderdid=c.iorderdid and a.cordercode=c.cmpocode AND c.cbatch=b.cbatch
+		GROUP BY a.cordercode) a
+		left join (select sum(isnull(b.iquantity,0)) as 'iquantity',a.ccode,b.csoordercode from OM_MOMain  a left join OM_MODetails b  on a.moid=b.moid
+		GROUP BY a.ccode,b.csoordercode) b on a.cordercode=b.ccode
+		where   a.count !='0'
 		<if test="code!=null and ''!=code">
-			b.csocode=#{code}
+		and	b.csoordercode=#{code}
 		</if>
+		GROUP BY b.csoordercode
 	</select>
+	<select id="getOrderCode" resultType="java.lang.String">
+		select distinct a.cpoid as 'cpoid' from PO_Pomain a left join PO_Podetails b on a.POID=b.POID
+		where a.cVenCode='T020001'
+		<if test="code!=null and ''!=code">
+			and b.csoordercode=#{code}
+		</if>
+	</select>
+
 </mapper>

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

@@ -31,6 +31,7 @@ public interface IFabricLossService extends IService<FabricLoss> {
 	//获取面料损耗数据
 	FabricLoss getFabricLossData(String code);
 
-
+	//面料损耗整体数据接口
+	Map<String,Object>getFabricLossDatas(String code);
 
 }

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

@@ -17,8 +17,12 @@ import org.jeecg.common.util.UUIDGenerator;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.base.service.BaseCommonService;
 import org.jeecg.modules.report.entity.FabricLoss;
+import org.jeecg.modules.report.entity.FabricOMOrder;
+import org.jeecg.modules.report.entity.FabricPoOrder;
 import org.jeecg.modules.report.mapper.FabricLossMapper;
 import org.jeecg.modules.report.service.IFabricLossService;
+import org.jeecg.modules.report.service.IFabricOmOrderService;
+import org.jeecg.modules.report.service.IFabricPoOrderService;
 import org.jeecg.modules.system.entity.*;
 import org.jeecg.modules.system.mapper.*;
 import org.jeecg.modules.system.model.SysUserSysDepartModel;
@@ -32,6 +36,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -50,6 +55,11 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 	@Autowired
 	private  FabricLossMapper fabricLossMapper;
 
+	@Autowired
+	private IFabricPoOrderService fabricPoOrderService;
+
+	@Autowired
+	private IFabricOmOrderService fabricOmOrderService;
 	/**
 	 * 面料损耗信息接口
 	 * @param code 计划号
@@ -60,17 +70,63 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 		if (oConvertUtils.isNotEmpty(code)){
 			FabricLoss fabricLoss = fabricLossMapper.getFabricLossData(code);
 			if (oConvertUtils.isNotEmpty(fabricLoss)){
-				//103排单数量
-				String number = fabricLossMapper.getNumber(code);
-				//制单人
-				List<String> makingPeople = fabricLossMapper.getMakingPeople(code);
-				//计划员
-				List<String> planner = fabricLossMapper.getPlanner(code);
-				//103单间成本
-				String price = fabricLossMapper.getPrice(code);
+				String orderCode = fabricLossMapper.getOrderCode(fabricLoss.getOrderCode());
+				if (oConvertUtils.isNotEmpty(orderCode)){
+					//103排单数量
+					String number = fabricLossMapper.getNumber(orderCode);
+					fabricLoss.setNumber(fabricLoss.getNumber()+number);
+					//制单人
+					List<String> makingPeople = fabricLossMapper.getMakingPeople(orderCode);
+					if (oConvertUtils.isNotEmpty(makingPeople)){
+						StringBuffer sb = new StringBuffer();
+						makingPeople.forEach(str->{
+							sb.append(str).append(",");
+						});
+						String keywordStr = sb.deleteCharAt(sb.length() - 1).toString();
+						fabricLoss.setMakingPeople(keywordStr);
+					}
+					//计划员
+					List<String> planner = fabricLossMapper.getPlanner(orderCode);
+					if (oConvertUtils.isNotEmpty(planner)){
+						StringBuffer sb = new StringBuffer();
+						makingPeople.forEach(str->{
+							sb.append(str).append(",");
+						});
+						String keywordStr = sb.deleteCharAt(sb.length() - 1).toString();
+						fabricLoss.setPlanner(keywordStr);
+					}
+					//103单间成本
+					String price = fabricLossMapper.getPrice(orderCode);
+					if(oConvertUtils.isNotEmpty(fabricLoss.getPrice())){
+						BigDecimal b=new BigDecimal(price);
+						b=b.add(new BigDecimal(fabricLoss.getPrice()));
+						b=b.divide(new BigDecimal("2"));
+						fabricLoss.setPrice(b.toString());
+						fabricLoss.setActualPrice(b.toString());
+					}else {
+						fabricLoss.setPrice(price);
+						fabricLoss.setActualPrice(price);
+					}
+
+
+
+				}
 
 			}
+			return  fabricLoss;
 		}
 		return null;
 	}
+
+	@Override
+	public Map<String, Object> getFabricLossDatas(String code) {
+		Map<String,Object>map=new HashMap<>();
+		if (oConvertUtils.isNotEmpty(code)){
+			List<FabricPoOrder> poOrderData = fabricPoOrderService.getPoOrderData(code);
+			List<FabricOMOrder> fabricOMOrderData = fabricOmOrderService.getFabricOMOrderData(code);
+			map.put("poOrder",poOrderData);
+			map.put("omOrder",fabricOMOrderData);
+		}
+		return map;
+	}
 }