|
|
|
@ -1412,91 +1412,14 @@ public class VoucherController {
|
|
|
|
|
@Operation(summary = "模板下载")
|
|
|
|
|
@GetMapping("/TemplateDownload")
|
|
|
|
|
public ActionResult<DownloadVO> TemplateDownload(){
|
|
|
|
|
DownloadVO vo = DownloadVO.builder().build();
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
|
//主表对象
|
|
|
|
|
List<ExcelExportEntity> entitys = new ArrayList<>();
|
|
|
|
|
//以下添加字段
|
|
|
|
|
entitys.add(new ExcelExportEntity("凭证编号" ,"voucherCode"));
|
|
|
|
|
dataMap.put("voucherCode", "系统自动生成");
|
|
|
|
|
entitys.add(new ExcelExportEntity("凭证类型" ,"voucherType"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("制单时间" ,"preparationTime"));
|
|
|
|
|
dataMap.put("preparationTime", "例: yyyy-MM-dd");
|
|
|
|
|
entitys.add(new ExcelExportEntity("磅单编号" ,"poundCode"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("车牌号" ,"vehicleName"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("发货单位" ,"supplierName"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("收货单位" ,"customerName"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("运输方式" ,"modeTransport"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("承运方式" ,"transportationMethod"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("承运商" ,"carrier"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("起运地" ,"placeDispatch"));
|
|
|
|
|
dataMap.put("placeDispatch", "例:福建省/莆田市/城厢区");
|
|
|
|
|
entitys.add(new ExcelExportEntity("到达地" ,"destination"));
|
|
|
|
|
dataMap.put("destination", "例:福建省/莆田市/城厢区");
|
|
|
|
|
entitys.add(new ExcelExportEntity("运费" ,"freight"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("关联单据号" ,"associatedDocumentNo"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("单据类型" ,"documentType"));
|
|
|
|
|
entitys.add(new ExcelExportEntity("凭证状态" ,"voucherStatus"));
|
|
|
|
|
//tableField111子表对象
|
|
|
|
|
ExcelExportEntity tableField111ExcelEntity = new ExcelExportEntity("","tableField111");
|
|
|
|
|
List<ExcelExportEntity> tableField111ExcelEntityList = new ArrayList<>();
|
|
|
|
|
Map<String, Object> tableField111ChildData = new HashMap<>();
|
|
|
|
|
List<Map<String, Object>> tableField111ChildDataList = new ArrayList<>();
|
|
|
|
|
tableField111ExcelEntityList.add(new ExcelExportEntity("规格" ,"spec"));
|
|
|
|
|
tableField111ExcelEntityList.add(new ExcelExportEntity("单位" ,"unit"));
|
|
|
|
|
tableField111ExcelEntityList.add(new ExcelExportEntity("毛重" ,"grossWeight"));
|
|
|
|
|
tableField111ExcelEntityList.add(new ExcelExportEntity("皮重" ,"tareWeight"));
|
|
|
|
|
tableField111ExcelEntityList.add(new ExcelExportEntity("扣重" ,"buckleWeight"));
|
|
|
|
|
tableField111ExcelEntityList.add(new ExcelExportEntity("净重" ,"netWeight"));
|
|
|
|
|
tableField111ExcelEntityList.add(new ExcelExportEntity("备注" ,"remark"));
|
|
|
|
|
tableField111ExcelEntityList.add(new ExcelExportEntity("打印时间" ,"printTime"));
|
|
|
|
|
tableField111ChildData.put("printTime", "例: yyyy-MM-dd");
|
|
|
|
|
tableField111ChildDataList.add(tableField111ChildData);
|
|
|
|
|
dataMap.put("tableField111",tableField111ChildDataList);
|
|
|
|
|
tableField111ExcelEntity.setList(tableField111ExcelEntityList);
|
|
|
|
|
entitys.add(tableField111ExcelEntity);
|
|
|
|
|
//tableField140子表对象
|
|
|
|
|
ExcelExportEntity tableField140ExcelEntity = new ExcelExportEntity("","tableField140");
|
|
|
|
|
List<ExcelExportEntity> tableField140ExcelEntityList = new ArrayList<>();
|
|
|
|
|
Map<String, Object> tableField140ChildData = new HashMap<>();
|
|
|
|
|
List<Map<String, Object>> tableField140ChildDataList = new ArrayList<>();
|
|
|
|
|
tableField140ExcelEntityList.add(new ExcelExportEntity("驾驶员名称" ,"driverName"));
|
|
|
|
|
tableField140ExcelEntityList.add(new ExcelExportEntity("联系电话" ,"telephone"));
|
|
|
|
|
tableField140ExcelEntityList.add(new ExcelExportEntity("承运商" ,"carrier"));
|
|
|
|
|
tableField140ChildDataList.add(tableField140ChildData);
|
|
|
|
|
dataMap.put("tableField140",tableField140ChildDataList);
|
|
|
|
|
tableField140ExcelEntity.setList(tableField140ExcelEntityList);
|
|
|
|
|
entitys.add(tableField140ExcelEntity);
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
list.add(dataMap);
|
|
|
|
|
|
|
|
|
|
ExportParams exportParams = new ExportParams(null, "凭证单模板");
|
|
|
|
|
exportParams.setType(ExcelType.XSSF);
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
DownloadVO vo = DownloadVO.builder().build();
|
|
|
|
|
try {
|
|
|
|
|
@Cleanup Workbook workbook = new HSSFWorkbook();
|
|
|
|
|
if (entitys.size()>0){
|
|
|
|
|
if (list.size()==0){
|
|
|
|
|
list.add(new HashMap<>());
|
|
|
|
|
}
|
|
|
|
|
//复杂表头-表头和数据处理
|
|
|
|
|
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(VoucherConstant.getColumnData(), ColumnDataModel.class);
|
|
|
|
|
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
|
|
|
|
|
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
|
|
|
|
|
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList);
|
|
|
|
|
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList);
|
|
|
|
|
}
|
|
|
|
|
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
|
|
|
|
|
}
|
|
|
|
|
String fileName = "凭证单模板" + DateUtil.dateNow("yyyyMMddHHmmss") + ".xlsx";
|
|
|
|
|
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
|
|
|
|
|
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
|
|
|
|
|
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
|
|
|
|
|
vo.setName(fileInfo.getFilename());
|
|
|
|
|
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
|
|
|
|
|
vo.setName("凭证导入.zip");
|
|
|
|
|
vo.setUrl(UploaderUtil.uploaderFile("/api/file/DownloadModel?encryption=", userInfo.getId() + "#" + "凭证导入.zip" + "#" + "Temporary"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("模板信息导出Excel错误:{}", e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("信息导出Excel错误:{}", e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success(vo);
|
|
|
|
|
}
|
|
|
|
@ -1509,14 +1432,14 @@ public class VoucherController {
|
|
|
|
|
@Operation(summary = "导入预览" )
|
|
|
|
|
@GetMapping("/ImportPreview")
|
|
|
|
|
public ActionResult<Map<String, Object>> ImportPreview(String fileName) throws Exception {
|
|
|
|
|
fileName = "66441f9464a4bd991e589f74.xls";
|
|
|
|
|
//fileName = "6645af470365f697b7120ff7.xls";
|
|
|
|
|
Map<String, Object> headAndDataMap = new HashMap<>(2);
|
|
|
|
|
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getWebAnnexFilePath();
|
|
|
|
|
FileUploadUtils.downLocal(configValueUtil.getTemporaryFilePath(), filePath, fileName);
|
|
|
|
|
File temporary = new File(XSSEscape.escapePath(filePath + fileName));
|
|
|
|
|
int headerRowIndex = 1;
|
|
|
|
|
ImportParams params = new ImportParams();
|
|
|
|
|
params.setTitleRows(0);
|
|
|
|
|
params.setTitleRows(2);
|
|
|
|
|
params.setHeadRows(headerRowIndex);
|
|
|
|
|
params.setNeedVerify(true);
|
|
|
|
|
try {
|
|
|
|
@ -1527,7 +1450,7 @@ public class VoucherController {
|
|
|
|
|
columns.add(new ExcelImFieldModel("businessType","业务类型"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("documentType","单据类型"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("voucherType","凭证类型"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("receivingDate","收货日期"));
|
|
|
|
|
// columns.add(new ExcelImFieldModel("receivingDate","收货日期"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("productName","商品名称"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("vehicleName","送货车号"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("unit","单位"));
|
|
|
|
@ -1557,7 +1480,7 @@ public class VoucherController {
|
|
|
|
|
columns.add(new ExcelImFieldModel("vehiclePictures10","车辆信息10"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("contractNo","合同编码"));
|
|
|
|
|
//tableField111子表对象
|
|
|
|
|
List<ExcelImFieldModel> tableField111columns = new ArrayList<>();
|
|
|
|
|
/*List<ExcelImFieldModel> tableField111columns = new ArrayList<>();
|
|
|
|
|
tableField111columns.add(new ExcelImFieldModel("spec" ,"规格"));
|
|
|
|
|
tableField111columns.add(new ExcelImFieldModel("unit" ,"单位"));
|
|
|
|
|
tableField111columns.add(new ExcelImFieldModel("grossWeight" ,"毛重"));
|
|
|
|
@ -1572,7 +1495,7 @@ public class VoucherController {
|
|
|
|
|
tableField140columns.add(new ExcelImFieldModel("driverName" ,"驾驶员名称"));
|
|
|
|
|
tableField140columns.add(new ExcelImFieldModel("telephone" ,"联系电话"));
|
|
|
|
|
tableField140columns.add(new ExcelImFieldModel("carrier" ,"承运商"));
|
|
|
|
|
columns.add(new ExcelImFieldModel("tableField140","",tableField140columns));
|
|
|
|
|
columns.add(new ExcelImFieldModel("tableField140","",tableField140columns));*/
|
|
|
|
|
headAndDataMap.put("dataRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(excelDataList)));
|
|
|
|
|
headAndDataMap.put("headerRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
|
|
|
|
|
} catch (Exception e){
|
|
|
|
|