|
@@ -12,6 +12,7 @@ import com.management.platform.mapper.*;
|
|
import com.management.platform.service.*;
|
|
import com.management.platform.service.*;
|
|
import com.management.platform.task.SFTPAsyncUploader;
|
|
import com.management.platform.task.SFTPAsyncUploader;
|
|
import com.management.platform.util.*;
|
|
import com.management.platform.util.*;
|
|
|
|
+import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
|
|
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
|
|
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
|
|
import me.chanjar.weixin.mp.api.WxMpService;
|
|
import me.chanjar.weixin.mp.api.WxMpService;
|
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
|
@@ -22,6 +23,7 @@ import org.apache.poi.EncryptedDocumentException;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
+import org.apache.poi.ss.util.CellRangeAddressList;
|
|
import org.apache.velocity.runtime.directive.contrib.For;
|
|
import org.apache.velocity.runtime.directive.contrib.For;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -62,6 +64,7 @@ import java.util.*;
|
|
import java.util.concurrent.CountDownLatch;
|
|
import java.util.concurrent.CountDownLatch;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
|
|
+import java.util.regex.Pattern;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static org.springframework.boot.system.SystemProperties.get;
|
|
import static org.springframework.boot.system.SystemProperties.get;
|
|
@@ -206,6 +209,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
private ReportAuditLogService reportAuditLogService;
|
|
private ReportAuditLogService reportAuditLogService;
|
|
@Resource
|
|
@Resource
|
|
private TimeTypeService timeTypeService;
|
|
private TimeTypeService timeTypeService;
|
|
|
|
+ @Resource
|
|
|
|
+ private ReportCustomMapper reportCustomMapper;
|
|
|
|
|
|
@Value(value = "${upload.path}")
|
|
@Value(value = "${upload.path}")
|
|
private String path;
|
|
private String path;
|
|
@@ -3811,6 +3816,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
String token = request.getHeader("TOKEN");
|
|
String token = request.getHeader("TOKEN");
|
|
User user = userMapper.selectById(token);
|
|
User user = userMapper.selectById(token);
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ List<ReportCustom> reportCustomList = reportCustomMapper.selectList(new QueryWrapper<ReportCustom>().eq("company_id", companyId));
|
|
TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
//对于存在预算成本的公司,暂不支持导入工时
|
|
//对于存在预算成本的公司,暂不支持导入工时
|
|
Company company = companyMapper.selectById(companyId);
|
|
Company company = companyMapper.selectById(companyId);
|
|
@@ -3840,8 +3846,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
//然后解析表格
|
|
//然后解析表格
|
|
Workbook workbook = WorkbookFactory.create(new FileInputStream(file));
|
|
Workbook workbook = WorkbookFactory.create(new FileInputStream(file));
|
|
|
|
|
|
- DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/M/d");
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy/M/d");
|
|
|
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
//获取公司全部成员
|
|
//获取公司全部成员
|
|
List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
|
|
|
@@ -3868,6 +3874,11 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ for (int i=1;i<7+reportCustomList.size(); i++) {
|
|
|
|
+ if (row.getCell(i) != null) {
|
|
|
|
+ row.getCell(i).setCellType(CellType.STRING);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
// String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
String username =row.getCell(1).getStringCellValue().trim();
|
|
String username =row.getCell(1).getStringCellValue().trim();
|
|
|
|
|
|
@@ -3880,6 +3891,18 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
if(username.equals("员工")){
|
|
if(username.equals("员工")){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ for (int i = 7; i <7+reportCustomList.size() ; i++) {
|
|
|
|
+ if(row.getCell(i)!=null){
|
|
|
|
+ int finalI = i;
|
|
|
|
+ if(!reportCustomList.stream().anyMatch(rl->rl.getCustomName().equals(row.getCell(finalI).getStringCellValue()))){
|
|
|
|
+ msg.setError("自定义字段已更新,请重新下载模板");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ msg.setError("自定义字段已更新,请重新下载模板");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if(!userNameList.contains(username)&&!username.equals("")){
|
|
if(!userNameList.contains(username)&&!username.equals("")){
|
|
userNameList.add(username);
|
|
userNameList.add(username);
|
|
@@ -3911,13 +3934,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
dataCount++;
|
|
dataCount++;
|
|
- //数据行
|
|
|
|
- for (int i=1;i<13; i++) {
|
|
|
|
- if (row.getCell(i) != null) {
|
|
|
|
- row.getCell(i).setCellType(CellType.STRING);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (row.getCell(0) == null) {
|
|
if (row.getCell(0) == null) {
|
|
//msg.setError("第"+dataCount+"行缺少日期");
|
|
//msg.setError("第"+dataCount+"行缺少日期");
|
|
msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
@@ -3930,6 +3946,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+ if(!isDateFormat){
|
|
|
|
+ msg.setError("请确认日期列是否为日期");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if(!isValidDate(reportDate)){
|
|
|
|
+ msg.setError("请确认日期列所填日期格式是否正确 示例:1999-01-01");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
// String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
// String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
|
|
String username = row.getCell(1).getStringCellValue().trim();
|
|
String username = row.getCell(1).getStringCellValue().trim();
|
|
//检查人员是否存在
|
|
//检查人员是否存在
|
|
@@ -3969,11 +3993,17 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
subP=subProject.get();
|
|
subP=subProject.get();
|
|
if(!subProject.get().getProjectId().equals(project.get().getId())){
|
|
if(!subProject.get().getProjectId().equals(project.get().getId())){
|
|
msg.setError("子项目["+subProject.get().getName()+"]不属于项目["+project.get().getProjectName()+"]");
|
|
msg.setError("子项目["+subProject.get().getName()+"]不属于项目["+project.get().getProjectName()+"]");
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
String stringCellValue = row.getCell(6).getStringCellValue();
|
|
String stringCellValue = row.getCell(6).getStringCellValue();
|
|
double time=0;
|
|
double time=0;
|
|
if(!StringUtils.isEmpty(stringCellValue)){
|
|
if(!StringUtils.isEmpty(stringCellValue)){
|
|
|
|
+ Pattern pattern= Pattern.compile("[0-9]*");
|
|
|
|
+ if(!pattern.matcher(stringCellValue).matches()){
|
|
|
|
+ msg.setError("工作时长只能为数字");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
time=Double.valueOf(stringCellValue);
|
|
time=Double.valueOf(stringCellValue);
|
|
if(time>0){
|
|
if(time>0){
|
|
Report report = new Report();
|
|
Report report = new Report();
|
|
@@ -3997,6 +4027,20 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
}
|
|
}
|
|
report.setCreateDate(LocalDate.parse(reportDate, dtf));
|
|
report.setCreateDate(LocalDate.parse(reportDate, dtf));
|
|
report.setCost(reportCreator.getCost()==null?new BigDecimal(0) : reportCreator.getCost().multiply(new BigDecimal(time)));
|
|
report.setCost(reportCreator.getCost()==null?new BigDecimal(0) : reportCreator.getCost().multiply(new BigDecimal(time)));
|
|
|
|
+ for (int i = 0; i < reportCustomList.size(); i++) {
|
|
|
|
+ switch (i+1){
|
|
|
|
+ case 1:report.setPlate1(row.getCell(7).getStringCellValue());
|
|
|
|
+ break;
|
|
|
|
+ case 2:report.setPlate2(row.getCell(8).getStringCellValue());
|
|
|
|
+ break;
|
|
|
|
+ case 3:report.setPlate3(row.getCell(9).getStringCellValue());
|
|
|
|
+ break;
|
|
|
|
+ case 4:report.setPlate4(row.getCell(10).getStringCellValue());
|
|
|
|
+ break;
|
|
|
|
+ case 5:report.setPlate5(row.getCell(11).getStringCellValue());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
reportList.add(report);
|
|
reportList.add(report);
|
|
}else {
|
|
}else {
|
|
msg.setError(MessageUtils.message("report.negativeError",username));
|
|
msg.setError(MessageUtils.message("report.negativeError",username));
|
|
@@ -6161,4 +6205,245 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg exportReportImportTemplate(HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ List<String> heads = new ArrayList<>();
|
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
|
+ Company company = companyMapper.selectById(companyId);
|
|
|
|
+ List<String> exampleDataList=new ArrayList<>();
|
|
|
|
+ heads.add("日期");
|
|
|
|
+ exampleDataList.add("2023-06-28");
|
|
|
|
+ heads.add("员工姓名");
|
|
|
|
+ exampleDataList.add("张三");
|
|
|
|
+ heads.add("员工工号");
|
|
|
|
+ exampleDataList.add("JOB001");
|
|
|
|
+ heads.add("项目名称");
|
|
|
|
+ exampleDataList.add("示例项目");
|
|
|
|
+ heads.add("子项目名称");
|
|
|
|
+ exampleDataList.add("示例子项目");
|
|
|
|
+ heads.add("工作事项");
|
|
|
|
+ exampleDataList.add("进行模块一的设计工作");
|
|
|
|
+ heads.add("投入时长");
|
|
|
|
+ exampleDataList.add("8");
|
|
|
|
+ List<ReportCustom> reportCustomList = reportCustomMapper.selectList(new QueryWrapper<ReportCustom>().eq("company_id", companyId));
|
|
|
|
+ if(reportCustomList.size()>0){
|
|
|
|
+ reportCustomList.forEach(rl->{
|
|
|
|
+ heads.add(rl.getCustomName());
|
|
|
|
+ exampleDataList.add("自定义示例内容");
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ List<List<String>> allList = new ArrayList<>();
|
|
|
|
+ allList.add(heads);
|
|
|
|
+ allList.add(exampleDataList);
|
|
|
|
+ String title = company.getCompanyName()+"_员工工时导入模板";
|
|
|
|
+ /*msg.data = ExcelUtil.exportGeneralExcelByTitleAndList(fileName, allList, path);*/
|
|
|
|
+ //String result="系统提示:Excel文件导出成功!";
|
|
|
|
+ String result=MessageUtils.message("file.excelScu");
|
|
|
|
+ String fileName= title+".xlsx";
|
|
|
|
+ try {
|
|
|
|
+// response.reset();
|
|
|
|
+// response.setHeader("Content-disposition",
|
|
|
|
+// "attachment;filename="+ URLEncoder.encode(fileName, "UTF-8"));
|
|
|
|
+// //设置文件头编码格式
|
|
|
|
+// response.setContentType("APPLICATION/OCTET-STREAM;charset=UTF-8");//设置类型
|
|
|
|
+// response.setHeader("Cache-Control","no-cache");//设置头
|
|
|
|
+// response.setDateHeader("Expires", 0);//设置日期头
|
|
|
|
+ // 创建工作簿
|
|
|
|
+ HSSFWorkbook workBook = new HSSFWorkbook();
|
|
|
|
+ // 创建工作类
|
|
|
|
+ HSSFSheet sheet = workBook.createSheet();
|
|
|
|
+ //设置首行冻结
|
|
|
|
+ sheet.createFreezePane(0, 1);
|
|
|
|
+ sheet.setDefaultColumnWidth(16);
|
|
|
|
+ //设置字体样式
|
|
|
|
+ HSSFFont headFont = workBook.createFont();
|
|
|
|
+ headFont.setBold(true);
|
|
|
|
+ headFont.setFontHeightInPoints((short) 10);
|
|
|
|
+ headFont.setFontName("黑体");
|
|
|
|
+
|
|
|
|
+ HSSFFont titleFont = workBook.createFont();
|
|
|
|
+ titleFont.setBold(true);
|
|
|
|
+ titleFont.setFontHeightInPoints((short) 10);
|
|
|
|
+ titleFont.setFontName("黑体");
|
|
|
|
+
|
|
|
|
+ HSSFFont font = workBook.createFont();
|
|
|
|
+ font.setFontHeightInPoints((short) 10);
|
|
|
|
+ font.setFontName("宋体");
|
|
|
|
+
|
|
|
|
+ //设置单元格样式
|
|
|
|
+ CellStyle headStyle = workBook.createCellStyle();
|
|
|
|
+ headStyle.setFont(headFont);
|
|
|
|
+ headStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ headStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
|
|
|
|
+ headStyle.setWrapText(true);
|
|
|
|
+ headStyle.setBorderBottom(BorderStyle.THIN); //下边框
|
|
|
|
+ headStyle.setBorderLeft(BorderStyle.THIN);//左边框
|
|
|
|
+ headStyle.setBorderTop(BorderStyle.THIN);//上边框
|
|
|
|
+ headStyle.setBorderRight(BorderStyle.THIN);//右边框
|
|
|
|
+
|
|
|
|
+ String color = "c0c0c0"; //此处得到的color为16进制的字符串
|
|
|
|
+ //转为RGB码
|
|
|
|
+ int r = Integer.parseInt((color.substring(0,2)),16); //转为16进制
|
|
|
|
+ int g = Integer.parseInt((color.substring(2,4)),16);
|
|
|
|
+ int b = Integer.parseInt((color.substring(4,6)),16);
|
|
|
|
+
|
|
|
|
+ //自定义cell颜色
|
|
|
|
+ HSSFPalette palette = workBook.getCustomPalette();
|
|
|
|
+ //这里的9是索引
|
|
|
|
+ palette.setColorAtIndex((short)9, (byte) r, (byte) g, (byte) b);
|
|
|
|
+
|
|
|
|
+ CellStyle titleStyle = workBook.createCellStyle();
|
|
|
|
+ titleStyle.setFont(titleFont);
|
|
|
|
+ titleStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ titleStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
|
|
|
|
+ titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); //填充单元格
|
|
|
|
+ titleStyle.setFillForegroundColor((short)9); //填色
|
|
|
|
+ titleStyle.setWrapText(true);
|
|
|
|
+ titleStyle.setBorderBottom(BorderStyle.THIN); //下边框
|
|
|
|
+ titleStyle.setBorderLeft(BorderStyle.THIN);//左边框
|
|
|
|
+ titleStyle.setBorderTop(BorderStyle.THIN);//上边框
|
|
|
|
+ titleStyle.setBorderRight(BorderStyle.THIN);//右边框
|
|
|
|
+
|
|
|
|
+ CellStyle cellStyle = workBook.createCellStyle();
|
|
|
|
+ cellStyle.setFont(font);
|
|
|
|
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ cellStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
|
|
|
|
+ cellStyle.setWrapText(true);
|
|
|
|
+ cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
|
|
|
|
+ cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
|
|
|
|
+ cellStyle.setBorderTop(BorderStyle.THIN);//上边框
|
|
|
|
+ cellStyle.setBorderRight(BorderStyle.THIN);//右边框
|
|
|
|
+
|
|
|
|
+ if(allList.size() > 0) {
|
|
|
|
+ //标题(如果需要在EXCEL内容最上面加标题,请打开下面的注释,修改start)
|
|
|
|
+ /*
|
|
|
|
+ HSSFRow titleRow = sheet.createRow(0);
|
|
|
|
+ titleRow.setHeightInPoints(30);
|
|
|
|
+ HSSFCell titleCell = titleRow.createCell(0);
|
|
|
|
+ titleCell.setCellStyle(headStyle);
|
|
|
|
+ titleCell.setCellValue(title);
|
|
|
|
+ //合并单元格
|
|
|
|
+ CellRangeAddress cellRangeAddress = new CellRangeAddress(0,0,0, list.get(0).size() - 1);
|
|
|
|
+ //加入合并单元格对象
|
|
|
|
+ sheet.addMergedRegion(cellRangeAddress);
|
|
|
|
+ //使用RegionUtil类为合并后的单元格添加边框
|
|
|
|
+ RegionUtil.setBorderBottom(BorderStyle.THIN, cellRangeAddress, sheet); // 下边框
|
|
|
|
+ RegionUtil.setBorderLeft(BorderStyle.THIN, cellRangeAddress, sheet); // 左边框
|
|
|
|
+ RegionUtil.setBorderRight(BorderStyle.THIN, cellRangeAddress, sheet); // 有边框
|
|
|
|
+ RegionUtil.setBorderTop(BorderStyle.THIN, cellRangeAddress, sheet); // 上边框
|
|
|
|
+ */
|
|
|
|
+ int start = 0;
|
|
|
|
+ for(List<String> rowList : allList) {
|
|
|
|
+ HSSFRow row = sheet.createRow(start);
|
|
|
|
+ row.setHeightInPoints(24);
|
|
|
|
+ for(int i = 0; i < rowList.size(); i++) {
|
|
|
|
+ HSSFCell cell = row.createCell(i);
|
|
|
|
+ ClientAnchor anchor = new HSSFClientAnchor();
|
|
|
|
+ if(start == 0) {
|
|
|
|
+ cell.setCellStyle(titleStyle);
|
|
|
|
+ // 关键修改
|
|
|
|
+ anchor.setDx1(0);
|
|
|
|
+ anchor.setDx2(0);
|
|
|
|
+ anchor.setDy1(0);
|
|
|
|
+ anchor.setDy2(0);
|
|
|
|
+ anchor.setCol1(cell.getColumnIndex());
|
|
|
|
+ anchor.setRow1(cell.getRowIndex());
|
|
|
|
+ anchor.setCol2(cell.getColumnIndex() + 5);
|
|
|
|
+ anchor.setRow2(cell.getRowIndex() + 6);
|
|
|
|
+ // 结束
|
|
|
|
+ Drawing drawing = sheet.createDrawingPatriarch();
|
|
|
|
+ Comment comment = null;
|
|
|
|
+ String[] textList=null;
|
|
|
|
+ DVConstraint constraint =null;
|
|
|
|
+ CellRangeAddressList regions =null;
|
|
|
|
+ HSSFDataValidation data_validation_list =null;
|
|
|
|
+ switch (rowList.get(i)){
|
|
|
|
+ case "日期":
|
|
|
|
+ // 输入批注信息
|
|
|
|
+ comment = drawing.createCellComment(anchor);
|
|
|
|
+ // 输入批注信息
|
|
|
|
+ //comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
|
|
+ // "例如: 2021-01-01"));
|
|
|
|
+ comment.setString(new HSSFRichTextString(MessageUtils.message("excel.dateFormat")+"\n" +
|
|
|
|
+ MessageUtils.message("excel.forExample")));
|
|
|
|
+ cell.setCellComment(comment);
|
|
|
|
+ break;
|
|
|
|
+ case "员工工号":
|
|
|
|
+ // 输入批注信息
|
|
|
|
+ comment = drawing.createCellComment(anchor);
|
|
|
|
+ // 输入批注信息
|
|
|
|
+ //comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
|
|
+ // "例如: 2021-01-01"));
|
|
|
|
+ comment.setString(new HSSFRichTextString("员工存在重名情况下,必填"));
|
|
|
|
+ cell.setCellComment(comment);
|
|
|
|
+ break;
|
|
|
|
+ case "子项目名称":
|
|
|
|
+ // 输入批注信息
|
|
|
|
+ comment = drawing.createCellComment(anchor);
|
|
|
|
+ // 输入批注信息
|
|
|
|
+ //comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
|
|
+ // "例如: 2021-01-01"));
|
|
|
|
+ comment.setString(new HSSFRichTextString("项目下的子项目,没有可以不填"));
|
|
|
|
+ cell.setCellComment(comment);
|
|
|
|
+ break;
|
|
|
|
+ case "投入时长":
|
|
|
|
+ // 输入批注信息
|
|
|
|
+ comment = drawing.createCellComment(anchor);
|
|
|
|
+ // 输入批注信息
|
|
|
|
+ //comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
|
|
+ // "例如: 2021-01-01"));
|
|
|
|
+ comment.setString(new HSSFRichTextString("填写当天在该项目上投入的工作时长,填写数字;单位为小时"));
|
|
|
|
+ cell.setCellComment(comment);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
|
+ }
|
|
|
|
+ cell.setCellValue(rowList.get(i));
|
|
|
|
+ }
|
|
|
|
+ start++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //用于非传统ajax;
|
|
|
|
+// String headStr = "attachment; filename=\"" + fileName + "\"";
|
|
|
|
+// response.setContentType("APPLICATION/OCTET-STREAM");//返回格式为流
|
|
|
|
+// response.setHeader("Content-Disposition", headStr);
|
|
|
|
+// //普通下载不需要以上三行,注掉即可
|
|
|
|
+// OutputStream os = response.getOutputStream();//在线下载
|
|
|
|
+ File dir = null;
|
|
|
|
+ dir = new File(path);
|
|
|
|
+ // D://cloud/upload 文件上传后所存储的位置,部署到服务器上时配置服务器地址即可
|
|
|
|
+ if (!dir.exists()) {
|
|
|
|
+ dir.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ FileOutputStream os = new FileOutputStream(path+fileName);//保存到本地
|
|
|
|
+ workBook.write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ os.close();
|
|
|
|
+ }catch(Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ //msg.setError("已存在模板名称为["+fileName+"]的文件,请删除后重新下载");
|
|
|
|
+ msg.setError(MessageUtils.message("file.duplicateTemplate",fileName));
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ msg.data= "/upload/"+fileName;
|
|
|
|
+ return msg;
|
|
|
|
+// return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static boolean isValidDate(String s) {
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ dateFormat.parse(s);
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|