package com.zskk.task; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; 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 PayTask implements ITask { @Override public void run() { // TODO Auto-generated method stub DataService dService = ServiceFactory.getService(DataService.class); List records = Db.use("connected").find("select * from paylist where ISFEE=1 order by PAYTIME desc"); for (Record record : records) { JSONObject jsonObject = new JSONObject(); jsonObject.put("institution_id", PropKit.get("institution_id")); jsonObject.put("patient_num", record.getStr("ACCESSIONNUMBER")); jsonObject.put("ins_type", "2"); JSONObject pJsonObject = new JSONObject(); pJsonObject.put("params", jsonObject.toJSONString()); ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class); tService.execute(() -> { dService.fee(pJsonObject); }); } } @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"); 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; } }