Просмотр исходного кода

微浦MES,PDA--增加飞达站位绑定解绑功能

xiaost 1 неделя назад
Родитель
Сommit
5a7168ef99

+ 69 - 0
src/com/uas/mes/api/pda/PdaSMTController.java

@@ -352,4 +352,73 @@ public class PdaSMTController extends BaseApiController{
 	public ModelMap quaCheckData(String dsl,String deviceLineMake){
 		return success(pdaSMTService.quaCheckData(dsl,deviceLineMake));
 	}
+
+	/**
+	 * 飞达站位绑定,飞达输入框
+	 * @param fecode 飞达
+	 * @param type  类型:bind/unbind (绑定或者解绑)
+	 */
+	@RequestMapping(value="/getFeederBindCheck.action",method = RequestMethod.GET)
+	public ModelMap getFeederBindCheck (String fecode,String type){
+		if(fecode == null || ("").equals(fecode)){
+			throw new APIErrorException(APIErrorCode.ILLEGAL_ARGUMENTS, "请传递必要的参数飞达");
+		}
+		if(type == null || ("").equals(type)){
+			throw new APIErrorException(APIErrorCode.ILLEGAL_ARGUMENTS, "请传递必要的参数操作类型解绑或者绑定");
+		}
+		return success(pdaSMTService.getFeederBindCheck(fecode,type));
+	}
+
+	/**
+	 * 飞达站位绑定
+	 * @param fecode 飞达
+	 * @param location 站位
+	 */
+	@RequestMapping(value="/feederBindLocation.action",method = RequestMethod.POST)
+	public ModelMap feederBindLocation (String fecode,String location){
+		if(fecode == null || ("").equals(fecode)){
+			throw new APIErrorException(APIErrorCode.ILLEGAL_ARGUMENTS, "请传递必要的参数飞达");
+		}
+		if(location == null || ("").equals(location)){
+			throw new APIErrorException(APIErrorCode.ILLEGAL_ARGUMENTS, "请传递必要的参数站位");
+		}
+		return success(pdaSMTService.feederBindLocation(fecode,location));
+	}
+
+	/**
+	 * * 飞达站位解绑
+	 * @param fecode
+	 * @param location
+	 * @return
+	 */
+	@RequestMapping(value="/feederUnBindLocation.action",method = RequestMethod.POST)
+	public ModelMap feederUnBindLocation (String fecode,String location){
+		if(fecode == null || ("").equals(fecode)){
+			throw new APIErrorException(APIErrorCode.ILLEGAL_ARGUMENTS, "请传递必要的参数飞达");
+		}
+		if(location == null || ("").equals(location)){
+			throw new APIErrorException(APIErrorCode.ILLEGAL_ARGUMENTS, "请传递必要的参数操作类型解绑或者绑定");
+		}
+		return success(pdaSMTService.feederUnBindLocation(fecode,location));
+	}
+
+	/**
+	 * 已经上线更换飞达之后需要进行校验:一进入上料界面,自动发送请求获取未校验站位
+	 */
+	@RequestMapping(value="/quaGetUnCheckFeeder.action",method = RequestMethod.GET)
+	public ModelMap quaGetUnCheckFeeder (String linecode){
+		//return success(pdaSMTService.quaGetUnCheckFeeder(linecode));
+		return success();
+	}
+
+	/**
+	 * 品质校验点击开始校验按钮,自动发送请求,清空校验站位,返回未校验信息
+	 */
+	@RequestMapping(value="/quaCheckFeederData.action",method = RequestMethod.GET)
+	public ModelMap quaCheckFeederData (String linecode){
+		//return success(pdaSMTService.quaCheckFeederData(linecode));
+		return success();
+	}
+
+
 }

+ 7 - 0
src/com/uas/mes/common/interceptor/PdaMobileInterceptor.java

@@ -45,6 +45,13 @@ public class PdaMobileInterceptor extends HandlerInterceptorAdapter {
 					request.getSession().setAttribute("language", "zh_CN");
 				/*baseDao.execute(INSERT_LOGINFO,getIpAddr(request),employee.getEm_name(),username,versioncode,"PDA");*/
 			   }
+			}else if(obj == null) {
+				ServletOutputStream out = response.getOutputStream();
+				String res = "登录失效,请重新登录!";
+				out.write(res.getBytes("utf-8"));
+				out.flush();
+				out.close();
+				return false;
 			}
 		}
 		/*if(username != null && password != null ){	

+ 6 - 0
src/com/uas/mes/pda/service/PdaSMTService.java

@@ -80,4 +80,10 @@ public interface PdaSMTService {
 	Map<String, Object> quaStartCheck(String linecode);
 
 	Map<String, Object> quaCheckData(String dsl, String deviceLineMake);
+
+	Map<String, Object> getFeederBindCheck(String fecode,String type);
+
+	Map<String, Object> feederBindLocation(String fecode, String location);
+
+	Map<String, Object> feederUnBindLocation(String fecode, String location);
 }

+ 87 - 3
src/com/uas/mes/pda/service/impl/PdaSMTServiceImpl.java

@@ -8,6 +8,7 @@ import com.uas.mes.core.exception.APIErrorException;
 import com.uas.mes.core.exception.APIErrorException.APIErrorCode;
 import com.uas.mes.core.util.DateUtil;
 import com.uas.mes.core.util.FlexJsonUtil;
+import com.uas.mes.core.util.StringUtil;
 import com.uas.mes.pda.service.PdaMsdService;
 import com.uas.mes.pda.service.PdaSMTService;
 import com.uas.mes.pm.service.MakePrepareService;
@@ -187,7 +188,6 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		SqlRowList rs = null;
 		//判断料卷号工单号不为空
 
-
 		Object dl_macode = map.get("DL_MACODE");
 		Object linecode= map.get("DL_LINECODE"),location = map1.get("dsl_location");
 		Object table = map.get("DL_TABLE");
@@ -212,8 +212,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 
 		rs = baseDao.queryForRowSet("select psl_baseqty,psl_prodcode,psl_repcode,psl_feeder,psl_id from productsmtlocation "
 				+" where psl_psid=? and psl_location=? and psl_table=? ",map.get("PS_ID"),location, map.get("DL_TABLE"));
-		if (rs.next())
-		{
+		if (rs.next()) {
 			psl_prodcode = rs.getString("psl_prodcode");
 		}
 
@@ -2249,6 +2248,91 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		return mapR;
 	}
 
+	/**
+	 * 飞达站位绑定,飞达输入框,校验飞达是否存在
+	 */
+	@Override
+	public Map<String, Object> getFeederBindCheck(String fecode,String type) {
+		SqlRowList rs = baseDao.queryForRowSet("select fe_id,fe_festatus,fe_location,fe_barcode,fe_code from feeder where fe_code=?",fecode);
+		if(rs.next()){
+			if(type.equals("bind")) { //绑定
+				if (!rs.getString("fe_festatus").contains("正常")) {
+					throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "飞达:" + fecode + "状态为" + rs.getString("fe_festatus") + ",不可操作");
+				}
+				if(StringUtil.hasText(rs.getString("fe_location"))) {
+					throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "飞达:"+fecode+"已绑定站位"+rs.getString("fe_location")+"!");
+				}
+			}
+			if(type.equals("unbind")) { //解绑
+				if(!StringUtil.hasText(rs.getString("fe_location"))) {
+					throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "飞达:"+fecode+"未绑定站位,无需解绑!");
+				}
+			}
+			return rs.getCurrentMap();
+		}else{
+			throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "飞达:"+fecode+"不存在");
+		}
+	}
+
+	/**
+	 * * 飞达站位绑定
+	 * @param fecode
+	 * @param location
+	 * @return
+	 */
+	@Override
+	@Transactional
+	public Map<String, Object> feederBindLocation(String fecode, String location) {
+		Map<String, Object> map = getFeederBindCheck(fecode,"bind");
+		//判断站位是否存在,DeviceLocation
+		SqlRowList rs = baseDao.queryForRowSet("select * from DeviceLocation where DL_LOCATION=?",location);
+		if(rs.next()){
+			//站位未被其它飞达绑定
+			String bfeeder = baseDao.getJdbcTemplate().queryForObject("select wm_concat(fe_code) from feeder where fe_location=?",String.class,location);
+			if(StringUtil.hasText(bfeeder)){
+				throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "站位:"+location+"已经绑定飞达:"+bfeeder);
+			}
+			baseDao.execute("update feeder set fe_location=? where fe_code=?",location,fecode);
+			//如果站位是在线的devsmtlocation 表里面并且dsl_status=0,并且线别非虚拟线别 未校验不可以接料
+			baseDao.execute("update devsmtlocation set dsl_iffeedcheck=-1,DSL_FECODE=? where dsl_id in (select dsl_id from devsmtlocation left join line on dsl_linecode=li_code " +
+					"where dsl_location=? and dsl_status=0 and nvl(li_isvirtual,0)=0)",fecode,location);
+			baseDao.execute("insert into feederlog(FL_ID, FL_FECODE, FL_FEID, FL_TYPE, FL_ITEM, FL_MAN, FL_DATE) " +
+					" select feederlog_seq.nextval,?,?,'绑定站位',?,?,sysdate from dual",fecode,map.get("FE_ID"),"站位:"+location,SystemSession.getUser().getEm_name());
+			Map<String, Object> rmap = new HashMap<>();
+			rmap.put("location",location);
+			rmap.put("fecode",fecode);
+			return rmap;
+		}else{
+			throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "站位:"+location+"不存在");
+		}
+	}
+
+	/**
+	 * * 飞达站位解绑
+	 * @param fecode
+	 * @param location
+	 * @return
+	 */
+	@Override
+	@Transactional
+	public Map<String, Object> feederUnBindLocation(String fecode, String location) {
+		Map<String, Object> map = getFeederBindCheck(fecode,"unbind");
+		if(!location.equals(map.get("FE_LOCATION"))){
+			throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "站位:"+location+"和飞达非绑定关系!绑定的飞达为:"+map.get("FE_LOCATION"));
+		}
+		baseDao.execute("update feeder set fe_location=null where fe_code=?",fecode);
+		//如果站位是在线的devsmtlocation 表里面并且dsl_status=0,并且线别非虚拟线别 未校验不可以接料
+		baseDao.execute("update devsmtlocation set dsl_iffeedcheck=0,DSL_FECODE=null where dsl_id in (select dsl_id from devsmtlocation left join line on dsl_linecode=li_code " +
+				"where dsl_location=? and dsl_status=0 and nvl(li_isvirtual,0)=0)",location);
+		baseDao.execute("insert into feederlog(FL_ID, FL_FECODE, FL_FEID, FL_TYPE, FL_ITEM, FL_MAN, FL_DATE) " +
+				" select feederlog_seq.nextval,?,?,'解绑站位',?,?,sysdate from dual",fecode,map.get("FE_ID"),"站位:"+location,SystemSession.getUser().getEm_name());
+		Map<String, Object> rmap = new HashMap<>();
+		rmap.put("location",location);
+		rmap.put("fecode",fecode);
+		return rmap;
+	}
+
+
 	//因为需要调用两次,所以封装了一个获取未校验站位的方法
 	private Map<String, Object> quaUnLoading(String linecode,int recheck){
 		SqlRowList rs = null;