Browse Source

微浦MES,增加飞达校验,等飞达相关修改

xiaost 3 days ago
parent
commit
c0ec64b24d
1 changed files with 42 additions and 9 deletions
  1. 42 9
      src/com/uas/mes/pda/service/impl/PdaSMTServiceImpl.java

+ 42 - 9
src/com/uas/mes/pda/service/impl/PdaSMTServiceImpl.java

@@ -197,6 +197,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		String type = "barcode", ps_prodcode = null;
 		int has_make = 0;
 		String handleType = "上料";
+		int fe_id = 0; //飞达ID
 		boolean bool = baseDao.isDBSetting("smthandleerrlog");
 		String mainline = "";
 		rs = baseDao.queryForRowSet("select dl_macode,dl_hasmake,dl_statuscode,dl_prodcode,dl_mainline from deviceline where dl_linecode =? ", linecode);
@@ -229,9 +230,10 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		//是否启动飞达绑定站位
 		boolean feederBindLocation = baseDao.isDBSetting("MESSetting", "FeederBindLocation");
 		if (feederBindLocation) {
-			rs = baseDao.queryForRowSet("select fe_code,fe_location from feeder where (fe_code=? or fe_location=?) and fe_code is not null", location, location);
+			rs = baseDao.queryForRowSet("select fe_id,fe_code,fe_location from feeder where (fe_code=? or fe_location=?) and fe_code is not null", location, location);
 			if (rs.next()) {
 				fe_code = rs.getString("fe_code");
+				fe_id = rs.getInt("fe_id");
 				if (StringUtil.hasText(rs.getString("fe_location"))) {
 					location = rs.getString("fe_location");
 				} else {
@@ -274,10 +276,11 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			if (rs.next()) {
 				showSmtError(APIErrorCode.DATA_NOT_FOUND, "该站位已上料", handleType, linecode, location, ps_prodcode, "", bool, table);
 			}
-			rs = baseDao.queryForRowSet("select fe_code,fe_location,fe_barcode from feeder where fe_code='" + bar_code + "' and fe_code is not null");
+			rs = baseDao.queryForRowSet("select fe_id,fe_code,fe_location,fe_barcode from feeder where fe_code='" + bar_code + "' and fe_code is not null");
 			//验证飞达是否存在
 			if (rs.next()) {
 				fe_code = rs.getString("fe_code");
+				fe_id = rs.getInt("fe_id");
 				String fe_location = rs.getString("fe_location");
 				String fe_barcode = rs.getString("fe_barcode");
 				bar_code = rs.getString("fe_barcode");
@@ -367,7 +370,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				baseDao.execute("update feeder set fe_usestatus='上线',fe_lastonlinetime=sysdate,fe_lastofflinetime=null where fe_code=?",fe_code);
 			    baseDao.execute("insert into feederlog(FL_ID, FL_FECODE, FL_FEID, FL_TYPE, FL_ITEM, FL_MAN, FL_DATE,FL_LOCATION,FL_LICODE,FL_MACODE,FL_TABLE,fl_isvirtualline) " +
 							" select feederlog_seq.nextval,?,?,?,?,?,sysdate,?,?,?,?,? from dual",
-						fe_code,map.get("FE_ID"),"上线","站位:"+location,SystemSession.getUser().getEm_name(),location,linecode,dl_macode,table,0);
+						fe_code,fe_id,"上线","站位:"+location,SystemSession.getUser().getEm_name(),location,linecode,dl_macode,table,0);
 		   }
 	    }
 		double ma_qty=0;
@@ -452,7 +455,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		int has_make=0;
 		int isVir = 0;  //是否虚拟备料线
 		boolean bool = baseDao.isDBSetting("smthandleerrlog");
-		rs = baseDao.queryForRowSet("select dl_statuscode,dl_prodcode,dl_mainline,dl_hasmake from deviceline where dl_linecode =?",linecode);
+		rs = baseDao.queryForRowSet("select dl_status code,dl_prodcode,dl_mainline,dl_hasmake from deviceline where dl_linecode =?",linecode);
 		if(rs.next()){
 			if(StringUtil.hasText(rs.getGeneralString("dl_mainline"))){
 				handleType = "备料下料";
@@ -484,7 +487,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			}
 		}*/
 		boolean feederBindLocation = baseDao.isDBSetting("MESSetting","FeederBindLocation");
-		rsReturn = baseDao.queryForRowSet("select max(dsl_location) dsl_location,max(dsl_remainqty) dsl_remainqty,max(dsl_id) dsl_id,max(dsl_barcode) dsl_barcode,max(dsl_fespec) dsl_fespec,max(dsl_prodcode) dsl_prodcode,wm_concat(nvl(dsl_barcode,dsl_prodcode)) dsl_return from devsmtlocation "
+		rsReturn = baseDao.queryForRowSet("select max(dsl_location) dsl_location,max(dsl_remainqty) dsl_remainqty,max(dsl_id) dsl_id,max(dsl_barcode) dsl_barcode,max(dsl_fecode) dsl_fespec,max(dsl_prodcode) dsl_prodcode,wm_concat(nvl(dsl_barcode,dsl_prodcode)) dsl_return from devsmtlocation "
 				+ " where dsl_linecode=? and dsl_makecode=? and dsl_status=0 and dsl_location =? and dsl_table =? ",linecode,ma_code,dsl_location,table);
 		if(rsReturn.next()){
 			rs = baseDao.queryForRowSet("select sum(dsl_remainqty) dsl_remainqty,max(dsl_id) dsl_id, count(1) cn from"
@@ -501,9 +504,9 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 					sqls.add("update barcode set bar_place=1 where bar_code=(select dsl_barcode from devsmtlocation "
 							+" where dsl_id="+rs.getInt("dsl_id")+" and dsl_linecode='"+linecode+"' and dsl_location='"+dsl_location+"' and dsl_makecode='"+ma_code+"' and dsl_status=0 and dsl_table= '"+table+"' ) and bar_place='"+ma_code+"'");
 				}
-					sqls.add("update devsmtlocation set dsl_status=-1,dsl_cutman='"+SystemSession.getUser().getEm_name()+"',dsl_invalidtime=sysdate"
+					sqls.add("update devsmtlocation set dsl_status=-1,dsl_cutman='"+SystemSession.getUser().getEm_name()+"',dsl_invalidtime=sysdate,dsl_fecode=null"
 						+" where dsl_linecode='"+linecode+"' and dsl_makecode='"+ma_code+"' and dsl_status=0 and dsl_location ='"+dsl_location+"' and dsl_table='"+table+"' and dsl_invalidtime is  null");
-					sqls.add("update devsmtlocation set dsl_status=-1,DSL_USABLE = 2 "
+					sqls.add("update devsmtlocation set dsl_status=-1,DSL_USABLE = 2 ,dsl_fecode=null "
 					+" where dsl_linecode='"+linecode+"' and dsl_makecode='"+ma_code+"' and dsl_status=0 and dsl_location ='"+dsl_location+"' and dsl_table='"+table+"' ");
 				//记录日志下料
 				//把飞达和站位解绑,Untying=-1飞达和条码号解绑
@@ -731,6 +734,36 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			}else{
 				sqls.add("update make set ma_smtbqty ="+dl_madeqty+" where ma_code = '"+dl_macode+"'");
 			}
+			baseDao.execute(sqls);
+			sqls = new ArrayList<>() ;
+			//使用完成的没下线的
+			if(feederBindLocation) {
+				rs = baseDao.queryForRowSet("select dsl_fecode,dsl_location from devsmtlocation left join feeder on fe_code=dsl_fecode " +
+						" where dsl_linecode=? and dsl_makecode=? and dsl_table=? and fe_location=dsl_location group by dsl_fecode,dsl_location ",
+						dl_linecode,dl_macode,dl_table);
+				if(rs.next()) {
+					String fecode = rs.getString("dsl_fecode");
+					dsl_location = rs.getString("dsl_location");
+					String type = "下线";
+					String sql = " update feeder set fe_location=''";
+					//非虚拟的 更新飞达状态,上线时间等,插入日志??
+					if (isVir == 0) {
+						sql += ",fe_lastofflinetime=sysdate," +
+								"fe_usetotalmin=nvl(fe_usetotalmin,0)+(case when fe_lastonlinetime is not null then" +
+								"  round((sysdate-fe_lastonlinetime)*24*60) else 0 end)," +
+								" fe_usestatus='未使用' ";
+					} else {
+						type = "解绑站位";
+						isVir = -1;
+					}
+					sqls.add("insert into feederlog(FL_ID,FL_FECODE,FL_FEID, FL_TYPE, FL_ITEM, FL_MAN, FL_DATE,FL_LOCATION,FL_LICODE,FL_MACODE,FL_TABLE,fl_isvirtualline) "
+							+ " select feederlog_seq.nextval,'" + fecode + "',fe_id,'" + type + "','站位:" + dsl_location + "," + handType + "','" + SystemSession.getUser().getEm_name() + "',"
+							+ " sysdate,'" + dsl_location + "','" + dl_linecode + "','" + dl_macode + "','" + dl_table + "'," + isVir + " from feeder where fe_code='" + fecode + "' and fe_location='" + dsl_location + "'");
+					sql += " where fe_location='" + dsl_location + "' and fe_code='" + fecode + "'";
+					sqls.add(sql);
+				}
+			}
+
 			//更新成下料将数据导入至makesmtlocation
 			sqls.add("update devsmtlocation set dsl_status=-1,dsl_invalidtime=sysdate,dsl_cutman='"+SystemSession.getUser().getEm_name()+"' where dsl_linecode='"+dl_linecode+"' and dsl_makecode='"+dl_macode+"' and dsl_status=0 and dsl_invalidtime is null");
 			sqls.add("insert into makesmtlocation(msl_id,msl_maid,msl_makecode,msl_mcid,msl_mccode,msl_mmdetno,msl_location,msl_prodcode,msl_repcode,msl_fespec,"
@@ -2578,7 +2611,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		baseDao.execute(sql + " where fe_code=?",fecode);
 
 		SqlRowList rs1 = baseDao.queryForRowSet("select DSL_MAKECODE,DSL_TABLE,DSL_LINECODE,nvl(li_isvirtual,0)li_isvirtual  from devsmtlocation left join line on dsl_linecode=li_code " +
-				" where dsl_location=? and dsl_status=0 and DSL_FECODE=? ",location,fecode);
+				" where dsl_location=? and DSL_FECODE=? ",location,fecode);
 		if(rs1.next()){
 			if(rs1.getInt("li_isvirtual") == 0 ) { //非虚拟线,描述为上线绑定站位
 				type = "下线解绑站位";
@@ -2593,7 +2626,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		}
 		//如果站位是在线的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)",location); //and nvl(li_isvirtual,0)=0 虚拟非虚拟线解绑都更新
+				"where dsl_location=? )",location); //and nvl(li_isvirtual,0)=0 虚拟非虚拟线解绑都更新
 		Map<String, Object> rmap = new HashMap<>();
 		rmap.put("location",location);
 		rmap.put("fecode",fecode);