fs-danaus
2022-04-14 f49f986a8d245d96b9f96741ed4159d97cbedfe1
优化在线退款功能
14个文件已修改
2439 ■■■■ 已修改文件
src/com/yc/action/grid/GT38Grid.java 2243 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/action/grid/GTGrid.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/init/InitSystemTaks.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/controller/MutualController.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/entity/CallBack120201Entity.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/entity/Push120201Entity.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/entity/T110203VO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/entity/T110302.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/schedule/Pull120201Schedule.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/schedule/Push110503Schedule.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/schedule/PushDataSchedule.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/service/MutualServiceIfc.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/open/mutual/service/MutualServiceImpl.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/service/panel/v2/TypeControl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/action/grid/GT38Grid.java
@@ -39,232 +39,233 @@
/***
 * 处理代码, gt-grid提交所有变化过的数据
 *
 *
 * @author 邓文峰 2010-3-24
 **/
@Controller
@RequestMapping("/gt38Grid.do")
public class GT38Grid extends com.yc.action.BaseAction {
    private int formID;// 功能号
    @Autowired
    private Grid38ServiceIfc gridService;// 表格处理的业务类
    @Autowired
    private GridServiceIfc grids;// 表格处理的业务类
    @Autowired
    TypeControlDao type38Ifc;
    @Autowired
    TypeControlDao typeControlDao;
    @Autowired
    Type38Ifc type38;
    String StatisNames = "";
    StringBuilder str1 = new StringBuilder();
    Page page1 = new Page();
    /**
     *正则表达式  是否有 sum,count,avg,min,max 这个字符
     */
  private static     Pattern SUM_COUNT_AVG_MIN_MAX_PATTERN = Pattern.compile("[^\\w](sum|avg|min|max|count)[^\\w]");
    /**
     *正则表达式  是否有 as 这个字符
     */
  private  static  Pattern  AS_PATTERN = Pattern.compile("[^\\w]as\\s+");
    /**
     * 正则表达式  以@开头的单词
     */
    private  static      Pattern START_WOROD_PATTERN = Pattern.compile("@.*?\\w+");
    @RequestMapping(params = "m=get")
    // Integer grapht 增加一个参数作为图表统计调用
    public String createGrid(Integer grapht, Model model,
            HttpServletRequest request, HttpServletResponse resp)
            throws Exception {
        // String
        // datalist="4.按仓库、商品规格汇总,companyid,分组|4.按仓库、商品规格汇总,freestockSQM,汇总|4.按仓库、商品规格汇总,gradename2,分组|4.按仓库、商品规格汇总,special,分组|4.按仓库、商品规格汇总,stCode,分组|4.按仓库、商品规格汇总,stname,分组";
        try {
            String root = request.getSession().getServletContext().getRealPath("/")
                    + "/";
            int formid = -1;
            int pos=request.getParameter("pos")==null?1:Integer.parseInt(request.getParameter("pos"));
            try {
                formid = Integer.parseInt(EncodeUtil.base64Decode(request.getParameter("formIdHid")));
            } catch (NumberFormatException e1) {
                log.debug(request.getParameter("formIdHid") + "转换数字格式出错",
                        e1.getCause());
            }
            String StatisNames = EncodeUtil.base64Decode(request
                    .getParameter("StatisNames"));
            String StatisID = EncodeUtil.base64Decode(request
                    .getParameter("StatisID"));
            String datalist = "";
            List<Map<String, Object>> list = gridService.selectdata(formid,
                    StatisID);
            Map<String, Object> mapObject = null;
            PanelBean panelBean=new PanelBean();
            if(list==null||list.size()==0){
                throw new ApplicationException("请在【9828】维护好查询参数!");
            }
            for (int i = 0; i < list.size(); i++) {
                mapObject = list.get(i);
                datalist += typeControlDao.getSelectAndCheckBoxss(
                        GridUtils.prossRowSetDataType_String(mapObject,"StatisID"),
                        GridUtils.prossRowSetDataType_String(mapObject,"FieldID"),
                        GridUtils.prossRowSetDataType_String(mapObject,"FieldAlias"),
                        GridUtils.prossRowSetDataType_String(mapObject,"StatisType"),
                        GridUtils.prossRowSetDataType_String(mapObject,"Sequence"),
                        GridUtils.prossRowSetDataType_String(mapObject,"DisplayWidth"),
                        GridUtils.prossRowSetDataType_String(mapObject,"displayformat"),
                        GridUtils.prossRowSetDataType_String(mapObject,"displayYN"),
                        GridUtils.prossRowSetDataType_String(mapObject,"isFilterZero"),
                        GridUtils.prossRowSetDataType_String(mapObject,"jionFlag"),
                        GridUtils.prossRowSetDataType_String(mapObject,"jionFlagGroup"),
                        GridUtils.prossRowSetDataType_String(mapObject,"conFlag"),
                        GridUtils.prossRowSetDataType_String(mapObject,"modfvalues"),
                        GridUtils.prossRowSetDataType_String(mapObject,"modfvalues2"),
                        GridUtils.prossRowSetDataType_String(mapObject,"fieldCaption"),panelBean)
                        ;
            }
    private int formID;// 功能号
    @Autowired
    private Grid38ServiceIfc gridService;// 表格处理的业务类
    @Autowired
    private GridServiceIfc grids;// 表格处理的业务类
    @Autowired
    TypeControlDao type38Ifc;
    @Autowired
    TypeControlDao typeControlDao;
    @Autowired
    Type38Ifc type38;
    String StatisNames = "";
    StringBuilder str1 = new StringBuilder();
    Page page1 = new Page();
    /**
     * 正则表达式  是否有 sum,count,avg,min,max 这个字符
     */
    private static Pattern SUM_COUNT_AVG_MIN_MAX_PATTERN = Pattern.compile("[^\\w](sum|avg|min|max|count)[^\\w]");
    /**
     * 正则表达式  是否有 as 这个字符
     */
    private static Pattern AS_PATTERN = Pattern.compile("[^\\w]as\\s+");
    /**
     * 正则表达式  以@开头的单词
     */
    private static Pattern START_WOROD_PATTERN = Pattern.compile("@.*?\\w+");
            this.StatisNames = StatisID;
            try {
                datalist = java.net.URLDecoder.decode(datalist.replace("%", "@~"),
                        "utf-8");
            } catch (UnsupportedEncodingException e) {
                log.debug(e.getCause().getMessage());
            }
            String encodeWhere=request.getParameter("where");
            GridData data = new GridData();
            //保存不解码的where,直接传回前端
            data.setWhere38(encodeWhere);
            String where =EncodeUtil.base64Decode(encodeWhere);
            gridService.create38Grid(data, formid, root,
                    this.setWhere(this.replaceBlank(datalist)), StatisID);
            data.setDatalist(this.replaceBlank(datalist));
            data.setWhere(where);
            Grid grid = new Grid();
            grid.setFormID(formid);
            grid.setWinType(data.winType + "");
            grid.setField(data.field);
            grid.setWhere(data.where);
            grid.setDatalist(data.datalist);
            grid.setTbCols(data.totalCols);
            grid.setPos(pos);
            grid.setQueryStringBy38(request.getQueryString());
            grid.setTotalRowNum(request.getParameter("totalRowNum")==null?0:Integer.parseInt(request.getParameter("totalRowNum")));
            grid.setTotalPageNum(request.getParameter("totalPageNum")==null?0:Integer.parseInt(request.getParameter("totalPageNum")));
            Object object= loadByFunc(model, data, grid, request, resp, grapht, formid,
                    StatisNames,StatisID);
            if(VersionUtils.getAPPTypeName(request) != null){//APP端
                Page page= (Page) object;
                Map<String,Object> map=new HashMap<>();
                map.put("data", page.getData());//数据
                map.put("cols", data.getCols_app());//列名
                map.put("align", page.getResultMap());//对齐方式
                map.put("summary", page.getTbColsOut());//页脚汇总
                this.printJson(resp,GridUtils.toJson(map));
                return null;
            }else{
                return String.valueOf(object);
            }
        }catch (Exception e){
            e.printStackTrace();
            this.printJson(resp,e.getCause()!=null?e.getCause().getMessage():e.getMessage());
        }
        return null;
    }
    @RequestMapping(params = "m=get")
    // Integer grapht 增加一个参数作为图表统计调用
    public String createGrid(Integer grapht, Model model,
                             HttpServletRequest request, HttpServletResponse resp)
            throws Exception {
        // String
        // datalist="4.按仓库、商品规格汇总,companyid,分组|4.按仓库、商品规格汇总,freestockSQM,汇总|4.按仓库、商品规格汇总,gradename2,分组|4.按仓库、商品规格汇总,special,分组|4.按仓库、商品规格汇总,stCode,分组|4.按仓库、商品规格汇总,stname,分组";
        try {
            String root = request.getSession().getServletContext().getRealPath("/")
                    + "/";
            int formid = -1;
            int pos = request.getParameter("pos") == null ? 1 : Integer.parseInt(request.getParameter("pos"));
            try {
                formid = Integer.parseInt(EncodeUtil.base64Decode(request.getParameter("formIdHid")));
            } catch (NumberFormatException e1) {
                log.debug(request.getParameter("formIdHid") + "转换数字格式出错",
                        e1.getCause());
            }
            String StatisNames = EncodeUtil.base64Decode(request
                    .getParameter("StatisNames"));
            String StatisID = EncodeUtil.base64Decode(request
                    .getParameter("StatisID"));
            String datalist = "";
            List<Map<String, Object>> list = gridService.selectdata(formid,
                    StatisID);
            Map<String, Object> mapObject = null;
            PanelBean panelBean = new PanelBean();
            if (list == null || list.size() == 0) {
                throw new ApplicationException("请在【9828】维护好查询参数!");
            }
            for (int i = 0; i < list.size(); i++) {
                mapObject = list.get(i);
                datalist += typeControlDao.getSelectAndCheckBoxss(
                        GridUtils.prossRowSetDataType_String(mapObject, "StatisID"),
                        GridUtils.prossRowSetDataType_String(mapObject, "FieldID"),
                        GridUtils.prossRowSetDataType_String(mapObject, "FieldAlias"),
                        GridUtils.prossRowSetDataType_String(mapObject, "StatisType"),
                        GridUtils.prossRowSetDataType_String(mapObject, "Sequence"),
                        GridUtils.prossRowSetDataType_String(mapObject, "DisplayWidth"),
                        GridUtils.prossRowSetDataType_String(mapObject, "displayformat"),
                        GridUtils.prossRowSetDataType_String(mapObject, "displayYN"),
                        GridUtils.prossRowSetDataType_String(mapObject, "isFilterZero"),
                        GridUtils.prossRowSetDataType_String(mapObject, "jionFlag"),
                        GridUtils.prossRowSetDataType_String(mapObject, "jionFlagGroup"),
                        GridUtils.prossRowSetDataType_String(mapObject, "conFlag"),
                        GridUtils.prossRowSetDataType_String(mapObject, "modfvalues"),
                        GridUtils.prossRowSetDataType_String(mapObject, "modfvalues2"),
                        GridUtils.prossRowSetDataType_String(mapObject, "fieldCaption"), panelBean)
                ;
            }
    /**
     * 生成38类型需要表格的标题列 StatisID,fieldid,StatisType|StatisID,fieldid,StatisType
     * **/
    private String setWhere(String data) {
        if ("".equalsIgnoreCase(data))
            return "";
        StringBuilder sb = new StringBuilder();
        String[] t = data.split("&#039;");
        int i = 0;
        for (String s : t) {
            String[] st = s.split("#P#");
            if (i != 0)
                sb.append(" or ");
            sb.append(" (StatisID='" + st[0]).append("' and ")
                    .append(" fieldid= '" + st[1]).append("') ");
            i++;
        }
        return sb.toString();
    }
            this.StatisNames = StatisID;
            try {
                datalist = java.net.URLDecoder.decode(datalist.replace("%", "@~"),
                        "utf-8");
            } catch (UnsupportedEncodingException e) {
                log.debug(e.getCause().getMessage());
            }
            String encodeWhere = request.getParameter("where");
            GridData data = new GridData();
            //保存不解码的where,直接传回前端
            data.setWhere38(encodeWhere);
            String where = EncodeUtil.base64Decode(encodeWhere);
            gridService.create38Grid(data, formid, root,
                    this.setWhere(this.replaceBlank(datalist)), StatisID);
            data.setDatalist(this.replaceBlank(datalist));
            data.setWhere(where);
            Grid grid = new Grid();
            grid.setFormID(formid);
            grid.setWinType(data.winType + "");
            grid.setField(data.field);
            grid.setWhere(data.where);
            grid.setDatalist(data.datalist);
            grid.setTbCols(data.totalCols);
            grid.setPos(pos);
            grid.setQueryStringBy38(request.getQueryString());
            grid.setTotalRowNum(request.getParameter("totalRowNum") == null ? 0 : Integer.parseInt(request.getParameter("totalRowNum")));
            grid.setTotalPageNum(request.getParameter("totalPageNum") == null ? 0 : Integer.parseInt(request.getParameter("totalPageNum")));
            Object object = loadByFunc(model, data, grid, request, resp, grapht, formid,
                    StatisNames, StatisID);
            if (VersionUtils.getAPPTypeName(request) != null) {//APP端
                Page page = (Page) object;
                Map<String, Object> map = new HashMap<>();
                map.put("data", page.getData());//数据
                map.put("cols", data.getCols_app());//列名
                map.put("align", page.getResultMap());//对齐方式
                map.put("summary", page.getTbColsOut());//页脚汇总
                this.printJson(resp, GridUtils.toJson(map));
                return null;
            } else {
                return String.valueOf(object);
            }
        } catch (Exception e) {
            e.printStackTrace();
            this.printJson(resp, e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        }
        return null;
    }
    /**
     * 生成38类型显示所需要的数据 StatisID,fieldid,StatisType|StatisID,fieldid,StatisType
     * **/
    private String[] setShow(String data) {
        if ("".equalsIgnoreCase(data))
            return new String[] { "*", "" };
        String[] t = data.split("&#039;");
        int i = 0;
        int j = 0;
        String sum = "";
        String order = "";
        String group = "";
        String as = "";
        String cv1 = "";
        int index = 0;
        int y = 0;
        int z = 0;
        for (String s : t) {
    /**
     * 生成38类型需要表格的标题列 StatisID,fieldid,StatisType|StatisID,fieldid,StatisType
     **/
    private String setWhere(String data) {
        if ("".equalsIgnoreCase(data))
            return "";
        StringBuilder sb = new StringBuilder();
        String[] t = data.split("&#039;");
        int i = 0;
        for (String s : t) {
            String[] st = s.split("#P#");
            if (i != 0)
                sb.append(" or ");
            sb.append(" (StatisID='" + st[0]).append("' and ")
                    .append(" fieldid= '" + st[1]).append("') ");
            i++;
        }
        return sb.toString();
    }
            String[] st = s.split("#P#");
            if ("分组".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))
                    || "".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                if (i != 0) {
                    sum += ", ";
                    order += ", ";
                    group += ", ";
                }
                if (z != 0 && i == 0) {
                    sum += ", ";
                    order += ", ";
                    z = 0;
                }
                boolean groupFlg=true;
                boolean orderFlg=true;
                //存在有sum count avg min max,不能放在group by中  by danaus 18-10-26
    /**
     * 生成38类型显示所需要的数据 StatisID,fieldid,StatisType|StatisID,fieldid,StatisType
     **/
    private String[] setShow(String data) {
        if ("".equalsIgnoreCase(data))
            return new String[]{"*", ""};
        String[] t = data.split("&#039;");
        int i = 0;
        int j = 0;
        String sum = "";
        String order = "";
        String group = "";
        String as = "";
        String cv1 = "";
        int index = 0;
        int y = 0;
        int z = 0;
        for (String s : t) {
                Matcher matcher= SUM_COUNT_AVG_MIN_MAX_PATTERN.matcher(st[1]);
                if(matcher.find()) {//存在则在最后不需要增加这个值
                    //group += st[1];
                    //存在有 as +字段的情况需要去掉
                    groupFlg=false;
                }
            String[] st = s.split("#P#");
            if ("分组".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))
                    || "".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                if (i != 0) {
                    sum += ", ";
                    order += ", ";
                    group += ", ";
                }
                if (z != 0 && i == 0) {
                    sum += ", ";
                    order += ", ";
                    z = 0;
                }
                boolean groupFlg = true;
                boolean orderFlg = true;
                //存在有sum count avg min max,不能放在group by中  by danaus 18-10-26
                Matcher matcher = SUM_COUNT_AVG_MIN_MAX_PATTERN.matcher(st[1]);
                if (matcher.find()) {//存在则在最后不需要增加这个值
                    //group += st[1];
                    //存在有 as +字段的情况需要去掉
                    groupFlg = false;
                }
                     matcher = AS_PATTERN.matcher(st[1]);
                    if (matcher.find()) {//存在 as 字段别名的情况,
                        //String filed=st[1].substring(matcher.end(),st[1].length());// accessoriesAmount
                        String sql = st[1].substring(0, matcher.start());
                        order += sql+ "  asc ";
                        orderFlg=false;
                     if(groupFlg){
                         group += sql+" ";
                         groupFlg=false;
                     }
                matcher = AS_PATTERN.matcher(st[1]);
                if (matcher.find()) {//存在 as 字段别名的情况,
                    //String filed=st[1].substring(matcher.end(),st[1].length());// accessoriesAmount
                    String sql = st[1].substring(0, matcher.start());
                    order += sql + "  asc ";
                    orderFlg = false;
                    if (groupFlg) {
                        group += sql + " ";
                        groupFlg = false;
                    }
                    }
                if(orderFlg)    order += st[1] + "  asc ";
                if(groupFlg)    group += st[1];
                sum += st[1];
                i++;
            } else if ("汇总".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                }
                if (orderFlg) order += st[1] + "  asc ";
                if (groupFlg) group += st[1];
                sum += st[1];
                i++;
            } else if ("汇总".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                Matcher matcher= AS_PATTERN.matcher(st[1]);
                String filed;
                String sumsql;
                // case when isnull(acctcode,'') in ('5101004','1403004') then isnull(InAmount,0) else 0 end   as accessoriesAmount
                //1,去掉 as accessoriesAmount
                //--> case when isnull(acctcode,'') in ('5101004','1403004') then isnull(InAmount,0) else 0 end
                //3,sum组装起来 sum(isnull(case when isnull(acctcode,'') in ('5101004','1403004') then isnull(InAmount,0) else 0 end ,0)
                //4,最后再加上之前的去掉的 as accessoriesAmount,变成:sum(isnull(case when isnull(acctcode,'') in ('5101004','1403004') then isnull(InAmount,0) else 0 end ,0)) as accessoriesAmount
                if(matcher.find()){//存在 as 字段别名的情况,在sum的情况下需要先去掉,组成好再重新加上
                    filed=st[1].substring(matcher.end(),st[1].length());// accessoriesAmount
                    sumsql=st[1].substring(0,matcher.start());
                }
                Matcher matcher = AS_PATTERN.matcher(st[1]);
                String filed;
                String sumsql;
                // case when isnull(acctcode,'') in ('5101004','1403004') then isnull(InAmount,0) else 0 end   as accessoriesAmount
                //1,去掉 as accessoriesAmount
                //--> case when isnull(acctcode,'') in ('5101004','1403004') then isnull(InAmount,0) else 0 end
                //3,sum组装起来 sum(isnull(case when isnull(acctcode,'') in ('5101004','1403004') then isnull(InAmount,0) else 0 end ,0)
                //4,最后再加上之前的去掉的 as accessoriesAmount,变成:sum(isnull(case when isnull(acctcode,'') in ('5101004','1403004') then isnull(InAmount,0) else 0 end ,0)) as accessoriesAmount
                if (matcher.find()) {//存在 as 字段别名的情况,在sum的情况下需要先去掉,组成好再重新加上
                    filed = st[1].substring(matcher.end(), st[1].length());// accessoriesAmount
                    sumsql = st[1].substring(0, matcher.start());
                }
//                else if(st[1].indexOf("case")>-1){// 自定义字段列名,但又不是写 as 列名的情况
//
//                    // case when isnull(acctcode,'') in ('5101004','1403004') then isnull(InAmount,0) else 0 end
@@ -272,976 +273,954 @@
//                    //sumsql=st[1];
//
//                }
                else{
                    filed=st[1];
                    sumsql=st[1];
                }
                else {
                    filed = st[1];
                    sumsql = st[1];
                }
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " sum(isnull(" + sumsql + ",0)) as " + filed;
                    order += ", ";
                    order += " sum(isnull(" + sumsql + ",0))  asc";
                    j++;
                } else {
                    sum += " sum(isnull(" + sumsql + ",0)) as " + filed;
                    order += " sum(isnull(" + sumsql + ",0))  asc";
                }
                z++;
            } else if ("自定义".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                //case when sum(isnull(balance,0)) >0 then sum(isnull(balance,0)) else 0 end as balance3
                if (j != 0 || sum.length() > 0) {
                    as = "";
                    as += st[1];
                    index = as.toLowerCase().lastIndexOf("end");
                    cv1 = as.substring(0, index + 4).trim();
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " sum(isnull(" + sumsql + ",0)) as " + filed;
                    order += ", ";
                    order += " sum(isnull(" + sumsql + ",0))  asc";
                    j++;
                } else {
                    sum += " sum(isnull(" + sumsql + ",0)) as " + filed;
                    order += " sum(isnull(" + sumsql + ",0))  asc";
                }
                z++;
            } else if ("自定义".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                //case when sum(isnull(balance,0)) >0 then sum(isnull(balance,0)) else 0 end as balance3
                if (j != 0 || sum.length() > 0) {
                    as = "";
                    as += st[1];
                    index = as.toLowerCase().lastIndexOf("end");
                    cv1 = as.substring(0, index + 4).trim();
                    sum += ", ";
                    sum += st[1];
                    order += ", ";
                    order += cv1 + "  asc";
                    y++;
                    j++;
                    sum += ", ";
                    sum += st[1];
                    order += ", ";
                    order += cv1 + "  asc";
                    y++;
                    j++;
                } else {
                    as = "";
                    as += st[1];
                    index = as.indexOf("end");
                    cv1 = as.toLowerCase().substring(0, index + 4);
                    sum += st[1] + "as" + cv1;
                    order += cv1 + "  asc";
                }
                z++;
            } else if ("最大".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " max(isnull(" + st[1] + ",0)) as " + st[1];
                    order += ", ";
                    order += " max(isnull(" + st[1] + ",0)) asc";
                    j++;
                } else {
                    sum += " max(isnull(" + st[1] + ",0)) as " + st[1];
                    order += " max(isnull(" + st[1] + ",0)) asc";
                }
                z++;
            } else if ("最小".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " min(isnull(" + st[1] + ",0)) as " + st[1];
                    order += ", ";
                    order += " min(isnull(" + st[1] + ",0))  asc";
                    j++;
                } else {
                    sum += " min(isnull(" + st[1] + ",0)) as " + st[1];
                    order += " min(isnull(" + st[1] + ",0))  asc";
                    j++;
                }
                z++;
            } else if ("平均".equalsIgnoreCase(st[3].replaceAll(" ", ""))) {
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " avg(isnull(" + st[1] + ",0)) as " + st[1];
                    order += ", ";
                    order += " avg(isnull(" + st[1] + ",0))  asc";
                    j++;
                } else {
                    sum += " avg(isnull(" + st[1] + ",0)) as " + st[1];
                    order += " avg(isnull(" + st[1] + ",0))  asc";
                    j++;
                }
                z++;
            } else if ("个数".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " count(isnull(" + st[1] + ",0)) as " + st[1];
                    order += ", ";
                } else {
                    as = "";
                    as += st[1];
                    index = as.indexOf("end");
                    cv1 = as.toLowerCase().substring(0, index + 4);
                    sum += st[1] + "as" + cv1;
                    order += cv1 + "  asc";
                }
                z++;
            } else if ("最大".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " max(isnull(" + st[1] + ",0)) as " + st[1];
                    order += ", ";
                    order += " max(isnull(" + st[1] + ",0)) asc";
                    j++;
                } else {
                    sum += " max(isnull(" + st[1] + ",0)) as " + st[1];
                    order += " max(isnull(" + st[1] + ",0)) asc";
                }
                z++;
            } else if ("最小".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " min(isnull(" + st[1] + ",0)) as " + st[1];
                    order += ", ";
                    order += " min(isnull(" + st[1] + ",0))  asc";
                    j++;
                } else {
                    sum += " min(isnull(" + st[1] + ",0)) as " + st[1];
                    order += " min(isnull(" + st[1] + ",0))  asc";
                    j++;
                }
                z++;
            } else if ("平均".equalsIgnoreCase(st[3].replaceAll(" ", ""))) {
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " avg(isnull(" + st[1] + ",0)) as " + st[1];
                    order += ", ";
                    order += " avg(isnull(" + st[1] + ",0))  asc";
                    j++;
                } else {
                    sum += " avg(isnull(" + st[1] + ",0)) as " + st[1];
                    order += " avg(isnull(" + st[1] + ",0))  asc";
                    j++;
                }
                z++;
            } else if ("个数".equalsIgnoreCase(st[3].replaceAll("[\\s]", ""))) {
                if (j != 0 || sum.length() > 0) {
                    sum += ", ";
                    sum += " count(isnull(" + st[1] + ",0)) as " + st[1];
                    order += ", ";
                    order += " count(isnull(" + st[1] + ",0))  asc";
                    order += " count(isnull(" + st[1] + ",0))  asc";
                    j++;
                } else {
                    sum += " count(isnull(" + st[1] + ",0)) as " + st[1];
                    order += " count(isnull(" + st[1] + ",0))  asc";
                    j++;
                } else {
                    sum += " count(isnull(" + st[1] + ",0)) as " + st[1];
                    order += " count(isnull(" + st[1] + ",0))  asc";
                    j++;
                }
                z++;
            }
                    j++;
                }
                z++;
            }
            // select a,b,c from t
            // select case when esle end sum(a) as a,max(b) as b ....
            // select a,b,c from t
            // select case when esle end sum(a) as a,max(b) as b ....
        }
        return new String[] { sum, order, group };
    }
private String  selectdata(HttpSession session, HttpServletRequest request,
                                 int formid, String StatisNames) throws ApplicationException{
        }
        return new String[]{sum, order, group};
    }
    Map<String,String> sql=new HashMap<>(8);
    Map<String,String> JionFlagMap=new HashMap<>(8);
    List<Map<String, Object>> list = gridService.selectdata(formid,
            StatisNames);
    //1.组装值sql
    for(Map map:list){
        StringBuffer havingstr=new StringBuffer();
        //针对 between and 或 not between and 的情况 作判断 ,因为需要取第二个值来组装sql
        boolean isbetween=false;
        //分组号
        int jionFlagGroup=0;
        //关系符
        String jionflag="";
        //连接符
        String conFlag="";
        int isFilterZeros =GridUtils.prossRowSetDataType_Int(map,"isFilterZero");
        try{
            //分组号
            jionFlagGroup=GridUtils.prossRowSetDataType_Int(map,"jionFlagGroup");
            //关系符
            jionflag=GridUtils.prossRowSetDataType_String(map,"jionFlag");
            //连接符
            conFlag=GridUtils.prossRowSetDataType_String(map,"conFlag");
        }catch(Exception e){
            throw new ApplicationException("jionFlagGroup,jionFlag,conFlag没进行设置,请检查里面设置");
        }
        if(isFilterZeros==0&&"".equals(conFlag.trim())) continue;
        String StatisType = GridUtils.prossRowSetDataType_String(map,"StatisType");
           if(StatisType.equals(""))
               StatisType= "分组";
        String FieldID = GridUtils.prossRowSetDataType_String(map,"FieldID");
        Matcher matcher= AS_PATTERN.matcher(FieldID);
        //存在 as 字段别名的情况,在sum的情况下需要先去掉,组成好再重新加上
        if(matcher.find()){
            FieldID=FieldID.substring(0,matcher.start());
        }
        //处理过滤空值和0
        if(isFilterZeros==1){
            havingstr.append(" ( ");
            if (StatisType.equalsIgnoreCase("分组")) {
                havingstr.append(" isnull(" + FieldID + ",'') <> '') ");
            } else if (StatisType.equalsIgnoreCase("汇总")) {
                havingstr.append(" sum(");
                havingstr.append("isnull(" + FieldID + ",0)) <> 0) ");
            } else if (StatisType.equalsIgnoreCase("最大")) {
                havingstr.append(" max(");
                havingstr.append(" isnull(" + FieldID + ",0)) <> 0) ");
            } else if (StatisType.equalsIgnoreCase("最小")) {
                havingstr.append(" min(");
                havingstr.append(" isnull(" + FieldID + ",0)) <> 0) ");
            } else if (StatisType.equalsIgnoreCase("平均")) {
                havingstr.append(" avg(");
                havingstr.append(" isnull(" + FieldID + ",0)) <> 0) ");
            } else if (StatisType.equalsIgnoreCase("个数")) {
                havingstr.append(" count(");
                havingstr.append(" isnull(" + FieldID + ",0)) <> 0) ");
            } else if (StatisType.equalsIgnoreCase("自定义")) {
                havingstr.append( FieldID + " <> 0) ");
            }
        }
        //设置了连接符和比较符及选上过滤空值的情况
        if (jionflag != null && !jionflag.trim().equals("") && conFlag != null
                        && !conFlag.trim().equals("")) {
                if (isFilterZeros == 1)
                    havingstr.append(" and (");
                else
                    havingstr.append("  (");
    private String selectdata(HttpSession session, HttpServletRequest request,
                              int formid, String StatisNames) throws ApplicationException {
                if (StatisType.equalsIgnoreCase("分组")) {
        Map<String, String> sql = new HashMap<>(8);
        Map<String, String> JionFlagMap = new HashMap<>(8);
        List<Map<String, Object>> list = gridService.selectdata(formid,
                StatisNames);
        //1.组装值sql
        for (Map map : list) {
            StringBuffer havingstr = new StringBuffer();
            //针对 between and 或 not between and 的情况 作判断 ,因为需要取第二个值来组装sql
            boolean isbetween = false;
            //分组号
            int jionFlagGroup = 0;
            //关系符
            String jionflag = "";
            //连接符
            String conFlag = "";
            int isFilterZeros = GridUtils.prossRowSetDataType_Int(map, "isFilterZero");
            try {
                //分组号
                jionFlagGroup = GridUtils.prossRowSetDataType_Int(map, "jionFlagGroup");
                //关系符
                jionflag = GridUtils.prossRowSetDataType_String(map, "jionFlag");
                //连接符
                conFlag = GridUtils.prossRowSetDataType_String(map, "conFlag");
            } catch (Exception e) {
                throw new ApplicationException("jionFlagGroup,jionFlag,conFlag没进行设置,请检查里面设置");
            }
            if (isFilterZeros == 0 && "".equals(conFlag.trim())) continue;
            String StatisType = GridUtils.prossRowSetDataType_String(map, "StatisType");
            if (StatisType.equals(""))
                StatisType = "分组";
            String FieldID = GridUtils.prossRowSetDataType_String(map, "FieldID");
            Matcher matcher = AS_PATTERN.matcher(FieldID);
            //存在 as 字段别名的情况,在sum的情况下需要先去掉,组成好再重新加上
            if (matcher.find()) {
                FieldID = FieldID.substring(0, matcher.start());
            }
            //处理过滤空值和0
            if (isFilterZeros == 1) {
                havingstr.append(" ( ");
                if (StatisType.equalsIgnoreCase("分组")) {
                    havingstr.append(" isnull(" + FieldID + ",'') <> '') ");
                } else if (StatisType.equalsIgnoreCase("汇总")) {
                    havingstr.append(" sum(");
                    havingstr.append("isnull(" + FieldID + ",0)) <> 0) ");
                } else if (StatisType.equalsIgnoreCase("最大")) {
                    havingstr.append(" max(");
                    havingstr.append(" isnull(" + FieldID + ",0)) <> 0) ");
                } else if (StatisType.equalsIgnoreCase("最小")) {
                    havingstr.append(" min(");
                    havingstr.append(" isnull(" + FieldID + ",0)) <> 0) ");
                } else if (StatisType.equalsIgnoreCase("平均")) {
                    havingstr.append(" avg(");
                    havingstr.append(" isnull(" + FieldID + ",0)) <> 0) ");
                } else if (StatisType.equalsIgnoreCase("个数")) {
                    havingstr.append(" count(");
                    havingstr.append(" isnull(" + FieldID + ",0)) <> 0) ");
                } else if (StatisType.equalsIgnoreCase("自定义")) {
                    havingstr.append(FieldID + " <> 0) ");
                }
            }
            //设置了连接符和比较符及选上过滤空值的情况
            if (jionflag != null && !jionflag.trim().equals("") && conFlag != null
                    && !conFlag.trim().equals("")) {
                if (isFilterZeros == 1)
                    havingstr.append(" and (");
                else
                    havingstr.append("  (");
                    havingstr.append(" isnull(" + FieldID + ",'') ");
                } else if (StatisType.equalsIgnoreCase("汇总")) {
                if (StatisType.equalsIgnoreCase("分组")) {
                    havingstr.append(" sum(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("最大")) {
                    havingstr.append(" isnull(" + FieldID + ",'') ");
                } else if (StatisType.equalsIgnoreCase("汇总")) {
                    havingstr.append(" max(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("最小")) {
                    havingstr.append(" sum(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("最大")) {
                    havingstr.append(" min(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("平均")) {
                    havingstr.append(" max(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("最小")) {
                    havingstr.append(" avg(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("个数")) {
                    havingstr.append(" min(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("平均")) {
                    havingstr.append(" count(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("自定义")) {
                    havingstr.append(" avg(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("个数")) {
                    havingstr.append(FieldID + "");
                }
                    havingstr.append(" count(");
                    havingstr.append(" isnull(" + FieldID + ",0)) ");
                } else if (StatisType.equalsIgnoreCase("自定义")) {
                    havingstr.append(FieldID + "");
                }
                String modfvalues = (String) map.get("modfvalues");
                String modfvalues2 = (String) map.get("modfvalues2");
                java.util.regex.Matcher propsMatcher = START_WOROD_PATTERN.matcher(modfvalues);
                while (propsMatcher.find()) {
                    try {
                        String tem = (String) session.getAttribute(propsMatcher.group().toLowerCase());
                        modfvalues = modfvalues.replaceAll(propsMatcher.group(), tem);
                    } catch (Exception e) {
                        throw new ApplicationException(propsMatcher.group() + "不存在于会话中,请检查数据组权限设置");
                    }
                String modfvalues = (String) map.get("modfvalues");
                String modfvalues2 = (String) map.get("modfvalues2");
                java.util.regex.Matcher propsMatcher = START_WOROD_PATTERN.matcher(modfvalues);
                while (propsMatcher.find()) {
                    try {
                        String tem = (String) session.getAttribute(propsMatcher.group().toLowerCase());
                        modfvalues = modfvalues.replaceAll(propsMatcher.group(), tem);
                    } catch (Exception e) {
                        throw new ApplicationException(propsMatcher.group() + "不存在于会话中,请检查数据组权限设置");
                    }
                }
                if (conFlag.toLowerCase().indexOf("between") > -1 ||
                        conFlag.toLowerCase().indexOf("not between") > -1
                        ) {
                    isbetween = true;
                }
                if (isbetween && (modfvalues2 == null || modfvalues2.length() == 0)) {
                    throw new ApplicationException("between and 或 not between and 的第二个值没有设置,请检查[功能号:9936(检查对象内容)]里面设置");
                }
                if (isbetween) {
                    propsMatcher = START_WOROD_PATTERN.matcher(modfvalues2);
                    while (propsMatcher.find()) {
                        modfvalues2 = modfvalues2.replaceAll(propsMatcher.group(), (String) session.getAttribute(propsMatcher.group().toLowerCase()));
                    }
                    havingstr.append(" " + conFlag)
                            .append("  " + modfvalues)
                            .append("  and  ")
                            .append(modfvalues2);
                } else if (conFlag.toLowerCase().indexOf("like") > -1 ||
                        conFlag.toLowerCase().indexOf("not like") > -1) {
                    //处理有单引号情况 'dddd'
                    modfvalues = modfvalues.replaceAll("'", "");
                    havingstr.append(" " + conFlag)
                            .append(" '%" + modfvalues + "%'");
                }
                if (conFlag.toLowerCase().indexOf("between") > -1 ||
                        conFlag.toLowerCase().indexOf("not between") > -1
                ) {
                    isbetween = true;
                }
                if (isbetween && (modfvalues2 == null || modfvalues2.length() == 0)) {
                    throw new ApplicationException("between and 或 not between and 的第二个值没有设置,请检查[功能号:9936(检查对象内容)]里面设置");
                }
                if (isbetween) {
                    propsMatcher = START_WOROD_PATTERN.matcher(modfvalues2);
                    while (propsMatcher.find()) {
                        modfvalues2 = modfvalues2.replaceAll(propsMatcher.group(), (String) session.getAttribute(propsMatcher.group().toLowerCase()));
                    }
                    havingstr.append(" " + conFlag)
                            .append("  " + modfvalues)
                            .append("  and  ")
                            .append(modfvalues2);
                } else if (conFlag.toLowerCase().indexOf("like") > -1 ||
                        conFlag.toLowerCase().indexOf("not like") > -1) {
                    //处理有单引号情况 'dddd'
                    modfvalues = modfvalues.replaceAll("'", "");
                    havingstr.append(" " + conFlag)
                            .append(" '%" + modfvalues + "%'");
                } else if (conFlag.toLowerCase().indexOf("in") > -1 ||
                        conFlag.toLowerCase().indexOf("not in") > -1) {
                    //*****处理广陶 CS版兼容问题,增加单引号  by 2016-3-4
                    String temp = "";
                    String[] arr = modfvalues.split(",");
                    for (String r : arr) {
                        if (r.startsWith("'") && r.endsWith("'"))
                            temp += r + ",";
                        else {
                            // System.out.println("r---->>>>>>>>>>>"+r);
                            if (r.startsWith("'") || r.endsWith("'"))//存在一种情况需要去掉单引号
                                temp += "'" + r.replaceAll("'", "") + "',";
                            else
                                temp += "'" + r + "',";
                        }
                    }
                    havingstr.append("  " + conFlag)
                            .append(" (" + temp.substring(0, temp.length() - 1) + ")");
                } else if (conFlag.toLowerCase().indexOf("in") > -1 ||
                        conFlag.toLowerCase().indexOf("not in") > -1) {
                    //*****处理广陶 CS版兼容问题,增加单引号  by 2016-3-4
                    String temp = "";
                    String[] arr = modfvalues.split(",");
                    for (String r : arr) {
                        if (r.startsWith("'") && r.endsWith("'"))
                            temp += r + ",";
                        else {
                            // System.out.println("r---->>>>>>>>>>>"+r);
                            if (r.startsWith("'") || r.endsWith("'"))//存在一种情况需要去掉单引号
                                temp += "'" + r.replaceAll("'", "") + "',";
                            else
                                temp += "'" + r + "',";
                        }
                    }
                    havingstr.append("  " + conFlag)
                            .append(" (" + temp.substring(0, temp.length() - 1) + ")");
                } else {
                    havingstr.append(" " + conFlag)
                            .append(" " + modfvalues);
                }
                havingstr.append(" )");//当前项结束
            }
                } else {
                    havingstr.append(" " + conFlag)
                            .append(" " + modfvalues);
                }
                havingstr.append(" )");//当前项结束
            }
        String temp=sql.get(jionFlagGroup+"");
        if(temp==null) {
            sql.put(jionFlagGroup + "", havingstr.toString());
            JionFlagMap.put(jionFlagGroup+"","".equals(jionflag.trim())?" and ":jionflag.trim());
        }else{//拼接
            if("".equals(jionflag.trim())){ jionflag=" and ";}
            sql.put(jionFlagGroup+"",sql.get(jionFlagGroup+"")+"" +jionflag+havingstr.toString());
        }
    }
            String temp = sql.get(jionFlagGroup + "");
            if (temp == null) {
                sql.put(jionFlagGroup + "", havingstr.toString());
                JionFlagMap.put(jionFlagGroup + "", "".equals(jionflag.trim()) ? " and " : jionflag.trim());
            } else {//拼接
                if ("".equals(jionflag.trim())) {
                    jionflag = " and ";
                }
                sql.put(jionFlagGroup + "", sql.get(jionFlagGroup + "") + "" + jionflag + havingstr.toString());
            }
        }
//2.再拼接最终sql的顺序,根据分组和连接符拼接
   String st="";
    int index=0;
    for(Map.Entry<String,String> entry:sql.entrySet()){
        String temJionFlag="";
        if(index>0) {
            temJionFlag = JionFlagMap.get(entry.getKey());
            st = st +" "+ temJionFlag + " (" + entry.getValue() + ")";
        }else{
            st +=  entry.getValue();
        }
        index++;
    }
    return st.equals("")?"":(" having ("+st+")");
}
        String st = "";
        int index = 0;
        for (Map.Entry<String, String> entry : sql.entrySet()) {
            String temJionFlag = "";
            if (index > 0) {
                temJionFlag = JionFlagMap.get(entry.getKey());
                st = st + " " + temJionFlag + " (" + entry.getValue() + ")";
            } else {
                st += entry.getValue();
            }
            index++;
        }
        return st.equals("") ? "" : (" having (" + st + ")");
    }
    private  void prossDisplayFormat(Page page){
        List list=page.getData();
        if(list==null||list.size()<0) {return;}
        Map<String, Map<String, Object>> resultMap= (Map<String, Map<String, Object>>) page.getResultMap();
        for(int i=0;i<list.size();i++){
            //每行
            Map<String,Object> map=(Map<String,Object>)list.get(i);
            if(map.containsKey("_ROWNO")) {map.remove("_ROWNO");}
            for(Map.Entry<String, Object> entry : map.entrySet()) {
                Map<String, Object> map2 = resultMap.get(entry.getKey().toLowerCase());
                if(map2!=null){
                String displayFormat = GridUtils.prossRowSetDataType_String(map2, "displayformat");
                if (StringUtils.isNotBlank(displayFormat)) {
                    if (displayFormat.indexOf("-") > 0) {//表示日期格式
                        String displayformat[] = (map2.get("displayformat") + "").split("-");
                        if (displayformat.length >= 2) {
                            SimpleDateFormat formatter = new SimpleDateFormat((map2.get("displayformat") + ""));
                            String dateString = formatter.format(entry.getValue());
                            entry.setValue(dateString);
                        }
                    } else {
                        if (displayFormat.startsWith(",0")) {
    private void prossDisplayFormat(Page page) {
        List list = page.getData();
        if (list == null || list.size() < 0) {
            return;
        }
        Map<String, Map<String, Object>> resultMap = (Map<String, Map<String, Object>>) page.getResultMap();
        for (int i = 0; i < list.size(); i++) {
            //每行
            Map<String, Object> map = (Map<String, Object>) list.get(i);
            if (map.containsKey("_ROWNO")) {
                map.remove("_ROWNO");
            }
            for (Map.Entry<String, Object> entry : map.entrySet()) {
                Map<String, Object> map2 = resultMap.get(entry.getKey().toLowerCase());
                if (map2 != null) {
                    String displayFormat = GridUtils.prossRowSetDataType_String(map2, "displayformat");
                    if (StringUtils.isNotBlank(displayFormat)) {
                        if (displayFormat.indexOf("-") > 0) {//表示日期格式
                            String displayformat[] = (map2.get("displayformat") + "").split("-");
                            if (displayformat.length >= 2) {
                                SimpleDateFormat formatter = new SimpleDateFormat((map2.get("displayformat") + ""));
                                String dateString = formatter.format(entry.getValue());
                                entry.setValue(dateString);
                            }
                        } else {
                            if (displayFormat.startsWith(",0")) {
                            displayFormat = displayFormat.replace(",0", ",###");
                        }else if(displayFormat.startsWith(",.")){
                            displayFormat = displayFormat.replace(",", ",###");
                        }
                        if(entry.getValue()!=null) {
                            entry.setValue(new DecimalFormat(displayFormat).format(Double.parseDouble(entry.getValue() + "")));
                        }else{
                            entry.setValue(entry.getValue());
                        }
                    }
                                displayFormat = displayFormat.replace(",0", ",###");
                            } else if (displayFormat.startsWith(",.")) {
                                displayFormat = displayFormat.replace(",", ",###");
                            }
                            if (entry.getValue() != null) {
                                entry.setValue(new DecimalFormat(displayFormat).format(Double.parseDouble(entry.getValue() + "")));
                            } else {
                                entry.setValue(entry.getValue());
                            }
                        }
                }
            }
            }
        }
        //处理页脚汇总
        String tbColsOut=page.getTbColsOut();
        String newtbCols=page.getNewTbCols();
        if(StringUtils.isNotBlank(tbColsOut)&&!tbColsOut.contains("replace")){
            tbColsOut=tbColsOut.replaceAll("\\.#", "#");
            Map<String, Map<String, Object>> map= (Map<String, Map<String, Object>>) page.getResultMap();
            String[] strings=tbColsOut.split("#p#");
            String[] fileds=newtbCols.split(";");//取汇总字段
            int index=0;
            for(String str:fileds){
                String[] cols=str.split("=");
                Map<String, Object> formatMap=map.get(cols[0]);
                String displayFormat=GridUtils.prossRowSetDataType_String(formatMap,"displayformat");
                if (StringUtils.isNotBlank(displayFormat)) {
                    if(displayFormat.startsWith(",0")){
                        displayFormat=displayFormat.replace(",0",",###");
                    }else if(displayFormat.startsWith(",.")){
                        displayFormat=displayFormat.replace(",",",###");
                    }
                    newtbCols=newtbCols.replace("#"+index,new DecimalFormat(displayFormat).format(Double.parseDouble(strings[index])));
                }else{
                    newtbCols=newtbCols.replace("#"+index,new DecimalFormat("0.00").format(Double.parseDouble(strings[index])));
                }
                index++;
            }
            page.setTbColsOut(newtbCols);
        }else{
            page.setTbColsOut("");
        }
    }
                    }
                }
            }
        }
        //处理页脚汇总
        String tbColsOut = page.getTbColsOut();
        String newtbCols = page.getNewTbCols();
        if (StringUtils.isNotBlank(tbColsOut) && !tbColsOut.contains("replace")) {
            tbColsOut = tbColsOut.replaceAll("\\.#", "#");
            Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) page.getResultMap();
            String[] strings = tbColsOut.split("#p#");
            String[] fileds = newtbCols.split(";");//取汇总字段
            int index = 0;
            for (String str : fileds) {
                String[] cols = str.split("=");
                Map<String, Object> formatMap = map.get(cols[0]);
                String displayFormat = GridUtils.prossRowSetDataType_String(formatMap, "displayformat");
                if (StringUtils.isNotBlank(displayFormat)) {
                    if (displayFormat.startsWith(",0")) {
                        displayFormat = displayFormat.replace(",0", ",###");
                    } else if (displayFormat.startsWith(",.")) {
                        displayFormat = displayFormat.replace(",", ",###");
                    }
                    newtbCols = newtbCols.replace("#" + index, new DecimalFormat(displayFormat).format(Double.parseDouble(strings[index])));
                } else {
                    newtbCols = newtbCols.replace("#" + index, new DecimalFormat("0.00").format(Double.parseDouble(strings[index])));
                }
                index++;
            }
            page.setTbColsOut(newtbCols);
        } else {
            page.setTbColsOut("");
        }
    }
    /**
     * 38类型窗体调用函数
     * */
    @RequestMapping(params = "m=load")
    public Object loadByFunc(Model model, GridData data, Grid grid,
            HttpServletRequest request, HttpServletResponse resp,
            Integer grapht, int formid, String StatisNames,String StatisID) throws Exception {
        Page page =null;
        if(request.getParameter("TGData")==null) {
            page = JOSNUtils.setPageInfoData(data);// 第一步,照写
        }else {
            page = this.setPageInfoTree(request);// 第一步,照写
        }
        page.setTbCols(EncodeUtil.base64Encode(data.getTotalCols()));
        this.formID = grid.getFormID();
        env = this.initEnv(request, this.formID, "", false);
        String[] temp = this.setShow(grid.getDatalist());// 参数
        page.setOrderBy(temp[1]);
        HttpSession session = request.getSession();
        String having = this.selectdata(session, request, formid, StatisID);//处理having
        if (temp.length >= 3) {
            page.setGroupby("".equalsIgnoreCase(temp[2]) ? "" : " group by "
                    + temp[2] + " " + having);
        } else {
            request.setAttribute("message", "没有定义输出的显示栏位!!!");
        }
        /**/
        page.setWhere(grid.getWhere().replaceAll("\\\\", ""));
        page.setFlag(grid.getFlag());
        String[] t = splitTable(grid.getWinType());
        page.setTableName(t[0]);
        page.setParms(t[1]);
        GTGrid gtGrid= (GTGrid) FactoryBean.getBean("GTGrid");
        String dataGroup="";
        dataGroup=gtGrid.prossDataGroup(request,this.formID,0);
        if("".equals(page.getWhere())){
            page.setWhere(" 1 =1 "+dataGroup);
        }else {
            page.setWhere(page.getWhere() + dataGroup);
        }
        page.setDataGroup(dataGroup);
        page.setSql(this.exprTOSql(page, temp[0]));
        request.setAttribute("StatisNames", StatisNames);
        request.setAttribute("formid", formid);
        request.setAttribute("where", data.getWhere38());
        String dbid=request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+"";
        createDyTitle(data, request, dbid);
        try {
            SpObserver.setDBtoInstance("_"+dbid);
            page.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE)+"");
            page.setUserName(request.getSession().getAttribute(SessionKey.USER_NAME)+"");
            page.setFormid(grid.getFormID());
            if(VersionUtils.getAPPTypeName(request) != null){
                page.setPageNum(grid.getPos());
            }
            type38Ifc.loadAllByFunc(page, env, false, StatisID, formid);// 第二步,调用相对应业务类取得数据
            if(page.getPos()>0){
                //表示不是第一页,分页功能不会再执行计总数和总页面和汇总操作,所以需要把前端传过来的做一个保存
                page.setTotalPageNum(grid.getTotalPageNum());
                page.setTotalRowNum(grid.getTotalRowNum());
            }
        } catch (Exception e) {
            //e.printStackTrace();
            /* this.print(resp, e.getMessage().split(";")[2]); */
            request.setAttribute("message", e.getCause()!=null?e.getCause().getMessage():e.getMessage());
            //return null;
        }finally {
            SpObserver.setDBtoInstance();
        }
        //区分是app端还是pc端调用
        if(VersionUtils.getAPPTypeName(request) != null){
            //处理格式,app不需要再处理一次格式
             prossDisplayFormat(page);
    /**
     * 38类型窗体调用函数
     */
    @RequestMapping(params = "m=load")
    public Object loadByFunc(Model model, GridData data, Grid grid,
                             HttpServletRequest request, HttpServletResponse resp,
                             Integer grapht, int formid, String StatisNames, String StatisID) throws Exception {
        Page page = null;
        if (request.getParameter("TGData") == null) {
            page = JOSNUtils.setPageInfoData(data);// 第一步,照写
        } else {
            page = this.setPageInfoTree(request);// 第一步,照写
        }
        page.setTbCols(EncodeUtil.base64Encode(data.getTotalCols()));
        this.formID = grid.getFormID();
        env = this.initEnv(request, this.formID, "", false);
        String[] temp = this.setShow(grid.getDatalist());// 参数
        page.setOrderBy(temp[1]);
        HttpSession session = request.getSession();
        String having = this.selectdata(session, request, formid, StatisID);//处理having
        if (temp.length >= 3) {
            page.setGroupby("".equalsIgnoreCase(temp[2]) ? "" : " group by "
                    + temp[2] + " " + having);
        } else {
            request.setAttribute("message", "没有定义输出的显示栏位!!!");
        }
        /**/
        page.setWhere(grid.getWhere().replaceAll("\\\\", ""));
        page.setFlag(grid.getFlag());
        String[] t = splitTable(grid.getWinType());
        page.setTableName(t[0]);
        page.setParms(t[1]);
        GTGrid gtGrid = (GTGrid) FactoryBean.getBean("GTGrid");
        String dataGroup = "";
        dataGroup = gtGrid.prossDataGroup(request, this.formID, 0);
        if ("".equals(page.getWhere())) {
            page.setWhere(" 1 =1 " + dataGroup);
        } else {
            page.setWhere(page.getWhere() + dataGroup);
        }
        page.setDataGroup(dataGroup);
        page.setSql(this.exprTOSql(page, temp[0]));
        request.setAttribute("StatisNames", StatisNames);
        request.setAttribute("formid", formid);
        request.setAttribute("where", data.getWhere38());
        String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
        createDyTitle(data, request, dbid);
        try {
            SpObserver.setDBtoInstance("_" + dbid);
            page.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE) + "");
            page.setUserName(request.getSession().getAttribute(SessionKey.USER_NAME) + "");
            page.setFormid(grid.getFormID());
            if (VersionUtils.getAPPTypeName(request) != null) {
                page.setPageNum(grid.getPos());
            }
            type38Ifc.loadAllByFunc(page, env, false, StatisID, formid);// 第二步,调用相对应业务类取得数据
            if (page.getPos() > 0) {
                //表示不是第一页,分页功能不会再执行计总数和总页面和汇总操作,所以需要把前端传过来的做一个保存
                page.setTotalPageNum(grid.getTotalPageNum());
                page.setTotalRowNum(grid.getTotalRowNum());
            }
        } catch (Exception e) {
            //e.printStackTrace();
            /* this.print(resp, e.getMessage().split(";")[2]); */
            request.setAttribute("message", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
            //return null;
        } finally {
            SpObserver.setDBtoInstance();
        }
        //区分是app端还是pc端调用
        if (VersionUtils.getAPPTypeName(request) != null) {
            //处理格式,app不需要再处理一次格式
            prossDisplayFormat(page);
            return page;
        }else {
            StringBuilder str = new StringBuilder();
            if(page.getPos()==0){
                String sql = "select optype,frozencols from gform where formid=" + formid + "";
                List<Map<String, Object>> list38 = type38.girddata(sql);
                Map<String, Object> map38 = null;
                int frozencols = 0;
                for (int i = 0; i < list38.size(); i++) {
                map38 = list38.get(i);
                request.setAttribute("optype", GridUtils.prossRowSetDataType_Int(map38,"optype"));
                request.getSession().setAttribute("optype38",GridUtils.prossRowSetDataType_Int(map38,"optype"));
                frozencols = map38.get("frozencols") == null ? 0 : Integer
                        .parseInt(map38.get("frozencols") + "");
            }
                String cosconfig[] = data.colsConfig.split("/>");
            str.append(
                    //Sorted='1' SortCols='bccname,amount' SortTypes='0,0'
                    "<Grid><Cfg id='T_"
                            + formid
                            + "'/><Cfg isNine='null' Paging='3' NoPager='1' Sorting='1' /><Cfg Deleting='0'/><Cfg SelectingText='1'/> <Cfg MinTagHeight='200' ConstHeight='1' ConstWidth='1' CacheTimeout='10' Cache='3'  FilterLap='1' gType='38'/><Cfg Code='STACPYRJRZDNTB'/>")
                    .append("<Cfg totalCols='").append(data.totalCols)
                    .append("'/>");
            if (frozencols == 0) {
                str.append("<Cols>").append(data.colsConfig)
                        .append("</Cols><Head>");
            } else if (frozencols < cosconfig.length) {
                str.append("<LeftCols>");
                for (int i = 0; i < frozencols; i++) {
                    str.append(cosconfig[i] + "/>");
                }
                str.append("</LeftCols>").append("<Cols>");
                for (int i = 0; i < cosconfig.length - frozencols; i++) {
                    str.append(cosconfig[i + frozencols] + "/>");
                }
                str.append("</Cols><Head>");
            return page;
        } else {
            StringBuilder str = new StringBuilder();
            if (page.getPos() == 0) {
                String sql = "select optype,frozencols from gform where formid=" + formid + "";
                List<Map<String, Object>> list38 = type38.girddata(sql);
                Map<String, Object> map38 = null;
                int frozencols = 0;
                for (int i = 0; i < list38.size(); i++) {
                    map38 = list38.get(i);
                    request.setAttribute("optype", GridUtils.prossRowSetDataType_Int(map38, "optype"));
                    request.getSession().setAttribute("optype38", GridUtils.prossRowSetDataType_Int(map38, "optype"));
                    frozencols = map38.get("frozencols") == null ? 0 : Integer
                            .parseInt(map38.get("frozencols") + "");
                }
                String cosconfig[] = data.colsConfig.split("/>");
                str.append(
                                //Sorted='1' SortCols='bccname,amount' SortTypes='0,0'
                                "<Grid><Cfg id='T_"
                                        + formid
                                        + "'/><Cfg isNine='null' Paging='3' NoPager='1' Sorting='1' /><Cfg Deleting='0'/><Cfg SelectingText='1'/> <Cfg MinTagHeight='200' ConstHeight='1' ConstWidth='1' CacheTimeout='10' Cache='3'  FilterLap='1' gType='38'/><Cfg Code='STACPYRJRZDNTB'/>")
                        .append("<Cfg totalCols='").append(data.totalCols)
                        .append("'/>");
                if (frozencols == 0) {
                    str.append("<Cols>").append(data.colsConfig)
                            .append("</Cols><Head>");
                } else if (frozencols < cosconfig.length) {
                    str.append("<LeftCols>");
                    for (int i = 0; i < frozencols; i++) {
                        str.append(cosconfig[i] + "/>");
                    }
                    str.append("</LeftCols>").append("<Cols>");
                    for (int i = 0; i < cosconfig.length - frozencols; i++) {
                        str.append(cosconfig[i + frozencols] + "/>");
                    }
                    str.append("</Cols><Head>");
            } else if (frozencols == cosconfig.length) {
                str.append("<LeftCols>");
                for (int i = 0; i < frozencols; i++) {
                    str.append(cosconfig[i] + "/>");
                }
                str.append("</LeftCols><Head>");
            } else if (frozencols > cosconfig.length) {
                str.append("<Cols>").append(data.colsConfig)
                        .append("</Cols><Head>");
            }
            str.append(data.header).append("</Head><Body><B  Pos='" + page.getPos() + "'>");
            str.append(JOSNUtils.toJosn38(page)).append("</B>");
            for (int i = 1; i < page.getTotalPageNum(); i++) {
                str.append("<B Count='"+page.getPageSize()+"'/>");
            }
            str.append("</Body>");
            if (data.totalCols.length() == 0) {
                str.append("<Toolbar Cells='Help,Pager' PagerType='Pager' PagerEditWidth='80'/></Grid>");
            } else {
                str.append("<Foot><I id='Fix1' CanEdit='0'/></Foot><Toolbar Cells='Help,Pager' PagerType='Pager' PagerEditWidth='80'/></Grid>");
            }
        }else {
                str.append("<Grid><Body><B  Pos='" + page.getPos() + "'>");
                str.append(JOSNUtils.toJosn38(page)).append("</B></Body></Grid>");
            }
            model.addAttribute("data", str.toString().replaceAll("\"", "\\\\\"").replaceAll("\\t|\\n",""));//"号要转义
            model.addAttribute("StatisID", StatisID);
            model.addAttribute("pageUrlPams", procssQueryString(grid,page));
            model.addAttribute("pageUrlPams2", grid.getQueryStringBy38());
            return "/public/template/grid38";
        }
    }
private String procssQueryString(Grid grid,Page page){
        if(grid.getQueryStringBy38().contains("&pos=")) {
            return grid.getQueryStringBy38().replaceAll("&pos=\\d", "&pos=" + (grid.getPos() + 1));
                    //.replaceAll("&totalRowNum=\\d","&totalRowNum="+ page.getTotalRowNum())
                    //.replaceAll("&totalPageNum=\\d","&totalPageNum="+page.getTotalPageNum());
        }else {
            return grid.getQueryStringBy38() + "&pos=" + (grid.getPos() + 1)+"&totalRowNum="+ page.getTotalRowNum()+"&totalPageNum="+page.getTotalPageNum();
        }
                } else if (frozencols == cosconfig.length) {
                    str.append("<LeftCols>");
                    for (int i = 0; i < frozencols; i++) {
                        str.append(cosconfig[i] + "/>");
                    }
                    str.append("</LeftCols><Head>");
                } else if (frozencols > cosconfig.length) {
                    str.append("<Cols>").append(data.colsConfig)
                            .append("</Cols><Head>");
                }
                str.append(data.header).append("</Head><Body><B  Pos='" + page.getPos() + "'>");
                str.append(JOSNUtils.toJosn38(page)).append("</B>");
                for (int i = 1; i < page.getTotalPageNum(); i++) {
                    str.append("<B Count='" + page.getPageSize() + "'/>");
                }
                str.append("</Body>");
                if (data.totalCols.length() == 0) {
                    str.append("<Toolbar Cells='Help,Pager' PagerType='Pager' PagerEditWidth='80'/></Grid>");
                } else {
                    str.append("<Foot><I id='Fix1' CanEdit='0'/></Foot><Toolbar Cells='Help,Pager' PagerType='Pager' PagerEditWidth='80'/></Grid>");
                }
            } else {
                str.append("<Grid><Body><B  Pos='" + page.getPos() + "'>");
                str.append(JOSNUtils.toJosn38(page)).append("</B></Body></Grid>");
            }
            model.addAttribute("data", str.toString().replaceAll("\"", "\\\\\"").replaceAll("\\t|\\n", ""));//"号要转义
            model.addAttribute("StatisID", StatisID);
            model.addAttribute("pageUrlPams", procssQueryString(grid, page));
            model.addAttribute("pageUrlPams2", grid.getQueryStringBy38());
            return "/public/template/grid38";
        }
    }
}
    public void createDyTitle(GridData data, HttpServletRequest request, String dbid) {
        //处理动态标题
        String[] capTionArray =StringUtils.split(data.getGridcaption(),"|");
        Map<String,String> titleMap=new HashMap<>();//保存sql的原sql,用作之后替换data.header用
        String sqlStr="";
        //组装sql,一次性查询
        for(String str:capTionArray){
            if(StringUtils.isNotEmpty(str)&&str.startsWith("!")) {
                String randomStr=RandomStringUtils.random(3, new char[]{'a','b','c','d','e','f'});
                if (StringUtils.isNotEmpty(str)) {
                    titleMap.put(randomStr, str);
                    sqlStr += "'" + randomStr + "='+" + str.replace("!", "").replaceAll("select", "")+ "+';'+";
    private String procssQueryString(Grid grid, Page page) {
        if (grid.getQueryStringBy38().contains("&pos=")) {
            return grid.getQueryStringBy38().replaceAll("&pos=\\d", "&pos=" + (grid.getPos() + 1));
            //.replaceAll("&totalRowNum=\\d","&totalRowNum="+ page.getTotalRowNum())
            //.replaceAll("&totalPageNum=\\d","&totalPageNum="+page.getTotalPageNum());
        } else {
            return grid.getQueryStringBy38() + "&pos=" + (grid.getPos() + 1) + "&totalRowNum=" + page.getTotalRowNum() + "&totalPageNum=" + page.getTotalPageNum();
        }
    }
    public void createDyTitle(GridData data, HttpServletRequest request, String dbid) {
        //处理动态标题
        String[] capTionArray = StringUtils.split(data.getGridcaption(), "|");
        Map<String, String> titleMap = new HashMap<>();//保存sql的原sql,用作之后替换data.header用
        String sqlStr = "";
        //组装sql,一次性查询
        for (String str : capTionArray) {
            if (StringUtils.isNotEmpty(str) && str.startsWith("!")) {
                String randomStr = RandomStringUtils.random(3, new char[]{'a', 'b', 'c', 'd', 'e', 'f'});
                if (StringUtils.isNotEmpty(str)) {
                    titleMap.put(randomStr, str);
                    sqlStr += "'" + randomStr + "='+" + str.replace("!", "").replaceAll("select", "") + "+';'+";
                }
                }
            }
        }
        if(sqlStr.endsWith("+")){
            sqlStr=sqlStr.substring(0,sqlStr.length()-5);
        }
        if(StringUtils.isNotEmpty(sqlStr)) {
            //从where取值,替换参数
            sqlStr = SQLUtils.ReplaceSQLParameter(sqlStr, SQLUtils.processStringObject(data.getWhere(),"and","="));
            sqlStr = SQLUtils.prossSessionInfo(request, sqlStr);
            //sqlStr = sqlStr.replaceAll("#", "&");
            //sqlStr>>select '!select dbo.fGetDynamicPeriodid(120301 , ''&mycompanyid&'',''&beginday&'',7)='+dbo.fGetDynamicPeriodid(120301 , 'LPCZ','2019-01-01',7)+';!select dbo.fGetDynamicPeriodid(120301, ''&mycompanyid&'',''&beginday&'',10 )='+  dbo.fGetDynamicPeriodid(120301, 'LPCZ','2019-01-01',10 )
            String result=null;
            try {
                SpObserver.setDBtoInstance("_"+dbid);
                result= grids.getSimpleJdbcTemplate().queryForObject(" select "+sqlStr, String.class);
            }finally {
                SpObserver.setDBtoInstance();
            }
            if (StringUtils.isNotEmpty(result)) {
                Map<String,String> map=SQLUtils.processStringObject(result,";","=");
            }
        }
        if (sqlStr.endsWith("+")) {
            sqlStr = sqlStr.substring(0, sqlStr.length() - 5);
        }
        if (StringUtils.isNotEmpty(sqlStr)) {
            //从where取值,替换参数
            sqlStr = SQLUtils.ReplaceSQLParameter(sqlStr, SQLUtils.processStringObject(data.getWhere(), "and", "="));
            sqlStr = SQLUtils.prossSessionInfo(request, sqlStr);
            //sqlStr = sqlStr.replaceAll("#", "&");
            //sqlStr>>select '!select dbo.fGetDynamicPeriodid(120301 , ''&mycompanyid&'',''&beginday&'',7)='+dbo.fGetDynamicPeriodid(120301 , 'LPCZ','2019-01-01',7)+';!select dbo.fGetDynamicPeriodid(120301, ''&mycompanyid&'',''&beginday&'',10 )='+  dbo.fGetDynamicPeriodid(120301, 'LPCZ','2019-01-01',10 )
            String result = null;
            try {
                SpObserver.setDBtoInstance("_" + dbid);
                result = grids.getSimpleJdbcTemplate().queryForObject(" select " + sqlStr, String.class);
            } finally {
                SpObserver.setDBtoInstance();
            }
            if (StringUtils.isNotEmpty(result)) {
                Map<String, String> map = SQLUtils.processStringObject(result, ";", "=");
                for (Map.Entry<String,String> entry:map.entrySet()) {
                for (Map.Entry<String, String> entry : map.entrySet()) {
                    data.header = data.header.replace(titleMap.get(entry.getKey()),entry.getValue());//把取得的值更新回标题定义
                }
            }
        }
    }
                    data.header = data.header.replace(titleMap.get(entry.getKey()), entry.getValue());//把取得的值更新回标题定义
                }
            }
        }
    }
    @RequestMapping(params = "m=print38Excel")
    protected void print2Excel(Integer grapht, Model model,
            HttpServletRequest request, HttpServletResponse resp)
            throws Exception {
        // 为了组成page
        String root = request.getSession().getServletContext().getRealPath("/")
                + "/";
        int formid = -1;
    @RequestMapping(params = "m=print38Excel")
    protected void print2Excel(Integer grapht, Model model,
                               HttpServletRequest request, HttpServletResponse resp)
            throws Exception {
        // 为了组成page
        String root = request.getSession().getServletContext().getRealPath("/")
                + "/";
        int formid = -1;
        try {
            formid = Integer.parseInt(new String(com.yc.utils.Base64
                    .decode(request.getParameter("formIdHid").getBytes())));
            /* PanelServiceImpl panel=new PanelServiceImpl(); */
        } catch (NumberFormatException e1) {
            log.debug(request.getParameter("formIdHid") + "转换数字格式出错",
                    e1.getCause());
        }
        String StatisNames = null;
        String sn = request.getParameter("StatisNames");
        String StatisID = request.getParameter("StatisID");
        if (sn != null) {
            sn = sn.replaceAll("%2B", "+");
            sn = sn.replaceAll("%2F", "/");
            sn = sn.replaceAll("%3D", "=");
            StatisNames = EncodeUtil.base64Decode(sn);
        }
        try {
            formid = Integer.parseInt(new String(com.yc.utils.Base64
                    .decode(request.getParameter("formIdHid").getBytes())));
            /* PanelServiceImpl panel=new PanelServiceImpl(); */
        } catch (NumberFormatException e1) {
            log.debug(request.getParameter("formIdHid") + "转换数字格式出错",
                    e1.getCause());
        }
        String StatisNames = null;
        String sn = request.getParameter("StatisNames");
        String StatisID = request.getParameter("StatisID");
        if (sn != null) {
            sn = sn.replaceAll("%2B", "+");
            sn = sn.replaceAll("%2F", "/");
            sn = sn.replaceAll("%3D", "=");
            StatisNames = EncodeUtil.base64Decode(sn);
        }
        // String StatisNames = new String(com.yc.utils.Base64.decode(request
        // .getParameter("StatisNames").getBytes()), "utf-8");
        String datalist = "";
        List<Map<String, Object>> list = gridService.selectdata1(formid,
                StatisID);
        Map<String, Object> mapObject1 = null;
        PanelBean panelBean=new PanelBean();
        for (int i = 0; i < list.size(); i++) {
            mapObject1 = list.get(i);
            try {
                datalist += typeControlDao.getSelectAndCheckBoxss(
                        GridUtils.prossRowSetDataType_String(mapObject1,"StatisID"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"FieldID"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"FieldAlias"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"StatisType"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"Sequence"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"DisplayWidth"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"displayformat"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"displayYN"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"isFilterZero"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"jionFlag"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"jionFlagGroup"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"conFlag"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"modfvalues"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"modfvalues2"),
                        GridUtils.prossRowSetDataType_String(mapObject1,"fieldCaption"),panelBean);
            }catch (Exception e){
                throw  new ApplicationException(e.getMessage());
            }
        }
        try {
            datalist = java.net.URLDecoder.decode(datalist.replace("%", "@~"),
                    "utf-8");
        } catch (UnsupportedEncodingException e) {
            log.debug(e.getCause().getMessage());
        }
        // String StatisNames = new String(com.yc.utils.Base64.decode(request
        // .getParameter("StatisNames").getBytes()), "utf-8");
        String datalist = "";
        List<Map<String, Object>> list = gridService.selectdata1(formid,
                StatisID);
        Map<String, Object> mapObject1 = null;
        PanelBean panelBean = new PanelBean();
        for (int i = 0; i < list.size(); i++) {
            mapObject1 = list.get(i);
            try {
                datalist += typeControlDao.getSelectAndCheckBoxss(
                        GridUtils.prossRowSetDataType_String(mapObject1, "StatisID"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "FieldID"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "FieldAlias"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "StatisType"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "Sequence"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "DisplayWidth"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "displayformat"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "displayYN"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "isFilterZero"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "jionFlag"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "jionFlagGroup"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "conFlag"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "modfvalues"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "modfvalues2"),
                        GridUtils.prossRowSetDataType_String(mapObject1, "fieldCaption"), panelBean);
            } catch (Exception e) {
                throw new ApplicationException(e.getMessage());
            }
        }
        try {
            datalist = java.net.URLDecoder.decode(datalist.replace("%", "@~"),
                    "utf-8");
        } catch (UnsupportedEncodingException e) {
            log.debug(e.getCause().getMessage());
        }
        try {
            String where = new String(com.yc.utils.Base64.decode(request
                    .getParameter("where").getBytes()), "utf-8");
            GridData data = new GridData();
            gridService.create38Grid(data, formid, root,
                    this.setWhere(this.replaceBlank(datalist)), StatisID);
            data.setDatalist(this.replaceBlank(datalist));
            data.setWhere(where);
            Grid grid = new Grid();
            grid.setFormID(data.formID);
            grid.setWinType(data.winType + "");
            grid.setField(data.field);
            grid.setWhere(data.where);
            grid.setDatalist(data.datalist);
            Page page = JOSNUtils.setPageInfoData(data);// 第一步,照写
            this.formID = grid.getFormID();
            env = this.initEnv(request, this.formID, "", false);
            String[] temp1 = this.setShow(grid.getDatalist());// 参数
            page.setOrderBy(temp1[1]);
            HttpSession session = request.getSession();
            String having = this.selectdata(session, request, formid,
                    StatisNames);
            if (temp1.length >= 3) {
                page.setGroupby("".equalsIgnoreCase(temp1[2]) ? ""
                        : " group by " + temp1[2] + " " + having);
            } else {
                request.setAttribute("message", "没有定义输出的显示栏位!!!");
            }
            /**/
            page.setWhere(grid.getWhere().replaceAll("\\\\", ""));
            page.setFlag(grid.getFlag());
            String[] t = splitTable(grid.getWinType());
            page.setTableName(t[0]);
            page.setParms(t[1]);
            // 库存查询(1)-companyid#公司|编号;companyname#公司|名称;plantname#plantname;stcode#仓库|编号;matcode#物料|编码;unlimitstock#库存|实际库存#,0.00;ontransstock#库存|在途#,0.00;-18-unlimitstock#1||5|,0.00;ontransstock#1||6|,0.00;
            page.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE)+"");
            page.setUserName(request.getSession().getAttribute(SessionKey.USER_NAME)+"");
            page.setFormid(grid.getFormID());
            page.setPageSize(1000000);
            page.setSql(this.exprTOSql(page, temp1[0]));
            type38Ifc.loadAllByFunc(page, env, false, StatisID, formid);// 第二步,调用相对应业务类取得数据
            // 读取当前功能号哪些字段是需要导出的
            String s = StatisNames;
            String g = "";
            String excelcount = "";
            int u=0;
            int z=0;
            Map<String, Object> mapObject = null;
            for (int i = 0; i < list.size(); i++) {
                mapObject = list.get(i);
                if ((Integer) mapObject.get("displayYN") == 1) {
                    u=i;
                    if(z!=0){
                        u=u-z;
                    }
                    String fieldalias = mapObject.get("fieldalias") + "";
                    String a = fieldalias.equals("")
                            || fieldalias.equals("null") ? mapObject
                            .get("FieldCaption") + "" : mapObject
                            .get("fieldalias") + "";
                    int y = (mapObject.get("fieldid") + "").toLowerCase()
                            .lastIndexOf("as");
        try {
            String where = new String(com.yc.utils.Base64.decode(request
                    .getParameter("where").getBytes()), "utf-8");
            GridData data = new GridData();
            gridService.create38Grid(data, formid, root,
                    this.setWhere(this.replaceBlank(datalist)), StatisID);
            data.setDatalist(this.replaceBlank(datalist));
            data.setWhere(where);
            Grid grid = new Grid();
            grid.setFormID(data.formID);
            grid.setWinType(data.winType + "");
            grid.setField(data.field);
            grid.setWhere(data.where);
            grid.setDatalist(data.datalist);
            Page page = JOSNUtils.setPageInfoData(data);// 第一步,照写
            this.formID = grid.getFormID();
            env = this.initEnv(request, this.formID, "", false);
            String[] temp1 = this.setShow(grid.getDatalist());// 参数
            page.setOrderBy(temp1[1]);
            HttpSession session = request.getSession();
            String having = this.selectdata(session, request, formid,
                    StatisNames);
            if (temp1.length >= 3) {
                page.setGroupby("".equalsIgnoreCase(temp1[2]) ? ""
                        : " group by " + temp1[2] + " " + having);
            } else {
                request.setAttribute("message", "没有定义输出的显示栏位!!!");
            }
            /**/
            page.setWhere(grid.getWhere().replaceAll("\\\\", ""));
            page.setFlag(grid.getFlag());
            String[] t = splitTable(grid.getWinType());
            page.setTableName(t[0]);
            page.setParms(t[1]);
            // 库存查询(1)-companyid#公司|编号;companyname#公司|名称;plantname#plantname;stcode#仓库|编号;matcode#物料|编码;unlimitstock#库存|实际库存#,0.00;ontransstock#库存|在途#,0.00;-18-unlimitstock#1||5|,0.00;ontransstock#1||6|,0.00;
            page.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE) + "");
            page.setUserName(request.getSession().getAttribute(SessionKey.USER_NAME) + "");
            page.setFormid(grid.getFormID());
            page.setPageSize(1000000);
            page.setSql(this.exprTOSql(page, temp1[0]));
            type38Ifc.loadAllByFunc(page, env, false, StatisID, formid);// 第二步,调用相对应业务类取得数据
            // 读取当前功能号哪些字段是需要导出的
            String titles = StatisNames;
            String formatStrs = "";
            String excelcount = "";
            int u = 0;
            int z = 0;
            Map<String, Object> mapObject = null;
            for (int i = 0; i < list.size(); i++) {
                mapObject = list.get(i);
                if ((Integer) mapObject.get("displayYN") == 1) {
                    u = i;
                    if (z != 0) {
                        u = u - z;
                    }
                    String fieldalias = mapObject.get("fieldalias") + "";
                    String filedTitle = org.apache.commons.lang3.StringUtils.isBlank(fieldalias) ? mapObject
                            .get("FieldCaption") + "" : mapObject
                            .get("fieldalias") + "";
// 处理自定义字段名称的情况 : case when xxxx as doccode,取doccode作为名称
                    final String[] byAsOfEnd = (mapObject.get("fieldid") + "").toLowerCase()
                            .split("\\s*\\b(?i)as\\b\\s*");
                    String filedId = "";
                    if (byAsOfEnd.length > 1) {
                        filedId = byAsOfEnd[1];
                    } else {
                        filedId = byAsOfEnd[0];
                    }
                    boolean isNotDisplayformat=org.apache.commons.lang3.StringUtils.isBlank(GridUtils.prossRowSetDataType_String(mapObject,"displayformat"));
                    if (isNotDisplayformat) {
                        formatStrs += filedId + "#" + filedTitle + ";";
                    } else {
                        formatStrs += filedId + "#" + filedTitle + "#"
                                + mapObject.get("displayformat") + ""
                                + ";";
                    }
                    if ((mapObject.get("StatisType") + "").equals("自定义")) {
                    String fied ="";
                    if(y>0)
                    fied=(mapObject.get("fieldid") + "")
                            .substring(
                                    y + 2,
                                    (mapObject.get("fieldid") + "")
                                            .length()).replace(" ", "");
                    else
                        fied=mapObject.get("FieldID")+"";
                        if ((mapObject.get("sumfield") + "").equals("1")) {
                            excelcount += filedId
                                    + "#1||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("2")) {
                            excelcount += filedId
                                    + "#2||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("3")) {
                            excelcount += filedId
                                    + "#3||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("6")) {
                            excelcount += filedId
                                    + "#6||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("7")) {
                            excelcount += filedId
                                    + "#7||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("5")) {
                            excelcount += filedId
                                    + "#5|"
                                    + filedId
                                    + ":"
                                    + (mapObject.get("funclinkname") == null
                                    || mapObject.get("funclinkname")
                                    .equals("") ? ""
                                    : mapObject.get("funclinkname")
                                    + "")
                                    + "|"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        }
                        if (mapObject.get("displayformat") == null
                                || (mapObject.get("displayformat") + "")
                                        .replace(" ", "").equals("")) {
                            g += fied + "#" + a + ";";
                        } else {
                                g += fied + "#" + a + "#"
                                        + mapObject.get("displayformat") + ""
                                        + ";";
                        }
                    if ((mapObject.get("StatisType") + "").equals("自定义")) {
                    } else {
                        if ((mapObject.get("sumfield") + "").equals("1")) {
                            excelcount += filedId
                                    + "#1||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("2")) {
                            excelcount += filedId
                                    + "#2||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("3")) {
                            excelcount += filedId
                                    + "#3||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("6")) {
                            excelcount += filedId
                                    + "#6||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("7")) {
                            excelcount += filedId
                                    + "#7||"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("5")) {
                            excelcount += filedId
                                    + "#5|"
                                    + filedId
                                    + ":"
                                    + (mapObject.get("funclinkname") == null
                                    || mapObject.get("funclinkname")
                                    .equals("") ? ""
                                    : mapObject.get("funclinkname")
                                    + "")
                                    + "|"
                                    + u
                                    + "|"
                                    + (isNotDisplayformat? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        }
                        if ((mapObject.get("sumfield") + "").equals("1")) {
                            excelcount += fied
                                    + "#1||"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("2")) {
                            excelcount += fied
                                    + "#2||"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("3")) {
                            excelcount += fied
                                    + "#3||"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("6")) {
                            excelcount += fied
                                    + "#6||"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("7")) {
                            excelcount += fied
                                    + "#7||"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("5")) {
                            excelcount += fied
                                    + "#5|"
                                    + fied
                                    + ":"
                                    + (mapObject.get("funclinkname") == null
                                            || mapObject.get("funclinkname")
                                                    .equals("") ? ""
                                            : mapObject.get("funclinkname")
                                                    + "")
                                    + "|"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        }
                    }
                } else {
                    z++;
                }
            }
            titles = titles + ";pb#" + formatStrs + ";pb#" + "38" + ";pb#" + excelcount;
                    } else {
                        if ((mapObject.get("sumfield") + "").equals("1")) {
                            excelcount += fied
                                    + "#1||"
                                    + u
                                    + "|"
                                    + ((mapObject.get("displayformat") == null || mapObject
                                    .get("displayformat").equals("")) ? ",0.00"
                                    : mapObject.get("displayformat")
                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("2")) {
                            excelcount += fied
                                    + "#2||"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("3")) {
                            excelcount += fied
                                    + "#3||"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("6")) {
                            excelcount += fied
                                    + "#6||"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("7")) {
                            excelcount += fied
                                    + "#7||"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        } else if ((mapObject.get("sumfield") + "").equals("5")) {
                            excelcount += fied
                                    + "#5|"
                                    + fied
                                    + ":"
                                    + (mapObject.get("funclinkname") == null
                                            || mapObject.get("funclinkname")
                                                    .equals("") ? ""
                                            : mapObject.get("funclinkname")
                                                    + "")
                                    + "|"
                                    + u
                                    + "|"
                                    + (mapObject.get("displayformat") == null
                                            || mapObject.get("displayformat")
                                                    .equals("") ? ",0.00"
                                            : mapObject.get("displayformat")
                                                    + "").replace(" ", "")
                                    + ";";
                        }
            if (request.getSession().getAttribute(SessionKey.USERCODE) == null) {
                this.printJson(resp, "error;会话过期,请重新登录!");
                return;
            }
            if ("".equalsIgnoreCase(titles) || titles == null) {
                this.printJson(resp, "error;未在9802设置有需要导出的内容或找不到相关的文件");
                return;
            }
            Map<String, Object> map = null;
            String[] panel_name = null;
            String[] panel_tfiled = null;
            String local = "";
            page.setExcelTitle("fg==");
            Map<String, String> gmap = getTitle(page, 1);// 1表示取格线
                    }
                }else{
                    z++;
                }
            }
            s = s + ";pb#" + g + ";pb#" + "38" + ";pb#" + excelcount;
            String[] str = titles.split(";pb#");
            String[] temp = str[1].split(";");
            int len = temp.length;
            String[] name = new String[len];// 字段说明
            String[] filed = new String[len];// 字段名
            setDyTtile(gmap, temp, name, filed);
            // 然后写入excel文件
            page.setExcelTitle(str.length == 4 ? str[3] : "");
            if (request.getSession().getAttribute(SessionKey.USERCODE) == null) {
                this.printJson(resp, "error;会话过期,请重新登录!");
                return;
            }
            if ("".equalsIgnoreCase(s) || s == null) {
                this.printJson(resp, "error;未在9802设置有需要导出的内容或找不到相关的文件");
                return;
            }
            Map<String, Object> map = null;
            String[] panel_name = null;
            String[] panel_tfiled = null;
            String local = "";
            page.setExcelTitle("fg==");
            Map<String, String> gmap = getTitle(page, 1);// 1表示取格线
            File file1 = new File(request.getServletContext().getRealPath("/")
                    + "excel"
                    + File.separator
                    + request.getSession()
                    .getAttribute(SessionKey.DATA_BASE_ID)
                    + File.separator + formid + File.separator + "38");
            if (!file1.exists()) {
                file1.mkdirs();
            }
            String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
            String path = request.getServletContext().getRealPath("/")
                    + "excel"
                    + File.separator
                    + dbid
                    + File.separator + formid + File.separator + "38"
                    + File.separator + str[0] + ".xlsx";
            String[] str = s.split(";pb#");
            String[] temp = str[1].split(";");
            int len = temp.length;
            String[] name = new String[len];// 字段说明
            String[] filed = new String[len];// 字段名
            setDyTtile(gmap, temp, name, filed);
            // 然后写入excel文件
            page.setExcelTitle(str.length == 4 ? str[3] : "");
            File file = new File(path);
            PoiExcelWriter poi = new PoiExcelWriter();
            String hostUrl = SettingKey.getHostUrl(request);
            Map m = poi.writeExcel(dbid, str[0], page, name, filed,
                    panel_name, panel_tfiled,
                    map != null ? (List<?>) map.get("plist") : null, str[0],
                    local, "", hostUrl);
            SXSSFWorkbook wb = (SXSSFWorkbook) m.get("wb");
            if (wb != null) {
                resp.setContentType("application/msexcel");
                resp.setHeader("Content-Disposition", "attachment;Filename="
                        + new String(str[0].getBytes("utf-8"), "ISO8859-1")
                        + ".xlsx");
                FileOutputStream fileOut = new FileOutputStream(file);
                wb.write(fileOut);
                fileOut.flush();
                fileOut.close();
                OutputStream os = resp.getOutputStream();
                try (FileInputStream fis = new FileInputStream(file)) {
                    int lens;
                    byte[] buffer = new byte[4096];
                    while ((lens = fis.read(buffer)) > 0) {
                        os.write(buffer, 0, lens);
                    }
                    os.flush();
                } catch (IOException e) {
                    e.printStackTrace();
                    this.printJson(resp, "error;" + e.getMessage());
                } finally {
                    os.close();
                }
                excelRecords(formid, "38", map, file, request, page);// 导出数据审计记录执行方法
                wb.dispose();
            }
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            this.printJson(resp, "error;" + e.getMessage());
            File file1 = new File(request.getServletContext().getRealPath("/")
                    + "excel"
                    + File.separator
                    + request.getSession()
                            .getAttribute(SessionKey.DATA_BASE_ID)
                    + File.separator + formid + File.separator + "38");
            if (!file1.exists()) {
                file1.mkdirs();
            }
            String dbid =request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+"";
            String path = request.getServletContext().getRealPath("/")
                    + "excel"
                    + File.separator
                    + dbid
                    + File.separator + formid + File.separator + "38"
                    + File.separator + str[0] + ".xlsx";
        } catch (Exception e) {
            e.printStackTrace();
            this.printJson(resp, "error;" + e.getMessage());
        }
            File file = new File(path);
            PoiExcelWriter poi = new PoiExcelWriter();
            String hostUrl = SettingKey.getHostUrl(request);
                Map m=poi.writeExcel(dbid, str[0], page, name, filed,
                    panel_name, panel_tfiled,
                    map != null ? (List<?>) map.get("plist") : null, str[0],
                    local,"",hostUrl);
            SXSSFWorkbook wb = (SXSSFWorkbook)m.get("wb");
            if (wb != null) {
                resp.setContentType("application/msexcel");
                resp.setHeader("Content-Disposition", "attachment;Filename="
                        + new String(str[0].getBytes("utf-8"), "ISO8859-1")
                        + ".xlsx");
                FileOutputStream fileOut = new FileOutputStream(file);
                wb.write(fileOut);
                fileOut.flush();
                fileOut.close();
                OutputStream os = resp.getOutputStream();
                try (FileInputStream fis = new FileInputStream(file)) {
                    int lens;
                    byte[] buffer = new byte[4096];
                    while ((lens = fis.read(buffer)) > 0) {
                        os.write(buffer, 0, lens);
                    }
                    os.flush();
                } catch (IOException e) {
                    e.printStackTrace();
                    this.printJson(resp, "error;"+e.getMessage());
                }finally {
                    os.close();
                }
                excelRecords(formid, "38", map, file, request, page);// 导出数据审计记录执行方法
                wb.dispose();
            }
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            this.printJson(resp, "error;" + e.getMessage());
    }
        } catch (Exception e) {
            e.printStackTrace();
            this.printJson(resp, "error;" + e.getMessage());
        }
    /**
     * 把字符串进行分割处理
     *
     * @param winType\ field 形式:frptmatstorage|companyid;stcode;matcode;
     * @return String 形式:frptmatstorage
     */
    private String[] splitTable(String winType) {
        String[] temp = grids.getTableName(this.formID, winType).split("\\|");
        return new String[]{temp[0], temp[1]};
    }
    }
    /**
     * 把字符串进行分割处理
     *
     * @param winType\
     *            field 形式:frptmatstorage|companyid;stcode;matcode;
     *
     * @return String 形式:frptmatstorage
     * */
    private String[] splitTable(String winType) {
        String[] temp = grids.getTableName(this.formID, winType).split("\\|");
        return new String[] { temp[0], temp[1] };
    }
    // 去除字符串中的换行符等
    public String replaceBlank(String str) {
        if (str == null) {
            return "";
        }
        Pattern p = Pattern.compile("\t|\r|\n");
        Matcher m = p.matcher(str);
        return m.replaceAll(" ");
    }
    // 去除字符串中的换行符等
    public String replaceBlank(String str) {
        if (str == null) {
            return "";
        }
        Pattern p = Pattern.compile("\t|\r|\n");
        Matcher m = p.matcher(str);
        return m.replaceAll(" ");
    }
}
src/com/yc/action/grid/GTGrid.java
@@ -1,5 +1,6 @@
package com.yc.action.grid;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
@@ -6038,7 +6039,13 @@
            printDate(grid, request, resp, page, dbid);
        } catch (Exception e) {
            e.printStackTrace();
            this.print(resp, this.getErrorMsg(e));
            if(request.getHeader("x-app-type")!=null) {
                CallBackMessage callBackMessage=new CallBackMessage();
                callBackMessage.sendErrorMessage(this.getErrorMsg(e));
                this.printJson(resp, JSON.toJSONString(callBackMessage.toJSONObject()));
            }else {
                this.print(resp, this.getErrorMsg(e));
            }
        } finally {
            page = null;
            env = null;
src/com/yc/open/init/InitSystemTaks.java
@@ -132,7 +132,7 @@
                        createScheduleTask(dataSourceEntity, task,new Pull140902Schedule((dataSourceEntity)));
                        break;
                    case "OP0014":
                        createScheduleTask(dataSourceEntity, task,new Pull120201Schedule((dataSourceEntity)));
                        createScheduleTask(dataSourceEntity, task,new Pull120201Schedule(dataSourceEntity,task));
                        break;
                    case "OP0015":
                        createScheduleTask(dataSourceEntity, task,new Push110503Schedule((dataSourceEntity)));
@@ -347,15 +347,23 @@
            SpObserver.setDBtoInstance("_" + dbid);
            final Task task = systemTaskIfc.getOpenAPI(docCode);
            if (task != null) {
                if(task.getStatus()==0){
                if(task.getStatus()==0){//停用
                    //取消作业,则需要在缓存时去掉
                    if (!"jobs".equals(task.getActionType()) && !"multijob".equals(task.getActionType())) {
                        //处理推送任务
                        pushTasksMap.remove(dbid + "_" + task.getApiCode() + "_" + task.getAffectedFormId());
                    } else {
                        for (Map.Entry<String, ScheduledFuture<?>> entry : scheduleTasksMap.entrySet()) {
                            if (entry.getKey().startsWith(dbid + "_" + task.getApiCode())) {
                                //以dbid+apiCode开头表示都需要停止任务
                                entry.getValue().cancel(true);
                                break;
                            }
                        }
                        scheduleTasksMap.remove(dbid + "_" + task.getApiCode());
                    }
                }else {
                }else {//启用
                    if (!"jobs".equals(task.getActionType()) && !"multijob".equals(task.getActionType())) {
                        //处理推送任务
                        pushTasksMap.put(dbid + "_" + task.getApiCode() + "_" + task.getAffectedFormId(), task);
@@ -393,7 +401,7 @@
            if (task != null) {
                if (!"jobs".equals(task.getActionType())||!"multijob".equals(task.getActionType())) {
                    //处理推送任务
                    final Task stopTask = pushTasksMap.get(dbid + "_" + task.getApiCode() + "_" + task.getAffectedFormId());
                     Task stopTask = pushTasksMap.get(dbid + "_" + task.getApiCode() + "_" + task.getAffectedFormId());
                    if (stopTask != null)
                        stopTask.setStatus(0);//修改为不启用
                } else {
src/com/yc/open/mutual/controller/MutualController.java
@@ -797,7 +797,7 @@
            }
        } catch (Exception e) {
            //写错误日志
            this.sendErrorLog(120201, t120201Entity.getDocCode(), e);
            this.sendErrorLog(t120201Entity.getHeadqSoFormId(), t120201Entity.getDocCode(), e);
            callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
            return callBackMessage.toJSONObject();
        } finally {
@@ -938,7 +938,7 @@
            return callBackMessage.toJSONObject();
        } catch (Exception e) {
            //写错误日志
            this.sendErrorLog(120201, t120201Entity.getDocCode(), e);
            this.sendErrorLog(t120201Entity.getHeadqSoFormId(), t120201Entity.getDocCode(), e);
            callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
            return callBackMessage.toJSONObject();
        } finally {
@@ -1054,7 +1054,7 @@
            return callBackMessage.toJSONObject();
        } catch (Exception e) {
            //写错误日志
            this.sendErrorLog(120201, null, e);
            this.sendErrorLog(130301, null, e);
            callBackMessage.sendErrorMessage(e.getCause() != null ? (e.getCause().getMessage()).trim() : e.getMessage());
            return callBackMessage.toJSONObject();
        } finally {
@@ -1078,6 +1078,7 @@
            SpObserver.setDBtoInstance("_" + dbid);
            data = URLDecoder.decode(request.getParameter("data"), "utf-8");
            CallBack120201Entity entity = JSON.parseObject(data, CallBack120201Entity.class);
            //TODO 还未处理固定写120201的情况,
            Integer result = mutualServiceIfc.update120201ByVndCode(entity);
            callBackMessage.sendSuccessMessageByDefault();
            return callBackMessage.toJSONObject();
@@ -1374,6 +1375,8 @@
            t110302.setBrands(t110203.getBrands());
            t110302.setVndDbid(t110203.getVndDbid());
            t110302.setPullSalesOrderFromDistributorLastDateTime(t110203.getPullSalesOrderFromDistributorLastDateTime());
            //指定取哪个功能号的销售数据(120201,120205...)
            t110302.setAffectedFormIdForTargetDatabase(t110203.getAffectedFormIdForTargetDatabase());
            final List<T121501Entity> list = mutualServiceIfc.get120201List(t110302);
            if (list != null && list.size() > 0) {
                list.stream().forEach(x -> {
@@ -1813,14 +1816,20 @@
        } else {
            url = url.replace(":9001", ":9010");
        }
        //------------
//        //------------
        log.info("内部推送url:" + url);
        //url="http://localhost:9001";
        String data = JSON.toJSONString(object);
        System.out.println("内部推送data:" + data);
        log.info("内部推送data:" + data);
        //this.sendErrorLog();
        //log.info("内部推送url:"+url);
//        try {
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        url += "/open/mutual/" + action + baseController.getSignV2(data, dbId);
        //log.info("内部推送url>>>:"+url);
        log.info("内部推送url>>>:"+url);
        return baseController.doPostByParameter(url, URLEncoder.encode(data, "UTF-8"));
    }
src/com/yc/open/mutual/entity/CallBack120201Entity.java
@@ -12,5 +12,6 @@
    private String  docCodeList;//客户采购订单号
    private String cltDbid;//客户dbid
    private String vndDbid;//自身dbid
    Integer affectedFormIdForTargetDatabase;//影响的功能号
}
src/com/yc/open/mutual/entity/Push120201Entity.java
@@ -11,5 +11,6 @@
    Integer vndDbid;
    List<T121501Entity> list;
    String pullSalesOrderFromDistributorLastDateTime;
    Integer affectedFormId;//本身的功能号
}
src/com/yc/open/mutual/entity/T110203VO.java
@@ -16,4 +16,6 @@
    String brands;
    String pullStockFromDistributorLastDateTime;
    String pullSalesOrderFromDistributorLastDateTime;//最后一次拉取销售数据
    Integer affectedFormId;//本身的功能号
    Integer affectedFormIdForTargetDatabase;//影响的功能号
}
src/com/yc/open/mutual/entity/T110302.java
@@ -17,4 +17,6 @@
   Integer vndDbid;
   String pullStockFromDistributorLastDateTime;
   String pullSalesOrderFromDistributorLastDateTime;
   Integer affectedFormId;//本身的功能号
   Integer affectedFormIdForTargetDatabase;//影响的功能号
}
src/com/yc/open/mutual/schedule/Pull120201Schedule.java
@@ -6,6 +6,7 @@
import com.yc.exception.CallBackMessage;
import com.yc.factory.FactoryBean;
import com.yc.multiData.SpObserver;
import com.yc.open.init.Task;
import com.yc.open.init.shcedule.BaseSchedule;
import com.yc.open.mutual.controller.MutualController;
import com.yc.open.mutual.entity.CallBack120201Entity;
@@ -34,9 +35,10 @@
    MutualController mutualController;
    @Autowired
    ThreadPoolTaskExecutor threadPoolExecutor;
    public Pull120201Schedule(DataSourceEntity dataSourceEntity) {
private  Task task;
    public Pull120201Schedule(DataSourceEntity dataSourceEntity, Task task) {
        super(dataSourceEntity);
        this.task=task;
        mutualServiceIfc = (MutualServiceIfc) FactoryBean.getBean("mutualServiceImpl");
        mutualController = (MutualController) FactoryBean.getBean("mutualController");
        threadPoolExecutor = (ThreadPoolTaskExecutor) FactoryBean.getBean("threadPoolExecutor");
@@ -48,7 +50,7 @@
        try {
            String dbid = dataSourceEntity.getDbId() + "";
            SpObserver.setDBtoInstance("_" + dbid);
            //---取出已认证的供应商
            //---取出已认证的经销商
            final List<T110203VO> byBrand = mutualServiceIfc.get110203ByDbid();
            for (T110203VO t110203 : byBrand) {
@@ -58,6 +60,8 @@
                }
                t110203.setVndDbid(Integer.parseInt(dbid));
                t110203.setCltDbid(t110203.getDbid());
                t110203.setAffectedFormId(task.getAffectedFormId());
                t110203.setAffectedFormIdForTargetDatabase(task.getAffectedFormIdForTargetDatabase());
                threadPoolExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
@@ -87,12 +91,14 @@
                                    });
                                    entity.setList(list);
                                    entity.setCustomerDbid(t110203.getCltDbid());
                                    entity.setAffectedFormId(t110203.getAffectedFormId());
                                    mutualServiceIfc.do120201All(entity);
                                    //--回写总部vndCode到经销商的销售订单
                                    CallBack120201Entity callBack120201Entity = new CallBack120201Entity();
                                    callBack120201Entity.setDocCodeList(String.join(",", docCodeList));
                                    callBack120201Entity.setCltDbid(t110203.getCltDbid() + "");
                                    callBack120201Entity.setVndDbid(dbid);
                                    callBack120201Entity.setAffectedFormIdForTargetDatabase(t110203.getAffectedFormIdForTargetDatabase());
                                    mutualController.createDataAndPush(callBack120201Entity.getCltDbid(), 121501, null, "update120201.do", callBack120201Entity);
                                }
                            } else {
src/com/yc/open/mutual/schedule/Push110503Schedule.java
@@ -1,36 +1,24 @@
package com.yc.open.mutual.schedule;
import com.alibaba.fastjson.JSON;
import com.yc.api.schedule.ScheduleUtils;
import com.yc.entity.AttachmentConfig;
import com.yc.entity.DataSourceEntity;
import com.yc.exception.ApplicationException;
import com.yc.exception.CallBackMessage;
import com.yc.factory.FactoryBean;
import com.yc.multiData.MultiDataSource;
import com.yc.multiData.SpObserver;
import com.yc.open.init.shcedule.BaseSchedule;
import com.yc.open.mutual.controller.MutualController;
import com.yc.open.mutual.entity.*;
import com.yc.open.mutual.entity.AttachmentEntity;
import com.yc.open.mutual.entity.T110203VO;
import com.yc.open.mutual.entity.T110503Data;
import com.yc.open.mutual.entity.T110503Entity;
import com.yc.open.mutual.service.MutualServiceIfc;
import com.yc.utils.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * <p>
@@ -62,12 +50,16 @@
                    final List<T110203VO> dbidList = mutualServiceIfc.get110203ByDbid();
                    if (dbidList != null && dbidList.size() > 0) {
                        for (T110203VO t110203VO : dbidList) {
                            if (StringUtils.isBlank(t110203VO.getBrands())) {
                                //没有品牌,跳过
                                continue;
                            }
                            T110503Entity entity = new T110503Entity();
                            entity.setCltDbid(t110203VO.getDbid());
                            entity.setVndDbid(dbid);
                            entity.setNowDateTime(DateUtil.toDay());
                            //--取最后一次更新时间之后的数据
                            final List<T110503Data> list = mutualServiceIfc.get110503List(t110203VO.getPushMatCodeToDistributorLastDateTime());
                            final List<T110503Data> list = mutualServiceIfc.get110503List(t110203VO);
                            if (list != null && list.size() > 0) {
                                list.stream().forEach(x->{
                                    //取出附件拼接url需要的数据
src/com/yc/open/mutual/schedule/PushDataSchedule.java
@@ -26,13 +26,10 @@
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Service;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
 * spring加载完成后启动
@@ -322,7 +319,7 @@
                            entity.setVndDbid(dbid);
                            entity.setNowDateTime(DateUtil.toDay());
                            //--取最后一次更新时间之后的数据
                            final List<T110503Data> list = mutualServiceIfc.get110503List(t110203VO.getPushMatCodeToDistributorLastDateTime());
                            final List<T110503Data> list = mutualServiceIfc.get110503List(t110203VO);
                            if (list != null && list.size() > 0) {
                                list.stream().forEach(x->{
                                    //取出附件拼接url需要的数据
src/com/yc/open/mutual/service/MutualServiceIfc.java
@@ -172,7 +172,7 @@
    List<T110203VO> get110203ByDbid();
    List<T110503Data> get110503List(String lastDateTime);
    List<T110503Data> get110503List(T110203VO entity);
    void do110503(T110503Entity entity);
src/com/yc/open/mutual/service/MutualServiceImpl.java
@@ -25,6 +25,7 @@
@Service
public class MutualServiceImpl extends BaseService implements MutualServiceIfc {
    @Transactional
    @Override
    public void saveLogs(MutualEntity mutualEntity) {
        String sql = "set nocount on \n insert into _sysAPIAuthLogs([cltCode],[cltName],[cltCompanyName],[vndCode],[vndName],[vndCompanyName],[remarks],insertTime) values (?,?,?,?,?,?,?,getdate())";
@@ -69,6 +70,7 @@
        return this.jdbcTemplate.queryForList(newSql, pageNumber, vndName);
    }
    @Transactional
    @Override
    public Integer save110203(SaveEntity saveEntity) {
        if (saveEntity.isUnbind()) {
@@ -78,6 +80,7 @@
        }
    }
    @Transactional
    @Override
    public Integer save110302(SaveEntity saveEntity) {
        if (saveEntity.isUnbind()) {
@@ -87,21 +90,23 @@
        }
    }
    @Transactional
    @Override
    public Integer doChangeRef110203(Integer dbid, String oldCltCode, String newCltCode) {
        return this.jdbcTemplate.update("set nocount on \n update  a set a.dbId=null from t110203 a where cltCode=? \n update  a set a.dbId=? from t110203 a where cltCode=?", oldCltCode, dbid, newCltCode);
    }
    @Transactional
    @Override
    public Integer doChangeRef110302(Integer dbid, String oldVndCode, String newVndCode) {
        return this.jdbcTemplate.update("set nocount on \n update  a set a.dbId=null from t110302 a where vndCode=? \n  update  a set a.dbId=? from t110302 a where vndCode=?", oldVndCode, dbid, newVndCode);
    }
    @Transactional
    @Override
    public Integer unbind110203(Integer refDbId) {
        return this.jdbcTemplate.update("set nocount on \n update  a set a.dbId=null from t110203 a where dbid=?", refDbId);
    }
    @Transactional
    @Override
    public Integer unbind110302(Integer refDbId) {
        return this.jdbcTemplate.update("set nocount on \n update  a set a.dbId=null from t110302 a where dbid=?", refDbId);
@@ -545,7 +550,7 @@
                "  raiserror('%s客户付款单已存在不能重复推送',16,1,@DistributorPoDocCode)\n" +
                "   return " +
                " end \n";
        System.out.println(sql);
       // System.out.println(sql);
        return this.jdbcTemplate.queryForObject(sql, String.class);
    }
@@ -583,7 +588,7 @@
        String sql = " set nocount on \n " +
                " declare @vndName varchar(50),@dbid int=" + entity.getVndDbid() + ",@docCode varchar(50)=" + GridUtils.prossSqlParm(entity.getDistributorPoDocCode()) + ",@HeadqSoDocCode varchar(50)=" + GridUtils.prossSqlParm(entity.getDocCode()) + " \n" +
                " select @vndName=vndName from t110302 where dbid=@dbid \n" +
                "  update a set a.callBackMsg=@vndName+'已审核通过',a.HeadqSoFormId=150101,a.HeadqSoDocCode=@HeadqSoDocCode from t150201H a where a.docCode=@docCode \n";
                "  update a set a.callBackMsg=@vndName+'已通过您的付款申请',a.HeadqSoFormId=150101,a.HeadqSoDocCode=@HeadqSoDocCode from t150201H a where a.docCode=@docCode \n";
        this.jdbcTemplate.execute(sql);
    }
@@ -592,7 +597,7 @@
        String sql = " set nocount on \n " +
                " declare @vndName varchar(50),@dbid int=" + entity.getVndDbid() + ",@docCode varchar(50)=" + GridUtils.prossSqlParm(entity.getDistributorPoDocCode()) + ",@HeadqSoDocCode varchar(50)=" + GridUtils.prossSqlParm(entity.getDocCode()) + " \n" +
                " select @vndName=vndName from t110302 where dbid=@dbid \n" +
                "  update a set a.callBackMsg=@vndName+'已审核通过',a.HeadqSoFormId=150170,a.HeadqSoDocCode=@HeadqSoDocCode from t150206H a where a.docCode=@docCode \n";
                "  update a set a.callBackMsg=@vndName+'已通过您的预付款申请',a.HeadqSoFormId=150170,a.HeadqSoDocCode=@HeadqSoDocCode from t150206H a where a.docCode=@docCode \n";
        this.jdbcTemplate.execute(sql);
    }
@@ -617,7 +622,7 @@
    @Override
    public DataSourceEntity getDataSourceByDbid(String dbId) {
        return this.jdbcTemplate.queryForObject("set nocount on \n" +
                " select systemID,systemDescribe,DBConnectionStr,systemFlag,host,userid,password,db,port,actived,activeVersion,domain,smsUid,smsKey,isShowAttendanceButton,LimitUserNumber,weixinID,systemType,siteSpaceMaxSize,ExpiredDate,isSaaS,isSendMail ,LimitDepartmentNumber,Remarks,DataCheckPageNum,CorpId,CorpContactsSecret ,CorpAppSecret ,CorpAppToken,CorpAppAesKey,CorpURL,MpAppId,MpSecret,MpToken,MpAesKey,MpOrgId,GeoWebApiKey,cltid,dbFileMaxSize,DataSize,LogSize,MpMchId,MpMchName,MpMchKey,CorpAppAgentId,isDisabledOpenNextPeriodId,InvitationCode,CorpAttendanceSecret,CorpSecret,CorpGroupSecret,CorpGroupName,MiniAppId,MiniAppSecret,MiniAppToken,MiniAppAesKey,MiniAppOrgId,SystemAccessKey,SystemSecretKey,DockingSystem,isUseAPP,isShowInLoginPage,OrgPassword,LogoIcon,TotalSize,DataFreeSpace,LogFreeSpace,TotalFreeSpace,Protocol,isAutoGenerateFormId,TengXunMapLocationServiceKey,PaymentMethod,AbcMchId,DataSourceInitialPoolSize,DataSourceMinPoolSize,DataSourceMaxPoolSize,DataSourceAcquireIncrement,DataSourceMaxIdleTime,DataSourceMaxStatements,DataSourceIdleConnectionTestPeriod,DomainIpList,DomainStaticIpList,AliPayAppId,MaintenanceFeeToDbId,MaintenanceFeeAcctCode from gsystem where id=?", new BeanPropertyRowMapper<>(DataSourceEntity.class), dbId);
                " select systemID,systemDescribe,DBConnectionStr,Protocol,domain,smsUid,smsKey,isnull(isShowAttendanceButton,0),isnull(LimitUserNumber,0),weixinID,systemType,ExpiredDate ,isnull(LimitDepartmentNumber,0),Remarks,isnull(DataCheckPageNum,0),CorpId,CorpContactsSecret,CorpAppSecret,CorpAppToken,CorpAppAesKey,CorpURL,MpAppId,MpSecret,MpToken,MpAesKey,MpOrgId,GeoWebApiKey,MpMchId,MpMchName,MpMchKey,isnull(CorpAppAgentId,0),isnull(isDisabledOpenNextPeriodId,0),InvitationCode,CorpAttendanceSecret,CorpSecret,CorpGroupSecret,CorpGroupName,MiniAppId,MiniAppSecret,MiniAppToken,MiniAppAesKey,MiniAppOrgId,SystemAccessKey,SystemSecretKey,DockingSystem,isnull(isUseAPP,0),isnull(isShowInLoginPage,0),OrgPassword,LogoIcon,TengXunMapLocationServiceKey,PaymentMethod,AbcMchId,DomainIpList,DomainStaticIpList,AliPayAppId,isnull(MaintenanceFeeToDbId,0),MaintenanceFeeAcctCode from gsystem where id=?", new BeanPropertyRowMapper<>(DataSourceEntity.class), dbId);
    }
    @Override
@@ -640,7 +645,7 @@
                " declare @vndName varchar(50),@dbid int=" + entity.getVndDbid() + ",@docCode varchar(50)=" + GridUtils.prossSqlParm(entity.getDistributorPoDocCode()) + ",@HeadqSoDocCode varchar(50)=" + GridUtils.prossSqlParm(entity.getDocCode()) + ",@hdMemo varchar(100)= " + GridUtils.prossSqlParm(entity.getHDMemo()) + ",@uploads varchar(100)=" + GridUtils.prossSqlParm(entity.getUploads()) + "\n" +
                " declare @matCode varchar(50),@price money,@Rowid varchar(50)" +
                " select @vndName=vndName from t110302 where dbid=@dbid \n" +
                "  update a set a.callBackMsg=@vndName+'已通过您的采购申请',a.HeadqSoFormId=120201,a.HeadqSoDocCode=@HeadqSoDocCode,a.HDMemo=@hdMemo,a.uploads=@uploads from t130301H a where a.docCode=@docCode \n";
                "  update a set a.callBackMsg=@vndName+'已通过您的采购申请',a.HeadqSoDocCode=@HeadqSoDocCode,a.HDMemo=@hdMemo,a.uploads=@uploads from t130301H a where a.docCode=@docCode \n";
        for (T120201DetailsEntity detailsEntity : entity.getDetails()) {
            sql += "    select @matCode=null,@price=null,@Rowid=null \n" +
@@ -670,8 +675,9 @@
    @Override
    public Integer do140201(T140201Entity t140201Entity) {
        return this.jdbcTemplate.queryForObject(" set nocount on \n " +
                " declare @logisticsCode varchar(50)=?,@shipperCode varchar(50)=?,@shipperName varchar(50)=?,@logisticsCodeState varchar(50)=?,@docCode varchar(50)=?,@ReceipterTelephone  varchar(50)=? \n" +
                "  update a set a.logisticsCode=@logisticsCode,a.shipperCode=@shipperCode ,a.shipperName=@shipperName ,a.logisticsCodeState=@logisticsCodeState  from t130301H a where a.docCode=@docCode \n select @@rowcount", Integer.class, t140201Entity.getLogisticsCode(), t140201Entity.getShipperCode(), t140201Entity.getShipperName(), t140201Entity.getLogisticsCodeState(), t140201Entity.getDocCode(), t140201Entity.getReceipterTelephone());
                " declare @vndName varchar(100),@dbid int=?,@logisticsCode varchar(50)=?,@shipperCode varchar(50)=?,@shipperName varchar(50)=?,@logisticsCodeState varchar(50)=?,@docCode varchar(50)=?,@ReceipterTelephone  varchar(50)=? \n" +
                " select @vndName=vndName from t110302 where dbid=@dbid \n" +
                "  update a set a.callbackMsg=@vndName+'已发货您的采购申请',a.logisticsCode=@logisticsCode,a.shipperCode=@shipperCode ,a.shipperName=@shipperName ,a.logisticsCodeState=@logisticsCodeState,a.ReceipterTelephone=@ReceipterTelephone  from t130301H a where a.docCode=@docCode \n select @@rowcount", Integer.class, t140201Entity.getRefDbId(),t140201Entity.getLogisticsCode(), t140201Entity.getShipperCode(), t140201Entity.getShipperName(), t140201Entity.getLogisticsCodeState(), t140201Entity.getDocCode(), t140201Entity.getReceipterTelephone());
    }
    @Transactional
@@ -728,6 +734,9 @@
                " declare @DealAfterDocSaveTable table(DealAfterDocSave varchar(200)) \n" +
                " --取客户资料\n" +
                " select @EnterCode=cltCode,@EnterName=cltName,@ModifyName=cltName,@CltCode=cltCode,@CltName=cltName,@companyID=companyid,@companyName=companyname,@ccCode=cccode,@ccName=ccname,@tel=Tel,@PropertyAddress=PropertyAddress,@clttype=clttype from t110203 where dbid=@dbid \n" +
                " if @@rowcount=0 begin \n" +
                "   raiserror('查找不到数据源dbid为%d的客户信息,请确保推送方与接收方系统进行过相互认证',16,1,@dbid);return \n" +
                "  end \n" +
                //是否已存在同客户同单号的采购订单
                " if not exists(select 1 from " + orderEntity.getHDtable() + " where CltCode=@CltCode and DistributorPoDocCode=@DistributorPoDocCode)  begin \n" +
                " exec sp_newdoccode @formid,'SYSTEM',@doccode output\n" +
@@ -917,7 +926,7 @@
            activated = 0;
        }
        String sql = "  set nocount on\n" +
                " declare @CheckDays int =" + checkDays + " \n" +
                " declare @CheckDays int =" + (Integer.parseInt(checkDays)+1) + " \n" +
                " declare @SystemDescribe varchar(150)=" + GridUtils.prossSqlParm(dataSource.getSystemDescribe()) + "\n" +
                " declare @DatabaseName varchar(50) = " + GridUtils.prossSqlParm(dataSource.getDb()) + ",@dbid int = " + dataSource.getDbId() + "\n" +
                " declare @LogonTimes int,@CustomerCount int,@TraceCustomerCount int\n" +
@@ -1251,17 +1260,17 @@
    @Override
    public Integer updateCallBackMsgBy130301(String docCode) {
        return this.jdbcTemplate.queryForObject(" set  nocount  on \n update a set a.callBackMsg=null,a.HeadqSoDocCode=null from t130301H a where a.DocCode=? \n select @@rowcount", Integer.class, docCode);
        return this.jdbcTemplate.queryForObject(" set  nocount  on \n update a set a.callBackMsg=null,a.HeadqSoFormId=null,a.HeadqSoDocCode=null from t130301H a where a.DocCode=? \n select @@rowcount", Integer.class, docCode);
    }
    @Override
    public Integer updateCallBackMsgBy150201(String docCode) {
        return this.jdbcTemplate.queryForObject(" set  nocount  on \n update a set a.callBackMsg=null,a.HeadqSoDocCode=null from t150201H a where a.DocCode=? \n select @@rowcount", Integer.class, docCode);
        return this.jdbcTemplate.queryForObject(" set  nocount  on \n update a set a.callBackMsg=null,a.HeadqSoFormId=null,a.HeadqSoDocCode=null from t150201H a where a.DocCode=? \n select @@rowcount", Integer.class, docCode);
    }
    @Override
    public Integer updateCallBackMsgBy150206(String docCode) {
        return this.jdbcTemplate.queryForObject(" set  nocount  on \n update a set a.callBackMsg=null,a.HeadqSoDocCode=null from t150206H a where a.DocCode=? \n select @@rowcount", Integer.class, docCode);
        return this.jdbcTemplate.queryForObject(" set  nocount  on \n update a set a.callBackMsg=null,a.HeadqSoFormId=null,a.HeadqSoDocCode=null from t150206H a where a.DocCode=? \n select @@rowcount", Integer.class, docCode);
    }
    /**
@@ -1487,6 +1496,7 @@
    @Transactional
    @Override
    public void do120201All(Push120201Entity entity) {
        final FormEntity orderEntity = getFormEntityInfo(entity.getAffectedFormId());
        String sql = " set nocount  on\n" +
                " ---定义变量 \n" +
                " declare @doccode varchar(50),@companyID varchar(50),@companyName varchar(50),@HeadqCltCode varchar(50),@HeadqCltName varchar(50),@ccCode varchar(50),@ccName varchar(50),@dbid int,@tel varchar(50),@PropertyAddress varchar(50),@clttype varchar(50), @PreDocStatus int,@PostDocStatus int,@DocStatusValue int,@FormId int, @Memo varchar(200),@LinkDocInfo varchar(200),@doccode1 varchar(50), @docitem int, @rowId varchar(50), @matName varchar(200)=null,@Barcode varchar(150)=null,@Brand varchar(150)=null,@UOM varchar(150)=null,@baseuom varchar(150)=null,@netprice decimal,@TrademarkPrice money=null,@special varchar(100)=null,@weight money=null,@matgroup varchar(100)=null,@matgroupname varchar(100)=null,@TCname varchar(100)=null,@TaxPrice money=null,@pricetype varchar(100)=null,@discount money=null,@whcode varchar(100)=null,@refcodeitem varchar(100)=null,@refrowid varchar(100)=null,@refcodeformid int,@Pricerefcodeitem varchar(100)=null,@Pricerefrowid varchar(100)=null,@Pricerefcodeformid int=null,@matCode varchar(50),@price money,@digit money,@itemMemo varchar(200),@stCode varchar(50),@stName varchar(50),@cv2 varchar(20),@totalmoney money,@totalmoney2 money,@MoneyType int,@CaiGouStatus varchar(50) ,@CaiGouDoccode varchar(50),@CaiGouFormid int,@CaiGouFormType int ,@CaiGouAmount varchar(50) ,@CaiGouLastDate datetime,@uploads varchar(200),@sumtotalmoney2 money  \n ";
@@ -1494,57 +1504,57 @@
        for (T121501Entity t120201Entity : entity.getList()) {
            //--客户资料
            sql += get110203(t120201Entity, entity.getCustomerDbid());
            sql += get120201Head(t120201Entity);
            sql += get120201Detail(t120201Entity);
            sql += get120201Head(t120201Entity,orderEntity);
            sql += get120201Detail(t120201Entity,orderEntity);
        }
        if (StringUtils.isNotBlank(entity.getPullSalesOrderFromDistributorLastDateTime())) {
            sql += " update  a set  a.PullSalesOrderFromDistributorLastDateTime='" + entity.getPullSalesOrderFromDistributorLastDateTime() + "' from t110203 a where a.dbid=" + entity.getCustomerDbid();
        }
        // log.info("120201sql:"+sql);
         log.info("120201sql:"+sql);
        this.jdbcTemplate.execute(sql);
    }
    private String get120201Head(T121501Entity entity) {
    private String get120201Head(T121501Entity entity,FormEntity formEntity) {
        T121501HeadEntity head = entity.getHead();
        StringBuilder sb = new StringBuilder();
        sb.append("  select @doccode1=doccode from t121501h a where a.HeadqCltCode=@HeadqCltCode and a.refCode=" + GridUtils.prossSqlParm(head.getDocCode()) + "  \n" +
        sb.append("  select @doccode1=doccode from "+formEntity.getHDtable()+" a where a.HeadqCltCode=@HeadqCltCode and a.refCode=" + GridUtils.prossSqlParm(head.getDocCode()) + "  \n" +
                        " if @@rowcount >0 \n" +
                        "  begin \n" +
                        " update a set a.Docdate=" + GridUtils.prossSqlParm(head.getDocDate()) + ",a.doctype=" + GridUtils.prossSqlParm(head.getDocType()) + ",a.DocStatus=" + head.getDocStatus() + ",a.[CltCode]=" + GridUtils.prossSqlParm(head.getCltCode()) + ",a.[CltName]=" + GridUtils.prossSqlParm(head.getCltName()) + ",a.[PropertyAddress]=" + GridUtils.prossSqlParm(head.getPropertyAddress()) + ",a.hDMemo=" + GridUtils.prossSqlParm(head.getHDMemo()) + ",a.tel=" + GridUtils.prossSqlParm(head.getTel()) + ",a.tel2=" + GridUtils.prossSqlParm(head.getTel2()) + ",a.CaiGouStatus=" + GridUtils.prossSqlParm(head.getCaiGouStatus()) + ",a.CaiGouDoccode=" + GridUtils.prossSqlParm(head.getCaiGouDoccode()) + ",a.CaiGouFormid =" + head.getCaiGouFormid() + ",a.CaiGouFormType=" + head.getCaiGouFormType() + " ,a.CaiGouAmount =" + head.getCaiGouAmount() + " ,a.CaiGouLastDate=" + GridUtils.prossSqlParm(head.getCaiGouLastDate()) + ",a.uploads=" + GridUtils.prossSqlParm(head.getUploads()) + ",a.sumtotalmoney2=" + head.getSumtotalmoney2() + "  from t121501h a where a.HeadqCltCode=@HeadqCltCode and a.refCode=" + GridUtils.prossSqlParm(head.getDocCode()) + "  \n" +
                        " update a set a.Docdate=" + GridUtils.prossSqlParm(head.getDocDate()) + ",a.doctype=" + GridUtils.prossSqlParm(head.getDocType()) + ",a.DocStatus=" + head.getDocStatus() + ",a.[CltCode]=" + GridUtils.prossSqlParm(head.getCltCode()) + ",a.[CltName]=" + GridUtils.prossSqlParm(head.getCltName()) + ",a.[PropertyAddress]=" + GridUtils.prossSqlParm(head.getPropertyAddress()) + ",a.hDMemo=" + GridUtils.prossSqlParm(head.getHDMemo()) + ",a.tel=" + GridUtils.prossSqlParm(head.getTel()) + ",a.tel2=" + GridUtils.prossSqlParm(head.getTel2()) + ",a.CaiGouStatus=" + GridUtils.prossSqlParm(head.getCaiGouStatus()) + ",a.CaiGouDoccode=" + GridUtils.prossSqlParm(head.getCaiGouDoccode()) + ",a.CaiGouFormid =" + head.getCaiGouFormid() + ",a.CaiGouFormType=" + head.getCaiGouFormType() + " ,a.CaiGouAmount =" + head.getCaiGouAmount() + " ,a.CaiGouLastDate=" + GridUtils.prossSqlParm(head.getCaiGouLastDate()) + ",a.uploads=" + GridUtils.prossSqlParm(head.getUploads()) + ",a.sumtotalmoney2=" + head.getSumtotalmoney2() + "  from "+formEntity.getHDtable()+" a where a.HeadqCltCode=@HeadqCltCode and a.refCode=" + GridUtils.prossSqlParm(head.getDocCode()) + "  \n" +
                        "  end \n" +
                        "  else \n")
                .append(" begin \n" +
                        " exec sp_newdoccode 121501,'SYSTEM',@doccode1 output \n" +
                        " insert into t121501h(docCode,formid,PeriodID,Docdate,doctype,EnterCode,EnterName,DocStatus,companyID,companyName,[CltCode],[CltName],[PropertyAddress],hDMemo,tel,tel2,hdcurrency,hdcurrencyrate,refCode,HeadqCltCode,HeadqCltName,CaiGouStatus  ,CaiGouDoccode ,CaiGouFormid ,CaiGouFormType  ,CaiGouAmount ,CaiGouLastDate ,uploads,sumtotalmoney2) values(@doccode1,121501,dbo.GetPeriodID(121501,@companyID,convert(char(10),GetDate(),120)),convert(char(10),GetDate(),120)," + GridUtils.prossSqlParm(head.getDocType()) + "," + GridUtils.prossSqlParm(head.getEnterCode()) + "," + GridUtils.prossSqlParm(head.getEnterName()) + ",0,@companyId,@companyName," + GridUtils.prossSqlParm(head.getCltCode()) + "," + GridUtils.prossSqlParm(head.getCltName()) + "," + GridUtils.prossSqlParm(head.getPropertyAddress()) + "," + GridUtils.prossSqlParm(head.getHDMemo()) + "," + GridUtils.prossSqlParm(head.getTel()) + "," + GridUtils.prossSqlParm(head.getTel2()) + ",'RMB',1," + GridUtils.prossSqlParm(head.getDocCode()) + ",@HeadqCltCode,@HeadqCltName," + GridUtils.prossSqlParm(head.getCaiGouStatus()) + "," + GridUtils.prossSqlParm(head.getCaiGouDoccode()) + "," + head.getCaiGouFormid() + "," + head.getCaiGouFormType() + "," + head.getCaiGouAmount() + "," + GridUtils.prossSqlParm(head.getCaiGouLastDate()) + "," + GridUtils.prossSqlParm(head.getUploads()) + "," + head.getSumtotalmoney2() + ") \n" +
                        " exec sp_newdoccode "+formEntity.getFormid()+",'SYSTEM',@doccode1 output \n" +
                        " insert into "+formEntity.getHDtable()+"(docCode,formid,PeriodID,Docdate,doctype,EnterCode,EnterName,DocStatus,companyID,companyName,[CltCode],[CltName],[PropertyAddress],hDMemo,tel,tel2,hdcurrency,hdcurrencyrate,refCode,HeadqCltCode,HeadqCltName,CaiGouStatus  ,CaiGouDoccode ,CaiGouFormid ,CaiGouFormType  ,CaiGouAmount ,CaiGouLastDate ,uploads,sumtotalmoney2) values(@doccode1,"+formEntity.getFormid()+",dbo.GetPeriodID("+formEntity.getFormid()+",@companyID,convert(char(10),GetDate(),120)),convert(char(10),GetDate(),120)," + GridUtils.prossSqlParm(head.getDocType()) + "," + GridUtils.prossSqlParm(head.getEnterCode()) + "," + GridUtils.prossSqlParm(head.getEnterName()) + ",0,@companyId,@companyName," + GridUtils.prossSqlParm(head.getCltCode()) + "," + GridUtils.prossSqlParm(head.getCltName()) + "," + GridUtils.prossSqlParm(head.getPropertyAddress()) + "," + GridUtils.prossSqlParm(head.getHDMemo()) + "," + GridUtils.prossSqlParm(head.getTel()) + "," + GridUtils.prossSqlParm(head.getTel2()) + ",'RMB',1," + GridUtils.prossSqlParm(head.getDocCode()) + ",@HeadqCltCode,@HeadqCltName," + GridUtils.prossSqlParm(head.getCaiGouStatus()) + "," + GridUtils.prossSqlParm(head.getCaiGouDoccode()) + "," + head.getCaiGouFormid() + "," + head.getCaiGouFormType() + "," + head.getCaiGouAmount() + "," + GridUtils.prossSqlParm(head.getCaiGouLastDate()) + "," + GridUtils.prossSqlParm(head.getUploads()) + "," + head.getSumtotalmoney2() + ") \n" +
                        " end \n");
        return sb.toString();
    }
    private String get120201Detail(T121501Entity entity) {
    private String get120201Detail(T121501Entity entity,FormEntity formEntity) {
        List<T121501DetailEntity> list = entity.getOrders();
        String sql = "--标记所有为删除状态 到最后再执行一次update以便可以删除这一次提交经销商已删除行的记录\n" +
                "  update a set a.isDeleted=1 from t121501D a where a.HeadqCltCode=@HeadqCltCode and refcodeitem=" + GridUtils.prossSqlParm(entity.getHead().getDocCode()) +
                "  update a set a.isDeleted=1 from "+formEntity.getDDtable()+" a where a.HeadqCltCode=@HeadqCltCode and refcodeitem=" + GridUtils.prossSqlParm(entity.getHead().getDocCode()) +
                " select @docitem=0 \n";
        for (T121501DetailEntity detailEntity : list) {
            sql += " select @docitem=isnull(@docitem,0)+10,@matCode=" + GridUtils.prossSqlParm(detailEntity.getMatCode()) + " , @price =" + detailEntity.getPrice() + ", @digit=" + detailEntity.getDigit() + ", @cv2=" + GridUtils.prossSqlParm(detailEntity.getCv2()) + "  , @itemMemo=" + GridUtils.prossSqlParm(detailEntity.getItemMemo()) + ",@matName=" + GridUtils.prossSqlParm(detailEntity.getMatName()) + ",@Barcode=" + GridUtils.prossSqlParm(detailEntity.getBarcode()) + ",@Brand=" + GridUtils.prossSqlParm(detailEntity.getBrand()) + ",@stCode=" + GridUtils.prossSqlParm(detailEntity.getStcode()) + ", @stName=" + GridUtils.prossSqlParm(detailEntity.getStname()) + " ,@UOM=" + GridUtils.prossSqlParm(detailEntity.getUom()) + ",@baseuom=" + GridUtils.prossSqlParm(detailEntity.getBaseuom()) + ",@netprice=" + detailEntity.getNetprice() + ",@TrademarkPrice=" + detailEntity.getTrademarkPrice() + ",@special=" + GridUtils.prossSqlParm(detailEntity.getSpecial()) + ",@weight=" + detailEntity.getWeight() + ",@matgroup=" + GridUtils.prossSqlParm(detailEntity.getMatgroup()) + ",@matgroupname=" + GridUtils.prossSqlParm(detailEntity.getMatgroupname()) + ",@TCname=" + GridUtils.prossSqlParm(detailEntity.getTCname()) + " ,@TaxPrice=" + detailEntity.getTaxPrice() + " ,@pricetype=" + GridUtils.prossSqlParm(detailEntity.getPricetype()) + " ,@discount=" + detailEntity.getDiscount() + " ,@whcode=" + GridUtils.prossSqlParm(detailEntity.getWhcode()) + " ,@refcodeitem=" + GridUtils.prossSqlParm(detailEntity.getDocCode()) + " ,@refrowid=" + GridUtils.prossSqlParm(detailEntity.getRowid()) + " ,@refcodeformid=" + detailEntity.getRefcodeformid() + " ,@Pricerefcodeitem=" + GridUtils.prossSqlParm(detailEntity.getPricerefcodeitem()) + " ,@Pricerefrowid=" + GridUtils.prossSqlParm(detailEntity.getPricerefrowid()) + " ,@Pricerefcodeformid=" + GridUtils.prossSqlParm(detailEntity.getPricerefcodeformid()) + ",@totalmoney=" + detailEntity.getTotalmoney() + ",@totalmoney2=" + detailEntity.getTotalmoney2() + ",@MoneyType=" + detailEntity.getMoneyType() + " \n" +
                    " update a set a.isDeleted=0,a.matCode=@matCode,a.price=@price,a.digit=@digit,a.cv2=@cv2,a.itemMemo=@itemMemo,a.matName=@matName,a.Barcode=@Barcode,a.Brand=@Brand,a.Stcode=@stCode,a.stname=@stName,a.UOM=@UOM,a.baseuom=@baseuom,a.netprice=@netprice,a.TrademarkPrice=@TrademarkPrice,a.special=@special,a.weight=@weight,a.matgroup=@matgroup,a.matgroupname=@matgroupname,a.TaxPrice=@TaxPrice ,a.pricetype=@pricetype ,a.totalmoney=@totalmoney,a.totalmoney2=@totalmoney2,a.discount=@discount ,a.whcode=@whcode ,a.Pricerefcodeitem=@Pricerefcodeitem ,a.Pricerefrowid=@Pricerefrowid ,a.Pricerefcodeformid=@Pricerefcodeformid,a.MoneyType=@MoneyType from t121501D a where a.HeadqCltCode=@HeadqCltCode and a.refcodeitem=@refcodeitem and a.refrowid=@refrowid \n" +
                    " update a set a.isDeleted=0,a.matCode=@matCode,a.price=@price,a.digit=@digit,a.cv2=@cv2,a.itemMemo=@itemMemo,a.matName=@matName,a.Barcode=@Barcode,a.Brand=@Brand,a.Stcode=@stCode,a.stname=@stName,a.UOM=@UOM,a.baseuom=@baseuom,a.netprice=@netprice,a.TrademarkPrice=@TrademarkPrice,a.special=@special,a.weight=@weight,a.matgroup=@matgroup,a.matgroupname=@matgroupname,a.TaxPrice=@TaxPrice ,a.pricetype=@pricetype ,a.totalmoney=@totalmoney,a.totalmoney2=@totalmoney2,a.discount=@discount ,a.whcode=@whcode ,a.Pricerefcodeitem=@Pricerefcodeitem ,a.Pricerefrowid=@Pricerefrowid ,a.Pricerefcodeformid=@Pricerefcodeformid,a.MoneyType=@MoneyType from "+formEntity.getDDtable()+" a where a.HeadqCltCode=@HeadqCltCode and a.refcodeitem=@refcodeitem and a.refrowid=@refrowid \n" +
                    " if @@rowcount=0 \n" +
                    " begin \n" +
                    "  exec getXXXX @rowId  output \n" +
                    " insert into t121501D(docCode,docitem,rowid,matCode,price,digit,cv2,itemMemo,matName,Barcode,Brand,Stcode,stname,UOM,baseuom,netprice,TrademarkPrice,special,weight,matgroup,matgroupname ,TaxPrice ,pricetype ,totalmoney,totalmoney2 ,discount ,whcode ,refcodeitem ,refrowid  ,Pricerefcodeitem ,Pricerefrowid ,Pricerefcodeformid,MoneyType,isDeleted,HeadqCltCode,HeadqCltName)values(@doccode1,@docitem,@rowId, @matCode , @price , @digit , @cv2   , @itemMemo  ,@matName,@Barcode,@Brand,@stCode, @stName ,@UOM,@baseuom,@netprice,@TrademarkPrice,@special,@weight,@matgroup,@matgroupname ,@TaxPrice ,@pricetype , @totalmoney,@totalmoney2  ,@discount ,@whcode ,@refcodeitem ,@refrowid  ,@Pricerefcodeitem ,@Pricerefrowid ,@Pricerefcodeformid,7,0,@HeadqCltCode,@HeadqCltName) \n" +
                    " insert into "+formEntity.getDDtable()+"(docCode,docitem,rowid,matCode,price,digit,cv2,itemMemo,matName,Barcode,Brand,Stcode,stname,UOM,baseuom,netprice,TrademarkPrice,special,weight,matgroup,matgroupname ,TaxPrice ,pricetype ,totalmoney,totalmoney2 ,discount ,whcode ,refcodeitem ,refrowid  ,Pricerefcodeitem ,Pricerefrowid ,Pricerefcodeformid,MoneyType,isDeleted,HeadqCltCode,HeadqCltName)values(@doccode1,@docitem,@rowId, @matCode , @price , @digit , @cv2   , @itemMemo  ,@matName,@Barcode,@Brand,@stCode, @stName ,@UOM,@baseuom,@netprice,@TrademarkPrice,@special,@weight,@matgroup,@matgroupname ,@TaxPrice ,@pricetype , @totalmoney,@totalmoney2  ,@discount ,@whcode ,@refcodeitem ,@refrowid  ,@Pricerefcodeitem ,@Pricerefrowid ,@Pricerefcodeformid,7,0,@HeadqCltCode,@HeadqCltName) \n" +
                    " end \n";
        }
        sql += " delete t121501D where HeadqCltCode=@HeadqCltCode and  refcodeitem=" + GridUtils.prossSqlParm(entity.getHead().getDocCode()) + " and isDeleted=1 \n" +
        sql += " delete "+formEntity.getDDtable()+" where HeadqCltCode=@HeadqCltCode and  refcodeitem=" + GridUtils.prossSqlParm(entity.getHead().getDocCode()) + " and isDeleted=1 \n" +
                " select @doccode1=doccode from t121501H where HeadqCltCode=@HeadqCltCode and  refcode= " + GridUtils.prossSqlParm(entity.getHead().getDocCode()) + " \n" +
                " exec p121501Save @doccode1 \n" +//保存时执行
                "    select @FormId = FormId,@DocStatusValue = DocStatus from t121501H where doccode = @doccode1\n" +
                " select @doccode1=doccode from "+formEntity.getHDtable()+" where HeadqCltCode=@HeadqCltCode and  refcode= " + GridUtils.prossSqlParm(entity.getHead().getDocCode()) + " \n" +
                " exec p"+formEntity.getFormid()+"Save @doccode1 \n" +//保存时执行
                "    select @FormId = FormId,@DocStatusValue = DocStatus from "+formEntity.getHDtable()+" where doccode = @doccode1\n" +
                "     select @PreDocStatus = PreDocStatus,@PostDocStatus = a.PostDocStatus from gform a where a.formid = @FormId \n" +
                " if isnull(@DocStatusValue,0) = isnull(@PreDocStatus,0) \n"
                + " begin \n"
                + "    update a set DocStatus = @PostDocStatus from t121501H a where a.DocCode = @doccode1 \n"
                + "    exec p121501Post @UserCode = 'SYSTEM',@UserName = '管理员', \n"
                + "    update a set DocStatus = @PostDocStatus from "+formEntity.getHDtable()+" a where a.DocCode = @doccode1 \n"
                + "    exec p"+formEntity.getFormid()+"Post @UserCode = 'SYSTEM',@UserName = '管理员', \n"
                + "        @DocCode = @doccode1,@FormID = @FormId,\n"
                + "         @DocStatusValue = @DocStatusValue,@ButtonType ='提交', \n"
                + "        @Memo=@Memo output ,@LinkDocInfo = @LinkDocInfo output  \n"
@@ -1584,6 +1594,7 @@
    @Override
    public List<T121501Entity> get120201List(T110302 t110302) {
        final FormEntity orderEntity = getFormEntityInfo(t110302.getAffectedFormIdForTargetDatabase());
        List<T121501Entity> results = null;
        String sql = "set nocount on \n" +
                "                declare @shouKuanAmount money,@docCode varchar(20),@preSendDate datetime,@docType varchar(50),\n" +
@@ -1636,8 +1647,8 @@
                "                e.referralsName as cltreferralsName,--介绍人         \n" +
                "                e.cltbrithday as cltbrithday,\n" +
                "                e.docStatus as cltdocStatus, e.docStatusName as cltdocStatusName \n" +
                "                from t120201H b  \n" +
                "                join t120201D c on b.doccode = c.doccode \n" +
                "                from "+orderEntity.getHDtable()+" b  \n" +
                "                join "+orderEntity.getDDtable()+" c on b.doccode = c.doccode \n" +
                "                join t110503 d on c.matcode = d.matcode \n" +
                "                join t110203 e on b.cltcode = e.cltcode \n" +
                "                where \n" +
@@ -2004,9 +2015,9 @@
    }
    @Override
    public List<T110503Data> get110503List(String lastDateTime) {
    public List<T110503Data> get110503List(T110203VO entity) {
        String sql = "set nocount  on\n" +
                " declare @PushMatCodeToDistributorLastDateTime datetime=? \n" +
                " declare @PushMatCodeToDistributorLastDateTime datetime=?,@Brands varchar(500)=? \n" +
                " select a.MatGroup,a.MatGroupName,b.ParentRowId,b.rowid,b.treecontrol,\n" +
                "  a.MatCode,a.MatName,a.Special,a.SalesPrice,a.BaseUOM,\n" +
                " a.brand,\n" +
@@ -2016,8 +2027,9 @@
                " a.baseuomrate,a.photoPath,a.salesUOM,a.purchaseUOM,a.uomrate,a.ratetxt \n" +
                "  from t110503 a join t110501 b on a.MatGroup=b.MatGroup \n" +
                "   where \n" +
                " a.ModifyDate is null or a.ModifyDate between isnull(@PushMatCodeToDistributorLastDateTime,'2000-01-01 00:00:00') and getdate()";
        return this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T110503Data.class), lastDateTime);
                "  a.Brand in (select list from getinstr(@Brands)) \n" +
                " and a.ModifyDate is null or a.ModifyDate between isnull(@PushMatCodeToDistributorLastDateTime,'2000-01-01 00:00:00') and getdate()";
        return this.jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T110503Data.class), entity.getPushMatCodeToDistributorLastDateTime(),entity.getBrands());
    }
    @Transactional
@@ -2106,12 +2118,13 @@
    @Transactional
    @Override
    public Integer update120201ByVndCode(CallBack120201Entity entity) {
        final FormEntity formEntityInfo = getFormEntityInfo(entity.getAffectedFormIdForTargetDatabase());
        return this.jdbcTemplate.queryForObject("set nocount  on \n" +
                "   declare @HeadqVndCode varchar(50),@HeadqVndName varchar(50),@dbid int=?,@docCodeList varchar(500)=? \n" +
                " select @HeadqVndCode=vndCode,@HeadqVndName=vndName from t110302 where isnull(dbid,0)=@dbid \n" +
                " if @@rowcount>0 \n" +
                "  begin \n" +
                "  update a set a.HeadqVndCode=@HeadqVndCode ,a.HeadqVndName=@HeadqVndName from t120201H a where a.doccode in(@docCodeList) \n  end \n select @@rowcount ", Integer.class, entity.getVndDbid(), entity.getDocCodeList());
                "  update a set a.HeadqVndCode=@HeadqVndCode ,a.HeadqVndName=@HeadqVndName from "+formEntityInfo.getHDtable()+" a where a.doccode in(@docCodeList) \n  end \n select @@rowcount ", Integer.class, entity.getVndDbid(), entity.getDocCodeList());
    }
    /**
src/com/yc/service/panel/v2/TypeControl.java
@@ -128,12 +128,12 @@
        Map<String, Map<String, Object>> resultMap = new HashMap<>();
        if (list1 != null && list1.size() > 0) {
            for (Map<String, Object> objectMap : list1) {
                String id = GridUtils.prossRowSetDataType_String(objectMap, "fieldID").toLowerCase();
                int indexd = id.toLowerCase().lastIndexOf("as");
                if (indexd > 0) {
                    id = id.substring(indexd + 2, id.length()).trim();
                    }
                   // objectMap.remove("fieldID");
                final String[] byAsOfEnd = id.split("\\s*\\b(?i)as\\b\\s*");
                if (byAsOfEnd.length > 1) {
                    id = byAsOfEnd[1];
                }
                    resultMap.put(id,objectMap);
                }
            }