1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- package com.zskk.task;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.jfinal.kit.PropKit;
- 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;
- import com.zskk.service.ThreadPoolService;
- public class PrintNumTask implements ITask {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- DataService dService = ServiceFactory.getService(DataService.class);
- List<Record> records = Db.use("print").find("select * from IMAGEVIEW where PRINTED=? and PRINTTIME >?", "true", parseStringToDate1());
- for (Record record : records) {
- try {
- if (record == null) {
- continue;
- }
- Map<String, String> annex_params = new HashMap<>();
- annex_params.put("institution_id", PropKit.get("institution_id"));
- annex_params.put("type", "2");
- annex_params.put("code", record.getStr("CHECKID"));
- annex_params.put("print_time", parseStringToDate(record.getStr("PRINTTIME")));
- ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
- tService.execute(() -> {
- dService.savePrint(annex_params);
- });
- } catch (Exception e) {
- // TODO: handle exception
- continue;
- }
- }
- }
- @Override
- public void stop() {
- // TODO Auto-generated method stub
- }
- /**
- * 日期字符串格式转换
- * @param dateStr
- * @return
- */
- private String parseStringToDate(String dateStr) {
- if (dateStr == null) {
- return "";
- }
- SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- Date date = null;
- String timeString = null;
- try {
- date = sdf.parse(dateStr);
- SimpleDateFormat sdf2= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- timeString = sdf2.format(date);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return timeString;
- }
-
- /**
- * 日期字符串格式转换
- *
- * @param dateStr
- * @return
- */
- private String parseStringToDate1() {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date = new Date();
- String timeString = null;
- Long i = date.getTime();
- Long j = i - 21600000;
- Date newdate = new Date(j);
- timeString = sdf.format(newdate);
- return timeString;
- }
- }
|