|
|
@@ -0,0 +1,361 @@
|
|
|
+package com.uas.mes.pda.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import com.uas.mes.common.data.BaseDao;
|
|
|
+import com.uas.mes.common.support.SystemSession;
|
|
|
+import com.uas.mes.core.data.SqlRowList;
|
|
|
+import com.uas.mes.core.exception.APIErrorException;
|
|
|
+import com.uas.mes.core.exception.APIErrorException.APIErrorCode;
|
|
|
+import com.uas.mes.core.util.NumberUtil;
|
|
|
+import com.uas.mes.core.util.StringUtil;
|
|
|
+import com.uas.mes.pda.service.PdaSpmService;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+@Service("pdaSpmServiceImpl")
|
|
|
+public class PdaSpmServiceImpl implements PdaSpmService {
|
|
|
+ @Autowired
|
|
|
+ private BaseDao baseDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> checkRewarm(String barcode) {
|
|
|
+ //锡膏条码通用校验
|
|
|
+ Map<String, Object> spmBarcode = validSpmBarcode(barcode);
|
|
|
+ //4、检测条码存在SPMBARCODE表且状态非”开封回存”或”‘回温回存”则提示”条码XXX,状态为:XXX,不允许出库回温。”
|
|
|
+ Object spb_status = spmBarcode.get("SPB_STATUS");
|
|
|
+ if (StringUtil.hasText(spb_status) && ((!spb_status.equals("开封回存")) && (!spb_status.equals("回温回存")))) {
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED, "条码" + barcode + ",状态为:" + spb_status + ",不允许出库回温!");
|
|
|
+ }
|
|
|
+ return spmBarcode;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void rewarm(String barcode) {
|
|
|
+ String[] barcodeArr = barcode.split(",");
|
|
|
+ List<String> sqls = new ArrayList<String>();
|
|
|
+ //PDA扫码出库并对该料开始记录回温时间,更新状态为‘出库回温’
|
|
|
+ for (String barcodeItem:barcodeArr) {
|
|
|
+ //1、条码出库回温校验(调用方法checkRewarm)。
|
|
|
+ checkRewarm(barcodeItem);
|
|
|
+ //2、将条码根据”,”分隔,存在锡膏管理数据的直接重置回温时间,更新状态为‘出库回温’否则插入SPMBARCODE表数据
|
|
|
+ sqls.add("MERGE INTO spmbarcode spm1 " +
|
|
|
+ "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 = '出库回温' " +
|
|
|
+ "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)");
|
|
|
+ //3、插入日志到SPMLOG记录条码出库回温
|
|
|
+ sqls.add(getSpmlog (barcodeItem,"出库","条码: "+barcodeItem+",出库回温成功。",""));
|
|
|
+ }
|
|
|
+ baseDao.execute(sqls);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> checkOpen(String barcode) {
|
|
|
+ //锡膏条码通用校验
|
|
|
+ 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 < 4.0){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,回温时长不足4小时,不允许开盖!");
|
|
|
+ }else if (rewarmingTime >= 24.0){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,回温时长超过24小时,不允许开盖!");
|
|
|
+ }
|
|
|
+ return spmBarcode;
|
|
|
+ }else{
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",尚未出库回温,不允许开盖!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void open(String barcode) {
|
|
|
+ String[] barcodeArr = barcode.split(",");
|
|
|
+ List<String> sqls = new ArrayList<String>();
|
|
|
+ for (String barcodeItem:barcodeArr) {
|
|
|
+ //1、条码出库开盖校验(调用方法checkOpen)。
|
|
|
+ checkOpen(barcodeItem);
|
|
|
+ //2、 批量更新条码状态为”已开封”,累计开盖累计时长,重置上次开盖时间
|
|
|
+ sqls.add("update spmbarcode set spb_status = '已开封',spb_opendate = sysdate where spb_barcode = '"+barcodeItem+"'");
|
|
|
+ //3、插入日志到SPMLOG记录条码出库回温
|
|
|
+ sqls.add(getSpmlog (barcodeItem,"开盖","条码: "+barcodeItem+",开盖成功。",""));
|
|
|
+ }
|
|
|
+ baseDao.execute(sqls);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> checkLoading(String barcode) {
|
|
|
+ //锡膏条码通用校验
|
|
|
+ Map<String, Object> spmBarcode = validSpmBarcode(barcode);
|
|
|
+ Object spb_status = spmBarcode.get("SPB_STATUS");
|
|
|
+ Double rewarmingTime = (NumberUtil.isEmpty(spmBarcode.get("REWARMINGTIME")) ? 0.0 : Double.valueOf(spmBarcode.get("REWARMINGTIME").toString()));
|
|
|
+ //PDA扫码上料,限制状态必须为‘已开封’,回温时间必须小于24H
|
|
|
+ if(StringUtil.hasText(spb_status)){
|
|
|
+ if(!spb_status.equals("已开封")){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+"状态为:"+spb_status+",不允许上料!");
|
|
|
+ }else if (rewarmingTime >= 24){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,回温时长超过24小时,不允许上料!");
|
|
|
+ }
|
|
|
+ return spmBarcode;
|
|
|
+ }else{
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",尚未出库回温,不允许上料!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void loding(String barcode,String linecode,Boolean isEmpty) {
|
|
|
+ //PDA扫码上料,限制状态必须为‘已开封’,回温时间必须小于24H
|
|
|
+ checkLoading(barcode);
|
|
|
+ //线别转大写处理,必须存在且已审核
|
|
|
+ if(StringUtil.hasText(linecode)){
|
|
|
+ linecode = linecode.toUpperCase();
|
|
|
+ boolean lineCheck = baseDao.checkIf("line","upper(li_code) = '"+linecode+"' and nvl(li_status,' ') = '已审核'");
|
|
|
+ if(!lineCheck){
|
|
|
+ throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND,"线别: "+linecode+",不存在或未审核!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String content = (StringUtil.hasText(linecode)) ? "线别: "+linecode+",上料成功。":"上料成功。";
|
|
|
+ //PDA扫码上料界面加选择项: 本瓶本次用完 如果勾选了该选择项,则上料之后将条码状态更新为‘已用尽’,对已用尽的条码只允许做空瓶回收操作
|
|
|
+ if(isEmpty){
|
|
|
+ baseDao.updateByCondition("spmbarcode","spb_status='已用尽',spb_linecode='"+linecode+"',spb_emptydate = sysdate","spb_barcode='"+barcode+"'");
|
|
|
+ content = content+"锡膏已用尽。";
|
|
|
+ }
|
|
|
+ saveSpmlog("'"+barcode+"'","上料",content,linecode);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> checkRestore(String barcode) {
|
|
|
+ //锡膏条码通用校验
|
|
|
+ Map<String, Object> spmBarcode = validSpmBarcode(barcode);
|
|
|
+ Object spb_status = spmBarcode.get("SPB_STATUS");
|
|
|
+ Double rewarmingTime = (NumberUtil.isEmpty(spmBarcode.get("REWARMINGTIME")) ? 0.0 : Double.valueOf(spmBarcode.get("REWARMINGTIME").toString()));
|
|
|
+ int restoreCount = (NumberUtil.isEmpty(spmBarcode.get("RESTORECOUNT")) ? 0: Integer.valueOf(spmBarcode.get("RESTORECOUNT").toString()));
|
|
|
+ // PDA扫码上料,限制状态必须为‘已开封’,回温时间必须小于24H
|
|
|
+ if(StringUtil.hasText(spb_status)){
|
|
|
+ if(!spb_status.equals("已开封") && !spb_status.equals("出库回温")){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+"状态为:"+spb_status+",不允许回存!");
|
|
|
+ }
|
|
|
+ if(restoreCount > 0){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",只允许回存一次,不允许多次回存!");
|
|
|
+ }
|
|
|
+ if (spb_status.equals("已开封") && rewarmingTime >= 19){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,开封状态下回温时长超过19小时,不允许回存!");
|
|
|
+ }
|
|
|
+ if(spb_status.equals("出库回温") && rewarmingTime >= 24){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",当前已回温: "+rewarmingTime+" 小时,未开封状态下回温时长超过24小时,不允许回存!");
|
|
|
+ }
|
|
|
+ return spmBarcode;
|
|
|
+ }else{
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",尚未出库回温,不允许上回存!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void restore(String barcode) {
|
|
|
+ String[] barcodeArr = barcode.split(",");
|
|
|
+ List<String> sqls = new ArrayList<String>();
|
|
|
+ for (String barcodeItem:barcodeArr) {
|
|
|
+ //1、条码回存校验(调用方法checkRestore)。
|
|
|
+ Map<String, Object> spmbarcodeMsg = checkRestore(barcodeItem);
|
|
|
+ Object spb_status = (spmbarcodeMsg.get("SPB_STATUS").equals("已开封") ? "开封回存" : "回温回存");
|
|
|
+ //2、 如果条码状态为”已开封”则更新条码状态为”开封回存”,如果条码状态为“出库回温”则更新条码状态为“回温回存”
|
|
|
+ sqls.add("update spmbarcode set spb_status = '"+spb_status+"'," +
|
|
|
+ "spb_opentime = round(nvl(spb_opentime,0) + round((sysdate - nvl(spb_opendate,sysdate))*24,2),2)," +
|
|
|
+ "spb_opendate = null," +
|
|
|
+ "spb_restorecount = 1 ," +
|
|
|
+ "spb_rewarmingdate = null " +
|
|
|
+ "where spb_barcode = '"+barcodeItem+"'");
|
|
|
+ //3、插入日志到SPMLOG记录条码出库回温
|
|
|
+ sqls.add(getSpmlog (barcodeItem,"回存","条码: "+barcodeItem+","+spb_status+"成功。",""));
|
|
|
+ }
|
|
|
+ baseDao.execute(sqls);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> checkScrap(String barcode) {
|
|
|
+ //锡膏条码通用校验
|
|
|
+ Map<String, Object> spmBarcode = validSpmBarcode(barcode,"scrap");
|
|
|
+ Object spb_status = spmBarcode.get("SPB_STATUS");
|
|
|
+ // PDA扫码上料,限制状态必须为‘已开封’,回温时间必须小于24H
|
|
|
+ if(StringUtil.hasText(spb_status)){
|
|
|
+ if(spb_status.equals("空瓶") || spb_status.equals("报废")){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+"已"+spb_status+",不允许报废!");
|
|
|
+ }
|
|
|
+ if(spb_status.equals("已用尽")){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+"已用尽,请做空瓶回收!");
|
|
|
+ }
|
|
|
+ return spmBarcode;
|
|
|
+ }
|
|
|
+ return spmBarcode;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void scrap(String barcode,String remark) {
|
|
|
+ String[] barcodeArr = barcode.split(",");
|
|
|
+ String barcodeStr = "'"+barcode.replace(",","','")+"'";
|
|
|
+ List<String> sqls = new ArrayList<String>();
|
|
|
+ for (String barcodeItem:barcodeArr) {
|
|
|
+ //1、锡膏条码通用校验。
|
|
|
+ checkScrap(barcodeItem);
|
|
|
+ //2、将条码根据”,”分隔,存在锡膏管理数据的直接重置回温时间,更新状态为‘出库回温’否则插入SPMBARCODE表数据
|
|
|
+ sqls.add("MERGE INTO spmbarcode spm1 " +
|
|
|
+ "USING (SELECT '"+barcodeItem+"' barcode FROM dual) spm2 " +
|
|
|
+ "ON ( spm1.spb_barcode=spm2.barcode) " +
|
|
|
+ "WHEN MATCHED THEN " +
|
|
|
+ " UPDATE SET spm1.spb_status = '报废',spm1.spb_remark = '"+remark+"',"
|
|
|
+ + "spm1.spb_opentime = round(nvl(spm1.spb_opentime,0) + round((sysdate - nvl(spm1.spb_opendate,sysdate))*24,2),2),"
|
|
|
+ + "spm1.spb_rewarmintime = round((sysdate - nvl(spm1.spb_rewarmingdate,sysdate))*24,2) " +
|
|
|
+ "WHEN NOT MATCHED THEN " +
|
|
|
+ " INSERT (SPB_ID,SPB_BARCODE,SPB_STATUS,spb_remark) " +
|
|
|
+ " VALUES(spmbarcode_seq.nextval,'"+barcodeItem+"','报废','"+remark+"')");
|
|
|
+ //3、插入日志到SPMLOG记录条码报废
|
|
|
+ sqls.add(getSpmlog (barcodeItem,"报废","条码: "+barcodeItem+",报废成功"+(StringUtil.hasText(remark) ? ",报废原因: "+remark :"" )+"。",""));
|
|
|
+ }
|
|
|
+ baseDao.execute(sqls);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> checkRecovery(String barcode) {
|
|
|
+ //锡膏条码通用校验
|
|
|
+ Map<String, Object> spmBarcode = validSpmBarcode(barcode);
|
|
|
+ Object spb_status = spmBarcode.get("SPB_STATUS");
|
|
|
+ // PDA扫码空瓶回收,限制状态必须为‘已用尽’
|
|
|
+ if(StringUtil.hasText(spb_status)){
|
|
|
+ if(!spb_status.equals("已用尽")){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+"状态为:"+spb_status+",不允许回收!");
|
|
|
+ }
|
|
|
+ return spmBarcode;
|
|
|
+ }else{
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",尚未出库回温,不允许空瓶回收!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void recovery(String barcode) {
|
|
|
+ String[] barcodeArr = barcode.split(",");
|
|
|
+ String barcodeStr = "'"+barcode.replace(",","','")+"'";
|
|
|
+ for (String barcodeItem:barcodeArr) {
|
|
|
+ //1、空瓶退回校验(调用方法checkRecovery)。
|
|
|
+ checkRecovery(barcodeItem);
|
|
|
+ }
|
|
|
+ //2、批量更新条码状态为”空瓶”
|
|
|
+ baseDao.execute("update spmbarcode set spb_status = '空瓶' where spb_barcode in ("+barcodeStr+")");
|
|
|
+ //3、插入日志到SPMLOG记录条码空瓶回收
|
|
|
+ saveSpmlog(barcodeStr,"回收","回收空瓶成功。","");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String,Object>> getMPMLog(String barcode) {
|
|
|
+ if(!StringUtil.hasText(barcode)){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码不允许为空!");
|
|
|
+ }
|
|
|
+ List<Map<String,Object>> res = new ArrayList<Map<String,Object>>();
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select SPL_OPERATION OPERATION ,to_char(SPL_DATE,'yyyy-mm-dd hh24:mi:ss') OPDATE ,SPL_OPERATOR OPERATOR," +
|
|
|
+ "SPL_LINECODE LINECODE,SPL_CONTENT CONTENT from SPMLOG where spl_barcode = '"+barcode+"' order by spl_id desc");
|
|
|
+ if(rs.next()){
|
|
|
+ res = rs.getResultList();
|
|
|
+ }else{
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码: "+barcode+",不存在或无操作日志信息!");
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author wuyx
|
|
|
+ * @Description 锡膏条码通用校验
|
|
|
+ * @Date 17:31 2019/6/13
|
|
|
+ * @Param [barcode]
|
|
|
+ * @return java.util.Map<java.lang.String,java.lang.Object>
|
|
|
+ **/
|
|
|
+ private Map<String, Object> validSpmBarcode(String barcode){
|
|
|
+ if(!StringUtil.hasText(barcode)){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码不允许为空!");
|
|
|
+ }
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select pr_kind3,nvl(round(months_between(sysdate,bar_validtime),2),-1) validMonth," +
|
|
|
+ "spb_status,spb_status STATUS,bar_code BARCODE,pr_brand BRAND,pr_spec SPEC,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 " +
|
|
|
+ "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()){
|
|
|
+ //3、条码必须是锡膏条码
|
|
|
+ if(!rs.getGeneralString("pr_kind3").equals("锡膏")){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",非锡膏条码!");
|
|
|
+ }
|
|
|
+ //4、条码有效期校验
|
|
|
+ if(rs.getGeneralDouble("validMonth") >= 6.0){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",已过有效期:"+rs.getGeneralDouble("validMonth")+"个月!");
|
|
|
+ }
|
|
|
+ return rs.getCurrentMap();
|
|
|
+ }else {
|
|
|
+ throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND,"条码"+barcode+",不存在或非在库状态!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author wuyx
|
|
|
+ * @Description 锡膏条码通用校验
|
|
|
+ * @Date 17:31 2019/6/13
|
|
|
+ * @Param [barcode]
|
|
|
+ * @return java.util.Map<java.lang.String,java.lang.Object>
|
|
|
+ **/
|
|
|
+ private Map<String, Object> validSpmBarcode(String barcode,String type){
|
|
|
+ if(!StringUtil.hasText(barcode)){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码不允许为空!");
|
|
|
+ }
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select pr_kind3,nvl(round(months_between(sysdate,bar_validtime),2),-1) validMonth," +
|
|
|
+ "spb_status,spb_status STATUS,bar_code BARCODE,pr_brand BRAND,pr_spec SPEC,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 " +
|
|
|
+ "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()){
|
|
|
+ //3、条码必须是锡膏条码
|
|
|
+ if(!rs.getGeneralString("pr_kind3").equals("锡膏")){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",非锡膏条码!");
|
|
|
+ }
|
|
|
+ //4、条码有效期校验
|
|
|
+ if(rs.getGeneralDouble("validMonth") >= 6 && !type.equals("scrap")){
|
|
|
+ throw new APIErrorException(APIErrorCode.BUSINESS_FAILED,"条码"+barcode+",已过有效期:"+rs.getGeneralDouble("validMonth")+"个月!");
|
|
|
+ }
|
|
|
+ return rs.getCurrentMap();
|
|
|
+ }else {
|
|
|
+ throw new APIErrorException(APIErrorCode.DATA_NOT_FOUND,"条码"+barcode+",不存在或非在库状态!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author wuyx
|
|
|
+ * @Description 锡膏日志记录
|
|
|
+ * @Date 18:38 2019/6/13
|
|
|
+ * @Param [barcode, operation, content, linecode]
|
|
|
+ * @return void
|
|
|
+ **/
|
|
|
+ private void saveSpmlog (String barcode,String operation,String content,String linecode){
|
|
|
+ baseDao.execute("insert into SPMLOG (SPL_ID,SPL_DATE,SPL_OPERATOR,SPL_LINECODE,SPL_BARCODE,SPL_OPERATION,SPL_CONTENT)" +
|
|
|
+ "select SPMLOG_SEQ.nextval,sysdate,'"+SystemSession.getUser().getEm_name()+"("+SystemSession.getUser().getEm_code()+")"+"','"+linecode+"'," +
|
|
|
+ "bar_code,'"+operation+"','条码: '||bar_code||',"+content+"' from barcode where bar_code in ("+barcode+")");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author wuyx
|
|
|
+ * @Description 获取锡膏日志SQL
|
|
|
+ * @Date 18:39 2019/6/13
|
|
|
+ * @Param [barcode, operation, content, linecode]
|
|
|
+ * @return java.lang.String
|
|
|
+ **/
|
|
|
+ private String getSpmlog (String barcode,String operation,String content,String linecode){
|
|
|
+ return"insert into SPMLOG (SPL_ID,SPL_DATE,SPL_OPERATOR,SPL_LINECODE,SPL_BARCODE,SPL_OPERATION,SPL_CONTENT) " +
|
|
|
+ "values (SPMLOG_SEQ.nextval,sysdate,'"+SystemSession.getUser().getEm_name()+"("+SystemSession.getUser().getEm_code()+")"
|
|
|
+ +"','"+linecode+"','"+barcode+"','"+operation+"','"+content+"')";
|
|
|
+ }
|
|
|
+}
|