New file |
| | |
| | | package com.zy.asrs.task.handler; |
| | | |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/7/7 |
| | | */ |
| | | @Service |
| | | public class PlcLogHandler extends AbstractHandler<String> { |
| | | |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | |
| | | @Transactional |
| | | public ReturnT<String> start() { |
| | | try { |
| | | // 下位机命令转历史档 |
| | | int updateCount = jdbcTemplate.update("insert into asr_stk_hplc select * from asr_stk_plcm where dateadd(day,7,appe_time) <= getdate();"); |
| | | if (updateCount > 0) { |
| | | int deleteCount = jdbcTemplate.update("delete from asr_stk_plcm where dateadd(day,7,io_time) <= getdate();"); |
| | | if (deleteCount <= 0) { |
| | | exceptionHandle("堆垛机&PLC命令转历史档错误 ! "); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg(e.getMessage()); |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | |
| | | } |