@ -156,16 +156,32 @@ public class SysCustomerController extends BaseController
/ * *
/ * *
* 导出客户基本信息列表
* 导出选择的 客户基本信息列表
* /
* /
@RequiresPermissions ( "system:customer:export" )
@RequiresPermissions ( "system:customer:export" )
@Log ( title = "客户基本信息" , businessType = BusinessType . EXPORT )
@Log ( title = "客户基本信息" , businessType = BusinessType . EXPORT )
@PostMapping ( "/export" )
@PostMapping ( "/export" )
@ResponseBody
@ResponseBody
public AjaxResult export ( SysCustomerVo sysCustomer )
public AjaxResult export ( @RequestBody String [ ] enterpriseCodes )
{
{
List < SysCustomerVo > list = sysCustomerService . selectSysCustomerList ( sysCustomer ) ;
List < SysCustomerVo > list = sysCustomerService . selectSysCustomerListByEnterpriseCodes ( enterpriseCodes ) ;
ExcelUtil < SysCustomerVo > util = new ExcelUtil < SysCustomerVo > ( SysCustomerVo . class ) ;
return util . exportExcel ( list , "客户基本信息数据" ) ;
}
/ * *
* 导出所有客户基本信息列表
* /
@RequiresPermissions ( "system:customer:export" )
@Log ( title = "客户基本信息" , businessType = BusinessType . EXPORT )
@PostMapping ( "/exportAll" )
@ResponseBody
public AjaxResult exportAll ( SysCustomerVo sysCustomer )
{
List < SysCustomerVo > list = sysCustomerService . selectExportSysCustomerList ( sysCustomer ) ;
ExcelUtil < SysCustomerVo > util = new ExcelUtil < SysCustomerVo > ( SysCustomerVo . class ) ;
ExcelUtil < SysCustomerVo > util = new ExcelUtil < SysCustomerVo > ( SysCustomerVo . class ) ;
return util . exportExcel ( list , "客户基本信息数据" ) ;
return util . exportExcel ( list , "客户基本信息数据" ) ;
}
}
@ -427,64 +443,62 @@ public class SysCustomerController extends BaseController
List < SysCustomerOper > list = sysCustomerOperService . selectSysCustomerOperList ( sysCustomerOper ) ;
List < SysCustomerOper > list = sysCustomerOperService . selectSysCustomerOperList ( sysCustomerOper ) ;
return getDataTable ( list ) ;
return getDataTable ( list ) ;
}
}
@RequiresPermissions ( "system:customer:export" )
// @RequiresPermissions("system:customer:export")
@Log ( title = "客户基本信息" , businessType = BusinessType . EXPORT )
// @Log(title = "客户基本信息", businessType = BusinessType.EXPORT)
@RequestMapping ( "/exportCustomerInfo" )
// @RequestMapping("/exportCustomerInfo")
@ResponseBody
// @ResponseBody
public void exportCustomerInfo ( @RequestBody String selectData , HttpServletResponse response ) throws IOException {
// public void exportCustomerInfo(@RequestBody String selectData, HttpServletResponse response) throws IOException {
//
//数据处理
// //数据处理
JSONObject jsonObject = ( JSONObject ) JSONObject . parse ( selectData ) ;
// JSONObject jsonObject = (JSONObject) JSONObject.parse(selectData);
JSONArray jsonArray = jsonObject . getJSONArray ( "selectData" ) ;
// JSONArray jsonArray = jsonObject.getJSONArray("selectData");
List < SysCustomerDto > selectDataList = JSONObject . parseArray ( String . valueOf ( jsonArray ) , SysCustomerDto . class ) ;
// List<SysCustomerDto> selectDataList = JSONObject.parseArray(String.valueOf(jsonArray), SysCustomerDto.class);
//
//
//获取发票基础信息
// //获取发票基础信息
SysCustomer sysCustomer = sysCustomerService . selectSysCustomerById ( selectDataList . get ( 0 ) . getId ( ) ) ;
// SysCustomer sysCustomer = sysCustomerService.selectSysCustomerById(selectDataList.get(0).getId());
SysCustomerDto sysCustomerDto = new SysCustomerDto ( ) ;
// SysCustomerDto sysCustomerDto = new SysCustomerDto();
BeanUtils . copyProperties ( sysCustomer , sysCustomerDto ) ;
// BeanUtils.copyProperties(sysCustomer,sysCustomerDto);
//
//填充表格
// //填充表格
response . setCharacterEncoding ( "utf-8" ) ;
// response.setCharacterEncoding("utf-8");
String fileName = URLEncoder . encode ( "国税发票" , "UTF-8" ) . replaceAll ( "\\+" , "%20" ) ;
// String fileName = URLEncoder.encode("国税发票", "UTF-8").replaceAll("\\+", "%20");
response . setHeader ( "Content-disposition" , "attachment;filename*=utf-8''" + fileName + ".xlsx" ) ;
// response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
String templateFileName = "C:\\exportTemplates\\exportCustomerInfo.xlsx" ;
// String templateFileName = "C:\\exportTemplates\\exportCustomerInfo.xlsx";
try ( ExcelWriter excelWriter = EasyExcel . write ( response . getOutputStream ( ) ) . withTemplate ( templateFileName ) . build ( ) ) {
// try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = EasyExcel . writerSheet ( ) . build ( ) ;
// WriteSheet writeSheet = EasyExcel.writerSheet().build();
Map < String , Object > map = MapUtils . newHashMap ( ) ;
// Map<String, Object> map = MapUtils.newHashMap();
// map.put("date", DateTimeFormatter.ofPattern("yyyy/MM/dd").format(LocalDateTime.now()));
//// map.put("date", DateTimeFormatter.ofPattern("yyyy/MM/dd").format(LocalDateTime.now()));
map . put ( "unifiedNumbering" , sysCustomerDto . getUnifiedNumbering ( ) ) ;
// map.put("unifiedNumbering", sysCustomerDto.getUnifiedNumbering());
map . put ( "enterpriseCode" , sysCustomerDto . getEnterpriseCode ( ) ) ;
// map.put("enterpriseCode", sysCustomerDto.getEnterpriseCode());
map . put ( "enterpriseName" , sysCustomerDto . getEnterpriseName ( ) ) ;
// map.put("enterpriseName", sysCustomerDto.getEnterpriseName());
map . put ( "englishName" , sysCustomerDto . getEnglishName ( ) ) ;
// map.put("englishName", sysCustomerDto.getEnglishName());
map . put ( "customerAddress" , sysCustomerDto . getCustomerAddress ( ) ) ;
// map.put("customerAddress", sysCustomerDto.getCustomerAddress());
map . put ( "postalCode" , sysCustomerDto . getPostalCode ( ) ) ;
// map.put("postalCode", sysCustomerDto.getPostalCode());
map . put ( "contactNumber" , sysCustomerDto . getContactNumber ( ) ) ;
// map.put("contactNumber", sysCustomerDto.getContactNumber());
map . put ( "customerFax" , sysCustomerDto . getCustomerFax ( ) ) ;
// map.put("customerFax", sysCustomerDto.getCustomerFax());
map . put ( "customerContact" , sysCustomerDto . getCustomerContact ( ) ) ;
// map.put("customerContact", sysCustomerDto.getCustomerContact());
map . put ( "deliveryAddress" , sysCustomerDto . getDeliveryAddress ( ) ) ;
// map.put("deliveryAddress", sysCustomerDto.getDeliveryAddress());
map . put ( "paymentTerms" , sysCustomerDto . getPaymentTerms ( ) ) ;
// map.put("paymentTerms", sysCustomerDto.getPaymentTerms());
map . put ( "taxRate" , sysCustomerDto . getTaxRate ( ) ) ;
// map.put("taxRate", sysCustomerDto.getTaxRate());
//
List < SysDictData > exportSalesData = sysDictTypeService . selectDictDataByType ( "sys_export_sales" ) ;
// List<SysDictData> exportSalesData = sysDictTypeService.selectDictDataByType("sys_export_sales");
for ( int i = 0 ; i < exportSalesData . size ( ) ; i + + ) {
// for (int i = 0;i<exportSalesData.size();i++) {
if ( sysCustomerDto . getExportSales ( ) . equals ( exportSalesData . get ( i ) . getDictValue ( ) ) ) {
// if (sysCustomerDto.getExportSales().equals(exportSalesData.get(i).getDictValue())) {
map . put ( "exportSales" , exportSalesData . get ( i ) . getDictLabel ( ) ) ;
// map.put("exportSales", exportSalesData.get(i).getDictLabel());
}
// }
}
// }
//
List < SysDictData > commonCurrencyData = sysDictTypeService . selectDictDataByType ( "sys_common_currency" ) ;
// List<SysDictData> commonCurrencyData = sysDictTypeService.selectDictDataByType("sys_common_currency");
for ( int i = 0 ; i < commonCurrencyData . size ( ) ; i + + ) {
// for (int i = 0;i<commonCurrencyData.size();i++) {
if ( sysCustomerDto . getCommonCurrency ( ) . equals ( commonCurrencyData . get ( i ) . getDictValue ( ) ) ) {
// if (sysCustomerDto.getCommonCurrency().equals(commonCurrencyData.get(i).getDictValue())) {
map . put ( "commonCurrency" , commonCurrencyData . get ( i ) . getDictLabel ( ) ) ;
// map.put("commonCurrency", commonCurrencyData.get(i).getDictLabel());
}
// }
}
// }
// System.out.println(exportSalesData);
// map.put("customerRemarks", sysCustomerDto.getCustomerRemarks());
// System.out.println(commonCurrencyData);
// excelWriter.fill(map, writeSheet);
map . put ( "customerRemarks" , sysCustomerDto . getCustomerRemarks ( ) ) ;
// }
excelWriter . fill ( map , writeSheet ) ;
// }
}
}
/ * *
/ * *
* 获取客户编号
* 获取客户编号