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