|
@@ -56,7 +56,6 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.*;
|
|
import java.time.*;
|
|
|
import java.time.chrono.ChronoLocalDate;
|
|
import java.time.chrono.ChronoLocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.time.format.DateTimeFormatterBuilder;
|
|
|
|
|
import java.time.format.DateTimeParseException;
|
|
import java.time.format.DateTimeParseException;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
import java.time.temporal.TemporalAdjusters;
|
|
@@ -67,7 +66,6 @@ import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -512,7 +510,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//针对柘中,增加重新设置customText
|
|
//针对柘中,增加重新设置customText
|
|
|
- if (companyId == 4811 || companyId == 10) {
|
|
|
|
|
|
|
+ if (companyId == 4811) {
|
|
|
List<ConstructionStage> stageList = constructionStageMapper.selectList(new QueryWrapper<ConstructionStage>());
|
|
List<ConstructionStage> stageList = constructionStageMapper.selectList(new QueryWrapper<ConstructionStage>());
|
|
|
for (Map map : nameList) {
|
|
for (Map map : nameList) {
|
|
|
List<Map<String, Object>> reportList = (List<Map<String, Object>>) map.get("data");
|
|
List<Map<String, Object>> reportList = (List<Map<String, Object>>) map.get("data");
|
|
@@ -947,11 +945,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
r.setMultiDegrIdList(list);
|
|
r.setMultiDegrIdList(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (companyId == 10 || companyId == 4811) {
|
|
|
|
|
|
|
+ if (companyId == 4811) {
|
|
|
List<ReportProjectConstruction> rpcList = reportProjectConstructionMapper.selectList(new QueryWrapper<ReportProjectConstruction>().eq("report_id", r.getId()));
|
|
List<ReportProjectConstruction> rpcList = reportProjectConstructionMapper.selectList(new QueryWrapper<ReportProjectConstruction>().eq("report_id", r.getId()));
|
|
|
- for (ReportProjectConstruction rpc : rpcList) {
|
|
|
|
|
- System.out.println(rpc.getConstructionStageId()+", "+rpc.getFinishNumber());
|
|
|
|
|
- }
|
|
|
|
|
List<ProjectConstructionStage> projectConstructionStageList = projectConstructionStageMapper.selectList(new QueryWrapper<ProjectConstructionStage>().eq("project_id", r.getProjectId()));
|
|
List<ProjectConstructionStage> projectConstructionStageList = projectConstructionStageMapper.selectList(new QueryWrapper<ProjectConstructionStage>().eq("project_id", r.getProjectId()));
|
|
|
for (ProjectConstructionStage stage : projectConstructionStageList) {
|
|
for (ProjectConstructionStage stage : projectConstructionStageList) {
|
|
|
if (rpcList.size() > 0) {
|
|
if (rpcList.size() > 0) {
|
|
@@ -979,10 +974,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
}
|
|
|
showRefresh = true;
|
|
showRefresh = true;
|
|
|
}else if(timeType.getSyncFanwei()==1){
|
|
}else if(timeType.getSyncFanwei()==1){
|
|
|
- System.out.println("获取泛微考勤==="+date+", userId="+userId);
|
|
|
|
|
List<UserFvTime> userFvTimeList = userFvTimeMapper.selectList(new QueryWrapper<UserFvTime>()
|
|
List<UserFvTime> userFvTimeList = userFvTimeMapper.selectList(new QueryWrapper<UserFvTime>()
|
|
|
.eq("user_id", userId).eq("work_date", date));
|
|
.eq("user_id", userId).eq("work_date", date));
|
|
|
- System.out.println("userFvTimeList:"+userFvTimeList.size());
|
|
|
|
|
if (userFvTimeList.size() > 0) {
|
|
if (userFvTimeList.size() > 0) {
|
|
|
UserFvTime time = userFvTimeList.get(0);
|
|
UserFvTime time = userFvTimeList.get(0);
|
|
|
resultMap.put("time", time);
|
|
resultMap.put("time", time);
|
|
@@ -1005,6 +998,15 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
showRefresh = true;
|
|
showRefresh = true;
|
|
|
}
|
|
}
|
|
|
resultMap.put("showRefresh", showRefresh);
|
|
resultMap.put("showRefresh", showRefresh);
|
|
|
|
|
+ if (company.getPackageOvertime() == 1) {
|
|
|
|
|
+ //有加班申请模块
|
|
|
|
|
+ Overtime overtime = overtimeMapper.selectOne(new QueryWrapper<Overtime>()
|
|
|
|
|
+ .select("user_id, sum(duration) as duration").eq("user_id", userId).eq("date", date).ne("status", -1).ne("status", 3));
|
|
|
|
|
+ if (overtime != null) {
|
|
|
|
|
+ //将秒转化为小时显示
|
|
|
|
|
+ resultMap.put("overtime", DateTimeUtil.getHoursFromSeconds(overtime.getDuration()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//顺便返回公司的工作时间设置
|
|
//顺便返回公司的工作时间设置
|
|
|
resultMap.put("timeType",timeType);
|
|
resultMap.put("timeType",timeType);
|
|
@@ -1481,10 +1483,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
//批量新增或更新
|
|
//批量新增或更新
|
|
|
if (reportList.size() > 0) {
|
|
if (reportList.size() > 0) {
|
|
|
reportService.saveOrUpdateBatch(reportList);
|
|
reportService.saveOrUpdateBatch(reportList);
|
|
|
- System.out.println("打印日报主键:");
|
|
|
|
|
- for (Report r : reportList) {
|
|
|
|
|
- System.out.println("reportId==========="+r.getId());
|
|
|
|
|
- }
|
|
|
|
|
//成都明夷电子,需要生成批量记录
|
|
//成都明夷电子,需要生成批量记录
|
|
|
Company company = companyMapper.selectById(companyId);
|
|
Company company = companyMapper.selectById(companyId);
|
|
|
if (company.getCompanyName().equals("成都明夷电子科技股份有限公司") || timeType.getEnableNewWeeklyfill() == 1 || timeType.getWeeklyChargeFilter() == 1) {//物奇需要填写周总结
|
|
if (company.getCompanyName().equals("成都明夷电子科技股份有限公司") || timeType.getEnableNewWeeklyfill() == 1 || timeType.getWeeklyChargeFilter() == 1) {//物奇需要填写周总结
|
|
@@ -1701,7 +1699,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//存储日报中的施工节点完成数量,并更新柘中的项目的完成度
|
|
//存储日报中的施工节点完成数量,并更新柘中的项目的完成度
|
|
|
- if (companyId == 10 || companyId == 4811) {
|
|
|
|
|
|
|
+ if (companyId == 4811) {
|
|
|
List<ReportProjectConstruction> rpcList = new ArrayList<>();
|
|
List<ReportProjectConstruction> rpcList = new ArrayList<>();
|
|
|
//先删除,当天该员工的rpc记录
|
|
//先删除,当天该员工的rpc记录
|
|
|
String creatorId = reportList.get(0).getCreatorId();
|
|
String creatorId = reportList.get(0).getCreatorId();
|
|
@@ -1783,6 +1781,96 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //保存日报的记录(提交和审核通过)
|
|
|
|
|
+ private void saveReportWithAuditLog(List<User> userList, List<Report> reportList) {
|
|
|
|
|
+ if (reportList.size() == 0) return;
|
|
|
|
|
+ Report r = reportList.get(0);
|
|
|
|
|
+ List<ReportLog> addLogList = new ArrayList<>();
|
|
|
|
|
+ List<ReportLogDetail> addLogDetailList = new ArrayList<>();
|
|
|
|
|
+ Integer companyId = r.getCompanyId();
|
|
|
|
|
+ //合并提交和审核的记录
|
|
|
|
|
+ List<Report> mergeList = new ArrayList<>();
|
|
|
|
|
+ for (Report report : reportList) {
|
|
|
|
|
+ Report exists = mergeList.stream().filter(m -> m.getCreatorId().equals(report.getCreatorId()) && m.getCreateDate().isEqual(report.getCreateDate())).findFirst().orElse(null);
|
|
|
|
|
+ if (exists != null) {
|
|
|
|
|
+ exists.setContent(exists.getContent() + "," + report.getId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ report.setContent(report.getId()+"");
|
|
|
|
|
+ mergeList.add(report);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (Report report : mergeList) {
|
|
|
|
|
+ //删除老的记录
|
|
|
|
|
+ reportLogMapper.delete(new QueryWrapper<ReportLog>().eq("company_id", r.getCompanyId()).eq("creator_id", report.getCreatorId())
|
|
|
|
|
+ .eq("create_date", report.getCreateDate()));
|
|
|
|
|
+
|
|
|
|
|
+ //提交记录
|
|
|
|
|
+ ReportLog log = new ReportLog();
|
|
|
|
|
+ String creatorId = report.getCreatorId();
|
|
|
|
|
+ log.setCreatorId(report.getCreatorId());
|
|
|
|
|
+ log.setCreateDate(report.getCreateDate());
|
|
|
|
|
+ log.setOperateDate(report.getCreateTime());
|
|
|
|
|
+ log.setReportIds(report.getContent());
|
|
|
|
|
+ log.setOperatorId(report.getCreatorId());
|
|
|
|
|
+
|
|
|
|
|
+ ReportLogDetail detail = new ReportLogDetail();
|
|
|
|
|
+ detail.setWorkDate(log.getCreateDate());
|
|
|
|
|
+ detail.setReportId(report.getId());
|
|
|
|
|
+ detail.setCompanyId(companyId);
|
|
|
|
|
+ detail.setOperateDate(report.getCreateTime());
|
|
|
|
|
+
|
|
|
|
|
+ Optional<User> first = userList.stream().filter(u -> u.getId().equals(creatorId)).findFirst();
|
|
|
|
|
+ String reportOwner = "";
|
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
|
+ reportOwner = first.get().getName();
|
|
|
|
|
+ }
|
|
|
|
|
+ //日报提交记录
|
|
|
|
|
+ String msg = MessageUtils.message("profession.submit",reportOwner);
|
|
|
|
|
+ log.setMsg(msg);
|
|
|
|
|
+ log.setCompanyId(companyId);
|
|
|
|
|
+ addLogList.add(log);
|
|
|
|
|
+
|
|
|
|
|
+ detail.setOperatorId(log.getOperatorId());
|
|
|
|
|
+ detail.setOperateDate(log.getOperateDate());
|
|
|
|
|
+ detail.setMsg(log.getMsg());
|
|
|
|
|
+
|
|
|
|
|
+ addLogDetailList.add(detail);
|
|
|
|
|
+
|
|
|
|
|
+ //审核记录
|
|
|
|
|
+ if (report.getProjectAuditorId() != null) {
|
|
|
|
|
+ String auditorId = report.getProjectAuditorId();
|
|
|
|
|
+ log = new ReportLog();
|
|
|
|
|
+ log.setCreatorId(report.getCreatorId());
|
|
|
|
|
+ log.setCreateDate(report.getCreateDate());
|
|
|
|
|
+ log.setOperateDate(report.getProjectAuditTime());
|
|
|
|
|
+ log.setReportIds(report.getContent());
|
|
|
|
|
+ log.setOperatorId(report.getProjectAuditorId());
|
|
|
|
|
+
|
|
|
|
|
+ detail = new ReportLogDetail();
|
|
|
|
|
+ detail.setWorkDate(log.getCreateDate());
|
|
|
|
|
+ detail.setReportId(report.getId());
|
|
|
|
|
+ detail.setCompanyId(companyId);
|
|
|
|
|
+ User auditorUser = userList.stream().filter(u -> u.getId().equals(auditorId)).findFirst().orElse(null);
|
|
|
|
|
+ if (auditorUser != null) {
|
|
|
|
|
+ //日报审核
|
|
|
|
|
+ log.setMsg(auditorUser.getName() + "审核通过了日报");
|
|
|
|
|
+ log.setCompanyId(companyId);
|
|
|
|
|
+ addLogList.add(log);
|
|
|
|
|
+
|
|
|
|
|
+ detail.setOperatorId(log.getOperatorId());
|
|
|
|
|
+ detail.setOperateDate(log.getOperateDate());
|
|
|
|
|
+ detail.setMsg(log.getMsg());
|
|
|
|
|
+ addLogDetailList.add(detail);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ reportLogService.saveBatch(addLogList);
|
|
|
|
|
+ //详细保存
|
|
|
|
|
+ reportLogDetailService.saveBatch(addLogDetailList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//保存提交日报的记录
|
|
//保存提交日报的记录
|
|
|
private void saveFillReportLog(List<Report> reportList) {
|
|
private void saveFillReportLog(List<Report> reportList) {
|
|
|
if (reportList.size() == 0) return;
|
|
if (reportList.size() == 0) return;
|
|
@@ -2001,7 +2089,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
}
|
|
|
reportDeleteService.saveOrUpdateBatch(delList);
|
|
reportDeleteService.saveOrUpdateBatch(delList);
|
|
|
//更新项目施工进度
|
|
//更新项目施工进度
|
|
|
- if (company.getId() == 10 || company.getId() == 4811) {
|
|
|
|
|
|
|
+ if (company.getId() == 4811) {
|
|
|
List<ReportProjectConstruction> rpcList = new ArrayList<>();
|
|
List<ReportProjectConstruction> rpcList = new ArrayList<>();
|
|
|
//先删除,当天该员工的rpc记录
|
|
//先删除,当天该员工的rpc记录
|
|
|
String creatorId = reportList.get(0).getCreatorId();
|
|
String creatorId = reportList.get(0).getCreatorId();
|
|
@@ -2547,7 +2635,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//针对柘中的施工节点进度显示
|
|
//针对柘中的施工节点进度显示
|
|
|
- if (companyId == 10 || companyId == 4811) {
|
|
|
|
|
|
|
+ if (companyId == 4811) {
|
|
|
changeCustomText(auditReportList);
|
|
changeCustomText(auditReportList);
|
|
|
List<ConstructionStage> stageList = constructionStageMapper.selectList(new QueryWrapper<ConstructionStage>());
|
|
List<ConstructionStage> stageList = constructionStageMapper.selectList(new QueryWrapper<ConstructionStage>());
|
|
|
for (Map map : nameList) {
|
|
for (Map map : nameList) {
|
|
@@ -7995,7 +8083,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (curUser.getDepartmentId() != null && curUser.getDepartmentId() != 0) {
|
|
if (curUser.getDepartmentId() != null && curUser.getDepartmentId() != 0) {
|
|
|
- noRecord.department = departmentList.stream().filter(d->d.getDepartmentId().equals(curUser.getDepartmentId())).findFirst().get().getDepartmentName();
|
|
|
|
|
|
|
+ noRecord.department = departmentList.stream().filter(d->d.getDepartmentId().equals(curUser.getDepartmentId())).findFirst().orElse(new Department().setDepartmentName("无")).getDepartmentName();
|
|
|
} else {
|
|
} else {
|
|
|
//noRecord.department = "无";
|
|
//noRecord.department = "无";
|
|
|
noRecord.department = MessageUtils.message("entry.none");
|
|
noRecord.department = MessageUtils.message("entry.none");
|
|
@@ -14888,6 +14976,322 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public HttpRespMsg importNewDataXiHe(Integer companyId, MultipartFile multipartFile, HttpServletRequest request) {
|
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
|
|
+ //然后处理文件
|
|
|
|
|
+ String fileName = multipartFile.getOriginalFilename();
|
|
|
|
|
+ File file = new File(fileName == null ? "file" : fileName);
|
|
|
|
|
+ InputStream inputStream = null;
|
|
|
|
|
+ OutputStream outputStream = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ inputStream = multipartFile.getInputStream();
|
|
|
|
|
+ outputStream = new FileOutputStream(file);
|
|
|
|
|
+ byte[] buffer = new byte[4096];
|
|
|
|
|
+ int temp = 0;
|
|
|
|
|
+ while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
|
|
|
|
|
+ outputStream.write(buffer, 0, temp);
|
|
|
|
|
+ }
|
|
|
|
|
+ inputStream.close();
|
|
|
|
|
+ outputStream.close();
|
|
|
|
|
+ //然后解析表格
|
|
|
|
|
+ Workbook workbook = WorkbookFactory.create(new FileInputStream(file));
|
|
|
|
|
+
|
|
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/M/d");
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/M/d");
|
|
|
|
|
+ SimpleDateFormat timeSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
|
+ DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
|
|
+ SimpleDateFormat createTimeFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ DateTimeFormatter createTimeFormatterLocal = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ //获取公司全部成员
|
|
|
|
|
+ List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
|
+ //由于第一行需要指明列对应的标题
|
|
|
|
|
+ int rowNum = sheet.getLastRowNum();
|
|
|
|
|
+ if (rowNum == 0) {
|
|
|
|
|
+ //msg.setError("请填写工时数据");
|
|
|
|
|
+ msg.setError(MessageUtils.message("report.data"));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Project> allProjectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
|
|
|
+ List<Report> reportList = new ArrayList<>();
|
|
|
|
|
+ List<String> userNameList=new ArrayList<>();
|
|
|
|
|
+ for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
|
|
|
+ Row row = sheet.getRow(rowIndex);
|
|
|
|
|
+ if (row == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ExcelUtil.isRowEmpty(row)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //设置字符格式,防止纯数字工号读取时报错
|
|
|
|
|
+ row.getCell(7).setCellType(CellType.STRING);
|
|
|
|
|
+ String username = row.getCell(7).getStringCellValue().trim();
|
|
|
|
|
+
|
|
|
|
|
+ if (rowIndex == 0) {
|
|
|
|
|
+ if(username.equals("填写人")){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!userNameList.contains(username)&&!username.equals("")){
|
|
|
|
|
+ System.out.println("读取到填写人:" + username);
|
|
|
|
|
+ userNameList.add(username);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
|
+ List<User> targetUserList=new ArrayList<>();
|
|
|
|
|
+ HttpRespMsg respMsg=new HttpRespMsg();
|
|
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
|
|
|
|
|
+ System.out.println("参与搜素的人员列表"+userNameList + userNameList.size());
|
|
|
|
|
+ respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
|
|
|
|
|
+ if(respMsg.code.equals("0")){
|
|
|
|
|
+ msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }
|
|
|
|
|
+ targetUserList= (List<User>) respMsg.data;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //下标从0开始
|
|
|
|
|
+ int dataCount = 0;
|
|
|
|
|
+ for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
|
|
|
|
|
+ Row row = sheet.getRow(rowIndex);
|
|
|
|
|
+ if (row == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ExcelUtil.isRowEmpty(row)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (rowIndex > 0) {
|
|
|
|
|
+ dataCount++;
|
|
|
|
|
+ //数据行
|
|
|
|
|
+ if (row.getCell(0) == null) {
|
|
|
|
|
+ //msg.setError("第"+dataCount+"行缺少日期");
|
|
|
|
|
+ msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (int i=0;i<=10;i++) {
|
|
|
|
|
+ if (i != 6 && row.getCell(i) != null && i != 9 && i != 10) {
|
|
|
|
|
+ row.getCell(i).setCellType(CellType.STRING);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean isDateFormat = row.getCell(6).getCellTypeEnum() == CellType.NUMERIC;
|
|
|
|
|
+ String reportDate = isDateFormat?sdf.format(row.getCell(6).getDateCellValue()):row.getCell(6).getStringCellValue();
|
|
|
|
|
+ if (StringUtils.isEmpty(reportDate)) {
|
|
|
|
|
+ //msg.setError("第"+dataCount+"行缺少日期");
|
|
|
|
|
+ msg.setError(MessageUtils.message("data.NullErrorByRow",dataCount));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }
|
|
|
|
|
+ String jobNumber = row.getCell(8) != null?row.getCell(8).getStringCellValue().trim():null;
|
|
|
|
|
+// if (StringUtils.isEmpty(jobNumber)) {
|
|
|
|
|
+// msg.setError("员工工号不能为空");
|
|
|
|
|
+// return msg;
|
|
|
|
|
+// }
|
|
|
|
|
+// //检查人员是否存在
|
|
|
|
|
+// Optional<User> any = allUserList.stream().filter(u -> (u.getJobNumber()!=null&&u.getJobNumber().equals(jobNumber))).sorted(new Comparator<User>() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public int compare(User o1, User o2) {
|
|
|
|
|
+// return o1.getIsActive() > o2.getIsActive() ? -1 : 1;
|
|
|
|
|
+// }
|
|
|
|
|
+// }).findAny();
|
|
|
|
|
+// if (!any.isPresent()) {
|
|
|
|
|
+// //msg.setError("人员["+username+"]不存在,请先在组织结构中添加或者通过钉钉同步导入");
|
|
|
|
|
+// msg.setError("工号:" + jobNumber + "不存在,请在系统组织架构中完善");
|
|
|
|
|
+// return msg;
|
|
|
|
|
+// }
|
|
|
|
|
+// User reportCreator = any.get();
|
|
|
|
|
+ String username = row.getCell(7).getStringCellValue().trim();
|
|
|
|
|
+ //检查人员是否存在
|
|
|
|
|
+ Optional<User> any;
|
|
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(username)).findFirst();
|
|
|
|
|
+ any = allUserList.stream().filter(u -> u.getName().equals(username)||(u.getJobNumber()!=null&&u.getJobNumber().equals(jobNumber))||(optional.isPresent()&&((u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))||(u.getDingdingUserid()!=null&&u.getDingdingUserid().equals(optional.get().getCorpwxUserid()))))).sorted(new Comparator<User>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(User o1, User o2) {
|
|
|
|
|
+ return o1.getIsActive() > o2.getIsActive() ? -1 : 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }).findAny();
|
|
|
|
|
+ if (!any.isPresent()) {
|
|
|
|
|
+ //msg.setError("人员["+username+"]不存在,请先在组织结构中添加或者通过钉钉同步导入");
|
|
|
|
|
+ msg.setError("人员["+username+"]不存在,请先在组织结构中同步导入");
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }
|
|
|
|
|
+ User reportCreator = any.get();
|
|
|
|
|
+ String pCode = row.getCell(0)==null?null:row.getCell(0).getStringCellValue();
|
|
|
|
|
+ String pName = row.getCell(1)==null?null:row.getCell(1).getStringCellValue();
|
|
|
|
|
+ Project project = null;
|
|
|
|
|
+ if (StringUtils.isEmpty(pCode) && StringUtils.isEmpty(pName)) {
|
|
|
|
|
+ msg.setError("项目编码和名称至少填写一项");
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ } else if (!StringUtils.isEmpty(pCode)) {
|
|
|
|
|
+ //优先按编码匹配
|
|
|
|
|
+ Optional<Project> first = allProjectList.stream().filter(p -> pCode.equals(p.getProjectCode())).findFirst();
|
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
|
+ project = first.get();
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (!StringUtils.isEmpty(pName)) {
|
|
|
|
|
+ Optional<Project> first = allProjectList.stream().filter(p -> pName.equals(p.getProjectName())).findFirst();
|
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
|
+ project = first.get();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (project == null) {
|
|
|
|
|
+ msg.setError(MessageUtils.message("project.noExist","编码:"+pCode+"/名称:"+pName));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String workContent = row.getCell(2) == null?null:row.getCell(2).getStringCellValue();
|
|
|
|
|
+ if (!StringUtils.isEmpty(workContent)) {
|
|
|
|
|
+ workContent = workContent.trim();
|
|
|
|
|
+ }
|
|
|
|
|
+ double time = 0;
|
|
|
|
|
+ String timeCell = row.getCell(3) == null?null:row.getCell(3).getStringCellValue();
|
|
|
|
|
+ if (!StringUtils.isEmpty(timeCell)) {
|
|
|
|
|
+ timeCell = timeCell.replace("H", "");
|
|
|
|
|
+ time = Double.parseDouble(timeCell);
|
|
|
|
|
+ }
|
|
|
|
|
+ String overtimeCell = row.getCell(4) == null?null:row.getCell(4).getStringCellValue();
|
|
|
|
|
+ Integer isOvertime = 0;
|
|
|
|
|
+ if (!StringUtils.isEmpty(overtimeCell)) {
|
|
|
|
|
+ overtimeCell = overtimeCell.replace("H", "");
|
|
|
|
|
+ isOvertime = overtimeCell.equals("正常工时")?1:0;
|
|
|
|
|
+ }
|
|
|
|
|
+ String isAbnormal = row.getCell(5) == null?null:row.getCell(5).getStringCellValue();
|
|
|
|
|
+ Integer extraField1 = "正常".equals(isAbnormal)? 0 : 1;
|
|
|
|
|
+ String finishTime = null;
|
|
|
|
|
+ if (row.getCell(9) == null) {
|
|
|
|
|
+ //完成时间没有,按当前时间作为完成时间
|
|
|
|
|
+ finishTime = timeSdf.format(new Date());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ isDateFormat = row.getCell(9).getCellTypeEnum() == CellType.NUMERIC;
|
|
|
|
|
+ finishTime = isDateFormat?timeSdf.format(row.getCell(9).getDateCellValue()):row.getCell(9).getStringCellValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(finishTime)) {
|
|
|
|
|
+ finishTime = timeSdf.format(new Date());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ isDateFormat = row.getCell(10).getCellTypeEnum() == CellType.NUMERIC;
|
|
|
|
|
+ String createTime = isDateFormat?createTimeFormatter.format(row.getCell(10).getDateCellValue()):row.getCell(10).getStringCellValue();
|
|
|
|
|
+
|
|
|
|
|
+ if (time >= 0) {
|
|
|
|
|
+ Report report = new Report();
|
|
|
|
|
+ report.setCreateDate(LocalDate.parse(reportDate, dtf));
|
|
|
|
|
+ report.setCompanyId(companyId);
|
|
|
|
|
+ report.setCreatorId(reportCreator.getId());
|
|
|
|
|
+ report.setDeptId(reportCreator.getDepartmentId());
|
|
|
|
|
+ report.setProjectId(project.getId());
|
|
|
|
|
+ report.setReportTimeType(1);
|
|
|
|
|
+ report.setWorkingTime(time);
|
|
|
|
|
+ report.setMultiWorktime(timeType.getMultiWorktime());
|
|
|
|
|
+ report.setContent(workContent);
|
|
|
|
|
+ report.setIsOvertime(isOvertime);
|
|
|
|
|
+ if (isOvertime == 1) {
|
|
|
|
|
+ report.setOvertimeHours(report.getWorkingTime());
|
|
|
|
|
+ }
|
|
|
|
|
+ report.setExtraField1(extraField1);
|
|
|
|
|
+ report.setProjectAuditState(1);
|
|
|
|
|
+ if (reportCreator.getDepartmentId() != null) {
|
|
|
|
|
+ Department dept = departmentList.stream().filter(dept2->dept2.getDepartmentId().equals(reportCreator.getDepartmentId())).findFirst().orElse(null);
|
|
|
|
|
+ if (dept != null) {
|
|
|
|
|
+ report.setProjectAuditorId(dept.getManagerId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ report.setProjectAuditTime(LocalDateTime.parse(finishTime, timeFormatter));
|
|
|
|
|
+ report.setCreateTime(LocalDateTime.parse(createTime, createTimeFormatterLocal));
|
|
|
|
|
+ report.setState(1);//直接设置为通过
|
|
|
|
|
+
|
|
|
|
|
+ report.setCreateDate(LocalDate.parse(reportDate, dtf));
|
|
|
|
|
+ report.setCost(reportCreator.getCost()==null?new BigDecimal(0) : reportCreator.getCost().multiply(new BigDecimal(time)));
|
|
|
|
|
+ reportList.add(report);
|
|
|
|
|
+ } else if (time < 0) {
|
|
|
|
|
+ msg.setError("第" + dataCount + "行工时为负数");
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (reportList.size() > 0) {
|
|
|
|
|
+ int shouldSkipPassData = 0;
|
|
|
|
|
+ //依赖于对是否需要部门审核的判断,如果不需要则认为导入的就是审核通过的,重新导入就直接覆盖之前的。
|
|
|
|
|
+ reportMapper.deleteUserSameDayReport(companyId, reportList, shouldSkipPassData);
|
|
|
|
|
+ //存储
|
|
|
|
|
+ if (reportList.size() == 0) {
|
|
|
|
|
+ //全部是重复的,本次没有需要导入的
|
|
|
|
|
+ //msg.setError("本次数据全部已审核通过,无法导入。");
|
|
|
|
|
+ msg.setError(MessageUtils.message("finance.importErrorByAllAdopt"));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ reportService.saveBatch(reportList);
|
|
|
|
|
+ saveReportWithAuditLog(allUserList, reportList);
|
|
|
|
|
+ msg.data = dataCount;
|
|
|
|
|
+ String originName = fileName;
|
|
|
|
|
+ //定义一个独立的文件夹
|
|
|
|
|
+ String importFolder = "report_import";
|
|
|
|
|
+ File dir = new File(path, importFolder);
|
|
|
|
|
+ if (!dir.exists()) {
|
|
|
|
|
+ dir.mkdir();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String[] names = originName.split("\\.");
|
|
|
|
|
+ String destFileName = names[0] + "_"+System.currentTimeMillis()+"."+names[1];
|
|
|
|
|
+ File destFile = new File(dir, destFileName);
|
|
|
|
|
+ FileUtils.copyFile(file, destFile);
|
|
|
|
|
+ ReportImportLog log = new ReportImportLog();
|
|
|
|
|
+ log.setCompanyId(user.getCompanyId());
|
|
|
|
|
+ log.setFileName(originName);
|
|
|
|
|
+ log.setServerName(importFolder+"/"+destFileName);
|
|
|
|
|
+ log.setUserId(user.getId());
|
|
|
|
|
+ log.setUserName(user.getName());
|
|
|
|
|
+ reportImportLogMapper.insert(log);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //msg.setError("工时数据不能为空");
|
|
|
|
|
+ msg.setError(MessageUtils.message("report.dataNullError"));
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ //msg.setError("文件处理出错");
|
|
|
|
|
+ msg.setError(MessageUtils.message("file.error"));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ } catch (NullPointerException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ //msg.setError("数据格式有误或存在空数据 导入失败");
|
|
|
|
|
+ msg.setError(MessageUtils.message("file.dataFormatError"));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }catch (InvalidFormatException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ //msg.setError("文件格式错误,如果安装了加密软件需要先解密再上传");
|
|
|
|
|
+ msg.setError(MessageUtils.message("file.FormatErrorAndDecrypt"));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }catch (EncryptedDocumentException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ //msg.setError("文件加密状态,需要先解除加密状态再上传");
|
|
|
|
|
+ msg.setError(MessageUtils.message("file.encryption"));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ //msg.setError("发生其他错误:"+e.getMessage());
|
|
|
|
|
+ msg.setError(MessageUtils.message("other.errorByParameter",e.getMessage()));
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ //关闭流
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (outputStream != null && inputStream != null) {
|
|
|
|
|
+ outputStream.close();
|
|
|
|
|
+ inputStream.close();
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ file.delete();
|
|
|
|
|
+ }
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public String getWeek(DayOfWeek dayOfWeek){
|
|
public String getWeek(DayOfWeek dayOfWeek){
|
|
|
//获取中文形式的星期几
|
|
//获取中文形式的星期几
|
|
|
String dayOfWeekChinese = "";
|
|
String dayOfWeekChinese = "";
|