Browse Source

催款统计表开发

anderx 4 years ago
parent
commit
a6ca82a463

+ 7 - 0
src/main/java/com/goafanti/common/dao/NewOrderDunMapper.java

@@ -5,6 +5,9 @@ import com.goafanti.common.model.NewOrderDunExample;
 import com.goafanti.order.bo.OutNewOrderDunBo;
 
 import java.util.List;
+
+import com.goafanti.order.bo.OutSelectOrderDun;
+import com.goafanti.order.bo.OutSelectOrderDunAll;
 import org.apache.ibatis.annotations.Param;
 
 public interface NewOrderDunMapper {
@@ -84,4 +87,8 @@ public interface NewOrderDunMapper {
 
 	void insertBatch(List<OutNewOrderDunBo> newtd2);
 
+	List<OutSelectOrderDunAll> selectOrderDunAll(@Param("depId") String depId, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+	List<OutSelectOrderDun> selectOrderDun(@Param("depId") String depId,@Param("aid") String aid,@Param("sort") Integer sort,@Param("province") Integer province,
+										   @Param("startDate") String startDate, @Param("endDate")  String endDate);
 }

+ 54 - 9
src/main/java/com/goafanti/common/mapper/NewOrderDunMapper.xml

@@ -474,22 +474,67 @@
   	from new_order_dun a
     where tid = #{tid} and status=0
   </select>
-  
+
   <insert id="insertBatch" parameterType="com.goafanti.order.bo.OutNewOrderDunBo">
-  insert into new_order_dun ( order_no, tid, 
-      project_type, dun_type, wait_day, 
-      effective_count, aid, status, 
-      create_time, start_time, money, 
+  insert into new_order_dun ( order_no, tid,
+      project_type, dun_type, wait_day,
+      effective_count, aid, status,
+      create_time, start_time, money,
       appropriation_ratio, customize_name, customize_time
       )
     values
     <foreach item="item" index="index" collection="list" separator=",">
-     (#{item.orderNo,jdbcType=VARCHAR}, #{item.tid,jdbcType=INTEGER}, 
-      #{item.projectType,jdbcType=INTEGER}, #{item.dunType,jdbcType=INTEGER}, #{item.waitDay,jdbcType=INTEGER}, 
-      #{item.effectiveCount,jdbcType=INTEGER}, #{item.aid,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER}, 
-      #{item.createTime,jdbcType=TIMESTAMP}, #{item.startTime,jdbcType=TIMESTAMP}, #{item.money,jdbcType=DECIMAL}, 
+     (#{item.orderNo,jdbcType=VARCHAR}, #{item.tid,jdbcType=INTEGER},
+      #{item.projectType,jdbcType=INTEGER}, #{item.dunType,jdbcType=INTEGER}, #{item.waitDay,jdbcType=INTEGER},
+      #{item.effectiveCount,jdbcType=INTEGER}, #{item.aid,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER},
+      #{item.createTime,jdbcType=TIMESTAMP}, #{item.startTime,jdbcType=TIMESTAMP}, #{item.money,jdbcType=DECIMAL},
       #{item.appropriationRatio,jdbcType=DECIMAL}, #{item.customizeName,jdbcType=VARCHAR}, #{item.customizeTime,jdbcType=TIMESTAMP}
       )
       </foreach>
   </insert>
+  <select id="selectOrderDunAll" resultType="com.goafanti.order.bo.OutSelectOrderDunAll">
+    select dg.name provinceName,z.province,z.quantity,z.totalAmount,z.receivables
+    from (select y.province,sum(1)quantity,sum(y.total_amount)totalAmount,sum(y.receivables)receivables
+    from (select c.province ,x.order_no,x.money receivables,a.total_amount
+    from (select order_no ,sum(money)money from new_order_dun nod where status=1
+     <if test="startDate!=null and endDate!=null">
+      and start_time between #{startDate} and #{endDate}
+     </if>
+      group by order_no)x left join t_order_new a on x.order_no=a.order_no left join admin b on a.salesman_id =b.id
+       left join department c on b.department_id =c.id
+    <if test="depId!=null">
+      where b.department_id = #{depId}
+    </if>
+     )y group by y.province)z left join district_glossory dg on z.province=dg.id
+  </select>
+  <select id="selectOrderDun" resultType="com.goafanti.order.bo.OutSelectOrderDun">
+    select  z.provinceName,z.aName,z.totalAmount,z.money
+    from( select dg.name provinceName,y.name aName,sum(y.total_amount)totalAmount, sum(y.money)money
+    from (select c.province ,b.name ,x.money ,x.quantity,a.total_amount
+    from (select order_no ,sum(money)money,1 quantity from new_order_dun nod where status=1
+    <if test="startDate!=null and endDate!=null">
+    and start_time between #{startDate} and #{endDate}
+    </if>
+    group by order_no)x left join t_order_new a on x.order_no=a.order_no left join admin b on a.salesman_id =b.id
+    left join department c on b.department_id =c.id
+    <if test="depId !=null">
+    where b.department_id = #{depId}
+    </if>
+      <if test="province !=null">
+    and c.province= #{province}
+      </if>
+      <if test="aid !=null">
+    and b.id= #{aid}
+      </if>
+    )y left join district_glossory dg on y.province=dg.id
+    group by dg.name ,y.name)z
+    order by
+     <if test="sort=0">
+       z.totalAmount
+     </if>
+    <if test="sort=1">
+      z.totalAmount
+    </if>
+    desc
+  </select>
 </mapper>

+ 2 - 2
src/main/java/com/goafanti/common/utils/excel/NewExcelUtil.java

@@ -211,7 +211,7 @@ public class NewExcelUtil<T> {
 					CellRangeAddress region = new CellRangeAddress(0, 0, 0, fields.size()-1);
 					sheet.addMergedRegion(region);
 					cell.setCellStyle(styles.get("total"));
-					if (StringUtils.isNotNull(screen)){
+					if (StringUtils.isNotEmpty(screen)){
 						log.debug(screen);
 						Row r = sheet.createRow(++line);
 						Cell c = r.createCell(0);
@@ -227,7 +227,7 @@ public class NewExcelUtil<T> {
 						Excel excel = (Excel) os[1];
 						this.createCell(excel, row, column++);
 					}
-					fillExcelData(index, row,line);
+					fillExcelData(index, row,++line);
 					addStatisticsRow();
 				}
 				response.addHeader("Content-Disposition", "attachment;filename="  + new String(dateFilename.getBytes(),"iso-8859-1"));

+ 49 - 0
src/main/java/com/goafanti/order/bo/OutSelectOrderDun.java

@@ -0,0 +1,49 @@
+package com.goafanti.order.bo;
+
+import com.goafanti.common.utils.excel.Excel;
+
+import java.math.BigDecimal;
+
+public class OutSelectOrderDun {
+
+    @Excel(name = "催收省份")
+    private String provinceName;
+    @Excel(name = "催收入")
+    private String aName;
+    @Excel(name = "签单额(万元)")
+    private BigDecimal totalAmount;
+    @Excel(name = "应收款(万元)")
+    private BigDecimal money;
+
+    public String getProvinceName() {
+        return provinceName;
+    }
+
+    public void setProvinceName(String provinceName) {
+        this.provinceName = provinceName;
+    }
+
+    public String getaName() {
+        return aName;
+    }
+
+    public void setaName(String aName) {
+        this.aName = aName;
+    }
+
+    public BigDecimal getTotalAmount() {
+        return totalAmount;
+    }
+
+    public void setTotalAmount(BigDecimal totalAmount) {
+        this.totalAmount = totalAmount;
+    }
+
+    public BigDecimal getMoney() {
+        return money;
+    }
+
+    public void setMoney(BigDecimal money) {
+        this.money = money;
+    }
+}

+ 58 - 0
src/main/java/com/goafanti/order/bo/OutSelectOrderDunAll.java

@@ -0,0 +1,58 @@
+package com.goafanti.order.bo;
+
+import com.goafanti.common.utils.excel.Excel;
+
+import java.math.BigDecimal;
+
+public class OutSelectOrderDunAll {
+
+    @Excel(name = "催收省份")
+    private String provinceName;
+    private Integer province;
+    @Excel(name = "签单数")
+    private Integer quantity;
+    @Excel(name = "签单额(万元)")
+    private BigDecimal totalAmount;
+    @Excel(name = "应收款(万元)")
+    private BigDecimal receivables;
+
+    public String getProvinceName() {
+        return provinceName;
+    }
+
+    public void setProvinceName(String provinceName) {
+        this.provinceName = provinceName;
+    }
+
+    public Integer getProvince() {
+        return province;
+    }
+
+    public void setProvince(Integer province) {
+        this.province = province;
+    }
+
+    public Integer getQuantity() {
+        return quantity;
+    }
+
+    public void setQuantity(Integer quantity) {
+        this.quantity = quantity;
+    }
+
+    public BigDecimal getTotalAmount() {
+        return totalAmount;
+    }
+
+    public void setTotalAmount(BigDecimal totalAmount) {
+        this.totalAmount = totalAmount;
+    }
+
+    public BigDecimal getReceivables() {
+        return receivables;
+    }
+
+    public void setReceivables(BigDecimal receivables) {
+        this.receivables = receivables;
+    }
+}

+ 66 - 2
src/main/java/com/goafanti/order/controller/AdminNewOrderDunApiController.java

@@ -2,6 +2,11 @@ package com.goafanti.order.controller;
 
 import javax.annotation.Resource;
 
+import com.goafanti.common.utils.excel.NewExcelUtil;
+import com.goafanti.order.bo.OutSelectOrderDun;
+import com.goafanti.order.bo.OutSelectOrderDunAll;
+import com.goafanti.order.bo.outStatisticsList;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
@@ -12,12 +17,16 @@ import com.goafanti.common.utils.StringUtils;
 import com.goafanti.order.bo.InputNewOrderDunBo;
 import com.goafanti.order.service.NewOrderDunService;
 
+import java.util.List;
+
 @RestController
 @RequestMapping(value = "/api/admin/newOrderDun")
 public class AdminNewOrderDunApiController extends CertifyApiController {
 	
 	@Resource
 	private NewOrderDunService	newOrderDunService;
+	@Value(value = "${upload.path}")
+	private String	uploadPath			= null;
 	
 	/**
 	 * 创建催款信息
@@ -86,7 +95,7 @@ public class AdminNewOrderDunApiController extends CertifyApiController {
 		}
 		res.data(newOrderDunService.selectDun( id));
 		return res;
-	}	
+	}
 	/**
 	 * 	催款信息列表
 	 * @return
@@ -96,5 +105,60 @@ public class AdminNewOrderDunApiController extends CertifyApiController {
 		Result res = new Result();
 		res.data(newOrderDunService.selectListNewOrderDun(orderNo));
 		return res;
-	}	
+	}
+
+	/**
+	 * 	全国应收款统计
+	 * @return
+	 */
+	@RequestMapping(value = "/selectOrderDunAll",method = RequestMethod.GET)
+	public Result selectOrderDunAll(String depId,String depName,String startDate ,String endDate){
+		Result res = new Result();
+		res.data(newOrderDunService.selectOrderDunAll(depId,startDate,endDate));
+		return res;
+	}
+
+	/**
+	 * 	全国应收款统计 导出
+	 * @return
+	 */
+	@RequestMapping(value = "/selectOrderDunAllExprot",method = RequestMethod.GET)
+	public Result selectOrderDunAllExprot(String depId,String depName,String startDate ,String endDate){
+		List<OutSelectOrderDunAll> list=newOrderDunService.selectOrderDunAll(depId,startDate,endDate);
+		NewExcelUtil<OutSelectOrderDunAll> excelUtil=new NewExcelUtil<>(OutSelectOrderDunAll.class);
+		StringBuffer sb=new StringBuffer("搜索条件=》");
+		if (depName!=null)sb=sb.append("省份:").append(depName).append(",");
+		if(startDate!=null&&endDate!=null)sb=sb.append("催收时间:").append(startDate).append("~").append(endDate).append(",");
+		return excelUtil.exportExcel(list,"签单统计表",uploadPath,sb.substring(0,sb.toString().length()-1));
+	}
+
+	/**
+	 * 	省份应收款统计详情列表
+	 * @return
+	 */
+	@RequestMapping(value = "/selectOrderDun",method = RequestMethod.GET)
+	public Result selectOrderDun(String depId,String depName,String aid,String aName,Integer sort,Integer province,String startDate ,String endDate){
+		Result res = new Result();
+		res.data(newOrderDunService.selectOrderDun(depId,depName,aid,aName,sort,province,startDate,endDate));
+		return res;
+	}
+
+	/**
+	 * 	催款信息列表
+	 * @return
+	 */
+	@RequestMapping(value = "/selectOrderDunExprot",method = RequestMethod.GET)
+	public Result selectOrderDunExprot(String depId,String depName,String aid,String aName,Integer sort,Integer province,String startDate ,String endDate){
+		List<OutSelectOrderDun> list=newOrderDunService.selectOrderDun(depId,depName,aid,aName,sort,province,startDate,endDate);
+		NewExcelUtil<OutSelectOrderDun> excelUtil=new NewExcelUtil<>(OutSelectOrderDun.class);
+		StringBuffer sb=new StringBuffer("搜索条件=》");
+		if (depName!=null)sb=sb.append("省份:").append(depName).append(",");
+		if (aName!=null)sb=sb.append("催款人:").append(depName).append(",");
+		if (sort!=null){
+			if (sort==0)sb=sb.append("排序:").append("按签单金额").append(",");
+			if (sort==1)sb=sb.append("排序:").append("按应收款").append(",");
+		}
+		if(startDate!=null&&endDate!=null)sb=sb.append("催收时间:").append(startDate).append("~").append(endDate).append(",");
+		return excelUtil.exportExcel(list,"签单统计表",uploadPath,sb.substring(0,sb.toString().length()-1));
+	}
 }

+ 5 - 0
src/main/java/com/goafanti/order/service/NewOrderDunService.java

@@ -4,6 +4,8 @@ import java.util.List;
 
 import com.goafanti.order.bo.InputNewOrderDunBo;
 import com.goafanti.order.bo.OutNewOrderDunBo;
+import com.goafanti.order.bo.OutSelectOrderDun;
+import com.goafanti.order.bo.OutSelectOrderDunAll;
 
 public interface NewOrderDunService {
 
@@ -24,4 +26,7 @@ public interface NewOrderDunService {
 	List<OutNewOrderDunBo> selectAllOrderDun();
 
 
+    List<OutSelectOrderDunAll> selectOrderDunAll(String depId, String startDate, String endDate);
+
+	List<OutSelectOrderDun> selectOrderDun(String depId, String depName, String aid, String aName,Integer sort,Integer province,String startDate, String endDate);
 }

+ 16 - 2
src/main/java/com/goafanti/order/service/impl/NewOrderDunServiceImpl.java

@@ -3,6 +3,8 @@ package com.goafanti.order.service.impl;
 import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 
+import com.goafanti.order.bo.OutSelectOrderDun;
+import com.goafanti.order.bo.OutSelectOrderDunAll;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.beanutils.converters.DateConverter;
@@ -73,7 +75,19 @@ public class NewOrderDunServiceImpl extends BaseMybatisDao<NewOrderDunMapper> im
 	public List<OutNewOrderDunBo> selectAllOrderDun() {
 		return newOrderDunMapper.selectAllOrderDun();
 	}
-	
-	
+
+	@Override
+	public List<OutSelectOrderDunAll> selectOrderDunAll(String depId, String startDate, String endDate) {
+		endDate=endDate+" 23:59:59";
+		return newOrderDunMapper.selectOrderDunAll(depId,startDate,endDate);
+	}
+
+	@Override
+	public List<OutSelectOrderDun> selectOrderDun(String depId, String depName, String aid, String aName,Integer sort,Integer province, String startDate, String endDate) {
+		endDate=endDate+" 23:59:59";
+		if(sort==null)sort=0;
+		return newOrderDunMapper.selectOrderDun(depId,aid,sort,province,startDate,endDate);
+	}
+
 
 }