Browse Source

染损报表

huxy 3 years ago
parent
commit
b644058458

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

@@ -41,14 +41,6 @@ public class DyeLossController extends JeecgController<DyeLoss, IDyeLossService>
     @Autowired
     private IDyeLossService dyeLossService;
 
-    //Result<IPage<DyeLoss>>
-    /*@AutoLog(value = "染损报表查询")
-    @ApiOperation(value="染损报表查询", notes="染损报表查询")
-    @RequestMapping(value = "/list",method = RequestMethod.GET)
-    public List<DyeLoss> list(DyeLossDto dyeLossDto){
-        return dyeLossService.select(dyeLossDto);
-    }*/
-
     @AutoLog(value = "染损报表查询")
     @ApiOperation(value="染损报表查询", notes="染损报表查询")
     @RequestMapping(value = "/list",method = RequestMethod.GET)
@@ -61,7 +53,8 @@ public class DyeLossController extends JeecgController<DyeLoss, IDyeLossService>
         }
         Result<IPage<DyeLoss>> result = new Result<IPage<DyeLoss>>();
         QueryWrapper<DyeLossDto> queryWrapper = new QueryWrapper<>();//初始化
-        queryWrapper.eq("c.cVCCode","0105");
+        queryWrapper.eq("c.cVCCode","0105");//确定为染厂
+        queryWrapper.eq("g.cRdBusType","委外发料");//选择为材料出库单
         if(dyeLossDto.getCode()!=null&& !dyeLossDto.getCode().trim().equals("") &&StringUtils.isNotBlank(dyeLossDto.getCode())){ //code;//订单号
             queryWrapper.eq("a.cCode",dyeLossDto.getCode());
         }
@@ -85,13 +78,6 @@ public class DyeLossController extends JeecgController<DyeLoss, IDyeLossService>
         return result;
     }
 
-    /*@AutoLog(value = "染损报表数据合计")
-    @ApiOperation(value="染损报表数据合计", notes="染损报表数据合计")
-    @RequestMapping(value = "/selectSum",method = RequestMethod.GET)
-    public Result<?> selectSum(){
-        Result.ok(dyeLossService.selectSum());
-        return Result.ok("查询成功!");
-    }*/
 
     @AutoLog(value = "按供应商名称按物料分组展现每个物料的染损")
     @ApiOperation(value="按供应商名称按物料分组展现每个物料的染损", notes="按供应商名称按物料分组展现每个物料的染损")

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

@@ -29,4 +29,6 @@ public class DyeLoss {
     private BigDecimal iMSQuantity;//核销数量
     @Excel(name = "染损", width = 15,suffix = "%"/*,numFormat="##.00"*/)
     private BigDecimal dyeLossRate;//染损
+
+    private String cInvNameColor;//物料名称和颜色
 }

+ 1 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/scas/mapper/DyeLossMapper.java

@@ -16,15 +16,12 @@ import java.util.List;
  * @Version: V1.0
  */
 public interface DyeLossMapper extends BaseMapper<DyeLoss> {
-    List<DyeLoss> querySelect(DyeLossDto dyeLossDto);
 
-    List<DyeLoss> selectSum();
+    IPage<DyeLoss> selectPage(IPage<DyeLoss> page, @Param("ew") QueryWrapper<DyeLossDto> queryWrapper);
 
     List<DyeLoss> selectVendor(String name);
 
     List<DyeLoss> selectCInvName();
 
     List<DyeLoss> excel();
-
-    IPage<DyeLoss> selectPage(IPage<DyeLoss> page, @Param("ew") QueryWrapper<DyeLossDto> queryWrapper);
 }

+ 41 - 131
jeecg-boot-module-system/src/main/java/org/jeecg/modules/scas/mapper/xml/DyeLossMapper.xml

@@ -1,136 +1,58 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.scas.mapper.DyeLossMapper">
-    <select id="querySelect" resultType="org.jeecg.modules.scas.entity.DyeLoss" parameterType="org.jeecg.modules.scas.dto.DyeLossDto">
-        select * from
-        (select	ROW_NUMBER() OVER(ORDER BY OM_MOMain.moid) index1,
-        Inventory.cinvcode,--物料编码
-        Inventory.cInvName,--物料名称
-        OM_MODetails.cfree1 color,--颜色
-        cVenName cVenName,--供应商
-        OM_MOMain.cCode cCode,--订单号
-        OM_MODetails.iQuantity,--订单数量
-
-        iReceivedQTY iQuantity2,--采购入库数
-        --(select sum(iQuantity) from rdrecords01 where OM_MODetails.MODetailsID=rdrecords01.iOMoDID) iQuantity2,--采购入库数
-
-		iMaterialSendQty iQuantity3,--材料出库数
-		--(select sum(iQuantity) from rdrecords11 where OM_MODetails.MODetailsID=rdrecords11.iOMoDID) iQuantity3,--材料出库数
-
-        (select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch
-				left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-				where OM_MODetails.MODetailsID=OM_MatSettleVouch.modetailsid) iMSQuantity,--核销数量
-
-		(1-iReceivedQTY/NULLIF((select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch
-				left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-				where OM_MODetails.MODetailsID=OM_MatSettleVouch.modetailsid),0))*100 dyeLossRate--染损
-
-        from OM_MOMain
-        left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid
-        left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode
-        left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode
-        --left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode
-        --left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-        <where>
-            <if  test="true">
-                and  Vendor.cVCCode='0105'--染厂
-            </if>
-            <if  test="code!=null">
-                and cCode=#{code} -- 订单号
-            </if>
-            <if  test="venName!=null">
-                and cVenName=#{venName} -- 供应商名称
-            </if>
-            <if  test="orderType!=null">
-                and iOrderType=#{orderType} --订单类型
-            </if>
-            <if  test="planLotNumber!=null">
-                and cPlanLotNumber=#{planLotNumber} --计划单号
-            </if>
-            <if  test="isosid!=null">
-                and isosid=#{isosid} --销售订单号
-            </if>
-        </where>
-        ) p	--计划时间
-        where p.index1&gt;=${pageNo*pageSize-pageSize} and p.index1&lt;=${pageSize*pageNo}
-    </select>
 
     <select id="selectPage" resultType="org.jeecg.modules.scas.entity.DyeLoss" >
-    select * from(
-        select
+     select
         d.cinvcode,--物料编码
         d.cInvName,--物料名称
         b.cfree1 color,--颜色
         cVenName cVenName,--供应商
         a.cCode cCode,--订单号
-        b.iQuantity,--订单数量
-
-        iReceivedQTY iQuantity2,--采购入库数
-
-        iMaterialSendQty iQuantity3,--材料出库数
-
-        (select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch
-        left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-        where b.MODetailsID=OM_MatSettleVouch.modetailsid) iMSQuantity,--核销数量
-
-        (1-iReceivedQTY/NULLIF((select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch
-        left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-        where b.MODetailsID=OM_MatSettleVouch.modetailsid),0))*100 dyeLossRate--染损
-
+        b.iQuantity iQuantity,--订单数量
+        ISNULL(iReceivedQTY, 0 ) iQuantity2,--采购入库数
+        ISNULL(iMaterialSendQty, 0 ) iQuantity3,--材料出库数
+        ISNULL(g.iMSQuantity, 0 ) iMSQuantity,--核销数量
+        ISNULL((1-iReceivedQTY/NULLIF(g.iMSQuantity,0))*100,0) dyeLossRate--染损
         from OM_MOMain a
         left join OM_MODetails b on b.moid=a.moid
         left join Vendor c on c.cVenCode=a.cVenCode
         left join Inventory d on b.cInvCode=d.cInvCode
         left join SO_SODetails e on e.iSOsID =b.iSOsID
-         ${ew.customSqlSegment})p--染厂
+        left join OM_MatSettleVouch f on  b.MODetailsID =f.MODetailsID
+        left join OM_MatSettleVouchs g on g.msid=f.msid
+       ${ew.customSqlSegment}
     </select>
 
-    <select  id="selectSum" resultType="org.jeecg.modules.scas.entity.DyeLoss">
-        --染损报表合计
-        select  sum(OM_MODetails.iQuantity) iQuantity2,
-				sum(iReceivedQTY) iQuantity3,--采购入库数
-				sum(iMaterialSendQty) iMSQuantity,--材料出库数
-				sum(iMSQuantity) dyeLossRate--核销数量
-        from OM_MOMain
-        left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid
-        left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode
-        left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode
-        left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode
-        left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-        where Vendor.cVCCode='0105'
-    </select>
     
     <select id="selectVendor"  resultType="org.jeecg.modules.scas.entity.DyeLoss" parameterType="java.lang.String">--选择供应商按物料分组展现每个物料的染损
         select
             cInvName,--物料名称
-            iQuantity2,--入库数量
-            iMSQuantity,--核销数量
-            (1-(iQuantity2/iMSQuantity)) dyeLossRate--染损数量
+			color,--颜色
+			cInvName+' '+color cInvNameColor,--物料和颜色
+            --(iMSQuantity/iQuantity2)*100 dyeLossRate--合格率
+            (1-(iQuantity2/NULLIF(iMSQuantity,0)))*100 dyeLossRate--染损率
          from
         (select Inventory.cInvName,--物料名称
+				OM_MODetails.cfree1 color,--颜色
             sum(iReceivedQTY) iQuantity2,--入库数量
-            sum(iMSQuantity) iMSQuantity,--核销数量
-            sum(1-(iReceivedQTY/iMSQuantity)) dyeLossRate--染损
+            sum(iMSQuantity) iMSQuantity--核销数量
         from OM_MOMain
         left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid
         left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode
         left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode
-	    left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode
+				left join OM_MatSettleVouch on  OM_MODetails.MODetailsID=OM_MatSettleVouch.MODetailsID--绑定委外订单子表
         left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-        where Vendor.cVCCode='0105'
+        where Vendor.cVCCode='0105' and  OM_MatSettleVouchs.cRdBusType='委外发料'
 				AND cVenName=#{value}
-				GROUP BY Inventory.cInvName)p
-
-
-
+				GROUP BY Inventory.cInvName,OM_MODetails.cfree1)p
     </select>
 
 
     <select id="selectCInvName"  resultType="org.jeecg.modules.scas.entity.DyeLoss">--按供应商分组展现每个供应商的染损
-		select 	cVenName,--供应商名称
-				iQuantity2,--入库数量
-				iMSQuantity,--核销数量
-				(1-(iQuantity2/iMSQuantity)) dyeLossRate
+
+        select 	cVenName,--供应商名称
+			    (1-(iQuantity2/NULLIF(iMSQuantity,0)))*100 dyeLossRate--染损
         from (
         select
             cVenName,--供应商名称
@@ -141,45 +63,33 @@
             left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid
             left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode
             left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode
-            left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode
+            left join OM_MatSettleVouch on  OM_MODetails.MODetailsID=OM_MatSettleVouch.MODetailsID
             left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-        where Vendor.cVCCode='0105'
+        where Vendor.cVCCode='0105' and  OM_MatSettleVouchs.cRdBusType='委外发料'
         GROUP BY cVenName) p
     </select>
 
 
     <select id="excel" resultType="org.jeecg.modules.scas.entity.DyeLoss">
-        select * from
-        (select	ROW_NUMBER() OVER(ORDER BY OM_MOMain.moid) index1,
-        Inventory.cinvcode,--物料编码
-        Inventory.cInvName,--物料名称
-        OM_MODetails.cfree1 color,--颜色
+    select
+        d.cinvcode,--物料编码
+        d.cInvName,--物料名称
+        b.cfree1 color,--颜色
         cVenName cVenName,--供应商
-        OM_MOMain.cCode cCode,--订单号
-        OM_MODetails.iQuantity,--订单数量
-
-        iReceivedQTY iQuantity2,--采购入库数
-        --(select sum(iQuantity) from rdrecords01 where OM_MODetails.MODetailsID=rdrecords01.iOMoDID) iQuantity2,--采购入库数
-
-		iMaterialSendQty iQuantity3,--材料出库数
-		--(select sum(iQuantity) from rdrecords11 where OM_MODetails.MODetailsID=rdrecords11.iOMoDID) iQuantity3,--材料出库数
-
-        (select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch
-				left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-				where OM_MODetails.MODetailsID=OM_MatSettleVouch.modetailsid) iMSQuantity,--核销数量
-
-		(1-iReceivedQTY/NULLIF((select sum(OM_MatSettleVouchs.iMSQuantity) from OM_MatSettleVouch
-				left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-				where OM_MODetails.MODetailsID=OM_MatSettleVouch.modetailsid),0))*100 dyeLossRate--染损
-
-        from OM_MOMain
-        left join OM_MODetails on OM_MODetails.moid=OM_MOMain.moid
-        left join Vendor on Vendor.cVenCode=OM_MOMain.cVenCode
-        left join Inventory on OM_MODetails.cInvCode=Inventory.cInvCode
-        --left join OM_MatSettleVouch on  OM_MOMain.cCode=OM_MatSettleVouch.cMOCode
-        --left join OM_MatSettleVouchs on OM_MatSettleVouchs.msid=OM_MatSettleVouch.msid
-        where Vendor.cVCCode='0105'
-        ) p	--计划时间
+        a.cCode cCode,--订单号
+        b.iQuantity iQuantity,--订单数量
+        ISNULL(iReceivedQTY, 0 ) iQuantity2,--采购入库数
+        ISNULL(iMaterialSendQty, 0 ) iQuantity3,--材料出库数
+        ISNULL(g.iMSQuantity, 0 ) iMSQuantity,--核销数量
+        ISNULL((1-iReceivedQTY/NULLIF(g.iMSQuantity,0))*100,0) dyeLossRate--染损
+        from OM_MOMain a
+        left join OM_MODetails b on b.moid=a.moid
+        left join Vendor c on c.cVenCode=a.cVenCode
+        left join Inventory d on b.cInvCode=d.cInvCode
+        left join SO_SODetails e on e.iSOsID =b.iSOsID
+        left join OM_MatSettleVouch f on  b.MODetailsID =f.MODetailsID
+        left join OM_MatSettleVouchs g on g.msid=f.msid
+        where c.cVCCode='0105' and  g.cRdBusType='委外发料'
     </select>
 
 

+ 1 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/scas/service/IDyeLossService.java

@@ -12,9 +12,7 @@ import java.util.List;
 
 public interface IDyeLossService extends IService<DyeLoss> {
 
-    List<DyeLoss> select(DyeLossDto dyeLossDto);
-
-    List<DyeLoss> selectSum();
+    IPage<DyeLoss> selectPage(IPage<DyeLoss> page,QueryWrapper<DyeLossDto> queryWrapper);
 
     List<DyeLoss> selectVendor(String name);
 
@@ -22,5 +20,4 @@ public interface IDyeLossService extends IService<DyeLoss> {
 
     List<DyeLoss> excel();
 
-    IPage<DyeLoss> selectPage(IPage<DyeLoss> page,QueryWrapper<DyeLossDto> queryWrapper);
 }

+ 2 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/scas/service/impl/DyeLossServiceImpl.java

@@ -21,15 +21,9 @@ public class DyeLossServiceImpl extends ServiceImpl<DyeLossMapper, DyeLoss> impl
     @Autowired
     DyeLossMapper dyeLossMapper;
 
-
     @DS("multi-one")
-    public List<DyeLoss> select(DyeLossDto dyeLossDto) {
-        return dyeLossMapper.querySelect(dyeLossDto);
-    }
-
-    @DS("multi-one")
-    public List<DyeLoss> selectSum() {
-        return dyeLossMapper.selectSum();
+    public IPage<DyeLoss> selectPage(IPage<DyeLoss> page, QueryWrapper<DyeLossDto> queryWrapper) {
+        return dyeLossMapper.selectPage(page,queryWrapper);
     }
 
     @DS("multi-one")
@@ -47,8 +41,4 @@ public class DyeLossServiceImpl extends ServiceImpl<DyeLossMapper, DyeLoss> impl
         return dyeLossMapper.excel();
     }
 
-    @DS("multi-one")
-    public IPage<DyeLoss> selectPage(IPage<DyeLoss> page, QueryWrapper<DyeLossDto> queryWrapper) {
-        return dyeLossMapper.selectPage(page,queryWrapper);
-    }
 }