Browse Source

订单项目统计列表修改

anderx 1 year ago
parent
commit
544cad1974

+ 1 - 159
src/main/java/com/goafanti/common/mapper/TOrderTaskMapper.xml

@@ -2511,163 +2511,5 @@
     where manager_id = #{aid}
   </update>
 
-  <select id="selectStatisticsOrderProject" resultType="com.goafanti.order.bo.OutOrderProject">
-    SELECT a.order_no as orderNo, a.order_type orderType,a.sales_type as salesType,b.service_type AS serviceType,
-           a.liquidation_status as liquidationStatus,b2.big_customer as bigCustomer, b.dun_node_content as dunNodeContent,
-           b.project_type as projectType, a.total_amount as totalAmount,a.approval ,a.sign_time as signTime,
-           a.create_time as createTime,b.buyer_name as buyerName,a.contract_no as contractNo, d2.cname htlx,
-           b.order_receivables orderReceivables,a.refund_amount refundAmount,a.settlement_amount as settlementAmount,
-           b.invoice_amount as invicueAmount, b.cost_amount as costAmount,b.payment_amount as paymentAmount,
-           b.finance_name as financeName,b.salesman_name as salesmanName, e.commodity_name as commodityName,ttm.service_year as serviceYear,
-           ttm.service_life as serviceLife,ttm.year_sum as yearSum,e.task_distribution_time as taskDistributionTime ,e.commodity_quantity as commodityQuantity,
-           e3.cost_amount as costAmount,e.project_status as  projectStatus,e.task_start_time as taskStartTime,e.task_end_time as taskEndTime,
-           e.receiver_name as receiverName ,'技术组' jsz,t1.cb restatement,a.order_status orderStatus,e.satisfaction_degree satisfactionDegree,
-      e.task_comment taskComment,'核算比例' hsbl,a.order_status orderStatus,t1.counts changeType,t1.tdtk refundType,a3.name depName,a4.name as  province
-    from t_order_new a left join t_order_mid b on a.order_no =b.order_no
-        left join admin a2 on a.salesman_id=a2.id left join department a3 on a2.department_id=a3.id
-        left join district_glossory a4 on a3.province=a4.id left join user_mid b2 on a.buyer_id=b2.uid
-        left join t_order_task c on a.order_no =c.order_no and c.main =1
-        left join business_project d on c.commodity_id =d.id left join business_category d2 on d.cid =d2.id
-        left join t_order_task e on a.order_no =e.order_no and e.split_status in (0,2)
-        left join admin e2 on e.task_receiver=e2.id left join t_task_mid e3 on e.id=e3.tid
-        left join t_task_member ttm on e.id =ttm.tid
-        left join (SELECT order_no ,count(*)counts,sum(if(`type`=0,1,0))tdtk,sum(if(`type`=4,1,0))cb
-            from new_order_change group by order_no ) t1 on a.order_no =t1.order_no
-    <if test="dunType !=null">
-      left join new_order_dun nod  on e.id=nod.tid
-    </if>
-    where a.process_status >6 and a.delete_sign in (0,2)
-    <if test="orderNo !=null">
-      and a.order_no like CONCAT('%',#{orderNo},'%')
-    </if>
-    <if test="contractNo !=null">
-      and a.contract_no like CONCAT('%',#{contractNo},'%')
-    </if>
-    <if test="userName !=null">
-      and b.buyer_name like CONCAT('%',#{userName},'%')
-    </if>
-    <if test="businessCategory !=null">
-      and d2.id = #{businessCategory}
-    </if>
-    <if test="projectName !=null">
-      and e.commodity_name like CONCAT('%',#{projectName},'%')
-    </if>
-    <if test="orderAmountType==1">
-      and a.total_amount &lt; 10
-    </if>
-    <if test="orderAmountType==2">
-      and a.total_amount &gt;= 10 and a.total_amount &lt; 20
-    </if>
-    <if test="orderAmountType==3">
-      and a.total_amount &gt;= 20 and a.total_amount &lt; 30
-    </if>
-    <if test="orderAmountType==4">
-      and a.total_amount &gt;= 30 and a.total_amount &lt; 40
-    </if>
-    <if test="orderAmountType==5">
-      and a.total_amount &gt;= 40
-    </if>
-    <if test="depId !=null">
-      and a3.id = #{depId}
-    </if>
-    <if test="liabilitiesDepId !=null">
-      and e2.department_id = #{liabilitiesDepId}
-    </if>
-    <if test="declarationBatch !=null">
-      and e.declaration_batch = #{declarationBatch}
-    </if>
-    <if test="projectAmountType==1">
-      and e.commodity_price &lt; 1
-    </if>
-    <if test="projectAmountType==2">
-      and e.commodity_price &gt;= 1 and e.commodity_price &lt; 5
-    </if>
-    <if test="projectAmountType==3">
-      and e.commodity_price &gt;= 5 and e.commodity_price &lt; 10
-    </if>
-    <if test="projectAmountType==4">
-      and e.commodity_price &gt;= 10 and e.commodity_price &lt; 20
-    </if>
-    <if test="projectAmountType==5">
-      and e.commodity_price &gt;= 20
-    </if>
-    <if test="projectStatus !=null">
-      and e.project_status = #{projectStatus}
-    </if>
-    <if test="satisfactionDegree !=null">
-      and e.satisfaction_degree = #{satisfactionDegree}
-    </if>
-    <if test="startDate !=null and endDate !=null">
-      and a.create_time BETWEEN #{startDate} and #{endDate}
-    </if>
-    <if test="signStartDate !=null and signEndDate !=null">
-      and a.sign_time BETWEEN #{signStartDate} and #{signEndDate}
-    </if>
-    <if test="projectStartDate !=null and projectEndDate !=null">
-      and e.task_distribution_time BETWEEN #{projectStartDate} and #{projectEndDate}
-    </if>
-    <if test="salesType !=null">
-      and a.sales_type = #{salesType}
-    </if>
-    <if test="serviceType !=null">
-      and find_in_set(b.service_type,#{serviceType})
-    </if>
-    <if test="liquidationStatus !=null">
-      and a.liquidation_status = #{liquidationStatus}
-    </if>
-    <if test="dunType !=null">
-      and nod.dun_type = #{dunType}
-    </if>
-    <if test="province !=null">
-      and a4.id = #{province}
-    </if>
-    <if test="salesmanId !=null">
-      and a.salesman_id = #{salesmanId}
-    </if>
-    <if test="financeId !=null">
-      and a.finance_id = #{financeId}
-    </if>
-    <if test="techId !=null">
-      and e.task_receiver =#{techId}
-    </if>
-    <if test="approval ==0">
-      and a.approval = 0
-    </if>
-    <if test="approval ==1">
-      and a.approval > 0
-    </if>
-    <if test="projectType !=null">
-      and b.project_type = #{projectType}
-    </if>
-    <if test="bigCustomer !=null">
-      and b2.big_customer = #{bigCustomer}
-    </if>
-    <if test="restatement ==0">
-     and t1.cb = 0
-    </if>
-    <if test="restatement ==1">
-      and t1.cb > 0
-    </if>
-    <if test="changeType ==0">
-      and t1.counts is null
-    </if>
-    <if test="changeType ==1">
-      and t1.counts >0
-    </if>
-    <if test="refundType ==0">
-      and (t1.tdtk = 0 or t1.tdtk is null)
-    </if>
-    <if test="refundType ==1">
-      and t1.tdtk >0
-    </if>
-    <if test="orderType ==0">
-      and a.order_type  in(0,2)
-    </if>
-    <if test="orderType ==1">
-      and a.order_type  in(1)
-    </if>
-    <if test="projectCompleteStartTime !=null and projectCompleteEndTime !=null">
-      and e.task_end_time BETWEEN #{projectCompleteStartTime} and #{projectCompleteEndTime}
-    </if>
-  </select>
+
 </mapper>

+ 179 - 0
src/main/java/com/goafanti/common/mapper/UserMidMapper.xml

@@ -717,4 +717,183 @@
       </if>
     </if>
   </select>
+  <select id="selectStatisticsOrderProjectList" resultType="com.goafanti.order.bo.OutOrderProject">
+    SELECT a.order_no as orderNo, a.order_type orderType,a.sales_type as salesType,b.service_type AS serviceType,
+    a.liquidation_status as liquidationStatus,b2.big_customer as bigCustomer, b.dun_node_content as dunNodeContent,
+    b.project_type as projectType, a.total_amount as totalAmount,a.approval ,a.sign_time as signTime,
+    a.create_time as createTime,b.buyer_name as buyerName,a.contract_no as contractNo, d2.cname htlx,
+    b.order_receivables orderReceivables,a.refund_amount refundAmount,a.settlement_amount as settlementAmount,
+    b.invoice_amount as invicueAmount, b.cost_amount as costAmount,b.payment_amount as paymentAmount,
+    b.finance_name as financeName,b.salesman_name as salesmanName, e.commodity_name as commodityName,ttm.service_year as serviceYear,
+    ttm.service_life as serviceLife,ttm.year_sum as yearSum,e.task_distribution_time as taskDistributionTime ,e.commodity_quantity as commodityQuantity,
+    e3.cost_amount as costAmount,e.project_status as  projectStatus,e.task_start_time as taskStartTime,e.task_end_time as taskEndTime,
+    e.receiver_name as receiverName ,'技术组' jsz,t1.cb restatement,a.order_status orderStatus,e.satisfaction_degree satisfactionDegree,
+    e.task_comment taskComment,'核算比例' hsbl,a.order_status orderStatus,t1.counts changeType,t1.tdtk refundType,a3.name depName,a4.name as  province
+    from t_order_new a left join t_order_mid b on a.order_no =b.order_no
+    left join admin a2 on a.salesman_id=a2.id left join department a3 on a2.department_id=a3.id
+    left join district_glossory a4 on a3.province=a4.id left join user_mid b2 on a.buyer_id=b2.uid
+    left join t_order_task c on a.order_no =c.order_no and c.main =1
+    left join business_project d on c.commodity_id =d.id left join business_category d2 on d.cid =d2.id
+    left join t_order_task e on a.order_no =e.order_no and e.split_status in (0,2)
+    left join admin e2 on e.task_receiver=e2.id left join t_task_mid e3 on e.id=e3.tid
+    left join t_task_member ttm on e.id =ttm.tid
+    left join (SELECT order_no ,count(*)counts,sum(if(`type`=0,1,0))tdtk,sum(if(`type`=4,1,0))cb
+    from new_order_change group by order_no ) t1 on a.order_no =t1.order_no
+       <include refid="selectStatisticsOrderProjectSql"/>
+    <if test="page_sql!=null">
+      ${page_sql}
+    </if>
+  </select>
+  <sql id="selectStatisticsOrderProjectSql">
+    <if test="dunType !=null">
+      left join new_order_dun nod  on e.id=nod.tid
+    </if>
+    where a.process_status >6 and a.delete_sign in (0,2)
+    <if test="orderNo !=null">
+      and a.order_no like CONCAT('%',#{orderNo},'%')
+    </if>
+    <if test="contractNo !=null">
+      and a.contract_no like CONCAT('%',#{contractNo},'%')
+    </if>
+    <if test="userName !=null">
+      and b.buyer_name like CONCAT('%',#{userName},'%')
+    </if>
+    <if test="businessCategory !=null">
+      and d2.id = #{businessCategory}
+    </if>
+    <if test="projectName !=null">
+      and e.commodity_name like CONCAT('%',#{projectName},'%')
+    </if>
+    <if test="orderAmountType==1">
+      and a.total_amount &lt; 10
+    </if>
+    <if test="orderAmountType==2">
+      and a.total_amount &gt;= 10 and a.total_amount &lt; 20
+    </if>
+    <if test="orderAmountType==3">
+      and a.total_amount &gt;= 20 and a.total_amount &lt; 30
+    </if>
+    <if test="orderAmountType==4">
+      and a.total_amount &gt;= 30 and a.total_amount &lt; 40
+    </if>
+    <if test="orderAmountType==5">
+      and a.total_amount &gt;= 40
+    </if>
+    <if test="depId !=null">
+      and a3.id = #{depId}
+    </if>
+    <if test="liabilitiesDepId !=null">
+      and e2.department_id = #{liabilitiesDepId}
+    </if>
+    <if test="declarationBatch !=null">
+      and e.declaration_batch = #{declarationBatch}
+    </if>
+    <if test="projectAmountType==1">
+      and e.commodity_price &lt; 1
+    </if>
+    <if test="projectAmountType==2">
+      and e.commodity_price &gt;= 1 and e.commodity_price &lt; 5
+    </if>
+    <if test="projectAmountType==3">
+      and e.commodity_price &gt;= 5 and e.commodity_price &lt; 10
+    </if>
+    <if test="projectAmountType==4">
+      and e.commodity_price &gt;= 10 and e.commodity_price &lt; 20
+    </if>
+    <if test="projectAmountType==5">
+      and e.commodity_price &gt;= 20
+    </if>
+    <if test="projectStatus !=null">
+      and e.project_status = #{projectStatus}
+    </if>
+    <if test="satisfactionDegree !=null">
+      and e.satisfaction_degree = #{satisfactionDegree}
+    </if>
+    <if test="startDate !=null and endDate !=null">
+      and a.create_time BETWEEN #{startDate} and #{endDate}
+    </if>
+    <if test="signStartDate !=null and signEndDate !=null">
+      and a.sign_time BETWEEN #{signStartDate} and #{signEndDate}
+    </if>
+    <if test="projectStartDate !=null and projectEndDate !=null">
+      and e.task_distribution_time BETWEEN #{projectStartDate} and #{projectEndDate}
+    </if>
+    <if test="salesType !=null">
+      and a.sales_type = #{salesType}
+    </if>
+    <if test="serviceType !=null">
+      and find_in_set(b.service_type,#{serviceType})
+    </if>
+    <if test="liquidationStatus !=null">
+      and a.liquidation_status = #{liquidationStatus}
+    </if>
+    <if test="dunType !=null">
+      and nod.dun_type = #{dunType}
+    </if>
+    <if test="province !=null">
+      and a4.id = #{province}
+    </if>
+    <if test="salesmanId !=null">
+      and a.salesman_id = #{salesmanId}
+    </if>
+    <if test="financeId !=null">
+      and a.finance_id = #{financeId}
+    </if>
+    <if test="techId !=null">
+      and e.task_receiver =#{techId}
+    </if>
+    <if test="approval ==0">
+      and a.approval = 0
+    </if>
+    <if test="approval ==1">
+      and a.approval > 0
+    </if>
+    <if test="projectType !=null">
+      and b.project_type = #{projectType}
+    </if>
+    <if test="bigCustomer !=null">
+      and b2.big_customer = #{bigCustomer}
+    </if>
+    <if test="restatement ==0">
+      and t1.cb = 0
+    </if>
+    <if test="restatement ==1">
+      and t1.cb > 0
+    </if>
+    <if test="changeType ==0">
+      and t1.counts is null
+    </if>
+    <if test="changeType ==1">
+      and t1.counts >0
+    </if>
+    <if test="refundType ==0">
+      and (t1.tdtk = 0 or t1.tdtk is null)
+    </if>
+    <if test="refundType ==1">
+      and t1.tdtk >0
+    </if>
+    <if test="orderType ==0">
+      and a.order_type  in(0,2)
+    </if>
+    <if test="orderType ==1">
+      and a.order_type  in(1)
+    </if>
+    <if test="projectCompleteStartTime !=null and projectCompleteEndTime !=null">
+      and e.task_end_time BETWEEN #{projectCompleteStartTime} and #{projectCompleteEndTime}
+    </if>
+  </sql>
+  <select id="selectStatisticsOrderProjectCount" resultType="java.lang.Integer">
+    SELECT count(*)
+    from t_order_new a left join t_order_mid b on a.order_no =b.order_no
+    left join admin a2 on a.salesman_id=a2.id left join department a3 on a2.department_id=a3.id
+    left join district_glossory a4 on a3.province=a4.id left join user_mid b2 on a.buyer_id=b2.uid
+    left join t_order_task c on a.order_no =c.order_no and c.main =1
+    left join business_project d on c.commodity_id =d.id left join business_category d2 on d.cid =d2.id
+    left join t_order_task e on a.order_no =e.order_no and e.split_status in (0,2)
+    left join admin e2 on e.task_receiver=e2.id left join t_task_mid e3 on e.id=e3.tid
+    left join t_task_member ttm on e.id =ttm.tid
+    left join (SELECT order_no ,count(*)counts,sum(if(`type`=0,1,0))tdtk,sum(if(`type`=4,1,0))cb
+    from new_order_change group by order_no ) t1 on a.order_no =t1.order_no
+    <include refid="selectStatisticsOrderProjectSql"/>
+  </select>
 </mapper>

+ 6 - 2
src/main/java/com/goafanti/order/controller/StatisticsApiController.java

@@ -5,6 +5,7 @@ import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.common.utils.excel.NewExcelUtil;
+import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.order.bo.*;
 import com.goafanti.order.bo.outStatistics.OutOrderSalesSourceAmount;
@@ -189,7 +190,7 @@ public class StatisticsApiController extends CertifyApiController {
 	 * @return
 	 */
 	@RequestMapping(value="/orderProject", method = RequestMethod.GET)
-	public Result<List<OutOrderProject>> orderProject(InputOrderProject in ){
+	public Result<Pagination<OutOrderProject>> orderProject(InputOrderProject in ){
 		Result res=new Result();
 		res.data(userStaticticsService.orderProject(in));
 		return res;
@@ -201,7 +202,10 @@ public class StatisticsApiController extends CertifyApiController {
 	 */
 	@RequestMapping(value = "/orderProject/export",method = RequestMethod.GET)
 	public Result orderProjectExport(InputOrderProject in){
-		List<OutOrderProject> list = userStaticticsService.orderProject(in);
+		in.setPageSize(999999);
+		in.setPageNo(1);
+		Pagination<OutOrderProject> p = userStaticticsService.orderProject(in);
+		List<OutOrderProject> list = (List<OutOrderProject>) p.getList();
 		NewExcelUtil<OutOrderProject> excelUtil=new NewExcelUtil<>(OutOrderProject.class);
 		return excelUtil.exportExcel(list,"订单项目数据统计表",uploadPath);
 	}

+ 1 - 1
src/main/java/com/goafanti/order/service/UserStaticticsService.java

@@ -17,5 +17,5 @@ public interface UserStaticticsService {
 
     List<OutSignStatistics> signStatisticsGetList(InputSignStatistics in);
 
-    List<OutOrderProject> orderProject(InputOrderProject in);
+    Pagination<OutOrderProject> orderProject(InputOrderProject in);
 }

+ 25 - 3
src/main/java/com/goafanti/order/service/impl/UserStatisticsServiceImpl.java

@@ -3,6 +3,7 @@ package com.goafanti.order.service.impl;
 import com.goafanti.admin.service.DepartmentService;
 import com.goafanti.common.dao.TOrderTaskMapper;
 import com.goafanti.common.dao.UserMidMapper;
+import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -13,6 +14,7 @@ import groovy.util.logging.Log4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.HashMap;
@@ -97,12 +99,15 @@ public class UserStatisticsServiceImpl extends BaseMybatisDao<UserMidMapper> imp
 	}
 
 	@Override
-	public List<OutOrderProject> orderProject(InputOrderProject in) {
+	public Pagination<OutOrderProject> orderProject(InputOrderProject in) {
+		Map<String, Object> map =new HashMap<>();
 		if (in.getEndDate()!=null)in.setEndDate(in.getEndDate()+" 23:59:59");
 		if (in.getProjectEndDate()!=null)in.setProjectEndDate(in.getProjectEndDate()+" 23:59:59");
 		if (in.getSignEndDate()!=null)in.setSignEndDate(in.getSignEndDate()+" 23:59:59");
 		if (in.getProjectCompleteEndTime()!=null)in.setProjectCompleteEndTime(in.getProjectCompleteEndTime()+" 23:59:59");
-		List<OutOrderProject> outOrderProject = tOrderTaskMapper.selectStatisticsOrderProject(in);
+		pushOrderProjectParam(in, map);
+		Pagination<OutOrderProject> page = (Pagination<OutOrderProject>) findPage("selectStatisticsOrderProjectList", "selectStatisticsOrderProjectCount", map, in.getPageNo(), in.getPageSize());
+		List<OutOrderProject> outOrderProject = (List<OutOrderProject>) page.getList();
 		for (OutOrderProject e : outOrderProject) {
 			//计算比例
 			BigDecimal orderReceivables=BigDecimal.ZERO;
@@ -144,6 +149,23 @@ public class UserStatisticsServiceImpl extends BaseMybatisDao<UserMidMapper> imp
 			}
 
 		}
-		return outOrderProject;
+		return page;
+	}
+
+	private void pushOrderProjectParam(InputOrderProject in, Map<String, Object> map) {
+		Class<InputOrderProject> clazz= (Class<InputOrderProject>) in.getClass();
+		Field[] declaredFields = clazz.getDeclaredFields();
+		for (Field field : declaredFields) {
+			field.setAccessible(true);
+
+            try {
+				String fieldName = field.getName();
+                Object fieldValue =field.get(in);
+				map.put(fieldName,fieldValue);
+            } catch (IllegalAccessException e) {
+
+                throw new BusinessException("");
+            }
+        }
 	}
 }