Browse Source

微浦MES,PDA--SMT恢复25年6月5日修改的接料校验等逻辑

xiaost 1 week ago
parent
commit
55ff0c4b6b
1 changed files with 71 additions and 55 deletions
  1. 71 55
      src/com/uas/mes/pda/service/impl/PdaSMTServiceImpl.java

+ 71 - 55
src/com/uas/mes/pda/service/impl/PdaSMTServiceImpl.java

@@ -97,7 +97,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 					}
 			    	rs0 = baseDao.queryForRowSet("select ps_id,ps_devcode from productsmt left join productsmtlocation on ps_id = psl_psid where ps_prodcode = ? and ps_linecode=? and psl_table = ? and ps_statuscode='AUDITED'",ma_prodcode,li_code,dl_table);
 				    if(rs0.next()){
-					   baseDao.execute("update deviceline set dl_macode=? ,dl_table=?,dl_hasmake=?,dl_smtid=?,dl_prodcode=?,dl_madeqty=0,dl_actmadeqty=0,dl_checkcount=0,dl_decode=? where dl_linecode=?",ma_code,dl_table,has_make,rs0.getInt("ps_id"),ma_prodcode,rs0.getString("ps_devcode"),li_code);
+					   baseDao.execute("update deviceline set dl_macode=? ,dl_table=?,dl_hasmake=?,dl_smtid=?,dl_prodcode=?,dl_madeqty=0,dl_actmadeqty=0,dl_checkcount=0,dl_decode=?,dl_quacheckcount=0 where dl_linecode=?",ma_code,dl_table,has_make,rs0.getInt("ps_id"),ma_prodcode,rs0.getString("ps_devcode"),li_code);
 					   mapReturn.put("DL_ID",rs.getInt("dl_id"));
 					   mapReturn.put("DL_DECODE",rs0.getString("ps_devcode"));
 					   mapReturn.put("DL_LINECODE",li_code);
@@ -253,9 +253,9 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				if(!rs1.next()){
 					rs1 = baseDao.queryForRowSet("select bd_mothercode,bd_soncode,prr_reprodcode from PRODUCTRELATION left join bomdetail on bd_id = prr_bdid where bd_mothercode = ? and bd_soncode = ? and prr_reprodcode = ?",ps_prodcode,psl_prodcode,rs.getString("bar_prodcode"));
 					if(!rs1.next()) {
-						rs1 = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@WP where mm_code = ? and MM_MOTHERCODE = ? and mm_prodcode = ? and mm_repprodcode like '%" + rs.getString("bar_prodcode") + "%'", dl_macode, ps_prodcode, psl_prodcode);
+						rs1 = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@WP where mm_code = ?  and mm_prodcode = ? and mm_repprodcode like '%" + rs.getString("bar_prodcode") + "%'", dl_macode, psl_prodcode);
 						if (!rs1.next()) {
-							rs1 = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@HY where mm_code = ? and MM_MOTHERCODE = ? and mm_prodcode = ? and mm_repprodcode like '%" + rs.getString("bar_prodcode") + "%'", dl_macode, ps_prodcode, psl_prodcode);
+							rs1 = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@HY where mm_code = ?  and mm_prodcode = ? and mm_repprodcode like '%" + rs.getString("bar_prodcode") + "%'", dl_macode, psl_prodcode);
 							if (!rs1.next()) {
 								showSmtError(APIErrorCode.DATA_NOT_FOUND, "料卷对应的物料[" + rs.getString("bar_prodcode") + "]不是该站位需要上料的物料", handleType, linecode, location, ps_prodcode, "料卷" + bar_code, bool, table);
 							}
@@ -417,12 +417,12 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				remain = rs.getDouble("dsl_remainqty");  //将第一个料卷剩余料加给第二个料卷
 					if(rs.getInt("cn") == 1){
 						if(rsReturn.getString("dsl_barcode") !=null && !("").equals(rsReturn.getString("dsl_barcode"))){
-							sqls.add("update barcode set bar_place=1,bar_forcastremain="+remain+",bar_remain="+remain+" where bar_code='"+rsReturn.getString("dsl_barcode")+"' and bar_place='"+ma_code+"'");
+							sqls.add("update barcode set bar_place=1 where bar_code='"+rsReturn.getString("dsl_barcode")+"' and bar_place='"+ma_code+"'");
 						}
 					}else{
-						sqls.add("update barcode set bar_place=1,bar_forcastremain=0,bar_remain=0 where bar_code in (select dsl_barcode from devsmtlocation"
+						sqls.add("update barcode set bar_place=1 where bar_code in (select dsl_barcode from devsmtlocation"
 								+" 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")+"' and dsl_id<>"+rs.getInt("dsl_id")+")  and bar_place='"+ma_code+"'");
-						sqls.add("update barcode set bar_place=1,bar_forcastremain="+remain+",bar_remain="+remain+ " where bar_code=(select dsl_barcode from devsmtlocation "
+						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= '"+map.get("DL_TABLE")+"' ) and bar_place='"+ma_code+"'");
 					}
 					    sqls.add("update devsmtlocation set dsl_status=-1,dsl_cutman='"+SystemSession.getUser().getEm_name()+"',dsl_invalidtime=sysdate"
@@ -460,12 +460,12 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		SqlRowList rs = null;
 		int madeqty = 0;
 		String dl_table="",dl_devcode = "",dl_prodcode;
-		int dl_checkcount,dl_smtid,dl_hasmake,dl_id;
+		int dl_checkcount,dl_smtid,dl_hasmake,dl_id,dl_quacheckcount;
 		//先判断传过来的值dl_madeqty,必须大于0,并且介于dl_madeqty和ma_qty之间
 		if(dl_madeqty<0){
 			throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"产出数不允许小于0");
 		}else{
-			rs=baseDao.queryForRowSet("select dl_id,nvl(ma_unlimitin,0)ma_unlimitin,nvL(ma_smtaqty,0)ma_smtaqty,nvL(ma_smtbqty,0)ma_smtbqty,ma_qty,ma_smtqty,dl_table,dl_decode,dl_prodcode,dl_checkcount,dl_hasmake,dl_smtid from deviceline left join make on ma_code=dl_macode where "
+			rs=baseDao.queryForRowSet("select dl_id,nvl(ma_unlimitin,0)ma_unlimitin,nvL(ma_smtaqty,0)ma_smtaqty,nvL(ma_smtbqty,0)ma_smtbqty,ma_qty,ma_smtqty,dl_table,dl_decode,dl_prodcode,dl_checkcount,dl_hasmake,dl_smtid,nvl(dl_quacheckcount,0)dl_quacheckcount from deviceline left join make on ma_code=dl_macode where "
 					+" dl_linecode=? and dl_macode=? ",dl_linecode,dl_macode);
 			if(rs.next()){
 				dl_id = rs.getInt("dl_id");
@@ -476,6 +476,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				dl_smtid = rs.getInt("dl_smtid");
 				dl_hasmake = rs.getInt("dl_hasmake");
 				dl_prodcode = rs.getString("dl_prodcode");
+				dl_quacheckcount = rs.getGeneralInt("dl_quacheckcount");
 //				if(dl_madeqty < madeqty ){
 //					throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"数量不能小于产出数");
 //				}else{
@@ -579,24 +580,24 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			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,"
 							+"msl_baseqty,msl_table,msl_needqty,msl_getqty,msl_remainqty,msl_fecode,msl_barcode,msl_linecode,msl_devcode,msl_status"
-							+",msl_indate,msl_ifcheck,msl_validtime,msl_invalidtime,msl_smtid,msl_inman,msl_cutman,msl_fprodcode,msl_usable,msl_madeqty,msl_aoimadeqty)"
+							+",msl_indate,msl_ifcheck,msl_validtime,msl_invalidtime,msl_smtid,msl_inman,msl_cutman,msl_fprodcode,msl_usable,msl_madeqty,msl_aoimadeqty,MSL_QUAIFCHECK)"
 							+"select makesmtlocation_seq.nextval,dsl_maid,dsl_makecode,dsl_mcid,dsl_mccode,dsl_mmdetno,dsl_location,dsl_prodcode,dsl_repcode,dsl_fespec,"
 							+"dsl_baseqty,dsl_table,dsl_needqty,dsl_getqty,dsl_remainqty,dsl_fecode,dsl_barcode,dsl_linecode,dsl_devcode,dsl_status"
-							+",dsl_indate,dsl_ifcheck,dsl_validtime,dsl_invalidtime,dsl_smtid,dsl_inman,dsl_cutman,dsl_fprodcode,dsl_usable,dsl_madeqty,dsl_aoimadeqty from devsmtlocation where dsl_linecode='"+dl_linecode+"' and dsl_makecode='"+dl_macode+"'");
+							+",dsl_indate,dsl_ifcheck,dsl_validtime,dsl_invalidtime,dsl_smtid,dsl_inman,dsl_cutman,dsl_fprodcode,dsl_usable,dsl_madeqty,dsl_aoimadeqty,DSL_QUAIFCHECK from devsmtlocation where dsl_linecode='"+dl_linecode+"' and dsl_makecode='"+dl_macode+"'");
 			sqls.add("delete from devsmtlocation where dsl_linecode='"+dl_linecode+"' and dsl_makecode='"+dl_macode+"'");
-			sqls.add("update deviceline set dl_macode='',dl_prodcode='',dl_statuscode='UNUSED',dl_status='未使用',dl_table='',dl_madeqty=0,dl_hasmake=0,dl_checkcount=0,dl_smtid=0,dl_actmadeqty=0  where dl_id="+dl_id);
+			sqls.add("update deviceline set dl_macode='',dl_prodcode='',dl_statuscode='UNUSED',dl_status='未使用',dl_table='',dl_madeqty=0,dl_hasmake=0,dl_checkcount=0,dl_smtid=0,dl_actmadeqty=0,dl_quacheckcount=0  where dl_id="+dl_id);
 			//操作记录表
-			sqls.add("insert into devicelinerecord(dlr_id,dlr_linecode,dlr_decode,dlr_macode,dlr_table,dlr_madeqty,dlr_actmadeqty,dlr_indate,dlr_inman,dlr_result,dlr_checkcount,dlr_smtid,dlr_prodcode,dlr_hasmake)"
-					+ "values(devicelinerecord_seq.nextval,'"+dl_linecode+"','"+dl_devcode+"','"+dl_macode+"','"+dl_table+"',"+madeqty+","+dl_madeqty+",sysdate,'"+SystemSession.getUser().getEm_name()+"','全部下料',"+dl_checkcount+","+dl_smtid+",'"+dl_prodcode+"',"+dl_hasmake+")");
+			sqls.add("insert into devicelinerecord(dlr_id,dlr_linecode,dlr_decode,dlr_macode,dlr_table,dlr_madeqty,dlr_actmadeqty,dlr_indate,dlr_inman,dlr_result,dlr_checkcount,dlr_smtid,dlr_prodcode,dlr_hasmake,DLR_QUACHECKCOUNT)"
+					+ "values(devicelinerecord_seq.nextval,'"+dl_linecode+"','"+dl_devcode+"','"+dl_macode+"','"+dl_table+"',"+madeqty+","+dl_madeqty+",sysdate,'"+SystemSession.getUser().getEm_name()+"','全部下料',"+dl_checkcount+","+dl_smtid+",'"+dl_prodcode+"',"+dl_hasmake+","+dl_quacheckcount+")");
 			baseDao.execute(sqls);
 		    //记录日志全部下料
 		    baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"全部下料","全部下料成功,"+(dl_hasmake == -1 ? "工单":"产品")+":"+dl_macode,dl_linecode,"",0,dl_prodcode,"",dl_table,dl_hasmake == -1?dl_macode:"");
 		}else{
 			//如果没有上料数据,则直接解除绑定不抛异常
-			sqls.add("update deviceline set dl_macode='',dl_prodcode='',dl_statuscode='UNUSED',dl_status='未使用',dl_table='',dl_madeqty=0,dl_hasmake=0,dl_checkcount=0,dl_smtid=0,dl_actmadeqty=0  where dl_id="+dl_id);
+			sqls.add("update deviceline set dl_macode='',dl_prodcode='',dl_statuscode='UNUSED',dl_status='未使用',dl_table='',dl_madeqty=0,dl_hasmake=0,dl_checkcount=0,dl_smtid=0,dl_actmadeqty=0 ,dl_quacheckcount=0 where dl_id="+dl_id);
 			//操作记录表
-			sqls.add("insert into devicelinerecord(dlr_id,dlr_linecode,dlr_decode,dlr_macode,dlr_table,dlr_madeqty,dlr_actmadeqty,dlr_indate,dlr_inman,dlr_result,dlr_checkcount,dlr_smtid,dlr_prodcode,dlr_hasmake)"
-					+ "values(devicelinerecord_seq.nextval,'"+dl_linecode+"','"+dl_devcode+"','"+dl_macode+"','"+dl_table+"',"+madeqty+","+dl_madeqty+",sysdate,'"+SystemSession.getUser().getEm_name()+"','全部下料-解除绑定',"+dl_checkcount+","+dl_smtid+",'"+dl_prodcode+"',"+dl_hasmake+")");
+			sqls.add("insert into devicelinerecord(dlr_id,dlr_linecode,dlr_decode,dlr_macode,dlr_table,dlr_madeqty,dlr_actmadeqty,dlr_indate,dlr_inman,dlr_result,dlr_checkcount,dlr_smtid,dlr_prodcode,dlr_hasmake,DLR_QUACHECKCOUNT)"
+					+ "values(devicelinerecord_seq.nextval,'"+dl_linecode+"','"+dl_devcode+"','"+dl_macode+"','"+dl_table+"',"+madeqty+","+dl_madeqty+",sysdate,'"+SystemSession.getUser().getEm_name()+"','全部下料-解除绑定',"+dl_checkcount+","+dl_smtid+",'"+dl_prodcode+"',"+dl_hasmake+","+dl_quacheckcount+")");
 			baseDao.execute(sqls);
 			 //记录日志全部下料
 		    baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"全部下料","全部下料成功,"+(dl_hasmake == -1 ? "工单":"产品")+":"+dl_macode+"没有上料数据,解除绑定",dl_linecode,"",0,dl_prodcode,"",dl_table,dl_hasmake == -1?dl_macode:"");
@@ -644,6 +645,12 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		}else{
 			showSmtError(APIErrorCode.BUSINESS_FAILED,"站位未上料无需接料",handleType,linecode,location,ps_prodcode,"",bool,table);
 		}
+
+		rs = baseDao.queryForRowSet("select * from (select dsl_id,dsl_barcode,dsl_repcode,dsl_prodcode from devSMTLocation where dsl_linecode=?  and  dsl_makecode=? and dsl_location=? and dsl_table=?  and dsl_status=0 and dsl_ifcheck = 0 order by dsl_id desc) where rownum=1",linecode,ma_code,location,map.get("DL_TABLE"));
+		if(rs.next()){
+			showSmtError(APIErrorCode.BUSINESS_FAILED,"站位存在未校验条码,无法接料",handleType,linecode,location,ps_prodcode,"",bool,table);
+		}
+
 		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())
@@ -651,7 +658,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			psl_prodcode = rs.getString("psl_prodcode");
 		}
 		String type="barcode";
-			rs = baseDao.queryForRowSet("select dsl_barcode,dsl_repcode from devSMTLocation where dsl_linecode=?  and  dsl_makecode=? and dsl_location=? and dsl_table =?  and dsl_status=0 and dsl_barcode=?",linecode,ma_code,location,map.get("DL_TABLE"),bar_code);
+		rs = baseDao.queryForRowSet("select dsl_barcode,dsl_repcode from devSMTLocation where dsl_linecode=?  and  dsl_makecode=? and dsl_location=? and dsl_table =?  and dsl_barcode=?",linecode,ma_code,location,map.get("DL_TABLE"),bar_code);
 		if(rs.next()){
 			if(isBarcode){
 				showSmtError(APIErrorCode.BUSINESS_FAILED,"不允许接同一个料卷号",handleType,linecode,location,ps_prodcode,"料卷"+bar_code,bool,table);
@@ -666,10 +673,12 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				if(!rs.next()){
 					rs = baseDao.queryForRowSet("select bd_mothercode,bd_soncode,prr_reprodcode from PRODUCTRELATION left join bomdetail on bd_id = prr_bdid where bd_mothercode = ? and bd_soncode = ? and prr_reprodcode = ?",ps_prodcode,psl_prodcode,rs1.getString("bar_prodcode"));
 					if(!rs.next()) {
-						rs = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@WP where mm_code = ? and MM_MOTHERCODE = ? and mm_prodcode = ? and mm_repprodcode like '%" + rs1.getString("bar_prodcode") + "%'", ma_code, ps_prodcode, psl_prodcode);
+						rs = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@WP where mm_code = ?  and mm_prodcode = ? and mm_repprodcode like '%" + rs1.getString("bar_prodcode") + "%'", ma_code, psl_prodcode);
 						if (!rs.next()) {
+							rs = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@HY where mm_code = ?  and mm_prodcode = ? and mm_repprodcode like '%" + rs1.getString("bar_prodcode") + "%'", ma_code, psl_prodcode);
+							if (!rs.next()) {
 							showSmtError(APIErrorCode.DATA_NOT_FOUND, "料卷对应的物料[" + rs1.getString("bar_prodcode") + "]不是该站位需要上料的物料", handleType, linecode, location, ps_prodcode, "料卷" + bar_code, bool, table);
-						}
+						}}
 					}
 				}
 			}
@@ -825,10 +834,13 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				if(!rs.next()) {
 					rs = baseDao.queryForRowSet("select bd_mothercode,bd_soncode,prr_reprodcode from PRODUCTRELATION left join bomdetail on bd_id = prr_bdid where bd_mothercode = ? and bd_soncode = ? and prr_reprodcode = ?", ps_prodcode, psl_prodcode, rs2.getString("bar_prodcode"));
 					if (!rs.next()) {
-						rs = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@WP where mm_code = ? and MM_MOTHERCODE = ? and mm_prodcode = ? and mm_repprodcode like '%" + rs2.getString("bar_prodcode") + "%'", ma_code, ps_prodcode, psl_prodcode);
+						rs = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@WP where mm_code = ?  and mm_prodcode = ? and mm_repprodcode like '%" + rs2.getString("bar_prodcode") + "%'", ma_code, psl_prodcode);
 						if(!rs.next()) {
+							rs = baseDao.queryForRowSet("select MM_MOTHERCODE,mm_prodcode,mm_repprodcode,mm_code from MakeMaterial@HY where mm_code = ?  and mm_prodcode = ? and mm_repprodcode like '%" + rs2.getString("bar_prodcode") + "%'", ma_code, psl_prodcode);
+							if (!rs.next()) {
 								showSmtError(APIErrorCode.DATA_NOT_FOUND, "料卷对应的物料[" + rs2.getString("bar_prodcode") + "]不是该站位需要上料的物料", handleType, linecode, location, ps_prodcode, "料卷" + bar_code, bool, table);
-					}
+
+							}}
 				}
 				}
 			}
@@ -1128,13 +1140,13 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 
 							baseDao.execute("insert into makesmtlocation(msl_id,msl_maid,msl_makecode,msl_mcid,msl_mccode,msl_mmdetno,msl_location,msl_prodcode,msl_repcode,msl_fespec,"
 								+"msl_baseqty,msl_table,msl_needqty,msl_getqty,msl_remainqty,msl_fecode,msl_barcode,msl_linecode,msl_devcode,msl_status"
-								+",msl_indate,msl_ifcheck,msl_validtime,msl_invalidtime,msl_smtid,msl_inman,msl_cutman,msl_fprodcode,msl_usable,msl_madeqty,msl_aoimadeqty)"
+								+",msl_indate,msl_ifcheck,msl_validtime,msl_invalidtime,msl_smtid,msl_inman,msl_cutman,msl_fprodcode,msl_usable,msl_madeqty,msl_aoimadeqty,MSL_QUAIFCHECK)"
 								+"select makesmtlocation_seq.nextval,dsl_maid,dsl_makecode,dsl_mcid,dsl_mccode,dsl_mmdetno,dsl_location,dsl_prodcode,dsl_repcode,dsl_fespec,"
 								+"dsl_baseqty,dsl_table,dsl_needqty,dsl_getqty,dsl_remainqty,dsl_fecode,dsl_barcode,dsl_linecode,dsl_devcode,dsl_status"
-								+",dsl_indate,dsl_ifcheck,dsl_validtime,dsl_invalidtime,dsl_smtid,dsl_inman,dsl_cutman,dsl_fprodcode,dsl_usable,dsl_madeqty,dsl_aoimadeqty from devsmtlocation where dsl_linecode=? and dsl_makecode=? ",dl_linecode,ma_oldcode);
+								+",dsl_indate,dsl_ifcheck,dsl_validtime,dsl_invalidtime,dsl_smtid,dsl_inman,dsl_cutman,dsl_fprodcode,dsl_usable,dsl_madeqty,dsl_aoimadeqty,DSL_QUAIFCHECK from devsmtlocation where dsl_linecode=? and dsl_makecode=? ",dl_linecode,ma_oldcode);
 							baseDao.execute("delete  from devsmtlocation  where dsl_linecode=? and dsl_makecode=? and dsl_table = ?",dl_linecode,ma_oldcode,dl_table);//原工单
 							baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"工单切换","切换成功,"+(has_make == -1 ? "工单":"产品")+":"+ma_oldcode+"全部下料",dl_linecode,"",0,ma_prodcode,"",dl_table,has_make == -1?ma_oldcode:"");
-							baseDao.execute("update deviceline set dl_macode=? , dl_table=? ,dl_statuscode='UNUSED' , dl_status='未使用',dl_madeqty=0,dl_prodcode=?,dl_hasmake=?,dl_checkcount=0,dl_actmadeqty=0 ,dl_smtid=? where dl_linecode=? ",ma_code,table,ma_prodcode,has_noma?0:-1,rs.getInt("ps_id"),dl_linecode);
+							baseDao.execute("update deviceline set dl_macode=? , dl_table=? ,dl_statuscode='UNUSED' , dl_status='未使用',dl_madeqty=0,dl_prodcode=?,dl_hasmake=?,dl_checkcount=0,dl_actmadeqty=0 ,dl_smtid=?,dl_quacheckcount=0 where dl_linecode=? ",ma_code,table,ma_prodcode,has_noma?0:-1,rs.getInt("ps_id"),dl_linecode);
 							//操作记录表
 							//1.记录原工单下料的情况
 							baseDao.execute("insert into devicelinerecord(dlr_id,dlr_linecode,dlr_decode,dlr_macode,dlr_table,dlr_madeqty,dlr_actmadeqty,dlr_indate,dlr_inman,dlr_result)"
@@ -1207,9 +1219,9 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				map.get("DL_MACODE"),map.get("DL_TABLE"));
 		if(rs0.next() && rs0.getInt("cn") > 0){
 			unloadLocation = rs0.getString("psl_location");
-			if(!("强制启动").equals(op)){
-			throw new APIErrorException(APIErrorCode.BUSINESS_SMTFORCE,"站位["+unloadLocation+"]没有上料料卷不允许启动");
-		    }
+//			if(!("强制启动").equals(op)){
+//			throw new APIErrorException(APIErrorCode.BUSINESS_SMTFORCE,"站位["+unloadLocation+"]没有上料料卷不允许启动");
+//		    }
 		}
 //		rs0 = baseDao.queryForRowSet("select wm_concat(distinct dsl_location) dsl_location,count(1) cn from devsmtlocation where dsl_linecode=? and dsl_makecode=? and dsl_table=?"
 //				+" and dsl_status=0 and (dsl_prodcode,dsl_location) not in (select psl_repcode,psl_location from productsmt left join productsmtlocation on ps_id=psl_psid"
@@ -1411,8 +1423,8 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		 //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) "
+		    		+" where psl_psid=? and psl_table=? and  psl_location  in (select distinct dsl_location from devsmtlocation where "
+		    		+" dsl_linecode=? and dsl_makecode=? and dsl_table=?  and dsl_status=0 and dsl_ifcheck = 0) "
 		    		+" group by psl_location order by psl_detno asc)) where rownum<=20 ",ps_id,table,linecode,ma_code,table);
 		if(rs.next()){
 			mapR.put("NotCheckLocation", rs.getResultList());
@@ -1420,8 +1432,8 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			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);
+			    +" psl_location  in (select distinct dsl_location from devsmtlocation where "
+			    +" dsl_linecode=? and dsl_makecode=? and dsl_table=? and dsl_status=0 and dsl_ifcheck = 0)) ",ps_id,table,linecode,ma_code,table);
 		if(rs.next()){
 			mapR.put("NotCheckCount", rs.getInt("cn"));
 		}else{
@@ -1432,8 +1444,8 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				+" 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("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"):"");
 		}
 		}
@@ -1600,9 +1612,14 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		//修改条码数量
 		@Override
 		public Map<String, Object> updateBarCodeQty( String barcode,double nowqty) {
-			SqlRowList rs = baseDao.queryForRowSet("select bar_id,bar_status,bar_prodcode,pr_detail,pr_spec,bar_batchcode, pr_tracekind,bar_whcode,bar_remain from barcode "
+			SqlRowList rs = baseDao.queryForRowSet("select bar_batchqty,bar_id,bar_status,bar_prodcode,pr_detail,pr_spec,bar_batchcode, pr_tracekind,bar_whcode,bar_remain from barcode "
 							+ "left join product on pr_code=bar_prodcode where bar_code=?",barcode);
 			if(rs.next()){
+				double bar_batchqty = rs.getDouble("bar_batchqty");
+				if (nowqty>bar_batchqty)
+				{
+					throw new APIErrorException(APIErrorCode.INVALID_ORDER_STATUS,"该条码原始数量为"+bar_batchqty+",不允许修改为"+nowqty);
+				}
 				baseDao.execute("update barcode set bar_remain=? where bar_id=?",nowqty,rs.getInt("bar_id"));
 				//增加操作日志记录
 				baseDao.execute("insert into barcodelogger(bl_id,bl_barcode,bl_barid,bl_prodcode,bl_whcode,bl_date,bl_inman,bl_action,bl_description)"
@@ -1616,7 +1633,7 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		//重新校验
 		@Override
 		public Map<String, Object> startCheck(String linecode) {
-				baseDao.execute("update devsmtlocation set dsl_ifcheck =0 where dsl_linecode = ? and dsl_status = 0 and dsl_ifcheck = -1",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"):"");
@@ -1638,10 +1655,10 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 				ps_prodcode = rs.getString("dl_prodcode");
 			}
 			 
-			 //未校验站位前二十条
-			 rs=baseDao.queryForRowSet("select * from (select psl_location,psl_prodcode from(select min(psl_detno)psl_detno,psl_location,wm_concat(psl_prodcode)psl_prodcode from productsmtlocation left join productsmt on ps_id=psl_psid "
-			    		+" where ps_linecode = ? and ps_prodcode = ? 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) "
+			 //未校验站位前二十条、、wm_concat(psl_prodcode)psl_prodcode
+			 rs=baseDao.queryForRowSet("select * from (select psl_location,psl_prodcode from (select min(psl_detno)psl_detno,psl_location,wm_concat(psl_prodcode)psl_prodcode from productsmtlocation left join productsmt on ps_id=psl_psid "
+			    		+" where ps_linecode = ? and ps_prodcode = ? and psl_table = ? and  psl_location  in (select distinct dsl_location from devsmtlocation where "
+			    		+" dsl_linecode=? and dsl_makecode=? and dsl_table=? and dsl_status=0 and dsl_ifcheck = 0) "
 			    		+" group by psl_location order by psl_detno)) where rownum<=20 ",linecode,ps_prodcode,table,linecode,macode,table);
 			if(rs.next()){
 				mapR.put("NotCheckLocation", rs.getResultList());
@@ -1650,8 +1667,8 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			}
 			//未校验站位数量
 			rs=baseDao.queryForRowSet("select count(1) cn from (select distinct psl_location from productsmtlocation left join productsmt on ps_id=psl_psid where ps_linecode = ? and "
-				    +" ps_prodcode = ? 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)) ",linecode,ps_prodcode,table,linecode,macode,table);
+				    +" ps_prodcode = ? and psl_table = ? and psl_location  in (select distinct dsl_location from devsmtlocation where "
+				    +" dsl_linecode=? and dsl_makecode=? and dsl_table=? and dsl_status=0 and dsl_ifcheck = 0)) ",linecode,ps_prodcode,table,linecode,macode,table);
 			if(rs.next()){
 				mapR.put("NotCheckCount", rs.getInt("cn"));
 			}else{
@@ -2201,9 +2218,9 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		baseDao.execute(INSERT_SMTLOG,SystemSession.getUser().getEm_name(),"品质校验",meg+",料号:"+prodcode,linecode,location,i,map.get("DL_PRODCODE"),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"):"");
 		//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_quaifcheck = -1) "
+		rs=baseDao.queryForRowSet("select * from (select psl_location,psl_prodcode from(select min(psl_detno)psl_detno,psl_location,wm_concat(psl_prodcode)psl_prodcode from productsmtlocation "
+				+" where psl_psid=? and psl_table=? and  psl_location  in (select distinct dsl_location from devsmtlocation where "
+				+" dsl_linecode=? and dsl_makecode=? and dsl_table=?  and dsl_status=0 and nvl(dsl_quaifcheck,0) = 0) "
 				+" group by psl_location order by psl_detno asc)) where rownum<=20 ",ps_id,table,linecode,ma_code,table);
 		if(rs.next()){
 			mapR.put("NotCheckLocation", rs.getResultList());
@@ -2211,8 +2228,8 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			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_quaifcheck = -1)) ",ps_id,table,linecode,ma_code,table);
+				+" psl_location in (select distinct dsl_location from devsmtlocation where "
+				+" dsl_linecode=? and dsl_makecode=? and dsl_table=? and dsl_status=0 and nvl(dsl_quaifcheck,0) = 0)) ",ps_id,table,linecode,ma_code,table);
 		if(rs.next()){
 			mapR.put("NotCheckCount", rs.getInt("cn"));
 		}else{
@@ -2223,8 +2240,8 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 					+" not in(select dsl_location,dsl_fprodcode from devsmtlocation where dsl_linecode=? "
 					+" and dsl_makecode=? and dsl_status=0 and dsl_quaifcheck=-1)",Integer.class,ps_id,table,linecode,ma_code);
 			if(psl_id == null || psl_id == 0){
-				baseDao.execute("update deviceline set dl_quacheckcount=nvl(dl_quacheckcount,0)+1 where dl_id=?",dl_id);
-				baseDao.execute("update devsmtlocation set dsl_quaifcheck = 0 where dsl_linecode=? and dsl_makecode=? and dsl_table=? and dsl_status=0",linecode,ma_code,table);
+				/*baseDao.execute("update deviceline set dl_quacheckcount=nvl(dl_quacheckcount,0)+1 where dl_id=?",dl_id);
+				baseDao.execute("update devsmtlocation set dsl_quaifcheck = 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"):"");
 			}
 		}
@@ -2244,11 +2261,10 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 			table = rs.getString("dl_table");
 			ps_prodcode = rs.getString("dl_prodcode");
 		}
-
-		//未校验站位前二十条
-		rs=baseDao.queryForRowSet("select * from (select psl_location,psl_prodcode from(select min(psl_detno)psl_detno,psl_location,wm_concat(psl_prodcode)psl_prodcode from productsmtlocation left join productsmt on ps_id=psl_psid "
-				+" where ps_linecode = ? and ps_prodcode = ? 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_quaifcheck = -1) "
+		//未校验站位前二十条、、wm_concat(psl_prodcode)psl_prodcode
+		rs=baseDao.queryForRowSet("select * from (select psl_location,psl_prodcode from (select min(psl_detno)psl_detno,psl_location,wm_concat(psl_prodcode)psl_prodcode from productsmtlocation left join productsmt on ps_id=psl_psid "
+				+" where ps_linecode = ? and ps_prodcode = ? and psl_table = ? and  psl_location in (select distinct dsl_location from devsmtlocation where "
+				+" dsl_linecode=? and dsl_makecode=? and dsl_table=? and dsl_status=0 and nvl(dsl_quaifcheck,0) = 0) "
 				+" group by psl_location order by psl_detno)) where rownum<=20 ",linecode,ps_prodcode,table,linecode,macode,table);
 		if(rs.next()){
 			mapR.put("NotCheckLocation", rs.getResultList());
@@ -2257,8 +2273,8 @@ public class PdaSMTServiceImpl implements PdaSMTService {
 		}
 		//未校验站位数量
 		rs=baseDao.queryForRowSet("select count(1) cn from (select distinct psl_location from productsmtlocation left join productsmt on ps_id=psl_psid where ps_linecode = ? and "
-				+" ps_prodcode = ? 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_quaifcheck = -1)) ",linecode,ps_prodcode,table,linecode,macode,table);
+				+" ps_prodcode = ? and psl_table = ? and psl_location  in (select distinct dsl_location from devsmtlocation where "
+				+" dsl_linecode=? and dsl_makecode=? and dsl_table=? and dsl_status=0 and nvl(dsl_quaifcheck,0) = 0)) ",linecode,ps_prodcode,table,linecode,macode,table);
 		if(rs.next()){
 			mapR.put("NotCheckCount", rs.getInt("cn"));
 		}else{