| | |
| | | |
| | | import com.zy.asrs.task.core.AsrsException; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.ints.entity.WaitMatin; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/7/4 |
| | |
| | | |
| | | import com.zy.ints.entity.WaitMatinLog; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Insert; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface WaitMatinLogMapper extends BaseMapper<WaitMatinLog> { |
| | | |
| | | @Insert("insert into ints_wait_matin_log select * from ints_wait_matin where bill_no=#{billNo} and seq_no=#{seqNo}") |
| | | int save(@Param("billNo") String billNo,@Param("seqNo") Integer seqNo); |
| | | } |
| | |
| | | |
| | | Integer getHeadPageCount(Map<String, Object> map); |
| | | |
| | | List<WaitMatin> selectWaitMatinBySts(); |
| | | } |
| | |
| | | |
| | | import com.zy.ints.entity.WaitMatoutLog; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Insert; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | |
| | | @Repository |
| | | public interface WaitMatoutLogMapper extends BaseMapper<WaitMatoutLog> { |
| | | |
| | | @Insert("insert into ints_wait_matout_log select * from ints_wait_matout where bill_no=#{billNo} and seq_no=#{seqNo}") |
| | | int save(String billNo, Integer seqNo); |
| | | } |
| | |
| | | package com.zy.ints.mapper; |
| | | |
| | | import com.zy.ints.entity.WaitMatin; |
| | | import com.zy.ints.entity.WaitMatout; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | |
| | | List<WaitMatout> getHeadPage(Map<String, Object> condition); |
| | | |
| | | Integer getHeadPageCount(Map<String, Object> condition); |
| | | |
| | | List<WaitMatout> selectWaitMatOutBySts(); |
| | | } |
| | |
| | | |
| | | public interface WaitMatinLogService extends IService<WaitMatinLog> { |
| | | |
| | | |
| | | boolean save(String billNo, Integer seqNo); |
| | | } |
| | |
| | | import com.zy.ints.entity.WaitMatin; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface WaitMatinService extends IService<WaitMatin> { |
| | | |
| | | Page<WaitMatin> getHeadPage(Page<WaitMatin> page); |
| | | |
| | | /** |
| | | * 查询已完成入库的入库通知档 |
| | | * @return |
| | | */ |
| | | List<WaitMatin> selectWaitMatinBySts(); |
| | | } |
| | |
| | | |
| | | public interface WaitMatoutLogService extends IService<WaitMatoutLog> { |
| | | |
| | | Boolean save(String billNo, Integer seqNo); |
| | | } |
| | |
| | | import com.zy.ints.entity.WaitMatout; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface WaitMatoutService extends IService<WaitMatout> { |
| | | |
| | | Page<WaitMatout> getHeadPage(Page<WaitMatout> toPage); |
| | | |
| | | /** |
| | | * 查询状态为出库完成的所有出库通知档 |
| | | * @return |
| | | */ |
| | | List<WaitMatout> selectWaitMatOutBySts(); |
| | | } |
| | |
| | | package com.zy.ints.service.impl; |
| | | |
| | | import com.zy.ints.mapper.WaitMatchkMapper; |
| | | import com.zy.ints.mapper.WaitMatinLogMapper; |
| | | import com.zy.ints.entity.WaitMatinLog; |
| | | import com.zy.ints.service.WaitMatinLogService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("waitMatinLogService") |
| | | public class WaitMatinLogServiceImpl extends ServiceImpl<WaitMatinLogMapper, WaitMatinLog> implements WaitMatinLogService { |
| | | |
| | | |
| | | @Override |
| | | public boolean save(String billNo, Integer seqNo) { |
| | | |
| | | return this.baseMapper.save(billNo,seqNo)>0; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service("waitMatinService") |
| | | public class WaitMatinServiceImpl extends ServiceImpl<WaitMatinMapper, WaitMatin> implements WaitMatinService { |
| | | |
| | |
| | | return page; |
| | | } |
| | | |
| | | @Override |
| | | public List<WaitMatin> selectWaitMatinBySts() { |
| | | return baseMapper.selectWaitMatinBySts(); |
| | | } |
| | | |
| | | } |
| | |
| | | @Service("waitMatoutLogService") |
| | | public class WaitMatoutLogServiceImpl extends ServiceImpl<WaitMatoutLogMapper, WaitMatoutLog> implements WaitMatoutLogService { |
| | | |
| | | @Override |
| | | public Boolean save(String billNo, Integer seqNo) { |
| | | |
| | | return this.baseMapper.save(billNo,seqNo)>0; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service("waitMatoutService") |
| | | public class WaitMatoutServiceImpl extends ServiceImpl<WaitMatoutMapper, WaitMatout> implements WaitMatoutService { |
| | | |
| | |
| | | page.setTotal(baseMapper.getHeadPageCount(page.getCondition())); |
| | | return page; |
| | | } |
| | | |
| | | @Override |
| | | public List<WaitMatout> selectWaitMatOutBySts() { |
| | | return this.baseMapper.selectWaitMatOutBySts(); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.zy.ints.task; |
| | | |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.ints.entity.WaitMatin; |
| | | import com.zy.ints.entity.WaitMatout; |
| | | import com.zy.ints.entity.WaitMatoutLog; |
| | | import com.zy.ints.service.WaitMatoutLogService; |
| | | import com.zy.ints.service.WaitMatoutService; |
| | | import com.zy.ints.task.handler.WaitMatOutLogHandler; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class WaitMatOutLogScheduler { |
| | | private static final Logger log = LoggerFactory.getLogger(WaitMatOutLogScheduler.class); |
| | | |
| | | @Autowired |
| | | private WaitMatoutService waitMatoutService; |
| | | |
| | | @Autowired |
| | | private WaitMatOutLogHandler waitMatOutLogHandler; |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | private void execute(){ |
| | | List<WaitMatout> waitMatouts = waitMatoutService.selectWaitMatOutBySts(); |
| | | for (WaitMatout waitMatout : waitMatouts) { |
| | | ReturnT<String> result = waitMatOutLogHandler.start(waitMatout); |
| | | if (!result.isSuccess()) { |
| | | log.error("入库通知档[billNo={}],[seqNo={}]历史档处理失败", waitMatout.getBillNo(),waitMatout.getSeqNo()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.ints.entity.WaitMatin; |
| | | import com.zy.ints.service.WaitMatinService; |
| | | import com.zy.ints.task.handler.WaitMatinLogHandler; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | */ |
| | | @Component |
| | | public class WaitMatinLogScheduler { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(WaitMatinLogScheduler.class); |
| | | |
| | | @Autowired |
| | | private WaitMatinLogHandler waitMatinLogHandler; |
| | | |
| | | @Autowired |
| | | private WaitMatinService waitMatinService; |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | private void execute(){ |
| | | List<WaitMatin> WaitMatins = null; |
| | | List<WaitMatin> WaitMatins = waitMatinService.selectWaitMatinBySts(); |
| | | for (WaitMatin waitMatin : WaitMatins) { |
| | | ReturnT<String> result = waitMatinLogHandler.start(waitMatin); |
| | | if (!result.isSuccess()) { |
| New file |
| | |
| | | package com.zy.ints.task.handler; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | |
| | | import com.zy.ints.entity.WaitMatin; |
| | | import com.zy.ints.entity.WaitMatout; |
| | | import com.zy.ints.service.WaitMatoutLogService; |
| | | import com.zy.ints.service.WaitMatoutService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | @Service |
| | | public class WaitMatOutLogHandler extends AbstractHandler<String> { |
| | | @Autowired |
| | | private WaitMatoutLogService waitMatoutLogService; |
| | | |
| | | @Autowired |
| | | private WaitMatoutService waitMatoutService; |
| | | |
| | | public ReturnT<String> start(WaitMatout waitMatout) { |
| | | |
| | | try { |
| | | // 保存工作主档历史档 |
| | | if (!waitMatoutLogService.save(waitMatout.getBillNo(),waitMatout.getSeqNo())) { |
| | | exceptionHandle("保存工作历史档[workNo={0}]失败", waitMatout.getBillNo()); |
| | | } |
| | | // 删除工作主档 |
| | | if (!waitMatoutService.delete(new EntityWrapper<WaitMatout>().eq("bill_no", waitMatout.getBillNo()).eq("seq_no", waitMatout.getSeqNo()))) { |
| | | exceptionHandle("删除工作主档[workNo={0}]失败", waitMatout.getBillNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg(e.getMessage()); |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | } |
| | |
| | | package com.zy.ints.task.handler; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.ints.entity.WaitMatin; |
| | |
| | | public ReturnT<String> start(WaitMatin waitMatin){ |
| | | try { |
| | | // 保存工作主档历史档 |
| | | // if (!WaitMatinLogService.save(waitMatin.getBillNo(),waitMatin.getSeqNo())) { |
| | | // exceptionHandle("保存工作历史档[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | // } |
| | | // // 删除工作主档 |
| | | // if (!wrkMastService.deleteById(wrkMast)) { |
| | | // exceptionHandle("删除工作主档[workNo={0}]失败", wrkMast.getWrkNo()); |
| | | // } |
| | | if (!waitMatinLogService.save(waitMatin.getBillNo(),waitMatin.getSeqNo())) { |
| | | exceptionHandle("保存工作历史档[workNo={0}]失败", waitMatin.getBillNo()); |
| | | } |
| | | // 删除工作主档 |
| | | if (!waitMatinService.delete(new EntityWrapper<WaitMatin>().eq("bill_no", waitMatin.getBillNo()).eq("seq_no", waitMatin.getSeqNo()))) { |
| | | exceptionHandle("删除工作主档[workNo={0}]失败", waitMatin.getBillNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | |
| | | ) r |
| | | ) t |
| | | </select> |
| | | <select id="selectWaitMatinBySts" resultMap="BaseResultMap"> |
| | | select * from ints_wait_matin |
| | | where io_status=2 |
| | | or (in_qty=qty) |
| | | order by modi_time,mat_no asc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | ) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize}) |
| | | </select> |
| | | <select id="getHeadPageCount" parameterType="java.util.Map" resultType="integer"> |
| | | |
| | | select count(1) from |
| | | ( |
| | | select *, |
| | |
| | | ) r |
| | | ) t |
| | | </select> |
| | | <select id="selectWaitMatOutBySts" resultMap="BaseResultMap"> |
| | | select * from ints_wait_matout |
| | | where io_status=2 |
| | | or (out_qty=qty) |
| | | order by modi_time,mat_no asc |
| | | </select> |
| | | |
| | | </mapper> |