Commit 1fd75c7e by chenweisong

更新

parent 7ad00e16
......@@ -114,16 +114,16 @@
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15-beta2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.7</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.poi</groupId>-->
<!-- <artifactId>poi-ooxml</artifactId>-->
<!-- <version>3.15-beta2</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>fastjson</artifactId>-->
<!-- <version>1.2.7</version>-->
<!-- </dependency>-->
<!-- 引入easypoi -->
<dependency>
......
......@@ -11,7 +11,7 @@ import com.keymobile.rest.akka.message.BreakExcelMsg;
import com.keymobile.rest.akka.message.ConfirmMsg;
import com.keymobile.rest.akka.message.ExportExcelMsg;
import com.keymobile.rest.akka.utils.ExcelModelColumnUtils;
import com.keymobile.rest.model.BankData;
import com.keymobile.rest.akka.model.BankData;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
......@@ -9,7 +9,8 @@ import java.util.Map;
import com.keymobile.rest.akka.message.ConfirmMsg;
import com.keymobile.rest.akka.message.ExportExcelMsg;
import com.keymobile.rest.model.BankData;
import com.keymobile.rest.akka.model.BankData;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.poi.ss.usermodel.Workbook;
......@@ -36,17 +37,21 @@ public class ExportExcelActor extends AbstractActor {
TemplateExportParams params = new TemplateExportParams(modelPath);
Map<String, Object> map = new HashMap<>();
List<BankData> list = new ArrayList<>();
String bankName = "";
for (BankData bd : bankDataList) {
BankData newBd = new BankData(
bd.getMonth() == null ? "" : DateFormatUtils.format(bd.getMonth(), "yyyy/MM/dd"),
bd.getUniqueKey(), bd.getOneSubBank(), bd.getOneSubBankName(),
bd.getUniqueKey(), bd.getOneSubBankName(),
bd.getBranches(), bd.getCustomerNum(), bd.getCustomerName(),
bd.getUpdateCustomerNum(), bd.getUpdateBranches(), bd.getUpdateCustomerName());
if (StringUtils.isEmpty(bankName)) {
bankName = bd.getOneSubBankName();
}
list.add(newBd);
}
map.put("list", list);
Workbook workbook = ExcelExportUtil.exportExcel(params, map);
fileName = fileName + "-" + breakColumn + "_" + index + ".xlsx";
fileName = fileName + "_" + breakColumn + "_" + (StringUtils.isEmpty(bankName) ? index : bankName) + ".xlsx";
File pathFile = new File(exportPath);
if (!pathFile.exists()) {
pathFile.mkdirs();
......
package com.keymobile.rest.akka.message;
import com.keymobile.rest.model.BankData;
import com.keymobile.rest.akka.model.BankData;
import java.io.Serializable;
import java.util.ArrayList;
......
package com.keymobile.rest.model;
package com.keymobile.rest.akka.model;
import java.io.Serializable;
import java.util.Date;
......@@ -18,23 +18,21 @@ public class BankData implements Serializable, IExcelModel, IExcelDataModel{
@Excel(name = "月份", format = "yyyy-MM-dd", orderNum = "0", width=30)
private Date month;//月份
@Excel(name = "唯一键", orderNum = "1", width=30)
@Excel(name = "分行编码", orderNum = "1", width=30)
private String uniqueKey;//唯一键
@Excel(name = "一级分行", orderNum = "2", width=30)
private String oneSubBank;//一级分行
@Excel(name = "一级分行名称", orderNum = "3", width=30)
private String oneSubBankName;//一级分行名称
@Excel(name = "网点", orderNum = "4", width=30)
@Excel(name = "分行名称", orderNum = "2", width=30)
private String oneSubBankName;// 分行名称
@Excel(name = "网点", orderNum = "3", width=30)
private String branches;//网点
@Excel(name = "客户号", orderNum = "5", width=30)
@Excel(name = "客户号", orderNum = "4", width=30)
private String customerNum;//客户号
@Excel(name = "客户名称", orderNum = "6", width=30)
@Excel(name = "客户名称", orderNum = "5", width=30)
private String customerName;//客户名称
@Excel(name = "修正后的客户号", orderNum = "7", width=30)
@Excel(name = "修正后的客户号", orderNum = "6", width=30)
private String updateCustomerNum;//修正后的客户号
@Excel(name = "修改后的客户开户网点", orderNum = "8", width=30)
@Excel(name = "修改后的客户开户网点", orderNum = "7", width=30)
private String updateBranches;//修改后的客户开户网点
@Excel(name = "修正后的客户名称", orderNum = "9", width=30)
@Excel(name = "修正后的客户名称", orderNum = "8", width=30)
private String updateCustomerName;//修正后的客户名称
private String monthString;
......@@ -43,12 +41,11 @@ public class BankData implements Serializable, IExcelModel, IExcelDataModel{
super();
}
public BankData(String monthString,String uniqueKey,String oneSubBank,String oneSubBankName,String branches,
public BankData(String monthString,String uniqueKey ,String oneSubBankName,String branches,
String customerNum,String customerName,String updateCustomerNum,String updateBranches,
String updateCustomerName) {
this.monthString = monthString;
this.uniqueKey = uniqueKey;
this.oneSubBank = oneSubBank;
this.oneSubBankName = oneSubBankName;
this.branches = branches;
this.customerNum = customerNum;
......@@ -60,7 +57,7 @@ public class BankData implements Serializable, IExcelModel, IExcelDataModel{
@Override
public String toString() {
return "BankData [month=" + month + ", uniqueKey=" + uniqueKey + ", oneSubBank=" + oneSubBank
return "BankData [month=" + month + ", uniqueKey=" + uniqueKey
+ ", oneSubBankName=" + oneSubBankName + ", branches=" + branches + ", customerNum=" + customerNum
+ ", customerName=" + customerName + ", updateCustomerNum=" + updateCustomerNum + ", updateBranches="
+ updateBranches + ", updateCustomerName=" + updateCustomerName + "]";
......@@ -82,14 +79,6 @@ public class BankData implements Serializable, IExcelModel, IExcelDataModel{
this.uniqueKey = uniqueKey;
}
public String getOneSubBank() {
return oneSubBank;
}
public void setOneSubBank(String oneSubBank) {
this.oneSubBank = oneSubBank;
}
public String getOneSubBankName() {
return oneSubBankName;
}
......
......@@ -8,9 +8,8 @@ public class ExcelModelColumnUtils {
static {
modelColumnMap.put("月份", "Month");
modelColumnMap.put("唯一键", "UniqueKey");
modelColumnMap.put("一级分行", "OneSubBank");
modelColumnMap.put("一级分行名称", "OneSubBankName");
modelColumnMap.put("分行编码", "UniqueKey");
modelColumnMap.put("分行名称", "OneSubBankName");
modelColumnMap.put("网点", "Branches");
modelColumnMap.put("客户号", "CustomerNum");
modelColumnMap.put("客户名称", "CustomerName");
......
package com.keymobile.rest.common.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
......@@ -18,41 +16,41 @@ import java.util.regex.Pattern;
public class DataFileUtil {
public static void main(String[] args) {
XSSFWorkbook book;
XSSFSheet sheet;
JSONArray jsons;
XSSFRow row;
try {
InputStream is = new FileInputStream(new File("D:\\workspace\\record-demo\\origin\\补录系统excel拆分java代码\\数据和模板文件\\excel拆分导入文件.xlsx"));
book = new XSSFWorkbook(is);
sheet = book.getSheetAt(0);
jsons = new JSONArray();
for (int i = 1; i < sheet.getLastRowNum(); i++) {
row = sheet.getRow(i);
if (row != null) {
JSONObject json = new JSONObject();
//对于纯数字内容要做这一操作
row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
json.put("进程数", row.getCell(0).getStringCellValue());
json.put("基准板", row.getCell(1).getStringCellValue());
json.put("优化比", row.getCell(2).getStringCellValue());
jsons.add(json);
}
}
System.out.println(jsons.toJSONString());
book.close();
} catch (FileNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
// public static void main(String[] args) {
//
// XSSFWorkbook book;
// XSSFSheet sheet;
// JSONArray jsons;
// XSSFRow row;
// try {
// InputStream is = new FileInputStream(new File("D:\\workspace\\record-demo\\origin\\补录系统excel拆分java代码\\数据和模板文件\\excel拆分导入文件.xlsx"));
// book = new XSSFWorkbook(is);
// sheet = book.getSheetAt(0);
// jsons = new JSONArray();
// for (int i = 1; i < sheet.getLastRowNum(); i++) {
// row = sheet.getRow(i);
// if (row != null) {
// JSONObject json = new JSONObject();
// //对于纯数字内容要做这一操作
// row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
// row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
// row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
// json.put("进程数", row.getCell(0).getStringCellValue());
// json.put("基准板", row.getCell(1).getStringCellValue());
// json.put("优化比", row.getCell(2).getStringCellValue());
// jsons.add(json);
// }
// }
// System.out.println(jsons.toJSONString());
// book.close();
// } catch (FileNotFoundException e) {
// // TODO 自动生成的 catch 块
// e.printStackTrace();
// } catch (IOException e) {
// // TODO 自动生成的 catch 块
// e.printStackTrace();
// }
// }
public static Object convertDatToJson(String path, int dataAt) {
List ArrList = new ArrayList();
......@@ -83,7 +81,7 @@ public class DataFileUtil {
e.printStackTrace();
}
}
return JSONObject.toJSON(ArrList);
return ArrList ;
}
public static Object convertDatToJson(MultipartFile file, int dataAt) {
......@@ -116,7 +114,7 @@ public class DataFileUtil {
e.printStackTrace();
}
}
return JSONObject.toJSON(ArrList);
return ArrList ;
}
......
......@@ -115,6 +115,9 @@ public class TaskController {
Template template = templateService.findById(templateId);
vars.put("config", template.getConfig());
vars.put("templateId", template.getId());
if (StringUtils.isNotEmpty(template.getUpStreamAddr())) {
vars.put("filePath", template.getUpStreamAddr());
}
}
missions.add(convertTaskToMission(task, vars));
});
......@@ -133,7 +136,15 @@ public class TaskController {
// 组id
String groupId = "id:" + templateId;
if (groupId.equals(identityLink.getGroupId())) {
missions.add(convertTaskToMission(groupTask, ImmutableMap.of("username", username, "type", CommonConstant.TASK_TYPE_GROUP, "templateId", templateId, "config", template.getConfig())));
Map vars = new HashMap();
vars.put("username", username);
vars.put("type", CommonConstant.TASK_TYPE_GROUP);
vars.put("config", template.getConfig());
vars.put("templateId", templateId);
if (StringUtils.isNotEmpty(template.getUpStreamAddr())) {
vars.put("filePath", template.getUpStreamAddr());
}
missions.add(convertTaskToMission(groupTask, vars));
}
});
}
......@@ -198,7 +209,7 @@ public class TaskController {
return finalActivity.getId();
}
@ApiOperation(value = "修改活动")
@ApiOperation(value = "修改活动", hidden = true)
@ApiImplicitParams({
@ApiImplicitParam(name = "taskId", value = "活动id", paramType = "path", required = true, dataType = "long")
})
......@@ -382,6 +393,8 @@ public class TaskController {
}
long templateId = Long.parseLong(params.get("templateId").toString());
String config = params.get("config").toString();
String filePath = params.get("filePath").toString();
builder.filePath(filePath);
builder.config(config);
builder.excelId(templateId);
} else if (task.getTaskDefinitionKey().equals(CommonConstant.MISSION_KEY_MANAGER_AUDIT)) {
......
package com.keymobile.rest.controller;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.keymobile.rest.akka.model.BankData;
import com.keymobile.rest.akka.utils.ExcelModelColumnUtils;
import com.keymobile.rest.common.utils.DataFileUtil;
import com.keymobile.rest.common.utils.DateUtil;
import com.keymobile.rest.common.validator.CommonValidator;
......@@ -11,12 +17,15 @@ import com.keymobile.rest.service.*;
import io.swagger.annotations.*;
import org.activiti.engine.*;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.Map;
import java.io.File;
import java.io.FileInputStream;
import java.lang.reflect.Method;
import java.util.*;
@Api(tags = "模板 控制器", description = "Template Mgr")
@RestController
......@@ -126,7 +135,7 @@ public class TemplateController {
return filePathService.findAll();
}
@ApiOperation(value = "获取txt或者dat文件的数据")
@ApiOperation(value = "获取txt或者dat文件的数据", hidden = true)
@ApiImplicitParams({
@ApiImplicitParam(name = "dataAt", required = true, value = "该行起读取数据(表头行数)", dataType = "integer", paramType = "query", defaultValue = "1")
})
......@@ -137,7 +146,69 @@ public class TemplateController {
return DataFileUtil.convertDatToJson(file, dataAt);
}
@ApiOperation(value = "获取txt或者dat文件的数据")
@ApiOperation(value = "补录时获取文件的上流数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "filePath", required = true, value = "filePath", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "templateId", required = true, value = "模板id", dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "missionType", value = "任务类型", dataType = "integer", paramType = "query")
})
@GetMapping(value = "/excel/getDataByFilePath")
public Object getDataByFilePath(String filePath, long templateId, Integer missionType) {
Template template = templateService.findById(templateId);
Map<String, List<BankData>> breakResultMap = new HashMap<>();
try {
ImportParams params = new ImportParams();
params.setTitleRows(1);
params.setHeadRows(1);
ExcelImportResult<BankData> excelImportResult = ExcelImportUtil.
importExcelMore(new FileInputStream(new File(filePath)), BankData.class, params);
List<BankData> bankDataList = excelImportResult.getList();
String breakColumnEn = ExcelModelColumnUtils.getBreakColumn(template.getColumnName());
if (StringUtils.isBlank(breakColumnEn)) {
} else {
for (BankData bd : bankDataList) {
Method m = bd.getClass().getMethod("get" + breakColumnEn);
if (breakResultMap.get(m.invoke(bd) + "") != null) {
breakResultMap.get(m.invoke(bd) + "").add(bd);
} else {
List<BankData> bankData = new ArrayList<>();
bankData.add(bd);
breakResultMap.put(m.invoke(bd) + "", bankData);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
// if (missionType == CommonConstant.MISSION_TYPE_DATA_ENTER) {
// } else if (missionType == CommonConstant.MISSION_TYPE_DATA_AUDIT) {
// }
User user = sessionService.getLoginUser();
Map org = feignAuthService.getUserOrgById(user.getId());
String key = org.get("fullname").toString().split(",")[1];
List<BankData> bankDataList = breakResultMap.get(key);
List<List<String>> listArrayList = new ArrayList<>();
bankDataList.forEach(bankData -> {
List<String> array = new ArrayList<>();
array.add(bankData.getMonth().toString());
array.add(bankData.getUniqueKey());
array.add(bankData.getOneSubBankName());
array.add(bankData.getBranches());
array.add(bankData.getCustomerNum());
array.add(bankData.getCustomerName());
array.add(bankData.getUpdateCustomerNum());
array.add(bankData.getUpdateBranches());
array.add(bankData.getUpdateCustomerName());
listArrayList.add(array);
});
return listArrayList;
}
@ApiOperation(value = "获取txt或者dat文件的数据", hidden = true)
@ApiImplicitParams({
@ApiImplicitParam(name = "pathId", required = true, value = "path id", dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "dataAt", required = true, value = "该行起读取数据(表头行数)", dataType = "integer", paramType = "query", defaultValue = "1")
......
......@@ -40,12 +40,15 @@ public class Template implements Serializable {
@Column(name = "need_merge", columnDefinition = ("integer(2) default 1 comment '需要数据合并'"))
private Integer needMerge = 1;
@Column(name = "up_stream_addr", columnDefinition = ("varchar(100) comment '上游地址'"))
@Column(name = "up_stream_addr", columnDefinition = ("varchar(100) comment '上游文件地址'"))
private String upStreamAddr;
@Column(name = "back_stream_addr", columnDefinition = ("varchar(100) comment '回流地址'"))
private String backStreamAddr;
@Column(name = "column_name", columnDefinition = ("varchar(100) comment '上游文件拆分名称'"))
private String columnName;
@Column(nullable = false, columnDefinition = ("bigint(22) comment '审核人userId'"))
private Long auditId;
......
......@@ -13,6 +13,8 @@ public class Mission {
private String id;
@ApiModelProperty(name = "user", value = "当前登录用户")
private String user;
@ApiModelProperty(name = "filePath", value = "文件路径")
private String filePath;
@ApiModelProperty(name = "taskType", value = "task类别 1 个人task 2 组task")
private int taskType;
@ApiModelProperty(name = "createAt", value = "任务发放时间")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment