Browse Source

SMT修改绑定飞达操作
(cherry picked from commit 33ab384)

callm 5 years ago
parent
commit
7e22c5688e

+ 15 - 26
src/com/uas/mes/api/pda/PdaSMTController.java

@@ -21,7 +21,6 @@ public class PdaSMTController extends BaseApiController{
 	private PdaSMTService pdaSMTService;
 	/**
 	 * 根据输入的线别编号,线别只能有一条记录,根据线别编号+工单号+板面
-	 * @param code
 	 * @param has_noma true 表示无工单,false表示有工单 ,可以允许用户无工单直接用产品编号或排位表数据进行上料防呆
 	 * @return
 	 */
@@ -32,7 +31,6 @@ public class PdaSMTController extends BaseApiController{
 	
 	/**
 	 *  获取料站排位表数据
-	 * @param data
 	 * @return
 	 */
 	@RequestMapping(value="/getSmtLocation.action",method = RequestMethod.GET)
@@ -43,7 +41,6 @@ public class PdaSMTController extends BaseApiController{
 	
 	/**
 	 * 确认上料,判断
-	 * @param data
 	 * @return
 	 */
 	@RequestMapping(value="/loading.action",method = RequestMethod.POST)
@@ -54,30 +51,27 @@ public class PdaSMTController extends BaseApiController{
 	
 	/**
 	 * 确认下料,判断
-	 * @param data
 	 * @return
 	 */
 	@RequestMapping(value="/cuttingStock.action",method = RequestMethod.POST)
-	public  ModelMap cuttingStock(String code ,String deviceLineMake){		
-		List<Map<String, Object>> modelMap = pdaSMTService.cuttingStock(code,deviceLineMake);
+	public  ModelMap cuttingStock(String code ,String deviceLineMake,Integer Untying){
+		List<Map<String, Object>> modelMap = pdaSMTService.cuttingStock(code,deviceLineMake,Untying);
 		return success(modelMap);
 		
 	}
 		
 	/**
 	 * 确认全部下料,判断
-	 * @param data
 	 * @return
 	 */
 	@RequestMapping(value="/cuttingAllStock.action",method = RequestMethod.POST)
-	public  ModelMap cuttingAllStock(String dl_macode,String dl_linecode,Integer dl_madeqty){				
-		pdaSMTService.cuttingAllStock(dl_macode,dl_linecode,dl_madeqty);
+	public  ModelMap cuttingAllStock(String dl_macode,String dl_linecode,Integer dl_madeqty,Integer Untying ){
+		pdaSMTService.cuttingAllStock(dl_macode,dl_linecode,dl_madeqty,Untying);
 		return success();
 	}
 		
 	/**
 	 * 接料,判断
-	 * @param data
 	 * @return
 	 */
 	@RequestMapping(value="/joinMaterial.action",method = RequestMethod.POST)
@@ -88,7 +82,6 @@ public class PdaSMTController extends BaseApiController{
 	
 	/**
 	 * 换料,判断
-	 * @param data
 	 * @return
 	 */
 	@RequestMapping(value="/changeMaterial.action",method = RequestMethod.POST)
@@ -98,7 +91,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 切换工单
 	 * has_noma:true 代表无工单,false 代表有工单
 	 */	
@@ -118,7 +110,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 机台操作-停止
 	 */	
 	@RequestMapping(value="/stopSmt.action",method = RequestMethod.POST)
@@ -127,7 +118,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 在线料卷查询
 	 */	
 	@RequestMapping(value="/queryData.action",method = RequestMethod.GET)
@@ -144,7 +134,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 产出数查询
 	 */	
 	@RequestMapping(value="/queryMadeqty.action",method = RequestMethod.GET)
@@ -163,7 +152,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 工单号的模糊查询
 	 */	
 	@RequestMapping(value="/fuzzySearch.action",method = RequestMethod.GET)
@@ -172,7 +160,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 工单号的模糊查询
 	 */	
 	@RequestMapping(value="/fuzzySearchProduct.action",method = RequestMethod.GET)
@@ -181,7 +168,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 接料前原工单的校验
 	 */	
 	@RequestMapping(value="/joinForecastDataCheck.action",method = RequestMethod.POST)
@@ -191,7 +177,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 一进入上料界面,自动发送请求获取未上料站位
 	 */	
 	@RequestMapping(value="/getUnLoadingLocation.action",method = RequestMethod.GET)
@@ -200,7 +185,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 一进入上料界面,自动发送请求获取未校验站位
 	 */	
 	@RequestMapping(value="/getUnCheckLocation.action",method = RequestMethod.GET)
@@ -209,7 +193,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 点击开始校验按钮,自动发送请求,清空校验站位,返回未校验信息
 	 */	
 	@RequestMapping(value="/startCheck.action",method = RequestMethod.GET)
@@ -218,7 +201,6 @@ public class PdaSMTController extends BaseApiController{
 	}
 	
 	/**
-	 * @param data
 	 * 接料前返回需要校验的物料/料卷信息
 	 */	
 	@RequestMapping(value="/joinForcastDataGet.action",method = RequestMethod.GET)
@@ -304,12 +286,19 @@ public class PdaSMTController extends BaseApiController{
 		return success(pdaSMTService.barcodeGetLocation(barcode,devicelineinfo));
 	}
 
+	/**
+	 SMT-根据条码号获取站位
+	 */
+	@RequestMapping(value="/bindFeederBarcode.action",method = RequestMethod.POST)
+	public ModelMap bindFeederBarcode(String barcode,String fe_code){
+		return success(pdaSMTService.bindFeederBarcode(barcode,fe_code));
+	}
 
 	/**
-	 SMT-根据条码号获取站位,备料使用
+	 SMT-根据飞达获取站位
 	 */
-	@RequestMapping(value="/prebarcodeGetLocation.action")
-	public ModelMap prebarcodeGetLocation(String barcode,String linecode,String makecode,String table){
-		return success(pdaSMTService.prebarcodeGetLocation(barcode, linecode,makecode,table));
+	@RequestMapping(value="/getFeederLocation.action")
+	public ModelMap getFeederLocation(String fe_code){
+		return success(pdaSMTService.getFeederLocation(fe_code));
 	}
 }

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

@@ -12,9 +12,9 @@ public interface PdaSMTService {
 
 	Map<String, Object> loading(String dsl, String deviceLineMake);
 
-	List<Map<String, Object>> cuttingStock(String code ,String deviceLineMake);
+	List<Map<String, Object>> cuttingStock(String code ,String deviceLineMake,Integer Untying);
 
-	void cuttingAllStock(String dl_macode,String dl_linecode , Integer dl_madeqty);
+	void cuttingAllStock(String dl_macode,String dl_linecode , Integer dl_madeqty,Integer Untying);
 
 	Map<String, Object> joinMaterial(String dsl, String deviceLineMake);
 
@@ -66,5 +66,7 @@ public interface PdaSMTService {
 
 	Map<String, Object> barcodeGetLocation(String barcode,String devicelineinfo);
 
-	Map<String, Object> prebarcodeGetLocation(String barcode,String linecode,String makecode,String table);
+	Map<String, Object> bindFeederBarcode(String barcode,String fe_code);
+
+	Map<String, Object> getFeederLocation(String fe_code);
 }

+ 107 - 101
src/com/uas/mes/pda/service/impl/PdaSMTServiceImpl.java

@@ -189,6 +189,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		Object dl_macode = map.get("DL_MACODE");
 		Object linecode= map.get("DL_LINECODE"),location = map1.get("dsl_location");
 		Object table = map.get("DL_TABLE");
+		Object fe_code = map1.get("dsl_fecode");
 		String type="barcode",ps_prodcode = null;
 		int has_make=0;
 		String handleType = "上料";
@@ -209,7 +210,23 @@ 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='"+fe_code+"'");
+		//验证飞达是否存在
+		if(rs.next()){
+            String fe_location=rs.getString("fe_location");
+            String fe_barcode=rs.getString("fe_barcode");
+			bar_code=rs.getString("fe_barcode");
+			//飞达未绑定其他站位的时候
+            if(fe_barcode == null || ("").equals(fe_barcode)){
+                throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "飞达未绑定料盘");
+            }
+			if(!(fe_location == null || ("").equals(fe_location))){
+                throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "飞达已绑定站位"+fe_location);
+            }
+		}else {
+			throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "飞达"+fe_code+"不存在");
+		}
+
 		rs = baseDao.queryForRowSet("select bar_remain,nvl(bar_place,1)bar_place,bar_prodcode,bar_code from barcode where bar_code=? ",bar_code);
 		if(rs.next()){
 			rs1 = baseDao.queryForRowSet("select psl_baseqty,psl_prodcode,psl_repcode,psl_feeder,psl_id from productsmtlocation "
@@ -236,15 +253,11 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 					if(bar_code.toString().contains(rs.getString("psl_prodcode"))){
 						pr_code = rs.getString("psl_prodcode");
 					}else{
-						try {
-							String [] stringArr= rs.getString("repcode").split(",");
-							for (String s : stringArr) {
-								if (bar_code.toString().contains(s)) {
-									pr_code = s;
-								}
+						String [] stringArr= rs.getString("repcode").split(","); 
+						for (String s : stringArr) {
+							if (bar_code.toString().contains(s)) {
+								pr_code = s;
 							}
-						}catch (Exception ex){
-
 						}
 						if(pr_code == null || ("").equals(pr_code)){
 								showSmtError(APIErrorCode.DATA_NOT_FOUND,"物料["+bar_code+"]不是该站位需要上料的物料",handleType,linecode,location,ps_prodcode,"料号"+bar_code,bool,table);
@@ -259,6 +272,8 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		        }
 			}
 		}
+		//更新飞达所在站位
+		baseDao.updateByCondition("feeder","fe_location='"+location+"'","fe_code='"+fe_code+"'");
 		double ma_qty=0;
 		rs = baseDao.queryForRowSet("select ma_qty from make where ma_id=?",map.get("MA_ID"));
 		if(rs.next()){
@@ -269,7 +284,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		 * @Date 2018-01-22
 		 * 校验是否湿敏条码
 		 * */
-		//checkMsdBarCode(bar_code);
+		checkMsdBarCode(bar_code);
 		//上料
 		rs = baseDao.queryForRowSet("select wm_concat(psl_repcode) repcode ,max(psl_prodcode)psl_prodcode,count(1) cn ,max(psl_feeder) psl_feeder, max(psl_baseqty) psl_baseqty from productsmtlocation "
 			+ " where  psl_psid=? and psl_location=? and psl_table=?",map.get("PS_ID"),location,map.get("DL_TABLE"));
@@ -286,9 +301,9 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		 * @Date 2018-01-22
 		 *  上料、接料、换料 更新状态为“已上线” 并记录日志
 		 * */
-//		if(checkMsdBarCode(bar_code)){
-//			updateMsdbarcodeOnLine(bar_code);
-//		}
+		if(checkMsdBarCode(bar_code)){
+			updateMsdbarcodeOnLine(bar_code);
+		}
 		//记录日志上料
 	    baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"上料","上料成功,"+(has_make == -1 ? "工单":"产品")+":"+dl_macode+","+(("product").equals(type)?"物料编号":"料卷号")+":"+bar_code,linecode,location,0,ps_prodcode,("product").equals(type)?"物料"+pr_code:"料卷"+bar_code,map.get("DL_TABLE"),has_make == -1?dl_macode:"");
 	    Map<String,Object> mapR = new HashMap<String,Object>();
@@ -326,7 +341,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 	 * 确认下料
 	 */
 	@Override
-	public List<Map<String, Object>> cuttingStock(String code ,String deviceLineMake) {
+	public List<Map<String, Object>> cuttingStock(String code ,String deviceLineMake,Integer Untying) {
 		Map<Object, Object> map = FlexJsonUtil.fromJson(deviceLineMake);
 		SqlRowList rs = null;
 		SqlRowList rsReturn = null;
@@ -352,7 +367,14 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		if(rsReturn.next()){
 			dsl_location = rsReturn.getString("dsl_location"); //站位,一个站位统一下料
 		}else{
-			showSmtError(APIErrorCode.DATA_NOT_FOUND,"机台+工单+站位["+code+"]无上料数据,无需下料",handleType,linecode,"",pr_code,"",bool,table);			
+			//查询Code是否是飞达
+			rs=baseDao.queryForRowSet("select fe_location from feeder where fe_code='"+code+"'");
+			if(rs.next()){
+				dsl_location=rs.getString("fe_location");
+			}else
+			{
+				showSmtError(APIErrorCode.DATA_NOT_FOUND,"机台+工单+站位["+code+"]无上料数据,无需下料",handleType,linecode,"",pr_code,"",bool,table);
+			}
 		}
 		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 "
 				+ " where dsl_linecode=? and dsl_makecode=? and dsl_status=0 and dsl_location =? and dsl_table =? ",linecode,map.get("DL_MACODE"),dsl_location,map.get("DL_TABLE"));
@@ -373,13 +395,19 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 					}
 					    sqls.add("update devsmtlocation set dsl_status=-1,dsl_cutman='"+SystemSession.getUser().getEm_name()+"',dsl_invalidtime=sysdate"
 							+" where dsl_linecode='"+linecode+"' and dsl_makecode='"+ma_code+"' and dsl_status=0 and dsl_location ='"+dsl_location+"' and dsl_table='"+map.get("DL_TABLE")+"'");
-				    baseDao.execute(sqls);
 				    //记录日志下料
 				    rs = baseDao.queryForRowSet("select dl_macode,dl_hasmake from deviceline where dl_linecode =?",linecode);
 					int has_make=0;
 					if(rs.next()){
 						has_make=rs.getInt("dl_hasmake");
 					}
+					//把飞达和站位解绑,Untying=-1飞达和条码号解绑
+					if(Untying==-1){
+						sqls.add("update feeder set fe_location='',fe_barcode='' where fe_location='"+dsl_location+"'");
+					}else {
+						sqls.add("update feeder set fe_location='' where  fe_location='"+dsl_location+"'");
+					}
+                    baseDao.execute(sqls);
 				    baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"下料","下料成功,"+(has_make == -1 ? "工单":"产品")+":"+ma_code+",料卷号或站位:"+code,linecode,dsl_location,0,pr_code,rsReturn.getString("dsl_return"),map.get("DL_TABLE"),has_make == -1?ma_code:"");
 				    return rsReturn.getResultList();
 			}else{
@@ -394,7 +422,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 	 */
 	@Override
 	@Transactional
-	public void cuttingAllStock(String dl_macode,String dl_linecode,Integer dl_madeqty) {
+	public void cuttingAllStock(String dl_macode,String dl_linecode,Integer dl_madeqty,Integer Untying) {
 		SqlRowList rs = null;
 		int madeqty = 0;
 		String dl_table="",dl_devcode = "",dl_prodcode;
@@ -468,6 +496,11 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 					//只有一条记录直接扣料
 					sqls.add("update devsmtlocation set dsl_remainqty="+dsl_remainqty+" where dsl_id="+rs.getInt("dsl_id"));
 					sqls.add("update barcode set bar_place=1,bar_forcastremain="+dsl_remainqty+",bar_remain="+dsl_remainqty+" where bar_code='"+rs.getString("dsl_barcode")+"' and bar_place='"+dl_macode+"'");
+                    if(Untying==-1){
+                        sqls.add("update feeder set fe_location='',fe_barcode='' where fe_location='"+dsl_location+"'");
+                    }else {
+                        sqls.add("update feeder set fe_location='' where fe_location='"+dsl_location+"'");
+                    }
 				}else{//多条记录
 					//扣料
 					if(actAddQty >0){
@@ -490,6 +523,12 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 							}
 						}
 					}
+					//把飞达和站位解绑,Untying=-1飞达和条码号解绑
+					if(Untying==-1){
+						sqls.add("update feeder set fe_location='',fe_barcode='' where fe_location='"+dsl_location+"'");
+					}else {
+						sqls.add("update feeder set fe_location='' where fe_location='"+dsl_location+"'");
+					}
 					//接料原料卷数量更新成0,接料实际操作是将原料卷剩余料拼到新料卷中
 					sqls.add("update barcode set bar_place=1,bar_forcastremain=0,bar_remain=0 where bar_code in (select dsl_barcode from devsmtlocation where dsl_linecode='"+dl_linecode+"' and dsl_makecode='"+dl_macode+"' and dsl_status=0 and dsl_location='"+rs.getString("dsl_location")+"' and dsl_id<>"+rs.getInt("dsl_id")+") and bar_place='"+dl_macode+"'");
 					//多条记录接料料卷
@@ -545,7 +584,6 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		Object bar_code = map1.get("dsl_barcode");
 		Boolean isBarcode = isOurBarcode(bar_code);
 		int has_make=0;
-		double remain = 0;
 		double bar_remain=0;
 		String pr_code = null;
 		String dsl_barcode = null;
@@ -628,17 +666,12 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		 * @Date 2018-01-22
 		 * 校验是否湿敏条码
 		 * */
-		//checkMsdBarCode(bar_code);
+		checkMsdBarCode(bar_code);
 		double ma_qty=0;
 		rs2 = baseDao.queryForRowSet("select ma_qty from make where ma_id=?",map.get("MA_ID"));
 		if(rs2.next()){
 			ma_qty=rs2.getDouble("ma_qty");
 		}
-		rs = baseDao.queryForRowSet("select sum(dsl_remainqty) dsl_remainqty,max(dsl_id) dsl_id, count(1) cn from"
-				+" devsmtlocation where dsl_linecode=? and dsl_makecode=? and dsl_status=0 and dsl_table=? and dsl_location =? ",linecode,ma_code,map.get("DL_TABLE"),location);
-		if(rs.next()) {
-			remain = rs.getDouble("dsl_remainqty")>0?rs.getDouble("dsl_remainqty"):0;  //将第一个料卷剩余料加给第二个料卷
-		}
 		rs2 = baseDao.queryForRowSet("select wm_concat(psl_repcode)repcode ,count(1) cn ,max(psl_prodcode)psl_prodcode,count(1) cn ,max(psl_feeder) psl_feeder, max(psl_baseqty) psl_baseqty from productsmtlocation "
 				+"where psl_psid=? and psl_location=? and psl_table=?",map.get("PS_ID"),location,map.get("DL_TABLE"));
 		if(rs2.next()){
@@ -662,7 +695,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			}
 			baseDao.execute("insert into devsmtlocation (dsl_id,dsl_maid,dsl_makecode,dsl_location,dsl_prodcode,dsl_repcode,dsl_fespec,dsl_baseqty,dsl_table,dsl_needqty,dsl_getqty,dsl_remainqty,dsl_barcode,dsl_linecode,dsl_devcode,dsl_status, dsl_indate,dsl_inman,dsl_ifcheck,dsl_fprodcode,dsl_usable,dsl_validtime)values( DEVSMTLOCATION_SEQ.nextval,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,sysdate,?,?,?,?,?)",map.get("MA_ID"),ma_code,location,pr_code,rs2.getString("repcode"),
 					rs2.getString("psl_feeder"),rs2.getDouble("psl_baseqty"),map.get("DL_TABLE"),rs2.getDouble("psl_baseqty")*ma_qty,
-					bar_remain+remain,bar_remain+remain,(("product").equals(type)?"":bar_code),linecode,map.get("DL_DECODE"),SystemSession.getUser().getEm_name(),0,rs2.getString("psl_prodcode"),usable,(usable==1)?Timestamp.valueOf(DateUtil.currentDateString(Constant.YMD_HMS)):"");
+					bar_remain,bar_remain,(("product").equals(type)?"":bar_code),linecode,map.get("DL_DECODE"),SystemSession.getUser().getEm_name(),0,rs2.getString("psl_prodcode"),usable,(usable==1)?Timestamp.valueOf(DateUtil.currentDateString(Constant.YMD_HMS)):"");
 		}else{
 			showSmtError(APIErrorCode.BUSINESS_FAILED,"没有排位图信息",handleType,linecode,"",ps_prodcode,"",bool,map.get("DL_TABLE"));
 		}
@@ -671,9 +704,9 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		 * @Date 2018-01-22
 		 *  上料、接料、换料 更新状态为“已上线” 并记录日志
 		 * */
-//		if(checkMsdBarCode(bar_code)){
-//			updateMsdbarcodeOnLine(bar_code);
-//		}
+		if(checkMsdBarCode(bar_code)){
+			updateMsdbarcodeOnLine(bar_code);
+		}
 		//记录日志接料
 		baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"接料","接料成功,"+(has_make == -1 ? "工单":"产品")+":"+ma_code+","+(("product").equals(type)?"物料编号":"料卷号")+":"+bar_code,linecode,location,0,ps_prodcode,(("product").equals(type)?"物料":"料卷")+":"+bar_code,map.get("DL_TABLE"),has_make == -1?ma_code:"");
 		Map<String,Object> mapReturn = new HashMap <String, Object>(); 
@@ -704,6 +737,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		int has_make=0;
 		List<String> sqls = new ArrayList<String>();
 		Object bar_code = map1.get("dsl_barcode"),ma_code = map.get("DL_MACODE"),table = map.get("DL_TABLE");
+		Object dsl_fecode= map1.get("dsl_fecode");
 		Object location = map1.get("dsl_location"),linecode= map.get("DL_LINECODE");
 		
 		rs=baseDao.queryForRowSet("select dl_macode,dl_statuscode,dl_hasmake,dl_prodcode from deviceline where dl_linecode=?",linecode);
@@ -747,16 +781,11 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 					if(bar_code.toString().contains(rs.getString("psl_prodcode"))){
 						pr_code = rs.getString("psl_prodcode");
 					}else{
-						try {
-							String[] stringArr = rs.getString("repcode").split(",");
-							for (String s : stringArr) {
-								if (bar_code.toString().contains(s)) {
-									pr_code = s;
-								}
+						String [] stringArr= rs.getString("repcode").split(","); 
+						for (String s : stringArr) {
+							if (bar_code.toString().contains(s)) {
+								pr_code = s;
 							}
-						}catch (Exception ex)
-						{
-
 						}
 					if(pr_code == null || ("").equals(pr_code)){
 							showSmtError(APIErrorCode.DATA_NOT_FOUND,"物料["+bar_code+"]不是该站位需要上料的物料",handleType,linecode,location,ps_prodcode,"料号"+bar_code,bool,table);
@@ -776,7 +805,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		 * @Date 2018-01-22
 		 * 校验是否湿敏条码
 		 * */
-		//checkMsdBarCode(bar_code);
+		checkMsdBarCode(bar_code);
 		double ma_qty=0;
 		rs0=baseDao.queryForRowSet("select ma_qty from make where ma_id=?",map.get("MA_ID"));
 		if(rs0.next()){
@@ -847,9 +876,9 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		 * @Date 2018-01-22
 		 *  上料、接料、换料 更新状态为“已上线” 并记录日志
 		 * */
-//		if(checkMsdBarCode(bar_code)){
-//			updateMsdbarcodeOnLine(bar_code);
-//		}
+		if(checkMsdBarCode(bar_code)){
+			updateMsdbarcodeOnLine(bar_code);
+		}
 	    Map<String,Object> mapReturn = new HashMap <String, Object>(); 
 		mapReturn.put("DSL_LOCATION",location);
 		mapReturn.put("DSL_BARCODE",("product").equals(type)?"":bar_code);
@@ -1870,14 +1899,13 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 						for(Map<String ,Object> mapnow:rs.getResultList()) {
 							if (barcode.toString().contains(mapnow.get("psl_prodcode").toString())) {
 								pr_code =mapnow.get("psl_prodcode").toString();
-							} else {try {
-									String[] stringArr = mapnow.get("repcode").toString().split(",");
-									for (String s : stringArr) {
-										if (barcode.toString().contains(s)) {
-											pr_code = s;
-										}
+							} else {
+								String[] stringArr = mapnow.get("repcode").toString().split(",");
+								for (String s : stringArr) {
+									if (barcode.toString().contains(s)) {
+										pr_code = s;
 									}
-								}catch(Exception e){}
+								}
 							}
 						}
 						if(pr_code == null || ("").equals(pr_code)){
@@ -1898,61 +1926,39 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				}
 		}
 
-	@Override
-	public Map<String, Object> prebarcodeGetLocation(String barcode, String linecode, String makecode, String table) {
-		Map<String, Object> location = new HashMap<String, Object>();
-		SqlRowList rr = baseDao.queryForRowSet("select ma_prodcode from make where ma_code = ?",makecode);
-		Object ps_prodcode;
-		if (rr.next())
-		{
-			 ps_prodcode = rr.getString("ma_prodcode");
-		}else {
-			throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "工单["+makecode+"]错误,不存在");
-		}
-
-		String pr_code = "";
-		SqlRowList rs = baseDao.queryForRowSet("select bar_status,bar_prodcode,pr_detail,pr_spec,bar_batchcode,bar_whcode,bar_remain,bar_vendcode "
-				+ "from barcode left join product on pr_code=bar_prodcode where bar_code=?", barcode);
-		if (rs.next()) {
-			SqlRowList ra = baseDao.queryForRowSet("select NVL(WM_CONCAT(PSL_LOCATION),' ') PSL_LOCATION  from productsmtlocation left join productsmt on ps_id = psl_psid  where ps_linecode = ? and ps_prodcode = ? and (psl_prodcode=? or psl_repcode=?) and psl_table=?", linecode, ps_prodcode, rs.getString("bar_prodcode"), rs.getString("bar_prodcode"), table);
-			ra.next();
-			if (" ".equals(ra.getString("PSL_LOCATION")))
-				throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "料卷对应的物料[" + rs.getString("bar_prodcode") + "]不是当前线别需要上料的物料");
-			else {
-				location.put("location", ra.getString("PSL_LOCATION"));
-				return location;
-			}
-		} else {
-			rs = baseDao.queryForRowSet("select psl_prodcode,wm_concat(psl_repcode)repcode from productsmtlocation left join productsmt on ps_id = psl_psid  where ps_linecode = ? and ps_prodcode = ?  and psl_table=? group by psl_prodcode",linecode,ps_prodcode,table);
-			if(rs.next()){
-				for(Map<String ,Object> mapnow:rs.getResultList()) {
-					if (barcode.toString().contains(mapnow.get("psl_prodcode").toString())) {
-						pr_code =mapnow.get("psl_prodcode").toString();
-					} else {try {
-						String[] stringArr = mapnow.get("repcode").toString().split(",");
-						for (String s : stringArr) {
-							if (barcode.toString().contains(s)) {
-								pr_code = s;
-							}
-						}
-					}catch(Exception e){}
+		@Override
+		public Map<String, Object> bindFeederBarcode(String barcode,String fe_code) {
+			Map<String, Object> map = new HashMap<String, Object>();
+			if(baseDao.checkIf("feeder","fe_code='"+fe_code+"'")){
+				SqlRowList rs = baseDao.queryForRowSet("select bar_remain,nvl(bar_place,1)bar_place,bar_prodcode,bar_code from barcode where bar_code=? ",barcode);
+				if(rs.next()){
+					if(rs.getDouble("bar_remain") <= 0){
+						throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND,"料卷号数量必须大于0");
+					}else if(!"1".equals(rs.getString("bar_place"))){
+						throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND,"料卷已被单据["+rs.getString("bar_place")+"]使用");
 					}
+					baseDao.updateByCondition("feeder","fe_barcode='"+barcode+"'","fe_code='"+fe_code+"'");
+                    map.put("barcode",barcode);
+                    map.put("fe_code",fe_code);
+				}else
+				{
+					throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "料卷"+barcode+"不存在");
 				}
-				if(pr_code == null || ("").equals(pr_code)){
-					throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "料卷["+barcode+"]不是该机台需要上料的料卷");
-				}
-
-				SqlRowList ra = baseDao.queryForRowSet("select NVL(WM_CONCAT(PSL_LOCATION),' ') PSL_LOCATION  from productsmtlocation left join productsmt on ps_id = psl_psid  where ps_linecode = ? and ps_prodcode = ? and (psl_prodcode=? or psl_repcode=?) and psl_table=?", linecode, ps_prodcode, pr_code,pr_code, table);
-				ra.next();
-				if (" ".equals(ra.getString("PSL_LOCATION")))
-					throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "料卷对应的物料[" + pr_code + "]不是当前机台需要上料的物料");
-				else {
-					location.put("location", ra.getString("PSL_LOCATION"));
-					return location;
-				}
-			}else {
-				throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "线别["+linecode+"],产品["+ps_prodcode+"],版面["+table+"]无对应排位表");
+			}else{
+				throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "飞达"+fe_code+"不存在");
 			}
+			return map;
 		}
-	}
+
+		@Override
+		public Map<String, Object> getFeederLocation(String fe_code) {
+			Map<String, Object> map = new HashMap<String, Object>();
+            if(baseDao.checkIf("feeder","fe_code='"+fe_code+"'")){
+                map.put("fe_code",fe_code);
+                map.put("fe_location",baseDao.getFieldDataByCondition("feeder","fe_location","fe_code='"+fe_code+"'"));
+            }else{
+                throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND, "飞达"+fe_code+"不存在");
+            }
+            return map;
+        }
 }