Explorar o código

新增接口类型

callm %!s(int64=3) %!d(string=hai) anos
pai
achega
b2f3b1eecb

+ 21 - 3
src/com/uas/mes/api/pda/PdaSMTController.java

@@ -160,7 +160,17 @@ public class PdaSMTController extends BaseApiController{
 	public ModelMap checkData(String dsl,String deviceLineMake){
 		return success(pdaSMTService.checkData(dsl,deviceLineMake));
 	}
-	
+
+	/**
+	 * 站位料卷校验记录日志
+	 * @param dsl 校验 type:loading (上料)、join(接料),dsl_location :站位,dsl_prodcode:物料编号,success:boolean true or false
+	 * @param deviceLineMake 线别等信息
+	 */
+	@RequestMapping(value="/checkDataRepeat.action",method = RequestMethod.POST)
+	public ModelMap checkDataRepeat(String dsl,String deviceLineMake){
+		return success(pdaSMTService.checkDataRepeat(dsl, deviceLineMake));
+	}
+
 	/**
 	 * @param data
 	 * 工单号的模糊查询
@@ -206,16 +216,24 @@ public class PdaSMTController extends BaseApiController{
 	public ModelMap getUnCheckLocation (String linecode){
 		return success(pdaSMTService.getUnCheckLocation(linecode));
 	}
-	
+
 	/**
 	 * @param data
 	 * 点击开始校验按钮,自动发送请求,清空校验站位,返回未校验信息
 	 */	
+	@RequestMapping(value="/startCheckRepeat.action",method = RequestMethod.GET)
+	public ModelMap startCheckRepeat (String linecode){
+		return success(pdaSMTService.startCheckRepeat(linecode));
+	}
+
+	/**
+	 * @param data
+	 * 点击开始校验按钮,自动发送请求,清空校验站位,返回未校验信息
+	 */
 	@RequestMapping(value="/startCheck.action",method = RequestMethod.GET)
 	public ModelMap startCheck (String linecode){
 		return success(pdaSMTService.startCheck(linecode));
 	}
-	
 	/**
 	 * @param data
 	 * 接料前返回需要校验的物料/料卷信息

+ 5 - 1
src/com/uas/mes/pda/service/PdaSMTService.java

@@ -33,7 +33,9 @@ public interface PdaSMTService {
 	Map<String, Object> diffData(String li_code, String ma_code, String table);
 
 	Map<String, Object> checkData(String dl_macode, String dl_linecode);
-	
+
+	Map<String, Object> checkDataRepeat(String dl_macode, String dl_linecode);
+
 	List<Map<String, Object>> fuzzySearch(String inoutNo);
 	
 	List<Map<String, Object>> fuzzySearchProduct(String pr_code);
@@ -45,6 +47,8 @@ public interface PdaSMTService {
 	Map<String, Object> getUnCheckLocation (String linecode);
 	
 	Map<String, Object> startCheck (String linecode);
+
+	Map<String, Object> startCheckRepeat (String linecode);
 	
 	Map<String, Object> joinForcastDataGet(String dsl_location,String dsl_linecode,String dsl_table);
 

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

@@ -1396,6 +1396,89 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		 return mapR;
 	}
 
+	@Override
+	public Map<String, Object> checkDataRepeat(String dsl,String deviceLineMake) {
+		Map<Object, Object> map = FlexJsonUtil.fromJson(deviceLineMake);
+		Map<Object, Object> map1 = FlexJsonUtil.fromJson(dsl);
+		String ma_prodcode = null;
+		String ma_code = String.valueOf(map.get("DL_MACODE"));
+		Object linecode = map.get("DL_LINECODE");
+		Object dl_prodcode = map.get("DL_PRODCODE");
+		String table = null;
+		Object location = map1.get("dsl_location");
+		Object prodcode = map1.get("dsl_prodcode");
+		Integer ps_id = 0;
+		Integer dl_id = 0;
+		boolean success = Boolean.valueOf(String.valueOf(map1.get("success")));
+		SqlRowList rs;
+		int cn=0;
+		cn=baseDao.getCount("select count(1) from devsmtlocation where dsl_linecode='"+linecode+"' and dsl_table ='"+map.get("DL_TABLE")+"' and dsl_location = '"+map1.get("dsl_location")+"' and dsl_status = 0");
+		if(cn==0){
+			baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"复检校验","校验失败,站位未上料",linecode,location,-1,map.get("DL_PRODCODE"),"",map.get("DL_TABLE"),Integer.valueOf(returnMake(linecode,dl_prodcode,map.get("DL_TABLE")).get("hasmake").toString()) == -1 ? returnMake(linecode,dl_prodcode,map.get("DL_TABLE")).get("macode"):"");
+			throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"无上料记录!");
+		}
+		//校验成功
+		if(success){
+			rs = baseDao.queryForRowSet("select dl_id,dl_hasmake,dl_smtid,dl_table,dl_decode,dl_prodcode from deviceline where dl_linecode=? and dl_macode=?",linecode,ma_code);
+			if(rs.next()){
+				dl_id = rs.getInt("dl_id");
+				table = rs.getString("dl_table");
+				ma_prodcode = rs.getString("dl_prodcode");
+				//无论上料还是接料,判断devsmtlocation 表中是否有记录,并且是否有料卷号,
+				//有记录,没有料卷号 --上料,接料:则更新物料编号.  有料卷号--上料、接料:则更新成已校验
+				ps_id = baseDao.getJdbcTemplate().queryForObject("select max(ps_id) from productsmt left join productsmtlocation on psl_psid=ps_id where ps_linecode=? and ps_prodcode=? and ps_statuscode='AUDITED' AND PSL_TABLE=?", Integer.class,linecode,ma_prodcode,table);
+				if(ps_id == null ||ps_id == 0){
+					throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"线别+产品对应的站位表不存在!");
+				}else if(ps_id!=rs.getInt("dl_smtid")){//更新排位表ID
+
+				}
+				baseDao.execute("update devsmtlocation set dsl_ifcheck=-1 where dsl_linecode=? and dsl_makecode=? and dsl_location=? and dsl_status=0",linecode,ma_code,location);
+			}
+		}
+		//成功失败都记录日志
+		int i=0;String meg = "校验成功";
+		if(!success){
+			i =-1;
+			meg = "校验失败";
+		}
+		baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"复检校验",meg+",料号:"+prodcode,linecode,location,i,map.get("DL_PRODCODE"),"",map.get("DL_TABLE"),Integer.valueOf(returnMake(linecode,dl_prodcode,map.get("DL_TABLE")).get("hasmake").toString()) == -1 ? returnMake(linecode,dl_prodcode,map.get("DL_TABLE")).get("macode"):"");
+		if(success)
+		{
+			baseDao.execute("update smtmessagelog  set sml_confirm = -1 where sml_linecode  = '"+linecode+"' and sml_type = '接料原物料号校验' and sml_location = '"+location+"' and sml_date > sysdate-1/2 and sml_table = '"+map.get("DL_TABLE")+"'");
+		}
+		//ps_id,table,linecode,ma_code,table
+		Map<String,Object> mapR = new HashMap <String, Object>();
+		rs=baseDao.queryForRowSet("select * from (select psl_location from(select min(psl_detno)psl_detno,psl_location from productsmtlocation "
+				+" where psl_psid=? and psl_table=? and  psl_location not in (select distinct dsl_location from devsmtlocation where "
+				+" dsl_linecode=? and dsl_makecode=? and dsl_table=?  and dsl_status=0 and dsl_ifcheck = -1) "
+				+" group by psl_location order by psl_detno)) where rownum<=20 ",ps_id,table,linecode,ma_code,table);
+		if(rs.next()){
+			mapR.put("NotCheckLocation", rs.getResultList());
+		}else{
+			mapR.put("NotCheckLocation", "");
+		}
+		rs=baseDao.queryForRowSet("select count(1) cn from (select distinct psl_location from productsmtlocation where psl_psid=? and psl_table=? and "
+				+" psl_location not in (select distinct dsl_location from devsmtlocation where "
+				+" dsl_linecode=? and dsl_makecode=? and dsl_table=? and dsl_status=0 and dsl_ifcheck = -1)) ",ps_id,table,linecode,ma_code,table);
+		if(rs.next()){
+			mapR.put("NotCheckCount", rs.getInt("cn"));
+		}else{
+			mapR.put("NotCheckCount",0);
+		}
+		if(success){
+			Integer psl_id = baseDao.getJdbcTemplate().queryForObject("select max(psl_id) from productsmtlocation where psl_psid=? and psl_table=? and (psl_location,psl_prodcode) "
+					+" not in(select dsl_location,dsl_fprodcode from devsmtlocation where dsl_linecode=? "
+					+" and dsl_makecode=? and dsl_status=0 and dsl_ifcheck=-1)",Integer.class,ps_id,table,linecode,ma_code);
+			if(psl_id == null || psl_id == 0){
+				baseDao.execute("update deviceline set dl_checkcount=nvl(dl_checkcount,0)+1 where dl_id=?",dl_id);
+				baseDao.execute("update devsmtlocation set dsl_ifcheck = 0 where dsl_linecode=? and dsl_makecode=? and dsl_table=? and dsl_status=0",linecode,ma_code,table);
+				baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"复检校验","完成一次校验",linecode,"",0,map.get("DL_PRODCODE"),"",map.get("DL_TABLE"),Integer.valueOf(returnMake(linecode,dl_prodcode,map.get("DL_TABLE")).get("hasmake").toString()) == -1 ? returnMake(linecode,dl_prodcode,map.get("DL_TABLE")).get("macode"):"");
+
+			}
+		}
+		return mapR;
+	}
+
 	/**
 	 * 针对输入的工单号进行模糊查询
 	 */
@@ -1538,9 +1621,21 @@ public class PdaSMTServiceImpl implements PdaSMTService {
                     baseDao.execute("update smtmessagelog  set sml_confirm = -1 where  sml_type = '接料原物料号校验' and sml_linecode  = '"+linecode+"' and sml_date > sysdate-1/2 and sml_table = '"+rs.getString("dl_table")+"'");
 				}
 			 return unLoading(linecode);
-		}	
-		
-		//因为需要调用两次,所以封装了一个获取未校验站位的方法
+		}
+
+	//重新校验
+	@Override
+	public Map<String, Object> startCheckRepeat(String linecode) {
+		baseDao.execute("update devsmtlocation set dsl_ifcheck =0 where dsl_linecode = ? and dsl_status = 0 and dsl_ifcheck = -1",linecode);
+		SqlRowList rs = baseDao.queryForRowSet("select dl_prodcode,dl_table from deviceline where dl_linecode = ?",linecode);
+		if(rs.next()){
+			baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"复检校验","重新校验",linecode,"",0,rs.getString("dl_prodcode"),"",rs.getString("dl_table"),Integer.valueOf(returnMake(linecode,rs.getString("dl_prodcode"),rs.getString("dl_table")).get("hasmake").toString()) == -1 ? returnMake(linecode,rs.getString("dl_prodcode"),rs.getString("dl_table")).get("macode"):"");
+			baseDao.execute("update smtmessagelog  set sml_confirm = -1 where  sml_type = '接料原物料号校验' and sml_linecode  = '"+linecode+"' and sml_date > sysdate-1/2 and sml_table = '"+rs.getString("dl_table")+"'");
+		}
+		return unLoading(linecode);
+	}
+
+	//因为需要调用两次,所以封装了一个获取未校验站位的方法
 		private Map<String, Object> unLoading(String linecode){
 			SqlRowList rs = null;
 			Object macode = null;