package com.cyx.cron; import com.cyx.entry.Entry; import com.cyx.log.EventLog; import com.cyx.utils.DateUtils; import com.jfinal.kit.Prop; import com.jfinal.kit.PropKit; /** * @Author Created by cyx.zhang Administrator on 2024/3/1 15:59 周五 * @Description: 任务调度控制层 */ public class MyTask implements Runnable{ /** * 加载配置文件 */ private static Prop p = PropKit.use("parameter.properties"); @Override public void run() { EventLog.info("......任务调度开始执行......"); doStart(); EventLog.info("......任务调度结束执行......"); } public static void doStart(){ String eventFarmIds = p.get("eventFarmIds");//牧场 /** * 事件数据 */ String eventBreedId = p.get("eventBreedId");//配种事件 String eventTurnId = p.get("eventTurnId");//转群事件 String eventIds = p.get("eventIds");//多个事件 String count = p.get("count");//总条数 Integer eventNumDays = p.getInt("eventNumDays");//间隔天数 String eventBeginDate = DateUtils.getOtherDay(eventNumDays);//开始日期 String eventEndDate = DateUtils.getNowDay();//结束日期 /** * 离场牛只修改数据 */ Integer editNumDays = p.getInt("editNumDays");//间隔天数 String editBeginDate = DateUtils.getOtherDay(editNumDays);//开始日期 String editEndDate = DateUtils.getNowDay();//结束日期 String[] farmIds = eventFarmIds.split(","); for(String farmId : farmIds){ EventLog.info("......牧场标识......"+farmId+"......"); /** * 配种事件 */ String breedArgs[] = new String[6]; breedArgs[0] = "syns"; breedArgs[1] = farmId; breedArgs[2] = eventBreedId; breedArgs[3] = count; breedArgs[4] = eventBeginDate; breedArgs[5] = eventEndDate; String baseFarmId = Entry.getKeyName(farmId); EventLog.info("......牧场名称......"+baseFarmId+"......"); /** * 基础信息 */ String baseArgs[] = new String[4]; baseArgs[0] = "info"; baseArgs[1] = baseFarmId; baseArgs[2] = count; baseArgs[3] = "4"; /** * 转群事件 */ String turnArgs[] = new String[7]; turnArgs[0] = "syns"; turnArgs[1] = farmId; turnArgs[2] = eventTurnId; turnArgs[3] = count; turnArgs[4] = eventBeginDate; turnArgs[5] = eventEndDate; turnArgs[6] = "0"; /** * 其他事件 */ String otherArgs[] = new String[6]; otherArgs[0] = "syns"; otherArgs[1] = farmId; otherArgs[2] = eventIds; otherArgs[3] = count; otherArgs[4] = eventBeginDate; otherArgs[5] = eventEndDate; String editFarmId = String.valueOf(Entry.getKey(farmId)); EventLog.info("......牧场ID......"+editFarmId+"......"); /** * 处理离场牛只数据 */ String editArgs[] = new String[4]; editArgs[0] = "edit"; editArgs[1] = editFarmId; editArgs[2] = editBeginDate; editArgs[3] = editEndDate; /** * 执行任务 */ goExecute(breedArgs, baseArgs, turnArgs, otherArgs, editArgs); } } private static void goExecute(String[] breedArgs, String[] baseArgs, String[] turnArgs, String[] otherArgs, String[] editArgs) { EventLog.info("......配种事件开始执行......"); Entry.synsData(breedArgs); EventLog.info("......配种事件结束执行......"); EventLog.info("......基础数据开始执行......"); Entry.InfoData(baseArgs); EventLog.info("......基础数据结束执行......"); EventLog.info("......转群事件开始执行......"); Entry.synsData(turnArgs); EventLog.info("......转群事件结束执行......"); EventLog.info("......其他事件开始执行......"); Entry.synsData(otherArgs); EventLog.info("......其他事件结束执行......"); EventLog.info("......屏蔽事件开始执行......"); Entry.editData(editArgs); EventLog.info("......屏蔽事件结束执行......"); } }