|
|
@@ -2137,4 +2137,133 @@ public class PdaSMTServiceImpl implements PdaSMTService {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> quaGetUnCheckLocation(String linecode) {
|
|
|
+ return quaUnLoading(linecode);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> quaStartCheck(String linecode) {
|
|
|
+ baseDao.execute("update devsmtlocation set dsl_quaifcheck =0 where dsl_linecode = ? and dsl_status = 0 and dsl_quaifcheck = -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"):"");
|
|
|
+ }
|
|
|
+ return quaUnLoading(linecode);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> quaCheckData(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_quaifcheck=-1 where dsl_linecode=? and dsl_makecode=? and dsl_location=? and dsl_status=0 and dsl_barcode = ?",linecode,ma_code,location,prodcode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //成功失败都记录日志
|
|
|
+ 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"),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) "
|
|
|
+ +" 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());
|
|
|
+ }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_quaifcheck = -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_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(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;
|
|
|
+ }
|
|
|
+
|
|
|
+ //因为需要调用两次,所以封装了一个获取未校验站位的方法
|
|
|
+ private Map<String, Object> quaUnLoading(String linecode){
|
|
|
+ SqlRowList rs = null;
|
|
|
+ Object macode = null;
|
|
|
+ Object table = null;
|
|
|
+ Object ps_prodcode = null;
|
|
|
+ Map<String,Object> mapR = new HashMap<String,Object>();
|
|
|
+ rs = baseDao.queryForRowSet("select dl_macode,dl_table,dl_prodcode from deviceline where dl_linecode = ?",linecode);
|
|
|
+ if(rs.next()){
|
|
|
+ macode = rs.getString("dl_macode");
|
|
|
+ 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) "
|
|
|
+ +" 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());
|
|
|
+ }else{
|
|
|
+ mapR.put("NotCheckLocation", "");
|
|
|
+ }
|
|
|
+ //未校验站位数量
|
|
|
+ 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);
|
|
|
+ if(rs.next()){
|
|
|
+ mapR.put("NotCheckCount", rs.getInt("cn"));
|
|
|
+ }else{
|
|
|
+ mapR.put("NotCheckCount",0);
|
|
|
+ }
|
|
|
+ return mapR;
|
|
|
+ }
|
|
|
}
|