Browse Source

1:物流单调整收货地址、收货人、联系方式判断方式
2:订单结案错误修复
3:新增数组倒置方法

沈静伟 4 years ago
parent
commit
8ea0a606bb

+ 29 - 0
src/apps/salogis/salogis.java

@@ -60,6 +60,9 @@ public class salogis extends PaoCust {
 
         String[] ffreightstatuss = getDistinctString(paoset, "ffreightstatus", true);
         String[] frecagentnum = getDistinctString(paoset, "frecagentnum", true);
+        String[] faddress = getDistinctString(paoset, "faddress", true);
+        String[] fcontact = getDistinctString(paoset, "fcontact", true);
+        String[] fphonenumber = getDistinctString(paoset, "fphonenumber", true);
         if (ffreightstatuss.length > 1) {
             throw new P2AppException("", "不可同时添加两种运费状态的发货单");
         }
@@ -72,6 +75,31 @@ public class salogis extends PaoCust {
         if (frecagentnum.length == 1 && !"".equals(getString("frecagentnum")) && !frecagentnum[0].equals(getString("frecagentnum"))) {
             throw new P2AppException("", "不可同时添加两个不同收货单位的发货单");
         }
+        if (faddress.length > 1) {
+            throw new P2AppException("", "不可同时添加两个不同收货地址的发货单");
+        }
+        if (fcontact.length > 1) {
+            throw new P2AppException("", "不可同时添加两个不同收货人的发货单");
+        }
+        if (fphonenumber.length > 1) {
+            throw new P2AppException("", "不可同时添加两个不同联系方式的发货单");
+        }
+        if (!salogisdetailSet.isEmpty()) {
+            DBConnect dbConnect = new DBConnect();
+            Rows rows = dbConnect.runSqlQuery("select t1.faddress,t1.fcontact,t1.fphonenumber from SALOGISDETAIL t1 inner join sainvoice t2 on t1.fsourceid=t2.sainvoiceid and t1.FSOURCEOBJECT='sainvoice'and t1.fparentid=" + getUniqueIDValue());
+            for (Row row : rows) {
+                if (faddress.length == 1 && !faddress[0].equals(row.getString("faddress"))) {
+                    throw new P2AppException("", "不可同时添加两个不同收货地址的发货单");
+                }
+                if (fcontact.length == 1 && !fcontact[0].equals(row.getString("fcontact"))) {
+                    throw new P2AppException("", "不可同时添加两个不同收货人的发货单");
+                }
+                if (fphonenumber.length == 1 && !fphonenumber[0].equals(row.getString("fphonenumber"))) {
+                    throw new P2AppException("", "不可同时添加两个不同联系方式的发货单");
+                }
+            }
+        }
+
         BatchAdd(paoset, new String[]{"sainvoiceid", "$SAINVOICE"}, salogisdetailSet, new String[]{"fsourceid", "fsourceobject"}, true);
 
         if (!salogisdetailSet.isEmpty()) {
@@ -313,6 +341,7 @@ public class salogis extends PaoCust {
 
     /**
      * 更新发货单已核销数量
+     *
      * @throws P2Exception
      */
     public void updatesainvoicewriteamount() throws P2Exception {

+ 1 - 1
src/apps/saorder/SaorderAppBean.java

@@ -373,7 +373,7 @@ public class SaorderAppBean extends AppBeanCust {
                     if (!issuccess) {
                         ((PaoSet) getPaoSet()).addWarning(new P2AppException("", "上传ERP失败,当前单据将自动反审核,请检查!"));
                         UNCHECK();
-                    }else{
+                    } else {
                         saorder.sendMail();
                     }
                 }

+ 7 - 5
src/apps/saorder/saorder.java

@@ -246,7 +246,7 @@ public class saorder extends BaseSaorder {
                         double fdetailamount = detailpao.getDouble("famount");
                         double fmjamount = detailpao.getDouble("fmjamount");
                         double fdetailflamount = Math.mul(Math.div(Math.sub(fdetailamount, fmjamount), ftotalamount), fuseflamount, 2);
-                        detailpao.setValue("fflamount", fdetailflamount,2L);
+                        detailpao.setValue("fflamount", fdetailflamount, 2L);
                         frowflamount = Math.add(frowflamount, fdetailflamount);
 
                         lastdetailpao = detailpao;
@@ -260,7 +260,7 @@ public class saorder extends BaseSaorder {
             double yu = Math.sub(frowflamount, fuseflamount);
 
             if (yu != 0) {
-                lastdetailpao.setValue("fflamount", Math.sub(lastdetailpao.getDouble("fflamount"), yu),2L);
+                lastdetailpao.setValue("fflamount", Math.sub(lastdetailpao.getDouble("fflamount"), yu), 2L);
             }
         }
     }
@@ -2028,7 +2028,9 @@ public class saorder extends BaseSaorder {
         }
         DBConnect dbConnect = new DBConnect("ORACLE_TZ");
         Rows rows = dbConnect.runSqlQuery("select SO_LINE2,sum(QTY)as QTY from v_eso_shipped_qty where SO_NO2='" + getString("fsonum") + "' and ZT='" + (getString("siteid").equalsIgnoreCase("TZ") ? "IDCZJ10" : "IBPNB10") + "' group by SO_LINE2");
-
+        if (!"".equals(rows.errmsg)) {
+            throw new P2AppException("", "erp连接失败");
+        }
         PaoSetRemote saorderdetail = getPaoSet("saorderdetail");
         saorderdetail.setOrderBy("frownum");
         saorderdetail.reset();
@@ -2073,10 +2075,10 @@ public class saorder extends BaseSaorder {
         PaoSetRemote saorderdetail = getPaoSet("saorderdetail");
         int i = 0;
         while (saorderdetail.getPao(i) != null) {
-            double fundeliqty = saorderdetail.getPao(i).getInt("fundeliqty");//订单未发货数量
+            //double fundeliqty = saorderdetail.getPao(i).getInt("fundeliqty");//订单未发货数量
             double fqty = saorderdetail.getPao(i).getInt("fqty");//订单数量
             double FERPDELIQTY = saorderdetail.getPao(i).getDouble("FERPDELIQTY");//erp已发货数量
-            if (fqty > fundeliqty) {
+            if (fqty > FERPDELIQTY) {
                 saorderdetail.getPao(i).setValue("fchangenotes", "订单结案变更", 11L);
                 saorderdetail.getPao(i).setValue("fchangeqty", FERPDELIQTY, 11L);
             }

+ 23 - 8
src/base/baseclass/PaoCust.java

@@ -42,11 +42,13 @@ public class PaoCust extends Pao implements PaoRemote {
     public void fieldAction(Object paoField, String fieldname)
             throws P2Exception {
     }
-    public void validatephone(String phone) throws P2Exception{
-        if(!Pattern.matches("^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$", phone)){
-            throw new P2AppException("","手机号格式有误");
+
+    public void validatephone(String phone) throws P2Exception {
+        if (!Pattern.matches("^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$", phone)) {
+            throw new P2AppException("", "手机号格式有误");
         }
     }
+
     /**
      * 数据更新日志
      *
@@ -577,7 +579,7 @@ public class PaoCust extends Pao implements PaoRemote {
         maxbill.setInsertSite(getSite());
         maxbill.setWhere("app='" + appname + "' and siteid='" + getString("siteid") + "'");
         maxbill.reset();
-        System.err.println("where:"+maxbill.getCompleteWhere());
+        System.err.println("where:" + maxbill.getCompleteWhere());
         PaoRemote pao = null;
         if (maxbill.isEmpty()) {
             pao = maxbill.addAtEnd();
@@ -1281,8 +1283,9 @@ public class PaoCust extends Pao implements PaoRemote {
         }
         return map;
     }
-    public String[] getMailBySalesGroup(String fagentnum,String siteid) throws P2Exception {
-        PaoSetRemote email = getPaoSet("$sales_email", "salesassistant", "fsalenum in (select fsalenum from tagentsales where fagentnum = '"+fagentnum+"'and siteid ='"+siteid+"') and sales_email is not null");
+
+    public String[] getMailBySalesGroup(String fagentnum, String siteid) throws P2Exception {
+        PaoSetRemote email = getPaoSet("$sales_email", "salesassistant", "fsalenum in (select fsalenum from tagentsales where fagentnum = '" + fagentnum + "'and siteid ='" + siteid + "') and sales_email is not null");
         String[] emailaddress = getStrings(email, "sales_email");
         return emailaddress;
     }
@@ -1295,9 +1298,9 @@ public class PaoCust extends Pao implements PaoRemote {
         if (pp_users.count() == 1) {
             String fusertype = pp_users.getPao(0).getString("fusertype");
             pp_users.close();
-            if(fusertype != null && fusertype.length()!=0){
+            if (fusertype != null && fusertype.length() != 0) {
                 return fusertype;
-            }else{
+            } else {
                 return null;
             }
 
@@ -1324,4 +1327,16 @@ public class PaoCust extends Pao implements PaoRemote {
         }
         paoset.close();
     }
+
+    public <T> T[] array_invert(T[] t) {
+        int length = t.length;
+        Object[] os = new Object[length];
+        for (int i = 0; i < length; i++) {
+            os[i] = t[i];
+        }
+        for (Object o : os) {
+            t[--length] = (T) o;
+        }
+        return t;
+    }
 }

+ 8 - 6
src/rest/openapi/base/data/db/DBConnect.java

@@ -63,14 +63,16 @@ public class DBConnect extends BaseClass {
     }
 
     public Rows runSqlQuery(String SQL) {
-        Connection conn = new DBConnectPool().getConnect(datakey);
-        if (conn == null) {
-            return new Rows();
-        }
-        Rows rows = new Rows();
+        Connection conn = null;
         ResultSet resultSet = null;
         PreparedStatement statement = null;
+        Rows rows = new Rows();
         try {
+            conn = new DBConnectPool().getConnect(datakey);
+            if (conn == null) {
+                rows.errmsg = "Á¬½Óʧ°Ü";
+                return rows;
+            }
             statement = conn.prepareStatement(SQL);
             resultSet = statement.executeQuery();
             ResultSetMetaData rsmd = resultSet.getMetaData();
@@ -129,7 +131,7 @@ public class DBConnect extends BaseClass {
                 rows.totalRows = rows.size();
                 rows.totalPage = 1;
             }
-        } catch (SQLException e) {
+        } catch (Exception e) {
             e.printStackTrace();
             printErrOut(e.getMessage(), SQL, false);
             rows.errmsg = e.getMessage();

+ 1 - 1
src/rest/openapi/base/data/db/SQLiteJDBC.java

@@ -26,7 +26,7 @@ public class SQLiteJDBC {
             if (OSName.contains("Windows")) {
                 c = DriverManager.getConnection("jdbc:sqlite:D:\\BYERP\\data.db");
             } else if (OSName.contains("Mac")) {
-                c = DriverManager.getConnection("jdbc:sqlite:/Users/shenjingwei/Documents/´úÂ뿪·¢/idea/Banninger/data.db");
+                c = DriverManager.getConnection("jdbc:sqlite:/Users/shenjingwei/Documents/Develop/idea/Banninger/data.db");
             }
             stmt = c.createStatement();
         } catch (ClassNotFoundException e) {

+ 1 - 1
src/rest/openapi/base/parameter/parameter.java

@@ -16,7 +16,7 @@ public class parameter {
     public static ArrayList<String> tokenlist = new ArrayList<String>(16);
     public static HashMap<String, String> siteidList = new HashMap<>(16);
     public static HashMap<String, String> usertypeList = new HashMap<>(16);
-    public static boolean isdebug = false;
+    public static boolean isdebug = true;
     public static String serverUrl = null;
 
     public static String getAttchDownUrl() {

+ 83 - 0
src/rest/openapi/restcontroller/housekeeperpublic/tools/HtmlConvertToPDFUtil.java

@@ -0,0 +1,83 @@
+package openapi.restcontroller.housekeeperpublic.tools;
+
+import openapi.base.restful.WebClientRest;
+
+
+import java.io.*;
+
+public class HtmlConvertToPDFUtil {
+
+
+/**
+    public static boolean convertToPDF(String srcPath, String filename) throws IOException, InterruptedException {
+        File file = new File(WebClientRest.WKHTMLTOPDF_DESTPATH);
+        // 如果pdf保存路径不存在,则创建路径
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        String cmd=WebClientRest.WKHTMLTOPDF_PDF_PATH+" "+srcPath+" "+WebClientRest.WKHTMLTOPDF_DESTPATH+filename;
+        Process proc = Runtime.getRuntime().exec(cmd.toString());
+        HtmlToPdfInterceptor error = new HtmlToPdfInterceptor(proc.getErrorStream());
+        HtmlToPdfInterceptor output = new HtmlToPdfInterceptor(proc.getInputStream());
+        error.start();
+        output.start();
+        proc.waitFor();
+        return true;
+    }
+
+    public static boolean convertToIMAGE(String srcPath, String filename) throws IOException, InterruptedException {
+        File file = new File(WebClientRest.WKHTMLTOPDF_DESTPATH);
+        // 如果pdf保存路径不存在,则创建路径
+        if (!file.exists()) {
+            file.mkdirs();
+        }
+        String cmd=WebClientRest.WKHTMLTOPDF_IMAGE_PATH+" "+srcPath+" "+WebClientRest.WKHTMLTOPDF_DESTPATH+filename;
+        Process proc = Runtime.getRuntime().exec(cmd.toString());
+//        HtmlToPdfInterceptor error = new HtmlToPdfInterceptor(proc.getErrorStream());
+//        HtmlToPdfInterceptor output = new HtmlToPdfInterceptor(proc.getInputStream());
+//        error.start();
+//        output.start();
+        proc.waitFor();
+        return true;
+    }
+
+
+    public static FileInputStream getStream(String filename) throws FileNotFoundException {
+        File file=new File(WebClientRest.WKHTMLTOPDF_DESTPATH+filename);
+        if(!file.exists())return null;
+        FileInputStream fileInputStream=new FileInputStream(file);
+        return fileInputStream;
+    }
+
+
+    public static void main(String[] args) throws IOException, InterruptedException {
+        convertToIMAGE("C:\\Users\\86188\\Desktop\\新建文件夹\\imgview.html","test.jpg");
+    }
+
+
+
+
+
+    static class HtmlToPdfInterceptor extends Thread {
+        private InputStream is;
+
+        public HtmlToPdfInterceptor(InputStream is){
+            this.is = is;
+        }
+        @Override
+        public void run(){
+            try{
+                InputStreamReader isr = new InputStreamReader(is, "utf-8");
+                BufferedReader br = new BufferedReader(isr);
+                String line = null;
+                while ((line = br.readLine()) != null) {
+                    System.out.println(line.toString()); //输出内容
+                }
+            }catch (IOException e){
+                e.printStackTrace();
+            }
+        }
+    }
+    **/
+
+}

+ 58 - 0
src/rest/openapi/tools/FileUploadUtils.java

@@ -0,0 +1,58 @@
+package openapi.tools;
+
+import p2.p2server.P2Server;
+import p2.pao.PaoRemote;
+import p2.pao.PaoSetRemote;
+import p2.util.P2Exception;
+
+import java.util.Date;
+
+public class FileUploadUtils {
+    public static void test(String siteid,String filename,String tablename,long onwerid) throws P2Exception {
+
+        PaoSetRemote doclinkSet = P2Server.getP2Server().getPaoSet("doclinks", P2Server.getP2Server().getSystemUserInfo());
+        doclinkSet.setWhere("document='"+filename+"' and ownertable='"+tablename+"' and ownerid="+onwerid);
+        doclinkSet.reset();
+        if(doclinkSet.isEmpty()){
+            PaoSetRemote docinfo = P2Server.getP2Server().getPaoSet("docinfo", P2Server.getP2Server().getSystemUserInfo());
+            docinfo.setInsertSite(siteid);
+            docinfo.reset();
+            PaoRemote newdocinfo = docinfo.addAtEnd();
+            newdocinfo.setValue("document", filename, 11L);
+            newdocinfo.setValue("description", "ϵͳµ¼Èë", 11L);
+            newdocinfo.setValue("createdate", new Date(), 11L);
+            newdocinfo.setValue("createby", "P2ADMIN", 11L);
+            newdocinfo.setValue("revision", 1, 11L);
+            newdocinfo.setValue("changeby","P2ADMIN", 11L);
+            newdocinfo.setValue("changedate", new Date(), 11L);
+            newdocinfo.setValue("doctype", "Attachments", 11L);
+            newdocinfo.setValue("urltype", "FILE", 11L);
+            newdocinfo.setValue("urlname", "URLNAME", 11L);
+            newdocinfo.setValue("printthrulinkdflt", 1, 11L);
+            newdocinfo.setValue("usedefaultfilepath", 0, 11L);
+            newdocinfo.setValue("show", 1, 11L);
+            newdocinfo.setValue("langcode", "ZH", 11L);
+            newdocinfo.setValue("postfix", filename.substring(filename.lastIndexOf(".") + 1).toUpperCase(), 11L);
+            newdocinfo.setValue("serialnumber", filename, 11L);
+            newdocinfo.setValue("ownertable",tablename, 11L);
+            newdocinfo.setValue("siteid", siteid, 11L);
+            PaoSetRemote doclinks = newdocinfo.getPaoSet("DOCLINKS");
+            if(doclinks.isEmpty()){
+                PaoRemote newdoclink = doclinks.addAtEnd();
+                newdoclink.setValue("document",filename,11l);
+                newdoclink.setValue("ownertable",tablename,11l);
+                newdoclink.setValue("ownerid",onwerid,11l);
+                newdoclink.setValue("doctype","Attachments",11l);
+                newdoclink.setValue("getlatestversion",1,11l);
+                newdoclink.setValue("printthrulink",1,11l);
+                newdoclink.setValue("copylinktowo",0,11l);
+                newdoclink.setValue("docinfoid",newdocinfo.getUniqueIDValue(),11l);
+            }
+
+            docinfo.save();
+
+        }
+
+    }
+
+}