Commit ff2e2b89 by 王军业

[下载Excel表格接口]

1 parent e37c8678
...@@ -11,6 +11,7 @@ import javax.annotation.Resource; ...@@ -11,6 +11,7 @@ import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -38,4 +39,10 @@ public class AppendixController extends BaseController{ ...@@ -38,4 +39,10 @@ public class AppendixController extends BaseController{
public Object upload(AppendixVo appendixVo) { public Object upload(AppendixVo appendixVo) {
return AppendixService.upload(appendixVo); return AppendixService.upload(appendixVo);
} }
@PutMapping(value="/{contract_unid}/upload/appendixes")
@ResponseBody
public Object update(Appendix appendix) {
return AppendixService.updateAppendix(appendix);
}
} }
package com.vion.financial.controller; package com.vion.financial.controller;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -57,4 +58,11 @@ public class ContractController extends BaseController { ...@@ -57,4 +58,11 @@ public class ContractController extends BaseController {
public Object queryByCondition(SelectVo selectVo) { public Object queryByCondition(SelectVo selectVo) {
return contractService.selectByCondition(selectVo); return contractService.selectByCondition(selectVo);
} }
@GetMapping(value="/export")
@ResponseBody
public void downLoadExcel(SelectVo selectVo,HttpServletResponse response) {
contractService.exportExcel(selectVo, response);
}
} }
...@@ -4,21 +4,21 @@ import java.util.List; ...@@ -4,21 +4,21 @@ import java.util.List;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.vion.financial.excel.ExportModel;
import com.vion.financial.vo.ContractVo; import com.vion.financial.vo.ContractVo;
import com.vion.financial.vo.SelectVo; import com.vion.financial.vo.SelectVo;
public interface ContractMapper { public interface ContractMapper {
@Transactional @Transactional
public void addOne(ContractVo contractVo); void addOne(ContractVo contractVo);
public ContractVo queryOne(String contract_unid); ContractVo queryOne(String contract_unid);
@Transactional @Transactional
public void updateOne(ContractVo contractVo); void updateOne(ContractVo contractVo);
@Transactional @Transactional
public void deleteOne(String contract_unid); void deleteOne(String contract_unid);
public List<String> queryList(); List<String> queryList();
public List<ContractVo> selectByCondition(SelectVo selectVo); List<ContractVo> selectByCondition(SelectVo selectVo);
int count(SelectVo selectVo);
public Boolean isDelete(String contract_unid); Boolean isDelete(String contract_unid);
public int countNumber(); List<ExportModel> exportContracts(SelectVo selectVo);
} }
...@@ -284,6 +284,111 @@ ...@@ -284,6 +284,111 @@
<!-- delete from tb_contract where contract_unid = #{contract_unid} --> <!-- delete from tb_contract where contract_unid = #{contract_unid} -->
</delete> </delete>
<select id="count" parameterType="com.vion.financial.vo.SelectVo" resultType="int">
select count(1) as count from tb_contract where 1=1
<if test="salesperson_unids !=null">
and
salesperson_unid in
<foreach collection="salesperson_unids" index="index" item="salesperson_unid" open="(" close=")" separator=",">
#{salesperson_unid}
</foreach>
</if>
<if test="project_name__like !=null and project_name__like !=''">
and
tb_contract.project_unid in (select tb_project.project_unid from tb_project where project_name like '%'||#{project_name__like}||'%')
</if>
<if test="customer_name__like !=null and customer_name__like !=''">
and
tb_contract.customer_unid in (select tb_customer.customer_unid from tb_customer where customer_name like '%'||#{customer_name__like}||'%')
</if>
<if test="province !=null and province !=''">
and
province=#{province}
</if>
<if test="city !=null and city !=''">
and
city=#{city}
</if>
<if test="county !=null and county !=''">
and
county=#{county}
</if>
<if test="guarantee_period !=null and guarantee_period !=0">
and
guarantee_period=#{guarantee_period}
</if>
<if test="year !=null and year !=''">
and
to_char(sign_date,'yyyy')=#{year}
</if>
<if test="month !=null and month!=''">
and
to_char(sign_date,'MM')=#{month}
</if>
<if test="product_line_type !=null and product_line_type !=''">
and
product_line_type=#{product_line_type}
</if>
<if test="contract_state !=null and contract_state!=''">
and
contract_state=#{contract_state}
</if>
<if test="contract_type !=null and contract_type !=''">
and
contract_type=#{contract_type}
</if>
<if test="is_archive !=null">
and
is_archive=#{is_archive}
</if>
<if test="acceptanc_type !=null and acceptanc_type !=''">
and
contract_unid in (select tb_project_acceptanc.contract_unid from tb_project_acceptanc where tb_project_acceptanc.acceptanc_type=#{acceptanc_type})
</if>
<if test="confirm_income_amount !=null">
and
confirm_income_amount=#{confirm_income_amount}
</if>
<if test="amount_state_unid !=null and amount_state_unid !=''">
and
amount_state_unid=#{amount_state_unid}
</if>
<if test="start_date != null and end_date !=null">
and
#{start_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} <![CDATA[<=]]> sign_date and sign_date <![CDATA[<=]]> #{end_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}
</if>
<if test="amount_start_point !=null and amount_start_point !=0.00">
and
contract_amount <![CDATA[>=]]> #{amount_start_point}
</if>
<if test="amount_end_point !=null and amount_end_point !=0.00">
and
contract_amount <![CDATA[<=]]> #{amount_end_point}
</if>
<if test="overdays_start_point !=null and overdays_start_point !=0">
and
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point})
</if>
<if test="overdays_end_point !=null and overdays_end_point !=0">
and
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point})
</if>
<if test="leave_amount_start_point !=null and leave_amount_start_point !=0.00">
<!--应收款余额-->and
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[>=]]> #{leave_amount_start_point})
</if>
<if test="leave_amount_end_point !=null and leave_amount_end_point !=0.00">
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[<=]]> #{leave_amount_end_point})
</if>
and is_delete=false
<if test="limit !=null and limit!=0 ">
limit #{limit}
</if>
<if test="offset !=0 and offset !=null">
offset #{offset}
</if>
</select>
<select id="selectByCondition" parameterType="com.vion.financial.vo.SelectVo" resultType="com.vion.financial.vo.ContractVo"> <select id="selectByCondition" parameterType="com.vion.financial.vo.SelectVo" resultType="com.vion.financial.vo.ContractVo">
select select
contract_unid, salesperson_unid, province, city, county, contract_unid, salesperson_unid, province, city, county,
...@@ -416,6 +521,142 @@ ...@@ -416,6 +521,142 @@
offset #{offset} offset #{offset}
</if> </if>
</select> </select>
<select id="exportContracts" parameterType="com.vion.financial.vo.SelectVo" resultType="com.vion.financial.excel.ExportModel">
select
contract_unid, salesperson_unid, province, city, county,
guarantee_period, sign_date, product_line_type, contract_state,
contract_type, cast(contract_amount as decimal(18,2)), cast(deduct_amount as decimal(18,2)), contract_amount_note,
cast(stop_amount as decimal(18,2)), reback_note, cast(exemptions_amount as decimal(18,2)), contract_remain_note,
is_archive, cast(bad_amount as decimal(18,2)), bad_amount_note, cast(confirm_income_amount as decimal(18,2)),
amount_state_unid, start_guarantee_date, end_guarantee_date,
mainten_start_point, contract_note, is_delete, project_unid,
customer_unid,
(cast(contract_amount as decimal(18,2))-(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-cast(deduct_amount as decimal(18,2))-cast(stop_amount as decimal(18,2))-cast(exemptions_amount as decimal(18,2))-cast(bad_amount as decimal(18,2))) as contract_remain,
(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid) as total_reback_amount,
(select cast(total_recv_amount_view.total_recv_amount as decimal(18,2)) from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid) as total_receive_amount ,
((select cast(total_recv_amount_view.total_recv_amount as decimal(18,2)) from total_recv_amount_view where tb_contract.contract_unid=total_recv_amount_view.contract_unid)-(select cast(total_reback_view.sum as decimal(18,2)) from total_reback_view where total_reback_view.contract_unid=tb_contract.contract_unid)-(cast(deduct_amount as decimal(18,2)))-(cast(stop_amount as decimal(18,2)))-(cast(exemptions_amount as decimal(18,2)))-(cast(bad_amount as decimal(18,2)))) as total_amount_remain ,
(select over_days_view.over_days from over_days_view where over_days_view.contract_unid=tb_contract.contract_unid) as over_days,
(select tb_project.project_name from tb_project where tb_project.project_unid=tb_contract.project_unid) as project_name,
(select tb_customer.customer_name from tb_customer where tb_customer.customer_unid=tb_contract.customer_unid) as customer_name,
(select cast(e17_view.e17 as decimal(18,2)) from e17_view where e17_view.contract_unid=tb_contract.contract_unid) as advance_pay,
(select cast(e18_view.e18 as decimal(18,2)) from e18_view where e18_view.contract_unid=tb_contract.contract_unid) as arrive_pay,
(select cast(e19_view.e19 as decimal(18,2)) from e19_view where e19_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay,
case when (select e20_view.e20 from e20_view where e20_view.contract_unid=tb_contract.contract_unid) is null
then (select cast(e21_view.e21 as decimal(18,2)) from e21_view where e21_view.contract_unid=tb_contract.contract_unid)
else (select cast(e20_view.e20 as decimal(18,2)) from e20_view where e20_view.contract_unid=tb_contract.contract_unid)
end as mainten_pay,
(select d18_view.d18 from d18_view where d18_view.contract_unid=tb_contract.contract_unid) as advance_pay_date,
(select d19_view.d19 from d19_view where d19_view.contract_unid=tb_contract.contract_unid) as arrive_pay_date,
(select d20_view.d20 from d20_view where d20_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay_date,
case when (select d21_view.d21 from d21_view where d21_view.contract_unid=tb_contract.contract_unid) is null
then (select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid)
else (select d21_view.d21 from d21_view where d21_view.contract_unid=tb_contract.contract_unid)
end as mainten_pay_date,
<!-- (select d21_view.d21 from d21_view where d21_view.contract_unid=tb_contract.contract_unid) as mainten_pay_deliver_date,
(select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_acceptanc_date, -->
(select max(tb_deliver_goods.deliver_goods_date) from tb_deliver_goods where tb_deliver_goods.contract_unid=tb_contract.contract_unid ) as deliver_date,
(select max(tb_project_acceptanc.acceptanc_date) from tb_project_acceptanc where tb_project_acceptanc.contract_unid=tb_contract.contract_unid ) as acceptanc_date
from tb_contract where 1=1
<if test="salesperson_unids !=null">
and
salesperson_unid in
<foreach collection="salesperson_unids" index="index" item="salesperson_unid" open="(" close=")" separator=",">
#{salesperson_unid}
</foreach>
</if>
<if test="project_name__like !=null and project_name__like !=''">
and
tb_contract.project_unid in (select tb_project.project_unid from tb_project where project_name like '%'||#{project_name__like}||'%')
</if>
<if test="customer_name__like !=null and customer_name__like !=''">
and
tb_contract.customer_unid in (select tb_customer.customer_unid from tb_customer where customer_name like '%'||#{customer_name__like}||'%')
</if>
<if test="province !=null and province !=''">
and
province=#{province}
</if>
<if test="city !=null and city !=''">
and
city=#{city}
</if>
<if test="county !=null and county !=''">
and
county=#{county}
</if>
<if test="guarantee_period !=null and guarantee_period !=0">
and
guarantee_period=#{guarantee_period}
</if>
<if test="year !=null and year !=''">
and
to_char(sign_date,'yyyy')=#{year}
</if>
<if test="month !=null and month!=''">
and
to_char(sign_date,'MM')=#{month}
</if>
<if test="product_line_type !=null and product_line_type !=''">
and
product_line_type=#{product_line_type}
</if>
<if test="contract_state !=null and contract_state!=''">
and
contract_state=#{contract_state}
</if>
<if test="contract_type !=null and contract_type !=''">
and
contract_type=#{contract_type}
</if>
<if test="is_archive !=null">
and
is_archive=#{is_archive}
</if>
<if test="acceptanc_type !=null and acceptanc_type !=''">
and
contract_unid in (select tb_project_acceptanc.contract_unid from tb_project_acceptanc where tb_project_acceptanc.acceptanc_type=#{acceptanc_type})
</if>
<if test="confirm_income_amount !=null">
and
confirm_income_amount=#{confirm_income_amount}
</if>
<if test="amount_state_unid !=null and amount_state_unid !=''">
and
amount_state_unid=#{amount_state_unid}
</if>
<if test="start_date != null and end_date !=null">
and
#{start_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler} <![CDATA[<=]]> sign_date and sign_date <![CDATA[<=]]> #{end_date,typeHandler=com.vion.financial.handler.MilliDateTypeHandler}
</if>
<if test="amount_start_point !=null and amount_start_point !=0.00">
and
contract_amount <![CDATA[>=]]> #{amount_start_point}
</if>
<if test="amount_end_point !=null and amount_end_point !=0.00">
and
contract_amount <![CDATA[<=]]> #{amount_end_point}
</if>
<if test="overdays_start_point !=null and overdays_start_point !=0">
and
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[>=]]> #{overdays_start_point})
</if>
<if test="overdays_end_point !=null and overdays_end_point !=0">
and
<!--逾期天数-->contract_unid in (select over_days_view.contract_unid from over_days_view where over_days <![CDATA[<=]]> #{overdays_end_point})
</if>
<if test="leave_amount_start_point !=null and leave_amount_start_point !=0.00">
<!--应收款余额-->and
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[>=]]> #{leave_amount_start_point})
</if>
<if test="leave_amount_end_point !=null and leave_amount_end_point !=0.00">
contract_unid in (select receive_amount_view.contract_unid from receive_amount_view where receive_amount_view.leave_amount_point <![CDATA[<=]]> #{leave_amount_end_point})
</if>
and is_delete=false
</select>
<select id="isDelete" parameterType="String" resultType="boolean"> <select id="isDelete" parameterType="String" resultType="boolean">
select is_delete from tb_contract where contract_unid = #{contract_unid} select is_delete from tb_contract where contract_unid = #{contract_unid}
</select> </select>
......
package com.vion.financial.service; package com.vion.financial.service;
import javax.servlet.http.HttpServletResponse;
import com.vion.financial.vo.ContractVo; import com.vion.financial.vo.ContractVo;
import com.vion.financial.vo.SelectVo; import com.vion.financial.vo.SelectVo;
...@@ -11,4 +13,5 @@ public interface ContractService { ...@@ -11,4 +13,5 @@ public interface ContractService {
public Object queryList(); public Object queryList();
boolean isDelete(String s); boolean isDelete(String s);
public Object selectByCondition(SelectVo selectVo); public Object selectByCondition(SelectVo selectVo);
public void exportExcel(SelectVo selectVo,HttpServletResponse response);
} }
package com.vion.financial.service.imp; package com.vion.financial.service.imp;
import java.util.ArrayList; import java.util.ArrayList;
import com.vion.financial.handler.DownLoad;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -12,6 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +15,7 @@ import org.springframework.stereotype.Service;
import com.vion.financial.config.FinanceConfig; import com.vion.financial.config.FinanceConfig;
import com.vion.financial.entity.Appendix; import com.vion.financial.entity.Appendix;
import com.vion.financial.excel.ExportModel;
import com.vion.financial.mapper.AppendixMapper; import com.vion.financial.mapper.AppendixMapper;
import com.vion.financial.mapper.ContractMapper; import com.vion.financial.mapper.ContractMapper;
import com.vion.financial.mapper.PaymentAgreeMapper; import com.vion.financial.mapper.PaymentAgreeMapper;
...@@ -201,6 +205,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -201,6 +205,7 @@ public class ContractServiceImpl implements ContractService {
} }
List<ContractVo> list = contractMapper.selectByCondition(selectVo); List<ContractVo> list = contractMapper.selectByCondition(selectVo);
int count = contractMapper.count(selectVo);
for (ContractVo contractVo : list) { for (ContractVo contractVo : list) {
contractVo.setPaymentAgree_list(paymentAgreeMapper.queryPaymentAgree(contractVo.getContract_unid())); contractVo.setPaymentAgree_list(paymentAgreeMapper.queryPaymentAgree(contractVo.getContract_unid()));
if(list_data != null && list_data.size() > 0) { if(list_data != null && list_data.size() > 0) {
...@@ -214,7 +219,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -214,7 +219,7 @@ public class ContractServiceImpl implements ContractService {
resultVo.setList_data(list); resultVo.setList_data(list);
resultVo.setList_size(selectVo.getLimit()); resultVo.setList_size(selectVo.getLimit());
resultVo.setOffset(selectVo.getOffset()); resultVo.setOffset(selectVo.getOffset());
resultVo.setTotal_number(list.size()); resultVo.setTotal_number(count);
return resultVo; return resultVo;
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
...@@ -224,4 +229,40 @@ public class ContractServiceImpl implements ContractService { ...@@ -224,4 +229,40 @@ public class ContractServiceImpl implements ContractService {
return failCode; return failCode;
} }
} }
@Override
public void exportExcel(SelectVo selectVo,HttpServletResponse response) {
logger.info("========================导出合同Excel表格===========================");
List<Map> list_data = null;
if (StringUtils.isNotBlank(selectVo.getSalesperson_name__like())) {
String url = financeConfig.getAuthurl();
String result = HttpNetClient.doGet(url+"?username="+selectVo.getSalesperson_name__like(), null);
Map map = JavaBean2Json.Json2JavaBean(result, Map.class);
list_data = (List<Map>) map.get("list_data");
if(list_data != null && list_data.size() > 0) {
List<String> salesperson_unids = new ArrayList<String>(list_data.size());
for(Map _map:list_data) {
salesperson_unids.add((String) _map.get("user_unid"));
}
selectVo.setSalesperson_unids(salesperson_unids);
}
}
List<ExportModel> list = contractMapper.exportContracts(selectVo);
for (ExportModel exportModel : list) {
if(list_data != null && list_data.size() > 0) {
for(Map _map:list_data) {
if (exportModel.getSalesperson_unid().equals(_map.get("user_unid"))) {
exportModel.setSalesperson_name((String) _map.get("username"));
}
}
}
}
try {
DownLoad downLoad =new DownLoad();
downLoad.exportExcel(list, "合同Excel表格", "合同Excel表格", ExportModel.class, "合同Excel表格.xls", response);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!