fs-danaus
2024-07-02 dbf53543a56970c7e10b6e274ff682ff4ebdaebe
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里取匹配项出来放到一个newList同时删除对应项
            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,再把剩余的项都加到newList里面返回
            newList.addAll(list9802);
        }else {
            newList=list9802;
        }
        return newList;
    }
    @Override
@@ -763,13 +818,15 @@
        }
        String where_str = null;//针对条件一部分是用作替换参数,@G@后面部分用作sql的where条件
        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])) {
                    //解密
                    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});
    }