/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2021-09-01
 * 描述            ：系统操作日志表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
***********************************************************/
package market.Mes.Opr.impl;
import java.util.List;

import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;
import market.Lms.Warehouse.mapper.YdmProductDetailMapper;
import market.Mes.Opr.mapper.MesOprLogMapper;
import market.Mes.Opr.service.MesOprLogService;
import market.Mes.Opr.vo.MesOprLog;

import org.apache.commons.lang.StringUtils;

import com.hnshituo.basic.service.impl.BaseServiceImpl;
import com.hnshituo.basic.spring.remoting.annotation.RemoteService;

@RemoteService(path="MesOprLogService")
public class MesOprLogServiceImpl extends BaseServiceImpl<MesOprLog,Object> implements MesOprLogService {
	
	/**
	 * 进程管理--操作进程查询
	 * @param cp
	 * @return
	 */
	public ResultModel doQueryMesOprLog(CommonPage<MesOprLog> cp) {
		 ResultModel rm = new ResultModel();
		 MesOprLog mol = cp.getObject();
		 String condition = "";
		 if (StringUtils.isNotEmpty(mol.getOpr_model().trim())) {//操作模块
			 condition += " and opr_model like '%"+mol.getOpr_model().trim()+"%'";
		 }
		 if (StringUtils.isNotEmpty(mol.getCoilno().trim())) {//操作卷号
			 condition += " and coilno like '%"+mol.getCoilno().trim()+"%'";
			 condition += " or MEMO like '%"+mol.getCoilno().trim()+"%'";
		 }
		 if (StringUtils.isNotEmpty(cp.getStartTime())) {
			 condition += " and opr_time >= '"+cp.getStartTime()+"'";
		 }
		 if (StringUtils.isNotEmpty(cp.getEndTime())) {
			 condition += " and opr_time <= '"+cp.getEndTime()+"'";
		 }
	     List<MesOprLog> molList = this.getMapper(MesOprLogMapper.class).findWithCondition(null, condition, "opr_time desc,opr_model,opr_view", 0, 0);
	     rm.setState("200");
	     rm.setData(molList);
	     return rm;
   }
	
	
	/**
	 * 进程管理--操作进程查询
	 * @param cp
	 * @return
	 */
	public ResultModel doQueryRollTuiJuan(CommonPage<MesOprLog> cp) {
		 ResultModel rm = new ResultModel();
		 MesOprLog mol = cp.getObject();
		 String condition = "";
		 if (StringUtils.isNotEmpty(mol.getOpr_model().trim())) {//操作模块
			 condition += " and opr_model like '%"+mol.getOpr_model().trim()+"%'";
		 }
		 if (StringUtils.isNotEmpty(mol.getCoilno().trim())) {//操作卷号
			 condition += " and coilno like '%"+mol.getCoilno().trim()+"%'";
		 }
		 if (StringUtils.isNotEmpty(cp.getStartTime())) {
			 condition += " and opr_time >= '"+cp.getStartTime()+"'";
		 }
		 if (StringUtils.isNotEmpty(cp.getEndTime())) {
			 condition += " and opr_time <= '"+cp.getEndTime()+"'";
		 }
//		 String steelName = this.getMapper(YdmProductDetailMapper.class).querySteelNmByJudgeCode("Y2241662T0801");
		 // 写死操作功能为"退卷"，操作界面为："可逆轧机作业管理"：OPR_VIEW 操作界面 ， OPR_FUNCTION 操作功能
		 condition += " and OPR_VIEW = '可逆轧机作业管理' and OPR_FUNCTION = '退卷'";
		 List<MesOprLog> molList = this.getMapper(MesOprLogMapper.class).findWithCondition(null, condition, "opr_time desc,opr_model,opr_view", 0, 0);
	     rm.setState("200");
	     rm.setData(molList);
	     return rm;
   }
}
