Commit 6c24982d by 谢明辉

Merge branch 'develop' of http://192.168.9.26/platform/finance_serv into develop

2 parents dd04b641 12218163
...@@ -16,25 +16,25 @@ public class ExportModel { ...@@ -16,25 +16,25 @@ public class ExportModel {
@ExcelIgnore() @ExcelIgnore()
private String product_line_type; private String product_line_type;
@Excel(name="产品线类型") @Excel(name="产品线类型")
private String product_line_type_name; //产品线类型 private String product_line_type_name="-"; //产品线类型
@Excel(name="签订日期",format="yyyy-MM-dd",width=15) @Excel(name="签订日期",width=15)
private Date sign_date; //签订日期 private String sign_date="-"; //签订日期
@Excel(name="所属月份") @Excel(name="所属月份")
private String month; //所属月份 private String month="-"; //所属月份
@Excel(name="销售员") @Excel(name="销售员")
private String salesperson_name="-"; //销售员名称 private String salesperson_name="-"; //销售员名称
@Excel(name="省") @Excel(name="省")
private String province_name="-"; //省份 private String province_name="-"; //省份
@ExcelIgnore() @ExcelIgnore()
private String province; private String province="-";
@Excel(name="市") @Excel(name="市")
private String city_name="-"; //城市 private String city_name="-"; //城市
@ExcelIgnore() @ExcelIgnore()
private String city; private String city="-";
@Excel(name="县") @Excel(name="县")
private String county_name="-"; //县 private String county_name="-"; //县
@ExcelIgnore() @ExcelIgnore()
private String county; private String county="-";
@Excel(name="客户名称",width=20) @Excel(name="客户名称",width=20)
private String customer_name="-"; //顾客名称 private String customer_name="-"; //顾客名称
@Excel(name="项目名称",width=20) @Excel(name="项目名称",width=20)
...@@ -54,7 +54,7 @@ public class ExportModel { ...@@ -54,7 +54,7 @@ public class ExportModel {
@Excel(name="合同余额",width=15,type=1,numFormat="###,###.00") @Excel(name="合同余额",width=15,type=1,numFormat="###,###.00")
private Double contract_remain; //合同余额 private Double contract_remain; //合同余额
@Excel(name="账款状态",width=15) @Excel(name="账款状态",width=15)
private String amount_state_unid_name; //账款 状态 private String amount_state_unid_name="-"; //账款 状态
@ExcelIgnore() @ExcelIgnore()
private String amount_state_unid; private String amount_state_unid;
@Excel(name="累计应收款",width=15,type=1,numFormat="###,###.00") @Excel(name="累计应收款",width=15,type=1,numFormat="###,###.00")
...@@ -65,24 +65,24 @@ public class ExportModel { ...@@ -65,24 +65,24 @@ public class ExportModel {
private Integer over_days; //逾期天数 private Integer over_days; //逾期天数
@Excel(name="预付款金额",width=15,type=1,numFormat="###,###.00") @Excel(name="预付款金额",width=15,type=1,numFormat="###,###.00")
private Double advance_pay; //预付款金额 private Double advance_pay; //预付款金额
@Excel(name="预付款到期日",format="yyyy-MM-dd",width=15) @Excel(name="预付款到期日",width=15)
private Date advance_pay_date; //预付款到期日 private String advance_pay_date="-"; //预付款到期日
@Excel(name="到货款金额",width=15,type=1,numFormat="###,###.00") @Excel(name="到货款金额",width=15,type=1,numFormat="###,###.00")
private Double arrive_pay; //到货款金额 private Double arrive_pay; //到货款金额
@Excel(name="发货日期",format="yyyy-MM-dd",width=15) @Excel(name="发货日期",width=15)
private Date deliver_date; //发货日期 private String deliver_date="-"; //发货日期
@Excel(name="到货款到期日",format="yyyy-MM-dd",width=15) @Excel(name="到货款到期日",width=15)
private Date arrive_pay_date; //到货款到期日 private String arrive_pay_date="-"; //到货款到期日
@Excel(name="验收款金额",width=15,type=1,numFormat="###,###.00") @Excel(name="验收款金额",width=15,type=1,numFormat="###,###.00")
private Double acceptanc_pay; //验收款金额 private Double acceptanc_pay; //验收款金额
@Excel(name="验收日期",format="yyyy-MM-dd",width=15) @Excel(name="验收日期",width=15)
private Date acceptanc_date; //验收日期 private String acceptanc_date="-"; //验收日期
@Excel(name="验收款到期日",format="yyyy-MM-dd",width=15) @Excel(name="验收款到期日",width=15)
private Date acceptanc_pay_date; //验货款到期日 private String acceptanc_pay_date="-"; //验货款到期日
@Excel(name="质保金额",width=15,type=1,numFormat="###,###.00") @Excel(name="质保金额",width=15,type=1,numFormat="###,###.00")
private Double mainten_pay; //质保金额 private Double mainten_pay; //质保金额
@Excel(name="质保款到期日",format="yyyy-MM-dd",width=15) @Excel(name="质保款到期日",width=15)
private Date mainten_pay_date; //质保款到期日 private String mainten_pay_date="-"; //质保款到期日
private String salesperson_unid; private String salesperson_unid;
...@@ -104,12 +104,7 @@ public class ExportModel { ...@@ -104,12 +104,7 @@ public class ExportModel {
public void setProduct_line_type(String product_line_type) { public void setProduct_line_type(String product_line_type) {
this.product_line_type = product_line_type; this.product_line_type = product_line_type;
} }
public Date getSign_date() {
return sign_date;
}
public void setSign_date(Date sign_date) {
this.sign_date = sign_date;
}
public String getMonth() { public String getMonth() {
return month; return month;
} }
...@@ -218,60 +213,27 @@ public class ExportModel { ...@@ -218,60 +213,27 @@ public class ExportModel {
public void setAdvance_pay(Double advance_pay) { public void setAdvance_pay(Double advance_pay) {
this.advance_pay = advance_pay; this.advance_pay = advance_pay;
} }
public Date getAdvance_pay_date() {
return advance_pay_date;
}
public void setAdvance_pay_date(Date advance_pay_date) {
this.advance_pay_date = advance_pay_date;
}
public Double getArrive_pay() { public Double getArrive_pay() {
return arrive_pay; return arrive_pay;
} }
public void setArrive_pay(Double arrive_pay) { public void setArrive_pay(Double arrive_pay) {
this.arrive_pay = arrive_pay; this.arrive_pay = arrive_pay;
} }
public Date getDeliver_date() {
return deliver_date;
}
public void setDeliver_date(Date deliver_date) {
this.deliver_date = deliver_date;
}
public Date getArrive_pay_date() {
return arrive_pay_date;
}
public void setArrive_pay_date(Date arrive_pay_date) {
this.arrive_pay_date = arrive_pay_date;
}
public Double getAcceptanc_pay() { public Double getAcceptanc_pay() {
return acceptanc_pay; return acceptanc_pay;
} }
public void setAcceptanc_pay(Double acceptanc_pay) { public void setAcceptanc_pay(Double acceptanc_pay) {
this.acceptanc_pay = acceptanc_pay; this.acceptanc_pay = acceptanc_pay;
} }
public Date getAcceptanc_date() {
return acceptanc_date;
}
public void setAcceptanc_date(Date acceptanc_date) {
this.acceptanc_date = acceptanc_date;
}
public Date getAcceptanc_pay_date() {
return acceptanc_pay_date;
}
public void setAcceptanc_pay_date(Date acceptanc_pay_date) {
this.acceptanc_pay_date = acceptanc_pay_date;
}
public Double getMainten_pay() { public Double getMainten_pay() {
return mainten_pay; return mainten_pay;
} }
public void setMainten_pay(Double mainten_pay) { public void setMainten_pay(Double mainten_pay) {
this.mainten_pay = mainten_pay; this.mainten_pay = mainten_pay;
} }
public Date getMainten_pay_date() {
return mainten_pay_date;
}
public void setMainten_pay_date(Date mainten_pay_date) {
this.mainten_pay_date = mainten_pay_date;
}
public String getSalesperson_unid() { public String getSalesperson_unid() {
return salesperson_unid; return salesperson_unid;
} }
...@@ -314,5 +276,49 @@ public class ExportModel { ...@@ -314,5 +276,49 @@ public class ExportModel {
public void setProduct_line_type_name(String product_line_type_name) { public void setProduct_line_type_name(String product_line_type_name) {
this.product_line_type_name = product_line_type_name; this.product_line_type_name = product_line_type_name;
} }
public String getSign_date() {
return sign_date;
}
public void setSign_date(String sign_date) {
this.sign_date = sign_date;
}
public String getAdvance_pay_date() {
return advance_pay_date;
}
public void setAdvance_pay_date(String advance_pay_date) {
this.advance_pay_date = advance_pay_date;
}
public String getDeliver_date() {
return deliver_date;
}
public void setDeliver_date(String deliver_date) {
this.deliver_date = deliver_date;
}
public String getArrive_pay_date() {
return arrive_pay_date;
}
public void setArrive_pay_date(String arrive_pay_date) {
this.arrive_pay_date = arrive_pay_date;
}
public String getAcceptanc_date() {
return acceptanc_date;
}
public void setAcceptanc_date(String acceptanc_date) {
this.acceptanc_date = acceptanc_date;
}
public String getAcceptanc_pay_date() {
return acceptanc_pay_date;
}
public void setAcceptanc_pay_date(String acceptanc_pay_date) {
this.acceptanc_pay_date = acceptanc_pay_date;
}
public String getMainten_pay_date() {
return mainten_pay_date;
}
public void setMainten_pay_date(String mainten_pay_date) {
this.mainten_pay_date = mainten_pay_date;
}
} }
...@@ -11,6 +11,7 @@ import org.apache.poi.ss.usermodel.Workbook; ...@@ -11,6 +11,7 @@ import org.apache.poi.ss.usermodel.Workbook;
import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
public class DownLoad { public class DownLoad {
private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response, private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response,
...@@ -34,5 +35,10 @@ public class DownLoad { ...@@ -34,5 +35,10 @@ public class DownLoad {
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName)); defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName));
} }
public static void dynamicExportExcel(String title, String sheetName,List<ExcelExportEntity> titlelist,List<Map<String, Object>> vallist,String fileName,HttpServletResponse response) throws Exception{
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(title, sheetName), titlelist, vallist);
if (workbook != null)
downLoadExcel(fileName, response, workbook);
}
} }
...@@ -577,11 +577,11 @@ ...@@ -577,11 +577,11 @@
</if> </if>
from (select from (select
contract_unid, salesperson_unid, province, city, county, province_name,city_name,county_name, contract_unid, salesperson_unid, province, city, county, province_name,city_name,county_name,
guarantee_period, sign_date, product_line_type, contract_state, guarantee_period,to_char(sign_date, 'yyyy-MM-dd') as 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, 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, 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)), 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, amount_state_unid, to_char(start_guarantee_date, 'yyyy-MM-dd') as start_guarantee_date, to_char(end_guarantee_date, 'yyyy-MM-dd') as end_guarantee_date,
mainten_start_point, contract_note, is_delete, project_unid, mainten_start_point, contract_note, is_delete, project_unid,
customer_unid, customer_unid,
to_char(sign_date,'yyyy') as year, to_char(sign_date,'MM') as month, to_char(sign_date,'yyyy') as year, to_char(sign_date,'MM') as month,
...@@ -596,14 +596,14 @@ ...@@ -596,14 +596,14 @@
(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(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, (select cast(e19_view.e19 as decimal(18,2)) from e19_view where e19_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay,
(select cast(e21_view.e21 as decimal(18,2)) from e21_view where e21_view.contract_unid=tb_contract.contract_unid) as mainten_pay, (select cast(e21_view.e21 as decimal(18,2)) from e21_view where e21_view.contract_unid=tb_contract.contract_unid) as mainten_pay,
(select d18_view.d18 from d18_view where d18_view.contract_unid=tb_contract.contract_unid) as advance_pay_date, to_char((select d18_view.d18 from d18_view where d18_view.contract_unid=tb_contract.contract_unid), 'yyyy-MM-dd') as advance_pay_date,
(select d19_view.d19 from d19_view where d19_view.contract_unid=tb_contract.contract_unid) as arrive_pay_date, to_char((select d19_view.d19 from d19_view where d19_view.contract_unid=tb_contract.contract_unid), 'yyyy-MM-dd') as arrive_pay_date,
(select d20_view.d20 from d20_view where d20_view.contract_unid=tb_contract.contract_unid) as acceptanc_pay_date, to_char((select d20_view.d20 from d20_view where d20_view.contract_unid=tb_contract.contract_unid), 'yyyy-MM-dd') as acceptanc_pay_date,
(select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid) as mainten_pay_date, to_char((select d22_view.d21 from d22_view where d22_view.contract_unid=tb_contract.contract_unid), 'yyyy-MM-dd') 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 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 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, to_char((select max(tb_deliver_goods.deliver_goods_date) from tb_deliver_goods where tb_deliver_goods.contract_unid=tb_contract.contract_unid ), 'yyyy-MM-dd') 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 to_char((select max(tb_project_acceptanc.acceptanc_date) from tb_project_acceptanc where tb_project_acceptanc.contract_unid=tb_contract.contract_unid ), 'yyyy-MM-dd') as acceptanc_date
from tb_contract where 1=1 from tb_contract where 1=1
<if test="contract_unid !=null and contract_unid !=''"> <if test="contract_unid !=null and contract_unid !=''">
and and
......
...@@ -57,7 +57,9 @@ import com.vion.financial.vo.ResultVo; ...@@ -57,7 +57,9 @@ import com.vion.financial.vo.ResultVo;
import com.vion.financial.vo.SelectVo; import com.vion.financial.vo.SelectVo;
import com.vion.financial.vo.SuccessCode; import com.vion.financial.vo.SuccessCode;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil; import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams; import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
...@@ -65,7 +67,76 @@ import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; ...@@ -65,7 +67,76 @@ import cn.afterturn.easypoi.handler.inter.IExcelDataHandler;
@Service @Service
public class ContractServiceImpl implements ContractService { public class ContractServiceImpl implements ContractService {
Logger logger = LoggerFactory.getLogger(ContractServiceImpl.class); Logger logger = LoggerFactory.getLogger(ContractServiceImpl.class);
private static Map<String,String> head_title_name = new HashMap<String,String>();
{
head_title_name.put("year","所属年份");
head_title_name.put( "product_line_type","产品线类型");
head_title_name.put("sign_date","签订日期");
head_title_name.put("month","所属月份");
head_title_name.put("salesperson_unid","销售员");
head_title_name.put("province","省");
head_title_name.put("city","市");
head_title_name.put("county","县");
head_title_name.put("customer_name","客户名称");
head_title_name.put("project_name","项目名称");
head_title_name.put("contract_amount","合同金额");
head_title_name.put("stop_amount","暂停金额");
head_title_name.put("bad_amount","坏账金额");
head_title_name.put("exemptions_amount","豁免金额");
head_title_name.put("deduct_amount","折扣金额");
head_title_name.put("total_reback_amount","累计已收款");
head_title_name.put("contract_remain","合同余额");
head_title_name.put("amount_state_unid","账款状态");
head_title_name.put("total_receive_amount","累计应收款");
head_title_name.put("total_amount_remain","应收账款余额");
head_title_name.put("over_days","逾期天数");
head_title_name.put("advance_pay","预付款金额");
head_title_name.put("advance_pay_date","预付款到期日");
head_title_name.put("arrive_pay","到货款金额");
head_title_name.put("deliver_date","发货日期");
head_title_name.put("arrive_pay_date","到货款到期日");
head_title_name.put("acceptanc_pay","验收款金额");
head_title_name.put("acceptanc_date","验收日期");
head_title_name.put("acceptanc_pay_date","验收款到期日");
head_title_name.put("mainten_pay","质保金额");
head_title_name.put("mainten_pay_date","质保款到期日");
}
private static Map<String,String> head_title_key = new HashMap<String,String>();
{
head_title_key.put("year","year");
head_title_key.put( "product_line_type","product_line_type_name");
head_title_key.put("sign_date","sign_date");
head_title_key.put("month","month");
head_title_key.put("salesperson_unid","salesperson_name");
head_title_key.put("province","province_name");
head_title_key.put("city","city_name");
head_title_key.put("county","county_name");
head_title_key.put("customer_name","customer_name");
head_title_key.put("project_name","project_name");
head_title_key.put("contract_amount","contract_amount");
head_title_key.put("stop_amount","stop_amount");
head_title_key.put("bad_amount","bad_amount");
head_title_key.put("exemptions_amount","exemptions_amount");
head_title_key.put("deduct_amount","deduct_amount");
head_title_key.put("total_reback_amount","total_reback_amount");
head_title_key.put("contract_remain","contract_remain");
head_title_key.put("amount_state_unid","amount_state_unid_name");
head_title_key.put("total_receive_amount","total_receive_amount");
head_title_key.put("total_amount_remain","total_amount_remain");
head_title_key.put("over_days","over_days");
head_title_key.put("advance_pay","advance_pay");
head_title_key.put("advance_pay_date","advance_pay_date");
head_title_key.put("arrive_pay","arrive_pay");
head_title_key.put("deliver_date","deliver_date");
head_title_key.put("arrive_pay_date","arrive_pay_date");
head_title_key.put("acceptanc_pay","acceptanc_pay");
head_title_key.put("acceptanc_date","acceptanc_date");
head_title_key.put("acceptanc_pay_date","acceptanc_pay_date");
head_title_key.put("mainten_pay","mainten_pay");
head_title_key.put("mainten_pay_date","mainten_pay_date");
}
@Autowired @Autowired
ContractMapper contractMapper; ContractMapper contractMapper;
@Autowired @Autowired
...@@ -261,7 +332,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -261,7 +332,7 @@ public class ContractServiceImpl implements ContractService {
selectVo.setSalesperson_unids(salesperson_unids.size() > 0 ? salesperson_unids : null); selectVo.setSalesperson_unids(salesperson_unids.size() > 0 ? salesperson_unids : null);
} }
if(salesperson_unids.size() == 0) { if(salesperson_unids.size() == 0) {
resultVo.setList_data(new ArrayList<>()); resultVo.setList_data(new ArrayList<ContractVo>());
resultVo.setList_size(selectVo.getLimit()== null ? 0 : selectVo.getLimit()); resultVo.setList_size(selectVo.getLimit()== null ? 0 : selectVo.getLimit());
resultVo.setOffset(selectVo.getOffset()== null ? 0 : selectVo.getOffset()); resultVo.setOffset(selectVo.getOffset()== null ? 0 : selectVo.getOffset());
resultVo.setTotal_number(0); resultVo.setTotal_number(0);
...@@ -590,7 +661,11 @@ public class ContractServiceImpl implements ContractService { ...@@ -590,7 +661,11 @@ public class ContractServiceImpl implements ContractService {
}else { }else {
downLoad.exportExcel(list, "合同Excel表格", "合同Excel表格", ExportModel.class, "合同.xls", response); downLoad.exportExcel(list, "合同Excel表格", "合同Excel表格", ExportModel.class, "合同.xls", response);
}*/ }*/
downLoad.exportExcel(list, "合同Excel表格", "合同Excel表格", ExportModel.class, "合同.xls", response); if(selectVo.getColumns() != null && selectVo.getColumns().length > 0) {
downLoad.dynamicExportExcel("合同Excel表格", "合同Excel表格", dynamicCreatTableHead(selectVo),dynamicCreatTableDatas(list), "合同.xls", response);
}else {
downLoad.exportExcel(list, "合同Excel表格", "合同Excel表格", ExportModel.class, "合同.xls", response);
}
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
...@@ -1135,5 +1210,38 @@ public class ContractServiceImpl implements ContractService { ...@@ -1135,5 +1210,38 @@ public class ContractServiceImpl implements ContractService {
return failCode; return failCode;
} }
/***
* 动态生成表头
* @return
*/
private List<ExcelExportEntity> dynamicCreatTableHead(SelectVo selectVo){
String[] cloumns = selectVo.getColumns();
int length = 1 + cloumns.length;
List<ExcelExportEntity> colList = new ArrayList<ExcelExportEntity>(length);
ExcelExportEntity excelExportEntity = new ExcelExportEntity("合同编号", "contract_unid");
colList.add(excelExportEntity);
Object title_name = null;
Object title_key = null;
for(String clo : cloumns) {
title_name = head_title_name.get(clo);
title_key = head_title_key.get(clo);
if(title_name != null) {
excelExportEntity = new ExcelExportEntity(head_title_name.get(clo), head_title_key.get(clo));
colList.add(excelExportEntity);
}
}
return colList;
}
/***
*动态生成表数据
*/
private List<Map<String, Object>> dynamicCreatTableDatas(List<ExportModel> list) {
List<Map<String, Object>> listValues = null;
if(list != null && list.size() > 0 ) {
listValues = JavaBean2Json.transBean2ListMap(list);
}
return listValues;
}
} }
...@@ -5,6 +5,7 @@ import java.beans.IntrospectionException; ...@@ -5,6 +5,7 @@ import java.beans.IntrospectionException;
import java.beans.Introspector; import java.beans.Introspector;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
...@@ -168,5 +169,45 @@ public class JavaBean2Json { ...@@ -168,5 +169,45 @@ public class JavaBean2Json {
} }
} }
return obj; return obj;
} }
public static List<Map<String, Object>> transBean2ListMap(List<?> objs) {
if(objs == null || objs.size() == 0){
return null;
}
List<Map<String, Object>> maps = new ArrayList<Map<String, Object>>(objs.size());
for(Object obj : objs) {
maps.add(transBean2Map(obj));
}
return maps;
}
// Bean --> Map 1: 利用Introspector和PropertyDescriptor 将Bean --> Map
public static Map<String, Object> transBean2Map(Object obj) {
if(obj == null){
return null;
}
Map<String, Object> map = new HashMap<String, Object>();
try {
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor property : propertyDescriptors) {
String key = property.getName();
// 过滤class属性
if (!key.equals("class")) {
// 得到property对应的getter方法
Method getter = property.getReadMethod();
Object value = getter.invoke(obj);
if(value != null) {
map.put(key, value);
}
}
}
} catch (Exception e) {
System.out.println("transBean2Map Error " + e);
}
return map;
}
} }
...@@ -94,7 +94,7 @@ public class ContractVo extends SelectVo{ ...@@ -94,7 +94,7 @@ public class ContractVo extends SelectVo{
return salesperson_unid; return salesperson_unid;
} }
public void setSalesperson_unid(String salesperson_unid) { public void setSalesperson_unid(String salesperson_unid) {
this.salesperson_unid = salesperson_unid.trim(); this.salesperson_unid = salesperson_unid;
} }
public Integer getProject_unid() { public Integer getProject_unid() {
return project_unid; return project_unid;
...@@ -106,13 +106,13 @@ public class ContractVo extends SelectVo{ ...@@ -106,13 +106,13 @@ public class ContractVo extends SelectVo{
return project_name; return project_name;
} }
public void setProject_name(String project_name) { public void setProject_name(String project_name) {
this.project_name = project_name.trim(); this.project_name = project_name;
} }
public String getCustomer_name() { public String getCustomer_name() {
return customer_name; return customer_name;
} }
public void setCustomer_name(String customer_name) { public void setCustomer_name(String customer_name) {
this.customer_name = customer_name.trim(); this.customer_name = customer_name;
} }
public Integer getCustomer_unid() { public Integer getCustomer_unid() {
return customer_unid; return customer_unid;
...@@ -124,19 +124,19 @@ public class ContractVo extends SelectVo{ ...@@ -124,19 +124,19 @@ public class ContractVo extends SelectVo{
return province; return province;
} }
public void setProvince(String province) { public void setProvince(String province) {
this.province = province.trim(); this.province = province;
} }
public String getCity() { public String getCity() {
return city; return city;
} }
public void setCity(String city) { public void setCity(String city) {
this.city = city.trim(); this.city = city;
} }
public String getCounty() { public String getCounty() {
return county; return county;
} }
public void setCounty(String county) { public void setCounty(String county) {
this.county = county.trim(); this.county = county;
} }
public Integer getGuarantee_period() { public Integer getGuarantee_period() {
return guarantee_period; return guarantee_period;
...@@ -155,19 +155,19 @@ public class ContractVo extends SelectVo{ ...@@ -155,19 +155,19 @@ public class ContractVo extends SelectVo{
return product_line_type; return product_line_type;
} }
public void setProduct_line_type(String product_line_type) { public void setProduct_line_type(String product_line_type) {
this.product_line_type = product_line_type.trim(); this.product_line_type = product_line_type;
} }
public String getContract_state() { public String getContract_state() {
return contract_state; return contract_state;
} }
public void setContract_state(String contract_state) { public void setContract_state(String contract_state) {
this.contract_state = contract_state.trim(); this.contract_state = contract_state;
} }
public String getContract_type() { public String getContract_type() {
return contract_type; return contract_type;
} }
public void setContract_type(String contract_type) { public void setContract_type(String contract_type) {
this.contract_type = contract_type.trim(); this.contract_type = contract_type;
} }
public Double getContract_amount() { public Double getContract_amount() {
return contract_amount; return contract_amount;
...@@ -185,7 +185,7 @@ public class ContractVo extends SelectVo{ ...@@ -185,7 +185,7 @@ public class ContractVo extends SelectVo{
return contract_amount_note; return contract_amount_note;
} }
public void setContract_amount_note(String contract_amount_note) { public void setContract_amount_note(String contract_amount_note) {
this.contract_amount_note = contract_amount_note.trim(); this.contract_amount_note = contract_amount_note;
} }
public Double getStop_amount() { public Double getStop_amount() {
return stop_amount; return stop_amount;
...@@ -197,7 +197,7 @@ public class ContractVo extends SelectVo{ ...@@ -197,7 +197,7 @@ public class ContractVo extends SelectVo{
return reback_note; return reback_note;
} }
public void setReback_note(String reback_note) { public void setReback_note(String reback_note) {
this.reback_note = reback_note.trim(); this.reback_note = reback_note;
} }
public Double getExemptions_amount() { public Double getExemptions_amount() {
return exemptions_amount; return exemptions_amount;
...@@ -209,7 +209,7 @@ public class ContractVo extends SelectVo{ ...@@ -209,7 +209,7 @@ public class ContractVo extends SelectVo{
return contract_remain_note; return contract_remain_note;
} }
public void setContract_remain_note(String contract_remain_note) { public void setContract_remain_note(String contract_remain_note) {
this.contract_remain_note = contract_remain_note.trim(); this.contract_remain_note = contract_remain_note;
} }
public Boolean getIs_archive() { public Boolean getIs_archive() {
return is_archive; return is_archive;
...@@ -227,7 +227,7 @@ public class ContractVo extends SelectVo{ ...@@ -227,7 +227,7 @@ public class ContractVo extends SelectVo{
return bad_amount_note; return bad_amount_note;
} }
public void setBad_amount_note(String bad_amount_note) { public void setBad_amount_note(String bad_amount_note) {
this.bad_amount_note = bad_amount_note.trim(); this.bad_amount_note = bad_amount_note;
} }
public Double getConfirm_income_amount() { public Double getConfirm_income_amount() {
return confirm_income_amount; return confirm_income_amount;
...@@ -259,13 +259,13 @@ public class ContractVo extends SelectVo{ ...@@ -259,13 +259,13 @@ public class ContractVo extends SelectVo{
return mainten_start_point; return mainten_start_point;
} }
public void setMainten_start_point(String mainten_start_point) { public void setMainten_start_point(String mainten_start_point) {
this.mainten_start_point = mainten_start_point.trim(); this.mainten_start_point = mainten_start_point;
} }
public String getContract_note() { public String getContract_note() {
return contract_note; return contract_note;
} }
public void setContract_note(String contract_note) { public void setContract_note(String contract_note) {
this.contract_note = contract_note.trim(); this.contract_note = contract_note;
} }
public Boolean getIs_delete() { public Boolean getIs_delete() {
return is_delete; return is_delete;
...@@ -343,7 +343,7 @@ public class ContractVo extends SelectVo{ ...@@ -343,7 +343,7 @@ public class ContractVo extends SelectVo{
return salesperson_name; return salesperson_name;
} }
public void setSalesperson_name(String salesperson_name) { public void setSalesperson_name(String salesperson_name) {
this.salesperson_name = salesperson_name.trim(); this.salesperson_name = salesperson_name;
} }
public Integer getList_size() { public Integer getList_size() {
return list_size; return list_size;
...@@ -450,25 +450,25 @@ public class ContractVo extends SelectVo{ ...@@ -450,25 +450,25 @@ public class ContractVo extends SelectVo{
return product_line_type_name; return product_line_type_name;
} }
public void setProduct_line_type_name(String product_line_type_name) { public void setProduct_line_type_name(String product_line_type_name) {
this.product_line_type_name = product_line_type_name.trim(); this.product_line_type_name = product_line_type_name;
} }
public String getContract_state_name() { public String getContract_state_name() {
return contract_state_name; return contract_state_name;
} }
public void setContract_state_name(String contract_state_name) { public void setContract_state_name(String contract_state_name) {
this.contract_state_name = contract_state_name.trim(); this.contract_state_name = contract_state_name;
} }
public String getContract_type_name() { public String getContract_type_name() {
return contract_type_name; return contract_type_name;
} }
public void setContract_type_name(String contract_type_name) { public void setContract_type_name(String contract_type_name) {
this.contract_type_name = contract_type_name.trim(); this.contract_type_name = contract_type_name;
} }
public String getAmount_state_unid_name() { public String getAmount_state_unid_name() {
return amount_state_unid_name; return amount_state_unid_name;
} }
public void setAmount_state_unid_name(String amount_state_unid_name) { public void setAmount_state_unid_name(String amount_state_unid_name) {
this.amount_state_unid_name = amount_state_unid_name.trim(); this.amount_state_unid_name = amount_state_unid_name;
} }
public Double getMainten_pay() { public Double getMainten_pay() {
return mainten_pay; return mainten_pay;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!