1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package com.zskk.task;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.jfinal.plugin.activerecord.Db;
- import com.jfinal.plugin.activerecord.Record;
- import com.jfinal.plugin.cron4j.ITask;
- import com.zskk.service.DataService;
- import com.zskk.service.ServiceFactory;
- public class BindTask implements ITask {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- DataService dService = ServiceFactory.getService(DataService.class);
- JSONArray jsonArray = dService.getBindList(parseStringToDate(),parseStringToDate());
- for (Object object : jsonArray) {
- try {
- JSONObject jsonObject = JSON.parseObject(object.toString());
- String source = "";
- switch (jsonObject.getString("source")) {
- case "1":
- source="数字影像云公众号";
- break;
-
- case "2":
- source="集成链接";
- break;
-
- case "3":
- source="推送短信";
- break;
- default:
- break;
- }
- Record recordei = Db.use("connected").findFirst("select * from examinfo where studyuid=?", jsonObject.getString("studyuid"));
- Record recordrc = Db.use("connected").findFirst("select * from reportcheck where studyuid=?", jsonObject.getString("studyuid"));
- Record recordri = Db.use("connected").findFirst("select * from reportinfo where studyuid=?", jsonObject.getString("studyuid"));
- if (recordei==null && recordrc==null && recordri==null) {
- continue;
- }
- if (recordei!=null) {
- Db.use("connected").update("update examinfo set ViewFlag='1',ViewTime=?,ViewName=? where studyuid=?",jsonObject.getString("createdAt"),jsonObject.getString("name") + "_"+ source,jsonObject.getString("studyuid"));
- }
- if (recordrc!=null) {
- Db.use("connected").update("update reportcheck set ViewFlag='1',ViewTime=?,ViewName=? where studyuid=?",jsonObject.getString("createdAt"),jsonObject.getString("name") + "_"+ source,jsonObject.getString("studyuid"));
- }
- if (recordri!=null) {
-
- Db.use("connected").update("update reportinfo set ViewFlag='1',ViewTime=?,ViewName=? where studyuid=?",jsonObject.getString("createdAt"),jsonObject.getString("name") + "_"+ source,jsonObject.getString("studyuid"));
- }
- } catch (Exception e) {
- // TODO: handle exception
- continue;
- }
- }
- }
- @Override
- public void stop() {
- // TODO Auto-generated method stub
- }
-
- /**
- * 日期字符串格式转换
- * @param dateStr
- * @return
- */
- private String parseStringToDate() {
- SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
- Date date = new Date();
- String timeString = sdf.format(date);
- return timeString;
- }
- }
|