|
@@ -1,21 +1,30 @@
|
|
package com.jpsoft.smart.schduled;
|
|
package com.jpsoft.smart.schduled;
|
|
|
|
|
|
|
|
+import com.jpsoft.smart.config.OSSConfig;
|
|
import com.jpsoft.smart.config.WxConfig;
|
|
import com.jpsoft.smart.config.WxConfig;
|
|
import com.jpsoft.smart.modules.base.entity.*;
|
|
import com.jpsoft.smart.modules.base.entity.*;
|
|
import com.jpsoft.smart.modules.base.service.*;
|
|
import com.jpsoft.smart.modules.base.service.*;
|
|
import com.jpsoft.smart.modules.business.entity.WorkAttendance;
|
|
import com.jpsoft.smart.modules.business.entity.WorkAttendance;
|
|
import com.jpsoft.smart.modules.business.service.WorkAttendanceService;
|
|
import com.jpsoft.smart.modules.business.service.WorkAttendanceService;
|
|
|
|
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
|
|
import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
|
|
import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
|
import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
+import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
import org.joda.time.DateTime;
|
|
import org.joda.time.DateTime;
|
|
import org.joda.time.Days;
|
|
import org.joda.time.Days;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -37,6 +46,9 @@ public class UnmeasureTemperatureAlarmTask {
|
|
@Autowired
|
|
@Autowired
|
|
private CompanyInfoService companyInfoService;
|
|
private CompanyInfoService companyInfoService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private CompanyPositionService companyPositionService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private WorkAttendanceService workAttendanceService;
|
|
private WorkAttendanceService workAttendanceService;
|
|
|
|
|
|
@@ -46,6 +58,9 @@ public class UnmeasureTemperatureAlarmTask {
|
|
@Autowired
|
|
@Autowired
|
|
private WxConfig wxConfig;
|
|
private WxConfig wxConfig;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private OSSConfig ossConfig;
|
|
|
|
+
|
|
public int batchUpdate(String companyId,Date startDate,Date endDate) throws Exception {
|
|
public int batchUpdate(String companyId,Date startDate,Date endDate) throws Exception {
|
|
DateTime dt1 = new DateTime(startDate);
|
|
DateTime dt1 = new DateTime(startDate);
|
|
DateTime dt2 = new DateTime(endDate);
|
|
DateTime dt2 = new DateTime(endDate);
|
|
@@ -302,14 +317,15 @@ public class UnmeasureTemperatureAlarmTask {
|
|
&& StringUtils.isNotEmpty(personInfo.getOpenId())) {
|
|
&& StringUtils.isNotEmpty(personInfo.getOpenId())) {
|
|
String message = "尊敬的" + personInfo.getName();
|
|
String message = "尊敬的" + personInfo.getName();
|
|
|
|
|
|
- if (alarmConfig.getClassifier()!=null && alarmConfig.getClassifier().equals(1)){
|
|
|
|
- message += ",请在" + startTime.toString("HH:mm") + "至" + attendanceTime.toString("HH:mm") + "时间内测量体温!";
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
- message += ",请在" + attendanceTime.toString("HH:mm") + "至" + endTime.toString("HH:mm") + "时间内测量体温!";
|
|
|
|
- }
|
|
|
|
|
|
+// if (alarmConfig.getClassifier()!=null && alarmConfig.getClassifier().equals(1)){
|
|
|
|
+// message += ",请在" + startTime.toString("HH:mm") + "至" + attendanceTime.toString("HH:mm") + "时间内在单位(校园)内任意打卡点打卡及测温!";
|
|
|
|
+// }
|
|
|
|
+// else{
|
|
|
|
+// message += ",请在" + attendanceTime.toString("HH:mm") + "至" + endTime.toString("HH:mm") + "时间内在单位(校园)内任意打卡点打卡及测温!";
|
|
|
|
+// }
|
|
|
|
+ message +=",请抓紧时间在单位(校园)内任意打卡点打卡和测温!";
|
|
|
|
|
|
- WechatMessageUtil.sendUnmeasureAlarmInfo(personInfo.getOpenId(), companyInfo.getName(), message, wxConfig.getAppId(), wxConfig.getAppSecret());
|
|
|
|
|
|
+ WechatMessageUtil.sendUnmeasureAlarmInfo(personInfo.getOpenId(), companyInfo.getName(), message,"", wxConfig.getAppId(), wxConfig.getAppSecret());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -354,16 +370,107 @@ public class UnmeasureTemperatureAlarmTask {
|
|
&& pusher.getMissingNoticeEnabled()!=null && pusher.getMissingNoticeEnabled()) {
|
|
&& pusher.getMissingNoticeEnabled()!=null && pusher.getMissingNoticeEnabled()) {
|
|
String message = "尊敬的" + pusher.getName()
|
|
String message = "尊敬的" + pusher.getName()
|
|
+ ",当天时段" + startTime.toString("HH:mm") + "至" + endTime.toString("HH:mm")
|
|
+ ",当天时段" + startTime.toString("HH:mm") + "至" + endTime.toString("HH:mm")
|
|
- + ",有" + total + "人未测量体温。名单如下:" + sb.toString();
|
|
|
|
|
|
+ + ",有" + total + "人未测量体温,具体名单请点击下方链接查看。";
|
|
|
|
+
|
|
|
|
+ //todo 生成未测量人员名单
|
|
|
|
+
|
|
|
|
+ String url = "";
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ url = createUnMeasureReport(companyInfo, unmeasuredList, startTime, endTime);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex){
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
+ }
|
|
|
|
|
|
WechatMessageUtil.sendUnmeasureAlarmInfo(
|
|
WechatMessageUtil.sendUnmeasureAlarmInfo(
|
|
pusher.getOpenId(),
|
|
pusher.getOpenId(),
|
|
companyInfo.getName(),
|
|
companyInfo.getName(),
|
|
- message, wxConfig.getAppId(), wxConfig.getAppSecret());
|
|
|
|
|
|
+ message,
|
|
|
|
+ url,
|
|
|
|
+ wxConfig.getAppId(), wxConfig.getAppSecret());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private String createUnMeasureReport(CompanyInfo companyInfo, List<PersonInfo> unmeasuredList, DateTime startTime, DateTime endTime) throws Exception{
|
|
|
|
+ ClassPathResource resource = new ClassPathResource("static/unMeasureReport.xlsx");
|
|
|
|
+
|
|
|
|
+ Workbook wb = WorkbookFactory.create(resource.getInputStream());
|
|
|
|
+
|
|
|
|
+ Sheet sheet = wb.getSheetAt(0);
|
|
|
|
+
|
|
|
|
+ Row row1 = sheet.getRow(0);
|
|
|
|
+ Row row2 = sheet.getRow(1);
|
|
|
|
+ Row row3 = sheet.getRow(2);
|
|
|
|
+
|
|
|
|
+ String title = row1.getCell(0).getStringCellValue();
|
|
|
|
+ String subTitle = row2.getCell(0).getStringCellValue();
|
|
|
|
+
|
|
|
|
+ row1.getCell(0).setCellValue(String.format(title, startTime.toString("HH:mm"), endTime.toString("HH:mm")));
|
|
|
|
+ row2.getCell(0).setCellValue(String.format(subTitle, DateTime.now().toString("yyyy-MM-dd HH:mm")));
|
|
|
|
+
|
|
|
|
+ //显示扩展字段
|
|
|
|
+ List<CompanyPosition> companyPositions = companyPositionService.findByCompanyId(companyInfo.getId());
|
|
|
|
+
|
|
|
|
+ if (companyPositions.size()>0){
|
|
|
|
+ CompanyPosition companyPosition = companyPositions.get(0);
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotEmpty(companyPosition.getPosition1Name())) {
|
|
|
|
+ row3.createCell(2).setCellValue(companyPosition.getPosition1Name());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotEmpty(companyPosition.getPosition2Name())) {
|
|
|
|
+ row3.createCell(3).setCellValue(companyPosition.getPosition2Name());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotEmpty(companyPosition.getPosition3Name())) {
|
|
|
|
+ row3.createCell(4).setCellValue(companyPosition.getPosition3Name());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotEmpty(companyPosition.getPosition4Name())) {
|
|
|
|
+ row3.createCell(5).setCellValue(companyPosition.getPosition4Name());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotEmpty(companyPosition.getPosition5Name())) {
|
|
|
|
+ row3.createCell(6).setCellValue(companyPosition.getPosition5Name());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int rowIndex = 3;
|
|
|
|
+
|
|
|
|
+ for (PersonInfo personInfo : unmeasuredList) {
|
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
|
+ row.createCell(0).setCellValue(rowIndex-2);
|
|
|
|
+ row.createCell(1).setCellValue(personInfo.getCompanyName());
|
|
|
|
+ row.createCell(2).setCellValue(personInfo.getName());
|
|
|
|
+ row.createCell(3).setCellValue(personInfo.getPosition1());
|
|
|
|
+ row.createCell(4).setCellValue(personInfo.getPosition2());
|
|
|
|
+ row.createCell(5).setCellValue(personInfo.getPosition3());
|
|
|
|
+ row.createCell(6).setCellValue(personInfo.getPosition4());
|
|
|
|
+ row.createCell(7).setCellValue(personInfo.getPosition4());
|
|
|
|
+
|
|
|
|
+ rowIndex++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //todo 将wb保存到oss
|
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
|
+ wb.write(output);
|
|
|
|
+
|
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
|
+
|
|
|
|
+ String fileName = "未测温统计表.xlsx";
|
|
|
|
+
|
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig,"unmeasuredReport",fileName,input);
|
|
|
|
+
|
|
|
|
+ wb.write(output);
|
|
|
|
+ wb.close();
|
|
|
|
+ output.close();
|
|
|
|
+
|
|
|
|
+ return downloadUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
Boolean result = null;
|
|
Boolean result = null;
|
|
|
|
|