Przeglądaj źródła

海盐优化2021年12月16日 14:06:33

hu 4 lat temu
rodzic
commit
de29ccddf4

+ 48 - 0
src/apps/afterserviceorder/AfterserviceordeCreatewkDataBean.java

@@ -0,0 +1,48 @@
+package afterserviceorder;
+
+import baseclass.DataBeanCust;
+import p2.pao.PaoRemote;
+import p2.pao.PaoSetRemote;
+import p2.util.P2AppException;
+import p2.util.P2Exception;
+import p2.webclient.system.controller.Utility;
+import sysmsg.sysmsg;
+
+public class AfterserviceordeCreatewkDataBean  extends DataBeanCust{
+	
+	public int createworkorder() throws P2Exception {
+		PaoRemote pao = app.getAppBean().getPao();
+		String ftype = pao.getString("ftype");// 工单状态
+		if (ftype==null || ftype.length()==0) {
+			throw new P2AppException("", "选择的工单状态不能为空");
+		}
+		PaoSetRemote paoset=pao.getPaoSet("HYWORKORDER");
+		if(!paoset.isEmpty()) {
+			int i=0;
+			PaoRemote paoRemote =null;
+			while ((paoRemote=paoset.getPao(i))!=null) {
+				if(paoRemote.getString("ftype").equals(ftype) && !paoRemote.getString("fstatus").equals("作废")) {
+					throw new P2AppException("", "已存在"+ftype+"类型的工单,无法继续生成此类型的工单");
+				}
+				i++;
+			}
+		}
+		 afterserviceorder afterserviceorder = (afterserviceorder) pao;
+		 System.out.println(afterserviceorder.getString("FAGENTNUM"));
+		 if (afterserviceorder != null) {
+			 System.out.println(888);
+	            long l = afterserviceorder.createhyWorkorder(ftype);
+	       	     app.getAppBean().save();
+	       	
+	         this.sessionContext.queueRefreshEvent();
+	       	    Utility.sendEvent(sessionContext, app.getCurrentPageId(),
+	  				"dialogclose", null);// 关闭当前对话框
+	       	  closeApp("AFTERORDER");
+		      openApp("AFTERORDER", pao.getUniqueIDValue());
+	         openApp("HYORDER",l);
+	       
+	         byrefresh();
+	        }
+		return 1;
+	}
+}

+ 16 - 2
src/apps/afterserviceorder/AfterserviceorderAppBean.java

@@ -13,9 +13,24 @@ public class AfterserviceorderAppBean extends AppBeanCust {
         super.initializeApp();
     }
 
+//    /**Éú³É¹¤µ¥**/
+//    public int createhyWorkorder() throws Exception {
+//        this.SAVE();
+//        afterserviceorder afterserviceorder = (afterserviceorder) getPao();
+//        if (afterserviceorder != null) {
+//            long l = afterserviceorder.createhyWorkorder();
+//            this.SAVE();
+//            this.REFRESH();
+//            byrefresh();
+//            openApp("HYORDER",l);
+//
+//        }
+//        return 1;
+//    }
     /**Éú³É¹¤µ¥**/
-    public int createhyWorkorder() throws Exception {
+    public int createhyWorkorder1() throws Exception {
         this.SAVE();
+        System.out.println("afterserviceorder");
         afterserviceorder afterserviceorder = (afterserviceorder) getPao();
         if (afterserviceorder != null) {
             long l = afterserviceorder.createhyWorkorder();
@@ -27,7 +42,6 @@ public class AfterserviceorderAppBean extends AppBeanCust {
         }
         return 1;
     }
-    
     /**ÍË»Ø**/
     public int SENDBACK() throws Exception {
         this.SAVE();

+ 2 - 0
src/apps/afterserviceorder/SQL/查询订单收货日期.sql

@@ -0,0 +1,2 @@
+select SALOGIS.receivedate from SALOGIS inner join  salogisdetail on salogisdetail.fparentid=SALOGIS.salogisid 
+                      inner join sainvoice on sainvoice.sainvoiceid=salogisdetail.fsourceid where SALOGIS.fstatus ='µ½»õ' and SALOGIS.siteid='HY' and fsonum=$fsonum$ order by SALOGIS.receivedate desc

+ 62 - 0
src/apps/afterserviceorder/afterserviceorder.java

@@ -1,7 +1,13 @@
 package afterserviceorder;
 
+import java.util.Calendar;
+import java.util.Date;
+
 import baseclass.PaoCust;
 import baseclass.tools.GetFieldsName;
+import openapi.base.SQLFactory;
+import openapi.base.data.Rows;
+import openapi.base.data.db.DBConnect;
 import p2.p2server.P2Server;
 import p2.pao.PaoRemote;
 import p2.pao.PaoSet;
@@ -81,7 +87,63 @@ public class afterserviceorder extends PaoCust {
         remote.setValue("scenephone",getString("scenephone"),11l);
         remote.setValue("errormsg",getString("error_msg"),11l);
         remote.setValue("ftext",getString("fnotes"),11l);
+        String fsonum=getString("fsonum");
+        DBConnect connect = new DBConnect();
+        SQLFactory factory = new SQLFactory(this, "查询订单收货日期");
+		factory.addParameter("fsonum", fsonum);
+        Rows rows = connect.runSqlQuery(factory.getSQL());		
+        if(!rows.isEmpty()) {
+        	System.out.println(888);
+        	Date receivedate=rows.get(0).getDate("receivedate");
+        	Calendar calendar = Calendar.getInstance(); 
+        	calendar.add(Calendar.YEAR, -2);
+        	Date date =calendar.getTime();
+        	if(date.before(receivedate)) {
+        		System.out.println(999);
+        		 remote.setValue("FISPERIOD",true,11l);
+        	}
+        }
+        hyworkorder.save();
+        //return 1;
+        return remote.getUniqueIDValue();
+    }
+    /**生成海盐工单**/
+    public long createhyWorkorder(String ftype) throws P2Exception {
+
+        if(!getString("fstatus").equals("待处理")&&!getString("fstatus").equals("进行中"))throw new P2AppException("","非处理和进行中状态不可生成工单");
+        PaoSetRemote hyworkorder = P2Server.getP2Server().getPaoSet("HYWORKORDER", P2Server.getP2Server().getSystemUserInfo());
+        hyworkorder.setInsertSite(getSite());
+
+        PaoRemote remote = hyworkorder.addAtEnd();
+        remote.setValue("FAGENTNUM",getString("FAGENTNUM"),11l);
+        remote.setValue("servernum",getString("Servicenum"),11l);
+        remote.setValue("FPROVINCE",getString("FPROVINCE"),11l);
+        remote.setValue("FCITY",getString("FCITY"),11l);
+        remote.setValue("FCOUNTY",getString("FCOUNTY"),11l);
+        remote.setValue("FADDRESS",getString("FADDRESS"),11l);
+        remote.setValue("scenefname",getString("scenefname"),11l);
+        remote.setValue("scenephone",getString("scenephone"),11l);
+        remote.setValue("errormsg",getString("error_msg"),11l);
+        remote.setValue("ftext",getString("fnotes"),11l);
+        remote.setValue("ftype",ftype,11l);
+        String fsonum=getString("fsonum");
+        DBConnect connect = new DBConnect();
+        SQLFactory factory = new SQLFactory(this, "查询订单收货日期");
+		factory.addParameter("fsonum", fsonum);
+        Rows rows = connect.runSqlQuery(factory.getSQL());		
+        if(!rows.isEmpty()) {
+        	System.out.println(888);
+        	Date receivedate=rows.get(0).getDate("receivedate");
+        	Calendar calendar = Calendar.getInstance(); 
+        	calendar.add(Calendar.YEAR, -2);
+        	Date date =calendar.getTime();
+        	if(date.before(receivedate)) {
+        		System.out.println(999);
+        		 remote.setValue("FISPERIOD",true,11l);
+        	}
+        }
         hyworkorder.save();
+        //return 1;
         return remote.getUniqueIDValue();
     }
 

+ 70 - 1
src/apps/hyworkorder/HYWorkOrderAppBean.java

@@ -1,8 +1,11 @@
 package hyworkorder;
 
 import baseclass.AppBeanCust;
+import p2.p2server.P2Server;
+import p2.pao.PaoRemote;
+import p2.pao.PaoSetRemote;
+import p2.util.P2AppException;
 import p2.util.P2Exception;
-import workorder.workorder;
 
 public class HYWorkOrderAppBean extends AppBeanCust {
 
@@ -25,4 +28,70 @@ public class HYWorkOrderAppBean extends AppBeanCust {
 
         return 1;
     }
+    /**暂停**/
+    public int stop() throws Exception {
+        this.SAVE();
+        hyworkorder hyworkorder = (hyworkorder) getPao();
+        if (!hyworkorder.getString("fstatus").equals("进行中")) {
+        	throw new P2AppException("","非进行中不可暂停");
+        	}
+        hyworkorder.setValue("fstatus", "暂停",11L);
+        this.SAVE();
+        this.REFRESH();
+         byrefresh();
+        return 1;
+    }
+    /**启用**/
+    public int USED() throws P2Exception {
+        this.SAVE();
+        hyworkorder hyworkorder = (hyworkorder) getPao();
+        if (!hyworkorder.getString("fstatus").equals("暂停")) {
+        	throw new P2AppException("","非暂停不可启用");
+        	}
+        hyworkorder.setValue("fstatus", "启用",11L);
+        this.SAVE();
+        this.REFRESH();
+         byrefresh();
+        return 1;
+    }
+    /**作废**/
+    public int cancel() throws Exception {
+        this.SAVE();
+        hyworkorder hyworkorder = (hyworkorder) getPao();
+        if (hyworkorder.getString("fstatus").equals("已完成")) {
+        	throw new P2AppException("","已完成不可作废");
+        	}
+        hyworkorder.setValue("fstatus", "作废",11L);
+        PaoSetRemote hyworkorders = P2Server.getP2Server().getPaoSet("HYWORKORDER", P2Server.getP2Server().getSystemUserInfo());
+        hyworkorders.setWhere("siteid='HY' and servernum='"+hyworkorder.getString("servernum")+"' and HYWORKORDERID!="+hyworkorder.getUniqueIDValue());
+        hyworkorders.reset();
+        if(hyworkorders.isEmpty()) {
+        	if(!hyworkorder.getPaoSet("AFTERSERVICEORDER").isEmpty()) {
+        		System.out.println(111);
+        		hyworkorder.getPaoSet("AFTERSERVICEORDER").getPao(0).setValue("fstatus", "待处理");
+        	}
+        }else {
+        	int i=0;
+        	int count=0;
+        	PaoRemote paoRemote=null;
+        	while ((paoRemote=hyworkorders.getPao(i))!=null) {
+        		if((paoRemote.getString("fstatus")==null || paoRemote.getString("fstatus").length()==0) || paoRemote.getString("fstatus").equals("作废")){
+        			System.out.println(paoRemote.getString("fworknum"));
+        			count++;
+        		}
+				i++;
+			}
+//        	System.out.println(55);
+//        	System.out.println(count);
+//        	System.out.println(hyworkorders.count());
+        	if(count==hyworkorders.count()) {
+        		System.out.println("测试");
+        		hyworkorder.getPaoSet("AFTERSERVICEORDER").getPao(0).setValue("fstatus", "待处理");
+        	}
+		}
+        this.SAVE();
+        this.REFRESH();
+         byrefresh();
+        return 1;
+    }
 }

+ 16 - 1
src/apps/hyworkorder/hyworkorder.java

@@ -54,11 +54,26 @@ public class hyworkorder extends PaoCust {
 //            System.out.println("test:"+getString("ProjectLeader"));
             PaoSetRemote hyWorkorder = P2Server.getP2Server().getPaoSet("hyWorkorder", P2Server.getP2Server().getSystemUserInfo());
             hyWorkorder.setInsertSite(getSite());
-            hyWorkorder.setWhere("servernum='"+getString("servernum")+"' and ProjectLeader='"+getString("ProjectLeader")+"' and FADDRESS='"+getString("FADDRESS")+"'");
+            hyWorkorder.setWhere("servernum='"+getString("servernum")+"' and ProjectLeader='"+getString("ProjectLeader")+"' and FADDRESS='"+getString("FADDRESS")+"' and fstatus !='作废'");
             hyWorkorder.reset();
             if(!hyWorkorder.isEmpty()){
                 throw new P2AppException("","不能指定该人员,该服务人员已经有指派工单");
             }
+        }else if(fieldname.equalsIgnoreCase("FTYPE")) {
+        	String ftype=getString("ftype");
+        	PaoSetRemote hyWorkorder = P2Server.getP2Server().getPaoSet("hyWorkorder", P2Server.getP2Server().getSystemUserInfo());
+            hyWorkorder.setInsertSite(getSite());
+            hyWorkorder.setWhere("servernum='"+getString("servernum")+"' and HYWORKORDERID!="+getUniqueIDValue()+" and fstatus !='作废'");
+            hyWorkorder.reset();
+            int i=0;
+        	PaoRemote paoRemote=null;
+        	while ((paoRemote=hyWorkorder.getPao(i))!=null) {
+        		if(paoRemote.getString("ftype").equals(ftype)) {
+        			 throw new P2AppException("","对应的服务单已存在此类型的工单,无法再次新建");
+        		}
+        		i++;
+        	}
+            
         }
     }