sysParamService.getParam("FACILITY_ID");报null异常,sysParamService为空
public class SchedulingRunnable implements Runnable {
@Autowired
private JpaRepository jpaRepository;
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private SysParamService sysParamService;
private ReeferTimerSet cron;
public SchedulingRunnable(ReeferTimerSet cron) {
this.cron = cron;
}
@Override
public void run() {
//执行任务
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");//定义格式,不显示毫秒
Timestamp now = new Timestamp(System.currentTimeMillis());//获取系统当前时间
String facilityId=sysParamService.getParam("FACILITY_ID");
String str = df.format(now);
String sql = "SELECT unitNo,unitVisitId" +
" FROM YardUnit " +
" WHERE isReefer = '1'";
List<YardUnit> list = jpaRepository.findListByJpql(sql, null);
String instertSql = "insert into REEFER_INSPECT_COMMAND (" +
"INSPECT_COMMAND_ID, " +
"TIMER, " +
"INSPECT_STATE, " +
"UNIT_VISIT_ID, " +
"UNIT_NO, " +
"NOTES, " +
"FACILITY_ID," +
"CREATOR, " +
"CREATED_ON, " +
"CHANGER, " +
"CHANGED_ON)" +
"Values(sys_guid(),?,'PLAN',?,?,'',?,'AUTO',?,'AUTO',?)";
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
YardUnit yardUnit = list.get(i);
ps.setString(1, str);
ps.setString(2, yardUnit.getUnitVisitId());
ps.setString(3, yardUnit.getUnitNo());
ps.setString(4, facilityId);
ps.setTimestamp(5, now);
ps.setTimestamp(6, now);
}
@Override
public int getBatchSize() {
return list.size();
}
});
System.out.println("***********");
System.out.println("执行完成");
System.out.println("执行完成");
System.out.println("***********");
}
}