起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3041|回复: 4

[结贴] 关于日期条件的写法

[复制链接]

16

主题

71

帖子

227

积分

中级会员

Rank: 3Rank: 3

积分
227
QQ
发表于 2017-3-7 08:04:38 | 显示全部楼层 |阅读模式
给数据送一条日期筛选条件,如下
data.setFilter('filter2',"stringToDate(Sfc_shop_ticket.record_date )   >=  justep.Date.fromString('" + this.comp("input2").val() + "', justep.Date.STANDART_FORMAT_SHOT ) and stringToDate(Sfc_shop_ticket.record_date )   <= justep.Date.fromString('" + this.comp("input1").val() + "', justep.Date.STANDART_FORMAT_SHOT )");

报错

2017-03-07 08:00:10 excute stream action, params:{"accept":"application/json","action":"querySfc_shop_ticketAction","actionFlag":"__action_0__","activity":"staticActivity1","contentType":"json","executeContext":"","executor":"","parameters":{"columns":"Sfc_shop_ticket,accum_qty,actual_hours,check_date,check_man,dept_code,employee,employee_dept,end_date,flag,grade_hours_1,grade_hours_2,grade_hours_3,grade_hours_4,grade_hours_5,grade_qty_1,grade_qty_2,grade_qty_3,grade_qty_4,grade_qty_5,gzl,hours_code,id,idle_hours,iii,item_code,lll,op_no,order_no,other_hours,out_op_cost,out_op_unit,plan_hours,plan_qty,record_date,remarks,remind_qty,run_time,run_unit,scrap_hours,scrap_qty,setup_time,shift,shift_seq,start_date,wc_code","filter":"(employee='gxj') AND (stringToDate(Sfc_shop_ticket.record_date )   >=  justep.Date.fromString('2017-03-01', justep.Date.STANDART_FORMAT_SHOT ) and stringToDate(Sfc_shop_ticket.record_date )   <= justep.Date.fromString('2017-03-07', justep.Date.STANDART_FORMAT_SHOT ))","limit":20,"offset":0,"variables":{}},"process":"/erp/cjgl/process/gp/gpProcess","translateParameter":{"cellnameByRelation":false,"dataType":"row-list","includeState":true,"rowsConfig":{"concept":"Sfc_shop_ticket","sequence":"Sfc_shop_ticket,accum_qty,actual_hours,calcCheckBox,check_date,check_man,dept_code,employee,employee_dept,end_date,flag,grade_hours_1,grade_hours_2,grade_hours_3,grade_hours_4,grade_hours_5,grade_qty_1,grade_qty_2,grade_qty_3,grade_qty_4,grade_qty_5,gzl,hours_code,id,idle_hours,iii,item_code,lll,op_no,order_no,other_hours,out_op_cost,out_op_unit,plan_hours,plan_qty,record_date,remarks,remind_qty,run_time,run_unit,scrap_hours,scrap_qty,setup_time,shift,shift_seq,start_date,wc_code"},"transformIdcolumn":true,"useNamespace":true}}
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.justep.system.action.Engine.invokeActions(Native Method)
        at com.justep.system.action.Engine.invokeActions(Unknown Source)
        at com.justep.business.server.BusinessServer.doAction(Unknown Source)
        at com.justep.business.server.BusinessServer.doExcute(Unknown Source)
        at com.justep.business.server.BusinessServer.excute(Unknown Source)
        at com.justep.business.server.BusinessServer.excute(Unknown Source)
        at com.justep.business.server.BusinessServerServlet.execService(Unknown Source)
        at com.justep.business.server.BusinessServerServlet.service(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at com.justep.x.bs.BusinessServerServlet.service(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:745)
Caused by: com.justep.exception.BusinessException: 编码: JUSTEP150210; 提示: 执行KSQL出错, KSQL: SELECT Sfc_shop_ticket.*  FROM Sfc_shop_ticket Sfc_shop_ticket WHERE ((employee='gxj') AND (stringToDate(Sfc_shop_ticket.record_date )   >=  justep.Date.fromString('2017-03-01', justep.Date.STANDART_FORMAT_SHOT ) and stringToDate(Sfc_shop_ticket.record_date )   <= justep.Date.fromString('2017-03-07', justep.Date.STANDART_FORMAT_SHOT ))) LIMIT 0, 20
--> sql:
--> binds: []
        at com.justep.exception.BusinessException.create(Unknown Source)
        at com.justep.system.data.impl.TableUtilsImplement.ksqlSelect(Unknown Source)
        at com.justep.system.data.impl.TableUtilsImplement.ksqlSelect(Unknown Source)
        at com.justep.system.data.impl.TableUtilsImplement.ksqlSelect(Unknown Source)
        at com.justep.system.data.BizData.query(Unknown Source)
        at BizProcedure.query(BizProcedure.java:12)
        ... 27 more
Caused by: com.justep.exception.KSQLException: 编码: JUSTEP154115; 提示: KSQL语法错误, >=  justep.Date^^.fromString('20中未找到需要的元素, 位置152期望是)
        at com.justep.exception.KSQLException.create(Unknown Source)
        at com.justep.system.ksql.token.TokenManager.matchToken(Unknown Source)
        at com.justep.system.ksql.token.TokenManager.match(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.unaryExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.multiExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.addExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.compExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.notExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.andExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.orExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.unaryExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.multiExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.addExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.compExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.notExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.andExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.orExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.conditionExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.whereExpression(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.selectSentenceNode(Unknown Source)
        at com.justep.system.ksql.parser.QueryParser.start(Unknown Source)
        at com.justep.system.ksql.parser.QueryParser.start(Unknown Source)
        at com.justep.system.ksql.parser.AbstractParser.parse(Unknown Source)
        ... 32 more



该怎样修改,请大神赐教!

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
36064
发表于 2017-3-7 09:43:01 | 显示全部楼层
justep.Date.fromString是js中的方法,不能在data的setFilter中用

你可以在js中先算出  justep.Date.fromString('" + this.comp("input2").val() + "', justep.Date.STANDART_FORMAT_SHOT ),然后直接在filter中直接用值
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

16

主题

71

帖子

227

积分

中级会员

Rank: 3Rank: 3

积分
227
QQ
 楼主| 发表于 2017-3-7 10:59:45 | 显示全部楼层
jishuang 发表于 2017-3-7 09:43
justep.Date.fromString是js中的方法,不能在data的setFilter中用

你可以在js中先算出  justep.Date.fromS ...

根据提示,代码修改如下:
             var data=this.comp("mainData");
          
            data.setFilter('filter1',"employee='" + this.comp("input5").val()+ "'");
            var sdate =justep.Date.fromString(this.comp("input2").val(), justep.Date.STANDART_FORMAT_SHOT );
            var edate =justep.Date.fromString(this.comp("input1").val(), justep.Date.STANDART_FORMAT_SHOT );
            
            data.setFilter('filter2',"stringToDate(Sfc_shop_ticket.record_date )>='" + sdate + "' and stringToDate(Sfc_shop_ticket.record_date )<='" + edate + "'");
         
            data.refreshData();

出现以下报错
提示: 执行sql: SELECT  Sfc_shop_ticket.fid AS Sfc_shop_ticket, Sfc_shop_ticket.ACCUM_QTY AS accum_qty, Sfc_shop_ticket.ACTUAL_HOURS AS actual_hours, Sfc_shop_ticket.CHECK_DATE AS check_date, Sfc_shop_ticket.CHECK_MAN AS check_man, Sfc_shop_ticket.DEPT_CODE AS dept_code, Sfc_shop_ticket.EMPLOYEE AS employee, Sfc_shop_ticket.EMPLOYEE_DEPT AS employee_dept, Sfc_shop_ticket.END_DATE AS end_date, Sfc_shop_ticket.FLAG AS flag, Sfc_shop_ticket.GRADE_HOURS_1 AS grade_hours_1, Sfc_shop_ticket.GRADE_HOURS_2 AS grade_hours_2, Sfc_shop_ticket.GRADE_HOURS_3 AS grade_hours_3, Sfc_shop_ticket.GRADE_HOURS_4 AS grade_hours_4, Sfc_shop_ticket.GRADE_HOURS_5 AS grade_hours_5, Sfc_shop_ticket.GRADE_QTY_1 AS grade_qty_1, Sfc_shop_ticket.GRADE_QTY_2 AS grade_qty_2, Sfc_shop_ticket.GRADE_QTY_3 AS grade_qty_3, Sfc_shop_ticket.GRADE_QTY_4 AS grade_qty_4, Sfc_shop_ticket.GRADE_QTY_5 AS grade_qty_5, Sfc_shop_ticket.GZL AS gzl, Sfc_shop_ticket.HOURS_CODE AS hours_code, Sfc_shop_ticket.ID AS id, Sfc_shop_ticket.IDLE_HOURS AS idle_hours, Sfc_shop_ticket.III AS iii, Sfc_shop_ticket.ITEM_CODE AS item_code, Sfc_shop_ticket.LLL AS lll, Sfc_shop_ticket.OP_NO AS op_no, Sfc_shop_ticket.ORDER_NO AS order_no, Sfc_shop_ticket.OTHER_HOURS AS other_hours, Sfc_shop_ticket.OUT_OP_COST AS out_op_cost, Sfc_shop_ticket.OUT_OP_UNIT AS out_op_unit, Sfc_shop_ticket.PLAN_HOURS AS plan_hours, Sfc_shop_ticket.PLAN_QTY AS plan_qty, Sfc_shop_ticket.RECORD_DATE AS record_date, Sfc_shop_ticket.REMARKS AS remarks, Sfc_shop_ticket.REMIND_QTY AS remind_qty, Sfc_shop_ticket.RUN_TIME AS run_time, Sfc_shop_ticket.RUN_UNIT AS run_unit, Sfc_shop_ticket.SCRAP_HOURS AS scrap_hours, Sfc_shop_ticket.SCRAP_QTY AS scrap_qty, Sfc_shop_ticket.SETUP_TIME AS setup_time, Sfc_shop_ticket.SHIFT AS shift, Sfc_shop_ticket.SHIFT_SEQ AS shift_seq, Sfc_shop_ticket.START_DATE AS start_date, Sfc_shop_ticket.WC_CODE AS wc_code FROM sfc_shop_ticket Sfc_shop_ticket  WHERE  (employee = ?) AND ( (CONVERT(datetime ,Sfc_shop_ticket.RECORD_DATE+ ' 00:00:00', 120) >= ?) AND (CONVERT(datetime ,Sfc_shop_ticket.RECORD_DATE+ ' 00:00:00', 120) <= ?) ) , binds: [gxj, Wed Mar 01 2017 00:00:00 GMT+0800 (中国标准时间), Tue Mar 07 2017 00:00:00 GMT+0800 (中国标准时间)]出错
java.sql.SQLException: 从字符串向 datetime 转换时失败。

我分析应该是stringToDate(Sfc_shop_ticket.record_date )在转化后台数据时出的问题CONVERT(datetime ,Sfc_shop_ticket.RECORD_DATE+ ' 00:00:00', 120)
我后台数据是“yyyy/mm/dd”格式,按道理应转化为CONVERT(datetime ,Sfc_shop_ticket.RECORD_DATE+ ' 00:00:00', 111),不知是否stringToDate缺陷,或者还有其它解决办法
回复 支持 反对

使用道具 举报

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
36064
发表于 2017-3-7 14:33:35 | 显示全部楼层
Sfc_shop_ticket.record_date不用转换
        var data2 = this.comp("data2");
                var date = data2.getValue("fDate");
                var data = this.comp("bizData1");
                 data.setFilter("filter2", "AP_RQ.fRQ = stringtoDate('" + date + "')");
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

16

主题

71

帖子

227

积分

中级会员

Rank: 3Rank: 3

积分
227
QQ
 楼主| 发表于 2017-3-7 14:55:49 | 显示全部楼层
jishuang 发表于 2017-3-7 14:33
Sfc_shop_ticket.record_date不用转换
        var data2 = this.comp("data2");
                var date ...

问题解决,多谢!请结帖
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-11-22 05:04 , Processed in 0.059921 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表