package com.shlanbao.tzsc.pms.equ.wcplan.service.impl; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.UUID; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.shlanbao.tzsc.base.dao.EqmFixedStoptimeDaoI; import com.shlanbao.tzsc.base.dao.SchCalendarDaoI; import com.shlanbao.tzsc.base.mapping.EqmFixedStoptime; import com.shlanbao.tzsc.base.mapping.SchCalendar; import com.shlanbao.tzsc.pms.equ.wcplan.service.EqmFixedStoptimeServiceI; import com.shlanbao.tzsc.utils.tools.DateUtil; @Service public class EqmFixedStoptimeServiceImpl implements EqmFixedStoptimeServiceI{ @Autowired private EqmFixedStoptimeDaoI eqmFixedStoptimeDaoI; @Autowired private SchCalendarDaoI schCalendarDaoI; /** * [功能说明]:定时器,每天早上7点生成固定停机时间 * @author wanchanghuang * @date 2017年5月8日15:42:07 * * 1、生产准备时间:每月第一天开始生产前的准备时间。 2、交接班及日常保养:40分钟。 3、停机用餐:白班30分钟;晚班无。 4、换牌时间:40分钟。 5、轮保或周保时间:尚未确定。 6、非作业停机时间:生产计划期内设备不作业的时间,如晚上一点至早上八点。 7、其它剔除时间:停水、电、气、汽以及烟丝断料,由调度员决定是否记录时间。 * * */ @Override public void queryCalendarAddQtyRecord() { try { /** * 1.查询工厂日历 * 2.判断工厂日历,根据固定停机时间设置 * 3.生成当天,当班次固定停机时间 * */ List params = new ArrayList(); params.add(new Date()); String hql="from SchCalendar o where ? between o.stim and o.etim and o.del=0 and o.mdWorkshop.id=1"; List list=schCalendarDaoI.query(hql, params); if(list!=null && list.size()>0){ SchCalendar scr= list.get(0); hql="from EqmFixedStoptime o where o.id in ('1','2','3','4','5','6','7')"; List listefs=null; listefs=eqmFixedStoptimeDaoI.query(hql,null); if(listefs!=null && listefs.size()>0){ EqmFixedStoptime efstime=null; for(EqmFixedStoptime efs:listefs){ efstime=new EqmFixedStoptime(); //efstime.setCreateTime( new Date()); efstime.setDate_(scr.getDate()); efstime.setShift(scr.getMdShift().getId()); efstime.setTeam(scr.getMdTeam().getId()); efstime.setTimes(efs.getTimes()); efstime.setType(efs.getType()); efstime.setUnit(efs.getUnit());//默认单位:分钟 efstime.setId(UUID.randomUUID().toString()); //查询判断是否重复插入 params.clear(); params.add(DateUtil.datetoStr(efstime.getDate_(), "yyyy-MM-dd")); params.add(efstime.getShift()); params.add(efstime.getTeam()); params.add(efstime.getType()); listefs=eqmFixedStoptimeDaoI.query("from EqmFixedStoptime o where to_char(o.date_,'yyyy-MM-dd')=? and o.shift=? and o.team=? and o.type=?", params); if(listefs.size()<=0){ eqmFixedStoptimeDaoI.updateInfo("INSERT INTO EQM_FIXED_STOPTIME (ID,SHIFT,TEAM,TYPE,DATE_,TIMES,UNIT,CREATE_TIME,del)VALUES('"+efstime.getId()+"','"+efstime.getShift()+"','"+efstime.getTeam()+"','"+efstime.getType()+"',to_date ( '"+DateUtil.formatDateToString( efstime.getDate_(),"yyyy-MM-dd HH:mm:ss")+"' , 'yyyy-MM-dd hh24:mi:ss' ),"+efstime.getTimes()+",'6',to_date ( '"+DateUtil.formatDateToString( new Date(),"yyyy-MM-dd HH:mm:ss")+"' , 'yyyy-MM-dd hh24:mi:ss' ),0 )", null); } } } } } catch (Exception e) { e.printStackTrace(); } } }