Bladeren bron

计划统计单,成本分配

zengtx 2 jaren geleden
bovenliggende
commit
7c680a1154

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

@@ -91,6 +91,7 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 
         JSONObject costJson = JSONObject.parseObject(JSON.toJSONString(json));
         SyCostJson cost = new SyCostJson();
+        cost.setStatus("保存");
         cost.setPlanNum(plannum);
         cost.setCostInfo(costJson);
         int i = syCostJsonMapper.insert(cost);

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

@@ -89,31 +89,31 @@
         ) t
         where PATINDEX('%[吖-咗]%', planNo)=0 and PATINDEX('%.%', planNo)=0 and PATINDEX('%/%', planNo)=0
         <if test="e.planNo !=null and e.planNo !=''">
-            and planNo like CONCAT(#{e.planNo},'%')
+            and t.planNo like CONCAT(#{e.planNo},'%')
         </if>
         <if test="e.dverifyDateB !=null and e.dverifyDateB !='' and e.dverifyDateE !=null and e.dverifyDateE !=''">
-            and dverifyDate between #{e.dverifyDateB} and #{e.dverifyDateE}
+            and t.dverifyDate between #{e.dverifyDateB} and #{e.dverifyDateE}
         </if>
         <if test="e.department !=null and e.department !=''">
-            and department like CONCAT(#{e.department},'%')
+            and t.department like CONCAT(#{e.department},'%')
         </if>
         <if test="e.salesman !=null and e.salesman !=''">
-            and salesman like CONCAT(#{e.salesman},'%')
+            and t.salesman like CONCAT(#{e.salesman},'%')
         </if>
         <if test="list != null">
-            and planNo in
+            and t.planNo in
             <foreach open="(" close=")" separator="," collection="list" item="item">
                 #{item}
             </foreach>
         </if>
         <if test="planlist.size!=0">
-            and planNo not in
+            and t.planNo not in
             <foreach open="(" close=")" separator="," collection="planlist" item="item">
                 #{item}
             </foreach>
         </if>
         GROUP BY t.planNo, t.dverifyDate
-        )
+        ) AND min(dverifyDate) between #{e.dverifyDateB} and #{e.dverifyDateE} ORDER BY min(dverifyDate)
 
 
     </select>
@@ -121,23 +121,65 @@
 
     <select id="querylistCount" resultType="java.lang.Integer">
 
-select count(*) from(
-        select planNo,min(dverifyDate) as dverifyDate,min(department) as department,min(salesman) as salesman,min(maker) as maker from (
+        select count(1) from(
+        select planNo from (
+        select case when PATINDEX('%备%', t.planNo) !=0 then left(t.planNo,6) else t.planNo end as
+        planNo,t.salesman,t.maker,t.department,t.dverifyDate from (
 
+        select LEFT(cCode,CHARINDEX('-',cCode)-1) as planNo,dverifydate as dverifyDate,de.cDepName as department,
+        pe.cPersonName as salesman,cMaker as maker from UFDATA_103_2021.dbo.OM_MOMain s
+        JOIN UFDATA_103_2021.dbo.Department de ON s.cDepCode = de.cDepCode
+        JOIN UFDATA_103_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
+        where cCode like 'sy%' and CHARINDEX('-',cCode)>0
 
-        select  case when PATINDEX('%备%', t.planNo) !=0 then left(t.planNo,6) else t.planNo end as planNo,t.salesman,t.maker,t.department,t.dverifyDate from (
+        union all
+        select LEFT(cPOID,CHARINDEX('-',cPOID)-1) as planNo,cAuditDate as dverifyDate,de.cDepName as department,
+        pe.cPersonName as salesman,cMaker as maker from UFDATA_103_2021.dbo.PO_Pomain s
+        JOIN UFDATA_103_2021.dbo.Department de ON s.cDepCode = de.cDepCode
+        JOIN UFDATA_103_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
+        where cPOID like 'sy%' and CHARINDEX('-',cPOID)>0
+
+        union all
+
+        select LEFT(cCode,CHARINDEX('-',cCode)-1) as planNo,dverifydate as dverifyDate,de.cDepName as department,
+        pe.cPersonName as salesman,cMaker as maker from UFDATA_101_2021.dbo.OM_MOMain s
+        JOIN UFDATA_101_2021.dbo.Department de ON s.cDepCode = de.cDepCode
+        JOIN UFDATA_101_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
+        where cCode like 'sy%' and CHARINDEX('-',cCode)>0
+
+        union all
+        select LEFT(cPOID,CHARINDEX('-',cPOID)-1) as planNo,cAuditDate as dverifyDate,de.cDepName as department,
+        pe.cPersonName as salesman,cMaker as maker from UFDATA_101_2021.dbo.PO_Pomain s
+        JOIN UFDATA_101_2021.dbo.Department de ON s.cDepCode = de.cDepCode
+        JOIN UFDATA_101_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
+        where cPOID like 'sy%' and CHARINDEX('-',cPOID)>0
+
+        union all
+        select LEFT(cPOID,CHARINDEX('-',cPOID)-1) as planNo,cAuditDate as dverifyDate,de.cDepName as department,
+        pe.cPersonName as salesman,cMaker as maker from UFDATA_102_2021.dbo.PO_Pomain s
+        JOIN UFDATA_102_2021.dbo.Department de ON s.cDepCode = de.cDepCode
+        JOIN UFDATA_102_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
+        where cPOID like 'sy%' and CHARINDEX('-',cPOID)>0
+
+        ) t
+        where PATINDEX('%[吖-咗]%', planNo)=0 and PATINDEX('%.%', planNo)=0 and PATINDEX('%/%', planNo)=0
+
+        ) as views
+        group by views.planNo HAVING planNo in(
+
+        select case when PATINDEX('%备%', t.planNo) !=0 then left(t.planNo,6) else t.planNo end as planNo from (
 
         select LEFT(cCode,CHARINDEX('-',cCode)-1) as planNo,dverifydate as dverifyDate,de.cDepName as department,
         pe.cPersonName as salesman,cMaker as maker from UFDATA_103_2021.dbo.OM_MOMain s
         JOIN UFDATA_103_2021.dbo.Department de ON s.cDepCode = de.cDepCode
-        JOIN UFDATA_103_2021.dbo.Person  pe ON s.cPersonCode = pe.cPersonCode
+        JOIN UFDATA_103_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
         where cCode like 'sy%' and CHARINDEX('-',cCode)>0
 
         union all
         select LEFT(cPOID,CHARINDEX('-',cPOID)-1) as planNo,cAuditDate as dverifyDate,de.cDepName as department,
         pe.cPersonName as salesman,cMaker as maker from UFDATA_103_2021.dbo.PO_Pomain s
         JOIN UFDATA_103_2021.dbo.Department de ON s.cDepCode = de.cDepCode
-        JOIN UFDATA_103_2021.dbo.Person  pe ON s.cPersonCode = pe.cPersonCode
+        JOIN UFDATA_103_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
         where cPOID like 'sy%' and CHARINDEX('-',cPOID)>0
 
         union all
@@ -145,51 +187,52 @@ select count(*) from(
         select LEFT(cCode,CHARINDEX('-',cCode)-1) as planNo,dverifydate as dverifyDate,de.cDepName as department,
         pe.cPersonName as salesman,cMaker as maker from UFDATA_101_2021.dbo.OM_MOMain s
         JOIN UFDATA_101_2021.dbo.Department de ON s.cDepCode = de.cDepCode
-        JOIN UFDATA_101_2021.dbo.Person  pe ON s.cPersonCode = pe.cPersonCode
+        JOIN UFDATA_101_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
         where cCode like 'sy%' and CHARINDEX('-',cCode)>0
 
         union all
         select LEFT(cPOID,CHARINDEX('-',cPOID)-1) as planNo,cAuditDate as dverifyDate,de.cDepName as department,
         pe.cPersonName as salesman,cMaker as maker from UFDATA_101_2021.dbo.PO_Pomain s
         JOIN UFDATA_101_2021.dbo.Department de ON s.cDepCode = de.cDepCode
-        JOIN UFDATA_101_2021.dbo.Person  pe ON s.cPersonCode = pe.cPersonCode
+        JOIN UFDATA_101_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
         where cPOID like 'sy%' and CHARINDEX('-',cPOID)>0
 
         union all
         select LEFT(cPOID,CHARINDEX('-',cPOID)-1) as planNo,cAuditDate as dverifyDate,de.cDepName as department,
         pe.cPersonName as salesman,cMaker as maker from UFDATA_102_2021.dbo.PO_Pomain s
         JOIN UFDATA_102_2021.dbo.Department de ON s.cDepCode = de.cDepCode
-        JOIN UFDATA_102_2021.dbo.Person  pe ON s.cPersonCode = pe.cPersonCode
+        JOIN UFDATA_102_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
         where cPOID like 'sy%' and CHARINDEX('-',cPOID)>0
 
         ) t
-        ) as views
         where PATINDEX('%[吖-咗]%', planNo)=0 and PATINDEX('%.%', planNo)=0 and PATINDEX('%/%', planNo)=0
         <if test="e.planNo !=null and e.planNo !=''">
-            and planNo like CONCAT(#{e.planNo},'%')
+            and t.planNo like CONCAT(#{e.planNo},'%')
         </if>
         <if test="e.dverifyDateB !=null and e.dverifyDateB !='' and e.dverifyDateE !=null and e.dverifyDateE !=''">
-            and dverifyDate between #{e.dverifyDateB} and #{e.dverifyDateE}
+            and t.dverifyDate between #{e.dverifyDateB} and #{e.dverifyDateE}
         </if>
         <if test="e.department !=null and e.department !=''">
-            and department like CONCAT(#{e.department},'%')
+            and t.department like CONCAT(#{e.department},'%')
         </if>
         <if test="e.salesman !=null and e.salesman !=''">
-            and salesman like CONCAT(#{e.salesman},'%')
+            and t.salesman like CONCAT(#{e.salesman},'%')
         </if>
         <if test="list != null">
-            and planNo in
+            and t.planNo in
             <foreach open="(" close=")" separator="," collection="list" item="item">
                 #{item}
             </foreach>
         </if>
         <if test="planlist.size!=0">
-            and planNo not in
+            and t.planNo not in
             <foreach open="(" close=")" separator="," collection="planlist" item="item">
                 #{item}
             </foreach>
         </if>
-        group by views.planNo) t1
+        GROUP BY t.planNo, t.dverifyDate
+        ) AND min(dverifyDate) between #{e.dverifyDateB} and #{e.dverifyDateE}
+        ) as dd
 
 
     </select>