Explorar el Código

SMT修改绑定飞达操作

callm hace 4 años
padre
commit
33ab38433c

+ 20 - 22
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)
@@ -303,4 +285,20 @@ public class PdaSMTController extends BaseApiController{
 	public ModelMap barcodeGetLocation(String barcode,String devicelineinfo){
 		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-根据飞达获取站位
+	 */
+	@RequestMapping(value="/getFeederLocation.action")
+	public ModelMap getFeederLocation(String fe_code){
+		return success(pdaSMTService.getFeederLocation(fe_code));
+	}
 }

+ 6 - 2
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);
 
@@ -65,4 +65,8 @@ public interface PdaSMTService {
 	void updateMakePrepare(String id);
 
 	Map<String, Object> barcodeGetLocation(String barcode,String devicelineinfo);
+
+	Map<String, Object> bindFeederBarcode(String barcode,String fe_code);
+
+	Map<String, Object> getFeederLocation(String fe_code);
 }

+ 85 - 5
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 "
@@ -255,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()){
@@ -322,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;
@@ -348,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"));
@@ -369,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{
@@ -390,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;
@@ -464,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){
@@ -486,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+"'");
 					//多条记录接料料卷
@@ -694,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);
@@ -1881,4 +1925,40 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 					}
 				}
 		}
+
+		@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+"不存在");
+				}
+			}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;
+        }
 }