From dbf53543a56970c7e10b6e274ff682ff4ebdaebe Mon Sep 17 00:00:00 2001
From: fs-danaus <danaus314@qq.com>
Date: 星期二, 02 七月 2024 14:48:35 +0800
Subject: [PATCH] 地图服务功能

---
 src/com/yc/service/grid/GridServiceImpl.java |   91 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 79 insertions(+), 12 deletions(-)

diff --git a/src/com/yc/service/grid/GridServiceImpl.java b/src/com/yc/service/grid/GridServiceImpl.java
index 40c92f8..697f82e 100644
--- a/src/com/yc/service/grid/GridServiceImpl.java
+++ b/src/com/yc/service/grid/GridServiceImpl.java
@@ -56,9 +56,9 @@
 public class GridServiceImpl extends BaseService implements GridServiceIfc {
     @Autowired
     Type38Ifc type38Ifc;
-    private final String gform = "[formid], [formname],[isused],[formmemo],[optype],[refformid],[hdtable],[dttable],[showdetail],[fetchrecnumber],[queryform],[refreshTime],[refresh_aftersave],[frozencols],[LockGridSort],[rowcopyfields],[rowcopyformids],[rowDelFormids],[index1],[index1primary],[index2],[index2primary],[index3],[index3Primary],[dataformid],[predocstatus],[postdocstatus],[DocStatusName],[transgroupcode],[codelength],[preFixcode],[precodetype],[helpdoc_udl],[checkblncfields],[formalign],[DealAfterDocSave],[AllowEmptyRow],[Busi2fiDataView],[glcodefield],[txtinputfields],[DBCtrlRowCount],[ShowAsDetailMode],[modifytableflag],[applytableflag],[CrossInputType],[MultiTitleType],[datapooled],[glentitycode],[formdatafilters],[ProcGroupafterSavedoc], [TransTypecode],[currencyfld],[chkFormula],[GridFormatFun],[SelectChecker],[ReturnCurChecker],[ReturnCurCheckerName],[FT],[FTFormType],[FK],[SeekGroupID],[sPremissField],[dPremissField],[FKeFilter],[GridRowHeight],[GridHeight], [isShowPwdEdit], [isOpenFuncShowPwdEdit], [isShowOnlineMsg] ,[isShowProcessTracking] ,[PanelLabelLayout],[isTitle], [isTaobao],[cellAlign] ,[pageSize],[version],[reportprompts],[CancelBtnProcName],[CancelBtnExpression],[CancelBtnEditStatus],[isShowCell],[importProcName],[CancelIsSave],[CancelBtnName],[isGantt],[byGroup],[DefaultRowCount],[Expanded], [isFilter], [JNIName],[JNIDataBaseURL], [JNIPort] ,[JNIDataBaseName], [JNIUser], [JNIPwd] ,[JNISql] ,[JNITempTable],[addNewRow],[autopaging],[RevokeBtnProcName],[RevokeBtnExpression],[RevokeBtnEditStatus],[autoOpen],isExchangeDataWithHost,isShowNewDocButton,isShowMemoWhenApprovals,isshowinserialbtn,inserialbtneditstatus,isshowoutserialbtn ,outserialbtneditstatus,isShowOnlinePaymentButton,isShowGridStyleForApp ,popupWindowsHeightRate,isShowCycleCountSerialBtn,cycleCountSerialBtnEditStatus,excludeTablesWhenSaving ";//
+    private final String gform = "[formid], [formname],[isused],[formmemo],[optype],[refformid],[hdtable],[dttable],[showdetail],[fetchrecnumber],[queryform],[refreshTime],[refresh_aftersave],[frozencols],[LockGridSort],[rowcopyfields],[rowcopyformids],[rowDelFormids],[index1],[index1primary],[index2],[index2primary],[index3],[index3Primary],[dataformid],[predocstatus],[postdocstatus],[DocStatusName],[transgroupcode],[codelength],[preFixcode],[precodetype],[helpdoc_udl],[checkblncfields],[formalign],[DealAfterDocSave],[AllowEmptyRow],[Busi2fiDataView],[glcodefield],[txtinputfields],[DBCtrlRowCount],[ShowAsDetailMode],[modifytableflag],[applytableflag],[CrossInputType],[MultiTitleType],[datapooled],[glentitycode],[formdatafilters],[ProcGroupafterSavedoc], [TransTypecode],[currencyfld],[chkFormula],[GridFormatFun],[SelectChecker],[ReturnCurChecker],[ReturnCurCheckerName],[FT],[FTFormType],[FK],[SeekGroupID],[sPremissField],[dPremissField],[FKeFilter],[GridRowHeight],[GridHeight], [isShowPwdEdit], [isOpenFuncShowPwdEdit], [isShowOnlineMsg] ,[isShowProcessTracking] ,[PanelLabelLayout],[isTitle], [isTaobao],[cellAlign] ,[pageSize],[version],[reportprompts],[CancelBtnProcName],[CancelBtnExpression],[CancelBtnEditStatus],[isShowCell],[importProcName],[CancelIsSave],[CancelBtnName],[isGantt],[byGroup],[DefaultRowCount],[Expanded], [isFilter], [JNIName],[JNIDataBaseURL], [JNIPort] ,[JNIDataBaseName], [JNIUser], [JNIPwd] ,[JNISql] ,[JNITempTable],[addNewRow],[autopaging],[RevokeBtnProcName],[RevokeBtnExpression],[RevokeBtnEditStatus],[autoOpen],isExchangeDataWithHost,isShowNewDocButton,isShowMemoWhenApprovals,isshowinserialbtn,inserialbtneditstatus,isshowoutserialbtn ,outserialbtneditstatus,isShowOnlinePaymentButton,isShowGridStyleForApp ,popupWindowsHeightRate,isShowCycleCountSerialBtn,cycleCountSerialBtnEditStatus,excludeTablesWhenSaving,showOnlineMsgExpression,showProcessTrackingExpression,showColsForApp ";//
 
-    private final String gfield = "[formid],[headflag], [fieldid],[statisid],[Lblcode],[fieldname],[datatype],[displayformat], [showongrid],[gridcaption],  [gridcontroltype],[gridlength],[ft],[ftformtype],[emptyrefdata], [fk],[seekgroupid],[spremissfield],[dpremissfield],[efilter],[return_one_record],[numfieldid],  [visible], [hidelabel], [controltype],[rowno],[colno],[lengthnum],[heightnum],[detailrowno],[detailcolno],[detaillength],[detailheight],[statisflag] ,[blcheckauth],[indexfld],[readonly],[datalink],[keyinput],[secretfld],[calcufield],[formula],[sumfield],[funclinkname],[activefuns] ,[initvalue] ,[checkauthmode],[PreLike],[EnterToNextRow],[tabsheetname],[passwordchar],[uppercase] ,[LinkFormDisplayFields], [dyfieldview],[copyfromlastrow],[ftlockconditionflag],[datafilterfield], [HelpKeyID] ,[MultiLangYN], [IMEactive] , [memo], [Hints],[editStatus],[isReader] ,[SqlScript],[MasterFieldShowLocation], [isCustomHTMLComponent] , [showFieldValueExpression],[HyperlinkFT],[HyperlinkFTFormType],[HyperlinkSPremissField],  [HyperlinkDPremissField],[HyperlinkEFilter],[Hyperlinkmode],[isAutoSaved],[stylecss],[rowSpan] ,[isImport],[isExport],[fieldtype],[cellAlign], [isCopyExclude],[isAutoRefresh],[isLoad],[Audit],[TipsExpression],[SuggestFileds],[RelationField],[onlyOne],AppColNo,AppHeight,AppHideLabel,AppLength,AppRowNo,AppVisible,ScanCodeField,funclinkname,exportTitle,isAPPExcludeField,SqlWhere,afterBlockDividingLine,appCellAlign,isSuppressBlankLineForDropDown ";
+    private final String gfield = "[formid],[headflag], [fieldid],[statisid],[Lblcode],[fieldname],[datatype],[displayformat], [showongrid],[gridcaption],  [gridcontroltype],[gridlength],[ft],[ftformtype],[emptyrefdata], [fk],[seekgroupid],[spremissfield],[dpremissfield],[efilter],[return_one_record],[numfieldid],  [visible], [hidelabel], [controltype],[rowno],[colno],[lengthnum],[heightnum],[detailrowno],[detailcolno],[detaillength],[detailheight],[statisflag] ,[blcheckauth],[indexfld],[readonly],[datalink],[keyinput],[secretfld],[calcufield],[formula],[sumfield],[funclinkname],[activefuns] ,[initvalue] ,[checkauthmode],[PreLike],[EnterToNextRow],[tabsheetname],[passwordchar],[uppercase] ,[LinkFormDisplayFields], [dyfieldview],[copyfromlastrow],[ftlockconditionflag],[datafilterfield], [HelpKeyID] ,[MultiLangYN], [IMEactive] , [memo], [Hints],[editStatus],[isReader] ,[SqlScript],[MasterFieldShowLocation], [isCustomHTMLComponent] , [showFieldValueExpression],[HyperlinkFT],[HyperlinkFTFormType],[HyperlinkSPremissField],  [HyperlinkDPremissField],[HyperlinkEFilter],[Hyperlinkmode],[isAutoSaved],[stylecss],[rowSpan] ,[isImport],[isExport],[fieldtype],[cellAlign], [isCopyExclude],[isAutoRefresh],[isLoad],[Audit],[TipsExpression],[SuggestFileds],[RelationField],[onlyOne],AppColNo,AppHeight,AppHideLabel,AppLength,AppRowNo,AppVisible,ScanCodeField,funclinkname,exportTitle,isAPPExcludeField,SqlWhere,afterBlockDividingLine,appCellAlign,isSuppressBlankLineForDropDown,qrcodesqlscript,qrcoderefrowid,qrcoderefdigit,qrcoderefformid,isshowqrcodesummary ";
 
     private final String GET_GFORM = " set nocount on; select " + gform + " from gform where formid=? \n";
     private final String GET_GFIELD = " set nocount on; select  " + gfield + " from gfield where formid=?  order by statisid asc\n";
@@ -130,10 +130,65 @@
     public SqlRowSet getGfiledByFormID(int formID) {
         return this.jdbcTemplate.queryForRowSet(this.GET_GFIELD, new Object[]{formID});
     }
-
+    @Override
     public List getGfiledByFormID9(int formID, int flag) {
-        // return this.jdbcTemplate.queryForRowSet(this.GET_GFIELD9, new Object[]{formID,flag});
         return this.jdbcTemplate.queryForList(this.GET_GFIELD9, new Object[]{formID, flag});
+    }
+    @Override
+    public List getGfiledByFormID9(int formID,int formType, int flag,String userCode) {
+
+        List<Map<String, Object>> userList =null;
+        List<Map<String, Object>> list9802 =null;
+        if(flag!=-1) {
+            userList = this.jdbcTemplate.queryForList("select rowno,colno,lengthnum,heightnum,fieldid,statisid,showongrid,headflag,visible from gFieldCustomLayout where usercode=? and formid=? and formType=? and headflag=?  order by headflag asc,statisid asc", new Object[]{userCode, formID, formType, flag});
+            list9802 = this.jdbcTemplate.queryForList(this.GET_GFIELD9.toLowerCase(), new Object[]{formID, flag});
+        }else {
+            //-1琛ㄧず涓讳粠琛ㄩ兘瑕佸彇
+            userList = this.jdbcTemplate.queryForList("select rowno,colno,lengthnum,heightnum,fieldid,statisid,showongrid,headflag,visible from gFieldCustomLayout where usercode=? and formid=? and formType=?   order by headflag asc,statisid asc", new Object[]{userCode, formID,formType});
+            list9802 = this.jdbcTemplate.queryForList(" set nocount on; select " + gfield.toLowerCase() + " from gfield where formid=?  order by headflag asc,statisid asc\n", new Object[]{formID});
+        }
+        List<Map<String, Object>> newList=new ArrayList<>();
+        if(userList!=null&&userList.size()>0) {
+            //---1,鎶婁釜浜烘暟鎹粠鎬荤殑9802閲屽彇鍖归厤椤瑰嚭鏉ユ斁鍒颁竴涓猲ewList鍚屾椂鍒犻櫎瀵瑰簲椤�
+            for (Map<String, Object> map : userList) {
+                for (Map<String, Object> map2 : list9802) {
+                    if ((map.get("fieldid")+"").equalsIgnoreCase(map2.get("fieldid")+"")
+                    &&(map.get("headflag")+"").equalsIgnoreCase(map2.get("headflag")+"")
+                    ) {
+                        map2.put("statisid",map.get("statisid"));//鏇存柊statisid
+                        map2.put("showongrid",map.get("showongrid"));//鏇存柊瀛楁鍦ㄨ〃鏍兼槸鍚﹀彲瑙�
+                        map2.put("visible",map.get("visible"));//鏇存柊瀛楁鍦ㄩ潰鏉挎槸鍚﹀彲瑙�
+                        map2.put("rowno",map.get("rowno"));//琛屽彿
+                        map2.put("colno",map.get("colno"));//鍒楀彿
+                        newList.add(map2);
+                        list9802.remove(map2);
+                        break;
+                    }
+                }
+            }
+for(int i=0;i<2;i++) {
+    final int filterFlag=i;
+    Integer lastStatisid = 0;
+    //澶勭悊涓讳粠琛ㄥ悇鑷渶澶у簭鍙�
+    Optional<Map<String,Object>> optional=newList.stream().filter(x->((Integer)x.get("headflag")).intValue()==filterFlag).max((o1, o2) -> (Integer) o1.get("statisid") - (Integer) o2.get("statisid"));
+    if(optional.isPresent()) {
+        lastStatisid= Integer.parseInt(optional.get().get("statisid") + "");
+    }
+    if(lastStatisid==0) continue;//涓嶅瓨鍦ㄨ嚜瀹氫箟璁剧疆鍒欒烦鍑�
+    for (Map<String, Object> x : list9802) {
+        if(((Integer)x.get("headflag")).intValue()==filterFlag){
+            //鐩稿悓鐨勬墠澶勭悊
+            lastStatisid += 10;
+            x.put("statisid", lastStatisid);//鏇存柊statisid
+        }
+    }
+}
+           //---2,鍐嶆妸鍓╀綑鐨勯」閮藉姞鍒皀ewList閲岄潰杩斿洖
+            newList.addAll(list9802);
+        }else {
+            newList=list9802;
+        }
+        return newList;
     }
 
     @Override
@@ -763,13 +818,15 @@
         }
         String where_str = null;//閽堝鏉′欢涓�閮ㄥ垎鏄敤浣滄浛鎹㈠弬鏁帮紝@G@鍚庨潰閮ㄥ垎鐢ㄤ綔sql鐨剋here鏉′欢
         if (where.trim().indexOf("@G@") == 0) {
+            //鍙湁琛ㄦ牸鍙傛暟鍊兼儏鍐碉紝娌¢潰鏉垮弬鏁板�硷紝鎵�浠ヨ鍘绘帀@G@
             where = where.replaceAll("@G@", "");// 浠鍒嗛殧鐨勭浜岄儴鍒嗘槸鏍肩嚎闇�瑕佺敤鐨�
             where_str = where;
         } else if (where.trim().indexOf("@G@") > 0) {//琛ㄧず鏈夊弬鏁板��
+            //琛ㄧず鏈夐潰鏉垮拰琛ㄦ牸鐨勫弬鏁板��
             String[] whereSplit = where.trim().split("@G@");
             if (whereSplit.length > 1) {
                 where_str = whereSplit[1];
-                where = whereSplit[0];//鍙傛暟鍊�
+                where = " ("+whereSplit[0]+") and ("+whereSplit[1]+" )";//鍙傛暟鍊�
             }
         } else {
             String[] temp_str = where.trim().split("@G@");
@@ -794,7 +851,10 @@
                     str.append(",");
                 }
                 for (String parmter : strs) {
-                    parmter = parmter.toLowerCase();
+                    parmter = parmter.toLowerCase().trim();
+                    if(parmter.startsWith("(")&&parmter.endsWith(")")) {
+                        parmter=parmter.substring(1,parmter.length()-1);
+                    }
                     if (parmter.trim().indexOf(toStr) > -1) {
                         String value=(parmter.indexOf("=") > -1 ? parmter.split("=") : parmter.split("like"))[1].replaceAll("%20", "").replaceAll("@~", "%");
                         if(value!=null&&value.trim().equals("'%%'")){
@@ -1298,7 +1358,14 @@
                 if (map.containsKey(result[0] + "_expr") && org.apache.commons.lang3.StringUtils.isNotBlank(result[1]) && !"null".equalsIgnoreCase(result[1])) {
                     //瑙e瘑
                     try {
-                        sb.add(ChangePassword.getDecryptPassword(EncodeUtil.replaceUrlChar(result[1].replace("@E@", "=="))));
+                        String value=null;
+                        if(org.apache.commons.lang3.StringUtils.isNotBlank(result[1])) {
+                            value = ChangePassword.getDecryptPassword(EncodeUtil.replaceUrlChar(result[1].replace("@E@", "==")));
+                            if (value.equalsIgnoreCase("")) {
+                                value = null;
+                            }
+                        }
+                        sb.add(value);
                     } catch (Exception e) {
                         throw new RuntimeException(e);
                     }
@@ -1341,7 +1408,7 @@
                 if (index >= 0) {
                     leftValue = value.substring(0, index);
                 }
-                rightValue = value.substring(index + 1).trim();
+                rightValue = value.substring(index + 1).trim().replace("@~","%");
                 if (parameterName.trim().equalsIgnoreCase(leftValue.replaceAll("\\s", ""))) {//鍖归厤鍒板弬鏁�
                     if (i != 0) sb.append(",");
                     sb.append("'null'".equalsIgnoreCase(rightValue.replaceAll("\\s", "")) ? null : (!rightValue.trim().startsWith("'")||"''".equalsIgnoreCase(rightValue))?rightValue:GridUtils.prossSqlParm(rightValue.substring(1,rightValue.length()-1)));
@@ -2010,7 +2077,7 @@
      **/
     public String getTypeLengthInfo(String tableName) {
         //
-        return this.jdbcTemplate.queryForObject(" set nocount on; declare @s varchar(max) SELECT @s=(isnull(@s+',','')+ column_name +'-'+ convert(varchar ,character_maximum_length) ) from INFORMATION_SCHEMA.columns where table_name =?  and data_type in ('char','nchar','varchar','nvarchar') \n select @s as s \n",
+        return this.jdbcTemplate.queryForObject(" set nocount on; declare @s varchar(max) SELECT @s=(isnull(@s+',','')+ column_name +'-'+ convert(varchar(100) ,character_maximum_length) ) from INFORMATION_SCHEMA.columns where table_name =?  and data_type in ('char','nchar','varchar','nvarchar') \n select @s as s \n",
                String.class, new Object[]{tableName});
 
     }
@@ -2098,8 +2165,8 @@
     public String getAutoCode2(String rowid, int length, String percode, String perc, String table) {
         StringBuilder sb = new StringBuilder();
         sb.append(" set nocount on; declare @curcode int   ,@rntcode varchar(20) , @Treetable varchar(50) ,@rowid varchar(20),@codelength int   ").append(" select  @rowid ='" + rowid + "',@codelength = " + length + " ")
-                .append("  begin Tran   select @curcode = isnull(curcode,0) from  " + table + "  with (updlock) where  rowid = @rowid  ").append(" select @curcode =convert(varchar ,   isnull(@curcode,0)   + 1 )  ")
-                .append(" select  @rntcode = '" + percode + "' + '" + perc + "' + replicate('0' , @codelength - len(convert(varchar,@curcode ) ))  + convert(varchar,@curcode)  ").append(" update   " + table + "  set Curcode = @curcode where rowid = @rowid  ")
+                .append("  begin Tran   select @curcode = isnull(curcode,0) from  " + table + "  with (updlock) where  rowid = @rowid  ").append(" select @curcode =convert(varchar(100) ,   isnull(@curcode,0)   + 1 )  ")
+                .append(" select  @rntcode = '" + percode + "' + '" + perc + "' + replicate('0' , @codelength - len(convert(varchar(100),@curcode ) ))  + convert(varchar(100),@curcode)  ").append(" update   " + table + "  set Curcode = @curcode where rowid = @rowid  ")
                 .append("if @@rowcount <> 0  begin  select @rntcode  commit Tran  end  else begin select   ''  rollback tran  end   ");
         return this.jdbcTemplate.queryForObject(sb.toString(), String.class);
     }
@@ -2123,7 +2190,7 @@
     }
 
     public String getTreeTable(int formid) {//杩斿洖鏍煎紡锛氭爲1鐨勮〃鍚�;鏍�1鍔熻兘鍙�,鏍�2琛ㄥ悕;鏍�2鍔熻兘鍙�
-        String sql = " set nocount on; SELECT stuff((SELECT ',' + CONVERT(VARCHAR, g.HDTable)+';'+CONVERT(VARCHAR, g.formid) from _systreeset s,gform g \n" +
+        String sql = " set nocount on; SELECT stuff((SELECT ',' + CONVERT(VARCHAR(100), g.HDTable)+';'+CONVERT(VARCHAR(100), g.formid) from _systreeset s,gform g \n" +
                 " where s.formid=? and s.treeformid=g.formid FOR XML PATH ('')),1,1,'')";
         return this.jdbcTemplate.queryForObject(sql, String.class, new Object[]{formid});
     }

--
Gitblit v1.8.0