package xin.glue.ui.H.H05; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.math.BigDecimal; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.Types; import java.util.List; import xin.glue.ui.common.PosGridSave; import xin.glue.ui.common.ProduceFactory; import xin.glue.ui.common.component.PosSiteLog; import xin.glue.user.common.UIJ030052; import com.posdata.glue.biz.activity.PosActivity; import com.posdata.glue.biz.constants.PosBizControlConstants; import com.posdata.glue.context.PosContext; import com.posdata.glue.dao.vo.PosParameter; import com.posdata.glue.dao.vo.PosRow; import com.posdata.glue.dao.vo.PosRowSet; /* * 发货明细回退业务处理,为方便成品发货操作添加 * @author TangLiang 唐亮 * @data 2009.12.15 */ public class returnDlivDirno extends PosActivity{ public String runActivity(PosContext context) { //发运指示号 String[] DLIV_DIRNO = (String[]) context.get("DLIV_DIRNO"); //录入人 String[] REG_ID = (String[]) context.get("REG_ID"); //退回原因 String[] RETURN_REASON = (String[]) context.get("RETURN_REASON"); String sqlOut = "select DLIV_DIRNO from tbj01_dliv_dir where DLIV_DIRNO = ? AND LAST_MAN IS NULL"; PosParameter paramg = new PosParameter(); paramg.setWhereClauseParameter(0,DLIV_DIRNO[0]); PosRowSet ischeck = this.getDao("mesdao").findByQueryStatement(sqlOut, paramg); UIJ030052 uij030052 = new UIJ030052(); String url="http://172.16.0.18:9090/TieQianinterface/services/MaterialOutInfo/materialoutinfo/"+DLIV_DIRNO[0]; String retr=uij030052.jsonPost(url, DLIV_DIRNO[0]); if(retr.contains("false")&&ischeck.hasNext()) { logger.logDebug("returnDlivDirno 车辆已出厂,需要审核!! "); String vtemp="ISOUT"; context.put("rs", vtemp); } else { //在做明细回退之前,必须要删除结算数据。如果结算没有接收则直接退到排车界面 PosParameter param11 = new PosParameter(); param11.setWhereClauseParameter(0,DLIV_DIRNO[0]); PosRowSet DIRNOVO = this.getDao("mesdao").find("UIH052200_02.select", param11); String strValue = null; Connection conn = null; if(DIRNOVO.hasNext()){ CallableStatement cstm= null; conn = this.getDao("mesdao").getDBConnection(); //存在值的情况下要判断销售是否进行结算退回操作 PosRow DIRNORow = DIRNOVO.next(); try{ CallableStatement cstmt = conn.prepareCall("{?=call SqListNumbRollBack(?)}"); cstmt.registerOutParameter(1, Types.VARCHAR); cstmt.setString(2, DLIV_DIRNO[0]); //cstmt.registerOutParameter(3, Types.INTEGER); cstmt.execute(); strValue = cstmt.getString(1); cstmt.close(); } catch(Exception ex) { //System.out.println(pDlivDirNo[i] + "明细数据发送到铁前数据库执行失败UIJ010060_01.CALL**********"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ex.printStackTrace(new PrintStream(baos)); String exception = baos.toString(); String errStr = "\n异常原因:" + exception; logger.logInfo(DLIV_DIRNO[0] + "明细退回执行失败SqListNumbRollBack;" + errStr); } if (cstm != null) { try { cstm.close(); conn.close(); } catch (Exception e) { } } //String ISCHANGEWGT = (String) DIRNORow.getAttribute("ISCHANGEWGT"); //if(ISCHANGEWGT != null && ISCHANGEWGT.equals("1")){ if(strValue != null && strValue.equals("1")){ //这里把发货指示号从发货明细完成退回到销售下车完成界面 //更新钢卷公共表 PosParameter param1 = new PosParameter(); param1.setWhereClauseParameter(0, REG_ID[0]); param1.setWhereClauseParameter(1, DLIV_DIRNO[0]); getDao("mesdao").update("UIH052200_COIL_COMM.UPDATE", param1); //删除货运中国 PosParameter paramdt = new PosParameter(); paramdt = new PosParameter(); paramdt.setWhereClauseParameter(0, DLIV_DIRNO[0]); this.getDao("mesdao").delete("UIJ010060_cargocn_02.update", paramdt); //更新发运表TBJ01_DLIV_DIR PosParameter param2 = new PosParameter(); param2.setWhereClauseParameter(0, DLIV_DIRNO[0]); getDao("mesdao").update("UIH052200_DLIV_DIR.UPDATE", param2); try{ cstm=getDao("mesdao").getCallableStatement("UIJ010060_01.CALL"); cstm.setString(1, "3"); cstm.setString(2, DLIV_DIRNO[0]); cstm.setString(3, ""); cstm.setString(4, ""); cstm.setString(5, ""); cstm.setString(6, "1"); cstm.setString(7, ""); cstm.setString(8, ""); cstm.setString(9, "4001RZ1"); cstm.setString(10, "热轧线"); cstm.execute(); } catch (Exception ex) { //System.out.println(pDlivDirNo[i] + "明细数据发送到铁前数据库执行失败UIJ010060_01.CALL**********"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ex.printStackTrace(new PrintStream(baos)); String exception = baos.toString(); String errStr = "\n异常原因:" + exception; logger.logInfo(DLIV_DIRNO[0] + "明细数据发送到铁前数据库执行失败UIJ010060_01.CALL;" + errStr); //ex.printStackTrace(); } if (cstm != null) { try { cstm.close(); } catch (Exception e) { } } //更新运送表 PosParameter param4 = new PosParameter(); param4.setWhereClauseParameter(0, DLIV_DIRNO[0]); getDao("mesdao").update("UIH052200_SHIP_DIR.UPDATE", param4); //删除结算接口表 PosParameter param3 = new PosParameter(); param3.setWhereClauseParameter(0, DLIV_DIRNO[0]); getDao("mesdao").update("UIH052200_J02_COMM.UPDATE", param3); //调用returndlivhis存储过程 CallableStatement cstm1= null; cstm1=getDao("mesdao").getCallableStatement("UIJ010060_05.CALL"); try { cstm1.setString(1, "3"); cstm1.setString(2, ""); cstm1.setString(3, DLIV_DIRNO[0]); cstm1.setString(4, ""); cstm1.setString(5, ""); cstm1.setString(6, ""); cstm1.setString(7, ""); cstm1.setString(8, ""); cstm1.setString(9, RETURN_REASON[0]); cstm1.setString(10, "H"); cstm1.setString(11, REG_ID[0]); cstm1.execute(); } catch (Exception e) { e.printStackTrace(); }finally{ try { if(cstm1!=null) cstm1.close(); } catch (Exception e) { e.printStackTrace(); } } //调用存货异动点存储过程 20210927暂时屏蔽 ProduceFactory PD= new ProduceFactory(); PD.ErpDataCover("HDLIVNO",DLIV_DIRNO[0],"69A","1","N",REG_ID[0],"热轧退货"); // PD.ErpDataCover("HDLIVNO",DLIV_DIRNO[0],"11AC","0","N",REG_ID[0],"热轧退货取消判定"); }else{ logger.logDebug("returnDlivDirno 销售已经进行结算接收操作,请退结算后再进行退明细操作!!! "); String vtemp="ISCHANGEWGT"; context.put("rs", vtemp); } }else{ //结算接口表内没有数据,说明销售还没有接收。可以直接进行发货明细退回操作 //这里把发货指示号从发货明细完成退回到销售下车完成界面 //更新钢卷公共表 PosParameter param1 = new PosParameter(); param1.setWhereClauseParameter(0, REG_ID[0]); param1.setWhereClauseParameter(1, DLIV_DIRNO[0]); getDao("mesdao").update("UIH052200_COIL_COMM.UPDATE", param1); //删除货运中国 PosParameter paramdt = new PosParameter(); paramdt = new PosParameter(); paramdt.setWhereClauseParameter(0, DLIV_DIRNO[0]); this.getDao("mesdao").delete("UIJ010060_cargocn_02.update", paramdt); //更新发运表TBJ01_DLIV_DIR PosParameter param2 = new PosParameter(); param2.setWhereClauseParameter(0, DLIV_DIRNO[0]); getDao("mesdao").update("UIH052200_DLIV_DIR.UPDATE", param2); //更新运送表 PosParameter param4 = new PosParameter(); param4.setWhereClauseParameter(0, DLIV_DIRNO[0]); getDao("mesdao").update("UIH052200_SHIP_DIR.UPDATE", param4); //删除结算接口表 PosParameter param3 = new PosParameter(); param3.setWhereClauseParameter(0, DLIV_DIRNO[0]); getDao("mesdao").update("UIH052200_J02_COMM.UPDATE", param3); //调用returndlivhis存储过程 CallableStatement cstm= null; cstm=getDao("mesdao").getCallableStatement("UIJ010060_05.CALL"); try { cstm.setString(1, "3"); cstm.setString(2, ""); cstm.setString(3, DLIV_DIRNO[0]); cstm.setString(4, ""); cstm.setString(5, ""); cstm.setString(6, ""); cstm.setString(7, ""); cstm.setString(8, ""); cstm.setString(9, RETURN_REASON[0]); cstm.setString(10, "H"); cstm.setString(11, REG_ID[0]); cstm.execute(); } catch (Exception e) { e.printStackTrace(); }finally{ try { if(cstm!=null) cstm.close(); } catch (Exception e) { e.printStackTrace(); } } //调用存货异动点存储过程 20210927暂时屏蔽 ProduceFactory PD= new ProduceFactory(); PD.ErpDataCover("HDLIVNO",DLIV_DIRNO[0],"69A","1","N",REG_ID[0],"热轧退货"); PD.ErpDataCover("HDLIVNO",DLIV_DIRNO[0],"11AC","0","N",REG_ID[0],"热轧退货取消判定"); } } return PosBizControlConstants.SUCCESS; } }