Переглянути джерело

修改微信提醒模板。

zhengqiang 5 роки тому
батько
коміт
850e50b87a

+ 9 - 7
common/src/main/java/com/jpsoft/smart/modules/business/service/impl/WorkAttendanceServiceImpl.java

@@ -143,13 +143,6 @@ public class WorkAttendanceServiceImpl implements WorkAttendanceService {
 					if (alarmConfig.getClassifier().equals(1)) {
 						//todo 上班考勤
 
-						//当天是否已经有该时段上班打卡记录,如果有则不记录
-						List<WorkAttendance> workAttendances = workAttendanceDAO.findByPeriod(personId,alarmConfig.getId(),recordTime.toDate());
-
-						if (workAttendances.size()>0){
-							continue;
-						}
-
 						//准时上班
 						if (recordTime.compareTo(startTime)>0 && recordTime.compareTo(attendanceTime)<=0){
 							attendanceResult = WorkAttendance.SUCCESS;
@@ -157,6 +150,15 @@ public class WorkAttendanceServiceImpl implements WorkAttendanceService {
 						else if(recordTime.compareTo(attendanceTime)>0 && recordTime.compareTo(endTime)<=0){
 							attendanceResult = WorkAttendance.LATE;
 						}
+
+						if(StringUtils.isNotEmpty(attendanceResult)){
+							//当天是否已经有该时段上班打卡记录,如果有则不记录
+							List<WorkAttendance> workAttendances = workAttendanceDAO.findByPeriod(personId,alarmConfig.getId(),recordTime.toDate());
+
+							if (workAttendances.size()>0){
+								continue;
+							}
+						}
 					} else {
 						//todo 下班考勤
 

+ 0 - 34
common/src/main/java/com/jpsoft/smart/modules/common/utils/WechatMessageUtil.java

@@ -414,40 +414,6 @@ public class WechatMessageUtil {
 		return ret;
 	}
 
-	public static boolean sendUnmeasureAlarmInfo(String openId,String companyName,String message,String url,String appId,String appSecret) {
-		String templateId = "Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M";
-
-		JSONObject sendData = new JSONObject();
-
-		JSONObject first = new JSONObject();
-		first.put("value", "未测量体温提醒");
-		first.put("color", "#FF0000");
-
-		JSONObject keyword1 = new JSONObject();
-		keyword1.put("value", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
-		keyword1.put("color", "#173177");
-
-		JSONObject keyword2 = new JSONObject();
-		keyword2.put("value", companyName);
-		keyword2.put("color", "#173177");
-
-		JSONObject remark = new JSONObject();
-		remark.put("value", message);
-		remark.put("color", "#173177");
-
-		sendData.put("first", first);
-		sendData.put("keyword1", keyword1);
-		sendData.put("keyword2", keyword2);
-		sendData.put("remark", remark);
-
-		//w8Zk_VQMFIEVSIBPZid7zSrvHmBdrgnqF76u8PLCZEs cs
-		boolean ret = sendTemplate(sendData, appId,appSecret,templateId,openId, url);
-
-		return ret;
-	}
-
-
-
 	public static void main(String[] args) {
 		/*AccessToken at = WeixinUtil.getAccessToken(APP_ID, APP_SECRET,"061iw9gy1sZ1dg09dqhy1ae3gy1iw9gq");
 

+ 31 - 0
web/src/main/java/com/jpsoft/smart/modules/business/controller/WorkAttendanceController.java

@@ -523,6 +523,37 @@ public class WorkAttendanceController {
         return messageResult;
     }
 
+    @ApiOperation(value="微信通知")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="alarmConfigId",value = "单位编号",required = true,paramType = "form")
+    })
+    @RequestMapping(value = "wxNotice",method = RequestMethod.POST)
+    public MessageResult<String> wxNotice(String alarmConfigId) {
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            AlarmConfig alarmConfig = alarmConfigService.get(alarmConfigId);
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+            String date = DateTime.now().toString("yyyy-MM-dd");
+
+            DateTime startTime = new DateTime(sdf.parse(date + " " + alarmConfig.getStartTime()));
+            DateTime endTime = new DateTime(sdf.parse(date + " " + alarmConfig.getEndTime()));
+
+            unmeasureTemperatureAlarmTask.noticePerson(alarmConfig,startTime,endTime);
+            unmeasureTemperatureAlarmTask.noticeManager(alarmConfig,startTime,endTime);
+
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            logger.error(ex.getMessage(),ex);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
     @ApiOperation(value="添加考勤记录")
     @ApiImplicitParams({
             @ApiImplicitParam(name="personId",value = "人员编号",required = true,paramType = "form"),

+ 68 - 9
web/src/main/java/com/jpsoft/smart/schduled/UnmeasureTemperatureAlarmTask.java

@@ -1,5 +1,6 @@
 package com.jpsoft.smart.schduled;
 
+import cn.hutool.core.date.DateUtil;
 import com.jpsoft.smart.config.OSSConfig;
 import com.jpsoft.smart.config.WxConfig;
 import com.jpsoft.smart.modules.base.entity.*;
@@ -14,6 +15,7 @@ import com.sun.corba.se.spi.orbutil.threadpool.Work;
 import io.jsonwebtoken.Jwts;
 import io.jsonwebtoken.security.Keys;
 import lombok.extern.slf4j.Slf4j;
+import net.sf.json.JSONObject;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Row;
@@ -76,6 +78,12 @@ public class UnmeasureTemperatureAlarmTask {
     @Value("${mobile.unMeasureUrl}")
     private String unMeasureUrl;
 
+    @Value("${wx.notice.remindTmplCode}")
+    private String remindTmplCode;
+
+    @Value("${wx.notice.supervisionTmplCode}")
+    private String supervisionTmplCode;
+
     @Autowired
     private HolidayInfoService holidayInfoService;
 
@@ -215,7 +223,7 @@ public class UnmeasureTemperatureAlarmTask {
                     if (now.compareTo(alarmTime)>=0 && now.compareTo(alarmTime.plusMinutes(intervalMinute))<0) {
                         //todo 通知个人
                         if(alarmConfig.getNeedMeasureTemperature()){
-                            noticePerson(alarmConfig,startTime,attendanceTime,endTime);
+                            noticePerson(alarmConfig,startTime,endTime);
                         }
                     }
 
@@ -358,7 +366,7 @@ public class UnmeasureTemperatureAlarmTask {
     }
 
     @Async
-    public void noticePerson(AlarmConfig alarmConfig, DateTime startTime, DateTime attendanceTime,DateTime endTime) {
+    public void noticePerson(AlarmConfig alarmConfig, DateTime startTime, DateTime endTime) {
         CompanyInfo companyInfo = companyInfoService.get(alarmConfig.getCompanyId());
 
         String companyCode = companyInfo.getCode();
@@ -389,7 +397,35 @@ public class UnmeasureTemperatureAlarmTask {
 //                }
                 message +=",请抓紧时间在单位(校园)内任意打卡点打卡和测温!";
 
-                WechatMessageUtil.sendUnmeasureAlarmInfo(personInfo.getOpenId(), companyInfo.getName(), message,"", wxConfig.getAppId(), wxConfig.getAppSecret());
+                JSONObject sendData = new JSONObject();
+
+                JSONObject first = new JSONObject();
+                first.put("value", "未测温提醒");
+                first.put("color", "#FF0000");
+
+                JSONObject keyword1 = new JSONObject();
+                keyword1.put("value", personInfo.getName());
+                keyword1.put("color", "#173177");
+
+                JSONObject keyword2 = new JSONObject();
+                keyword2.put("value", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
+                keyword2.put("color", "#173177");
+
+                JSONObject keyword3 = new JSONObject();
+                keyword3.put("value", "待测温");
+                keyword3.put("color", "#173177");
+
+                JSONObject remark = new JSONObject();
+                remark.put("value", message);
+                remark.put("color", "#173177");
+
+                sendData.put("first", first);
+                sendData.put("keyword1", keyword1);
+                sendData.put("keyword2", keyword2);
+                sendData.put("keyword3", keyword3);
+                sendData.put("remark", remark);
+
+                WechatMessageUtil.sendTemplate(sendData, wxConfig.getAppId(),wxConfig.getAppSecret(),remindTmplCode,personInfo.getOpenId(), null);
             }
         }
     }
@@ -442,12 +478,35 @@ public class UnmeasureTemperatureAlarmTask {
                     url += "&queryDate=" + startTime.toString("yyyy-MM-dd");
                     url += "&alarmConfigId=" + alarmConfig.getId();
 
-                    WechatMessageUtil.sendUnmeasureAlarmInfo(
-                            pusher.getOpenId(),
-                            companyInfo.getName(),
-                            message,
-                            url,
-                            wxConfig.getAppId(), wxConfig.getAppSecret());
+                    JSONObject sendData = new JSONObject();
+
+                    JSONObject first = new JSONObject();
+                    first.put("value", "未测温提醒");
+                    first.put("color", "#FF0000");
+
+                    JSONObject keyword1 = new JSONObject();
+                    keyword1.put("value", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
+                    keyword1.put("color", "#173177");
+
+                    JSONObject keyword2 = new JSONObject();
+                    keyword2.put("value", companyInfo.getName());
+                    keyword2.put("color", "#173177");
+
+                    JSONObject keyword3 = new JSONObject();
+                    keyword3.put("value", pusher.getName());
+                    keyword3.put("color", "#173177");
+
+                    JSONObject remark = new JSONObject();
+                    remark.put("value", message);
+                    remark.put("color", "#173177");
+
+                    sendData.put("first", first);
+                    sendData.put("keyword1", keyword1);
+                    sendData.put("keyword2", keyword2);
+                    sendData.put("keyword3", keyword3);
+                    sendData.put("remark", remark);
+
+                    WechatMessageUtil.sendTemplate(sendData, wxConfig.getAppId(),wxConfig.getAppSecret(),supervisionTmplCode,pusher.getOpenId(), url);
                 }
                 catch(Exception ex){
                     log.error(ex.getMessage(),ex);

+ 3 - 0
web/src/main/resources/application.yml

@@ -131,6 +131,9 @@ wx:
     mchKey: jpsoft11111111111111111111111111
     notifyUrl: http://zldb.xiaoxinda.com:8088/smart-community-server/wxPay/payNotify
     ip: 58.54.251.155
+  notice:
+    remindTmplCode: "Nsn_8-M25Ef_KThmin8uDocXeh8XVQMC1rVzBAIaeig"
+    supervisionTmplCode: "Kr1YX2JQdRhTDasUbKp30RwpK0A5nDUlx9Q7FpY108A"
 
 doorApi:
   referer: http://58.54.251.155