|
@@ -1,6 +1,5 @@
|
|
|
package com.jpsoft.smart.modules.business.controller;
|
|
|
|
|
|
-import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.smart.config.OSSConfig;
|
|
|
import com.jpsoft.smart.modules.base.entity.AlarmConfig;
|
|
|
import com.jpsoft.smart.modules.base.entity.CompanyInfo;
|
|
@@ -9,18 +8,17 @@ import com.jpsoft.smart.modules.base.service.AlarmConfigService;
|
|
|
import com.jpsoft.smart.modules.base.service.CompanyInfoService;
|
|
|
import com.jpsoft.smart.modules.base.service.PersonInfoService;
|
|
|
import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
|
-import com.jpsoft.smart.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
|
import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.smart.modules.business.entity.WorkAttendance;
|
|
|
import com.jpsoft.smart.modules.business.service.WorkAttendanceService;
|
|
|
-import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
|
|
+import com.jpsoft.smart.schduled.UnmeasureTemperatureAlarmTask;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
|
|
import org.joda.time.DateTime;
|
|
|
import org.joda.time.Days;
|
|
|
import org.joda.time.Months;
|
|
@@ -30,8 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.*;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -55,6 +51,9 @@ public class WorkAttendanceController {
|
|
|
@Autowired
|
|
|
private AlarmConfigService alarmConfigService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UnmeasureTemperatureAlarmTask unmeasureTemperatureAlarmTask;
|
|
|
+
|
|
|
@Autowired
|
|
|
private OSSConfig ossConfig;
|
|
|
|
|
@@ -124,7 +123,7 @@ public class WorkAttendanceController {
|
|
|
Map<String,Object> personMap = new HashMap<>();
|
|
|
Map<String,List> workAttendanceMap = new HashMap<>();
|
|
|
|
|
|
- for (int i=0;i<=days;i++){
|
|
|
+ for (int i=0;i<days;i++){
|
|
|
List<WorkAttendance> list = new ArrayList<>();
|
|
|
DateTime dt = startTime.plusDays(i);
|
|
|
workAttendanceMap.put(dt.toString("yyyy-MM-dd"),list);
|
|
@@ -140,7 +139,7 @@ public class WorkAttendanceController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (int i=0;i<=days;i++){
|
|
|
+ for (int i=0;i<days;i++){
|
|
|
DateTime dt = startTime.plusDays(i);
|
|
|
String key = dt.toString("yyyy-MM-dd");
|
|
|
|
|
@@ -254,6 +253,9 @@ public class WorkAttendanceController {
|
|
|
//todo 写考勤记录
|
|
|
int startRowIndex = 3;
|
|
|
|
|
|
+ Font redFont = wb.createFont();
|
|
|
+ redFont.setColor(Font.COLOR_RED);
|
|
|
+
|
|
|
for (int i=0;i<personMapList.size();i++) {
|
|
|
Row row = sheet.createRow(startRowIndex + i);
|
|
|
Map personMap = personMapList.get(i);
|
|
@@ -301,8 +303,14 @@ public class WorkAttendanceController {
|
|
|
if (workAttendanceMap.containsKey(key)){
|
|
|
List<WorkAttendance> workAttendanceList = workAttendanceMap.get(key);
|
|
|
|
|
|
- String value = workAttendanceList.stream().map((item)->{
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
+ List<Map> posList = new ArrayList<>();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ for (WorkAttendance item : workAttendanceList) {
|
|
|
+ if (sb.length()!=0){
|
|
|
+ sb.append("\r\n");
|
|
|
+ }
|
|
|
|
|
|
if(item.getClassifier().equals(1)){
|
|
|
sb.append("上班");
|
|
@@ -320,18 +328,35 @@ public class WorkAttendanceController {
|
|
|
else if (WorkAttendance.LEAVE_EARLY.equals(item.getResult())){
|
|
|
sb.append("早退");
|
|
|
}
|
|
|
- else{
|
|
|
+
|
|
|
+ Map<String,Integer> pos = null;
|
|
|
+
|
|
|
+ if(WorkAttendance.MISSING.equals(item.getResult())){
|
|
|
+ pos = new HashMap<>();
|
|
|
+ pos.put("start",sb.length()-2);
|
|
|
sb.append("缺卡");
|
|
|
}
|
|
|
|
|
|
- if (item.getRecordTime()!=null) {
|
|
|
+ if(item.getRecordTime()!=null) {
|
|
|
sb.append(" " + sdf.format(item.getRecordTime()));
|
|
|
+
|
|
|
+ if(pos!=null) {
|
|
|
+ pos.put("end", sb.length());
|
|
|
+ posList.add(pos);
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- return sb.toString();
|
|
|
- }).collect(Collectors.joining("\r\n"));
|
|
|
+ XSSFRichTextString sText = new XSSFRichTextString(sb.toString());
|
|
|
|
|
|
- row.createCell(dayStartColIndex + j).setCellValue(value);
|
|
|
+ for (Map map : posList) {
|
|
|
+ int start = Integer.valueOf(map.get("start").toString());
|
|
|
+ int end = Integer.valueOf(map.get("end").toString());
|
|
|
+
|
|
|
+ sText.applyFont(start,end,redFont);
|
|
|
+ }
|
|
|
+
|
|
|
+ row.createCell(dayStartColIndex + j).setCellValue(sText);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -367,4 +392,52 @@ public class WorkAttendanceController {
|
|
|
|
|
|
return downloadUrl;
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value="更新考勤记录")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="companyId",value = "单位编号",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "startDate",value = "开始时间", required = true,paramType="form"),
|
|
|
+ @ApiImplicitParam(name = "endDate",value = "截止时间", required = true,paramType="form"),
|
|
|
+ @ApiImplicitParam(name = "subject",value = "subject", required = false,paramType="form")
|
|
|
+ })
|
|
|
+ @RequestMapping(value = "batchUpdate",method = RequestMethod.POST)
|
|
|
+ public MessageResult<String> batchUpdate(
|
|
|
+ String companyId,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
|
|
|
+ @RequestAttribute String subject) {
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (startDate==null){
|
|
|
+ startDate = DateTime.now().dayOfMonth().withMinimumValue().toDate();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (endDate==null){
|
|
|
+ endDate = DateTime.now().plusMonths(1).dayOfMonth().withMinimumValue().toDate();
|
|
|
+ }
|
|
|
+
|
|
|
+ //todo 起始时间与结束时间间隔最大1个月
|
|
|
+ DateTime startTime = new DateTime(startDate);
|
|
|
+ DateTime endTime = new DateTime(endDate);
|
|
|
+
|
|
|
+ int months = Months.monthsBetween(startTime,endTime).getMonths();
|
|
|
+
|
|
|
+ if(months>1){
|
|
|
+ throw new Exception("最多只能更新一个月内的考勤记录!");
|
|
|
+ }
|
|
|
+
|
|
|
+ int affectCount = unmeasureTemperatureAlarmTask.batchUpdate(companyId, startDate, endDate);
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setMessage("共添加" + affectCount + "考勤记录");
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
}
|