|
|
@@ -55,7 +55,7 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
"USING (SELECT '"+barcodeItem+"' barcode FROM dual) spm2 " +
|
|
|
"ON ( spm1.spb_barcode=spm2.barcode) " +
|
|
|
"WHEN MATCHED THEN " +
|
|
|
- " UPDATE SET spm1.spb_rewarmingdate = sysdate,spm1.spb_status = '出库回温' " +
|
|
|
+ " UPDATE SET spm1.spb_rewarmingdate = sysdate,spm1.spb_status = '出库回温',spm1.spb_linecode=null,spm1.spb_makecode=null,spb_mixdate=null " +
|
|
|
"WHEN NOT MATCHED THEN " +
|
|
|
" INSERT (SPB_ID,SPB_BARCODE,SPB_STATUS,SPB_REWARMINGDATE,SPB_RESTORECOUNT,SPB_OPENTIME) " +
|
|
|
" VALUES(spmbarcode_seq.nextval,'"+barcodeItem+"','出库回温',sysdate,0,0)");
|
|
|
@@ -75,16 +75,41 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
Object spb_status = spmBarcode.get("SPB_STATUS");
|
|
|
Double rewarmingTime = (NumberUtil.isEmpty(spmBarcode.get("REWARMINGTIME")) ? 0.0 : Double.valueOf(spmBarcode.get("REWARMINGTIME").toString()));
|
|
|
if(StringUtil.hasText(spb_status)){
|
|
|
- if(!spb_status.equals("出库回温")&&!spb_status.equals("已搅拌")){
|
|
|
+ if(!spb_status.equals("已搅拌")){
|
|
|
throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+"状态为:"+spb_status+",不允许开盖!");
|
|
|
}else if (rewarmingTime < data){
|
|
|
throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,回温时长不足"+data+"小时,不允许开盖!");
|
|
|
}else if (rewarmingTime >= 24.0){
|
|
|
throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,回温时长超过24小时,不允许开盖!");
|
|
|
}
|
|
|
+ //不能开盖超过两次
|
|
|
+ if(Integer.valueOf(spmBarcode.get("spb_opentimes").toString())>=2){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+"已经开盖过两次,不允许再开盖!");
|
|
|
+ }
|
|
|
+ return spmBarcode;
|
|
|
+ }else{
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",尚未搅拌,不允许开盖!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> checkMix(String barcode) {
|
|
|
+ //锡膏条码通用校验
|
|
|
+ double data=Double.parseDouble(baseDao.getFieldDataByCondition("configs","data","code='warmtime' and caller='sys'").toString());
|
|
|
+ Map<String, Object> spmBarcode = validSpmBarcode(barcode);
|
|
|
+ //3、检测条码存在SPMBARCODE表且状态非”开封回存”或”‘回温回存”则提示”条码XXX,状态为:XXX,不允许出库回温。”
|
|
|
+ Object spb_status = spmBarcode.get("SPB_STATUS");
|
|
|
+ Double rewarmingTime = (NumberUtil.isEmpty(spmBarcode.get("REWARMINGTIME")) ? 0.0 : Double.valueOf(spmBarcode.get("REWARMINGTIME").toString()));
|
|
|
+ if(StringUtil.hasText(spb_status)){
|
|
|
+ if(!spb_status.equals("出库回温")){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+"状态为:"+spb_status+",不允许搅拌!");
|
|
|
+ }else if (rewarmingTime < data){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,回温时长不足"+data+"小时,不允许搅拌!");
|
|
|
+ }else if (rewarmingTime >= 24.0){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,回温时长超过24小时,不允许搅拌!");
|
|
|
+ }
|
|
|
return spmBarcode;
|
|
|
}else{
|
|
|
- throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",尚未出库回温,不允许开盖!");
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",尚未出库回温,不允许搅拌!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -96,7 +121,7 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
//1、条码出库开盖校验(调用方法checkOpen)。
|
|
|
checkOpen(barcodeItem);
|
|
|
//2、 批量更新条码状态为”已开封”,累计开盖累计时长,重置上次开盖时间
|
|
|
- sqls.add("update spmbarcode set spb_status = '已开封',spb_opendate = sysdate where spb_barcode = '"+barcodeItem+"'");
|
|
|
+ sqls.add("update spmbarcode set spb_status = '已开封',spb_opendate = sysdate,spb_opentimes=nvl(spb_opentimes,0)+1 where spb_barcode = '"+barcodeItem+"'");
|
|
|
//3、插入日志到SPMLOG记录条码出库回温
|
|
|
sqls.add(getSpmlog (barcodeItem,"开盖","条码: "+barcodeItem+",开盖成功。",""));
|
|
|
}
|
|
|
@@ -116,6 +141,15 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
}else if (rewarmingTime >= 24){
|
|
|
throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,回温时长超过24小时,不允许上料!");
|
|
|
}
|
|
|
+ //不能上料超过两次
|
|
|
+ if(Integer.valueOf(spmBarcode.get("SPB_LOADINGTIMES").toString())>=2){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+"已经上料过两次,不允许再上料!");
|
|
|
+ }
|
|
|
+ //搅拌后时间累计需要≥3分钟后才允许扫描上线使用
|
|
|
+ if(Float.compare(Float.valueOf(spmBarcode.get("MIXMINUTE").toString()),3)<=0){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",需要搅拌3分钟之后才可以上线使用。搅拌时间为:"+spmBarcode.get("SPB_MIXDATE"));
|
|
|
+ }
|
|
|
+ checkOpenHours(barcode);
|
|
|
return spmBarcode;
|
|
|
}else{
|
|
|
throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",尚未出库回温,不允许上料!");
|
|
|
@@ -140,8 +174,9 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
}
|
|
|
String content = (StringUtil.hasText(linecode)) ? "线别: "+linecode+",上料成功。":"上料成功。";
|
|
|
//PDA扫码上料界面加选择项: 本瓶本次用完 如果勾选了该选择项,则上料之后将条码状态更新为‘已用尽’,对已用尽的条码只允许做空瓶回收操作
|
|
|
+ baseDao.execute("update spmbarcode set spb_linecode=?,spb_makecode=?,SPB_LOADINGTIMES=nvl(SPB_LOADINGTIMES,0)+1 where spb_barcode=?",linecode,macode,barcode);
|
|
|
if(isEmpty){
|
|
|
- baseDao.updateByCondition("spmbarcode","spb_status='已用尽',spb_linecode='"+linecode+"',spb_emptydate = sysdate","spb_barcode='"+barcode+"'");
|
|
|
+ baseDao.updateByCondition("spmbarcode","spb_status='已用尽',spb_emptydate = sysdate","spb_barcode='"+barcode+"'");
|
|
|
content = content+"锡膏已用尽。";
|
|
|
}
|
|
|
saveSpmlog("'"+barcode+"'","上料",content,linecode,macode);
|
|
|
@@ -168,6 +203,7 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
if(spb_status.equals("出库回温") && rewarmingTime >= 24){
|
|
|
throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,未开封状态下回温时长超过24小时,不允许回存!");
|
|
|
}
|
|
|
+ checkOpenHours(barcode);
|
|
|
return spmBarcode;
|
|
|
}else{
|
|
|
throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",尚未出库回温,不允许上回存!");
|
|
|
@@ -187,7 +223,8 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
"spb_opentime = round(nvl(spb_opentime,0) + round((sysdate - nvl(spb_opendate,sysdate))*24,2),2)," +
|
|
|
"spb_opendate = null," +
|
|
|
"spb_restorecount = nvl(spb_restorecount,0)+1 ," +
|
|
|
- "spb_rewarmingdate = null " +
|
|
|
+ "spb_rewarmingdate = null, " +
|
|
|
+ "spb_linecode=null,spb_makecode=null,spb_mixdate=null "+
|
|
|
"where spb_barcode = '"+barcodeItem+"'");
|
|
|
//3、插入日志到SPMLOG记录条码出库回温
|
|
|
sqls.add(getSpmlog (barcodeItem,"回存","条码: "+barcodeItem+","+spb_status+"成功。",""));
|
|
|
@@ -298,7 +335,8 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
"spb_status,spb_status STATUS,bar_code BARCODE,pr_brand BRAND,pr_spec SPEC,pr_detail,nvl(spb_restorecount,0) RESTORECOUNT," +
|
|
|
"to_char(SPB_REWARMINGDATE,'yyyy-mm-dd hh24:mi:ss') REWARMDATE,round((sysdate - SPB_REWARMINGDATE)*24,2) REWARMINGTIME, " +
|
|
|
"to_char(SPB_OPENDATE,'yyyy-mm-dd hh24:mi:ss') OPENDATE,round(nvl(spb_opentime,0) + round((sysdate - nvl(spb_opendate,sysdate))*24,2),2) OPENTIME," +
|
|
|
- "to_char(SPB_EMPTYDATE,'yyyy-mm-dd hh24:mi:ss') EMPTYDATE " +
|
|
|
+ "to_char(SPB_EMPTYDATE,'yyyy-mm-dd hh24:mi:ss') EMPTYDATE,nvl(spb_loadingtimes,0)spb_loadingtimes,nvl(spb_opentimes,0) spb_opentimes," +
|
|
|
+ " round((sysdate - SPB_MIXDATE)*24*60,2) MIXMINUTE, to_char(SPB_MIXDATE,'yyyy-mm-dd hh24:mi:ss') SPB_MIXDATE " +
|
|
|
"from barcode left join product on pr_code = bar_prodcode left join spmbarcode on spb_barcode = bar_code " +
|
|
|
"where bar_code = '"+barcode+"' and nvl(bar_status,0) = 1");
|
|
|
if(rs.next()){
|
|
|
@@ -330,7 +368,8 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
"spb_status,spb_status STATUS,bar_code BARCODE,pr_brand BRAND,pr_spec SPEC,pr_detail,nvl(spb_restorecount,0) RESTORECOUNT," +
|
|
|
"to_char(SPB_REWARMINGDATE,'yyyy-mm-dd hh24:mi:ss') REWARMDATE,round((sysdate - SPB_REWARMINGDATE)*24,2) REWARMINGTIME, " +
|
|
|
"to_char(SPB_OPENDATE,'yyyy-mm-dd hh24:mi:ss') OPENDATE,round(nvl(spb_opentime,0) + round((sysdate - nvl(spb_opendate,sysdate))*24,2),2) OPENTIME," +
|
|
|
- "to_char(SPB_EMPTYDATE,'yyyy-mm-dd hh24:mi:ss') EMPTYDATE " +
|
|
|
+ "to_char(SPB_EMPTYDATE,'yyyy-mm-dd hh24:mi:ss') EMPTYDATE ,nvl(spb_loadingtimes,0)spb_loadingtimes,nvl(spb_opentimes,0) spb_opentimes," +
|
|
|
+ " round((sysdate - SPB_MIXDATE)*24*60,2) MIXMINUTE, to_char(SPB_MIXDATE,'yyyy-mm-dd hh24:mi:ss') SPB_MIXDATE " +
|
|
|
"from barcode left join product on pr_code = bar_prodcode left join spmbarcode on spb_barcode = bar_code " +
|
|
|
"where bar_code = '"+barcode+"' and nvl(bar_status,0) = 1");
|
|
|
if(rs.next()){
|
|
|
@@ -378,10 +417,10 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
String barcodeStr = "'"+barcode.replace(",","','")+"'";
|
|
|
for (String barcodeItem:barcodeArr) {
|
|
|
//1、空瓶退回校验(调用方法checkRecovery)。
|
|
|
- checkOpen(barcodeItem);
|
|
|
+ checkMix(barcodeItem);
|
|
|
}
|
|
|
//2、批量更新条码状态为”空瓶”
|
|
|
- baseDao.execute("update spmbarcode set spb_status = '已搅拌' where spb_barcode in ("+barcodeStr+")");
|
|
|
+ baseDao.execute("update spmbarcode set spb_status = '已搅拌',SPB_MIXDATE=SYSDATE where spb_barcode in ("+barcodeStr+")");
|
|
|
//3、插入日志到SPMLOG记录条码空瓶回收
|
|
|
saveSpmlog(barcodeStr,"搅拌","回温成功,搅拌成功。","","");
|
|
|
}
|
|
|
@@ -390,7 +429,7 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
public Map<String, Object> checkmixing(String barcode) {
|
|
|
//锡膏条码通用校验
|
|
|
Map<String, Object> spmBarcode = validSpmBarcode(barcode);
|
|
|
- checkOpen(barcode);
|
|
|
+ checkMix(barcode);
|
|
|
return spmBarcode;
|
|
|
}
|
|
|
|
|
|
@@ -404,4 +443,26 @@ public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断最近一次开封(开盖时长有没有超)
|
|
|
+ * @param barcode
|
|
|
+ */
|
|
|
+ private void checkOpenHours(String barcode) {
|
|
|
+ String spmopentime = baseDao.getDBSetting("SpmOpenTime"); //锡膏最近一次开盖超过时长(H)未下线,SMT印刷需要强制下线并且只能做报废
|
|
|
+ float hours = 0;
|
|
|
+ if (null != spmopentime) {
|
|
|
+ try {
|
|
|
+ hours = Float.parseFloat(spmopentime);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Float.compare(hours,0) > 0) {
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("SELECT round((SYSDATE-SPB_OPENDATE)*24,2) openhours ,to_char(SPB_OPENDATE,'yyyy-mm-dd hh24:mi:ss')SPB_OPENDATE FROM SPMBARCODE WHERE spb_barcode=? " +
|
|
|
+ " and SPB_STATUS='已开封' and (SYSDATE-SPB_OPENDATE)*24>? ", barcode, hours);
|
|
|
+ if(rs.next()){
|
|
|
+ throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND,"条码"+barcode+",距离最近一次开盖时间("+rs.getString("spb_opendate")+")超过了"+hours+"小时,不允许做其它操作,只能报废!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|