Dataway 接口(DataQL语言)开发记录

hasor DataQL

1、 入参和出参的一一对应,注意逗号等符号的问题

2、 注意hint的引用,true或者false

3、 left join.....on ....的使用,多表的使用

4、 关于sop号的剪切和组合,对sop序列号上的日期月份进行自增自减操作

5、 where ismi.is_delete = false加上这一列,数据库的删除逻辑

6、 代表该参数为空的话就输出所有的。

<if test="sopPlanNo!=null and sopPlanNo!=''">
       and ismi.sop_plan_code = #{sopPlanNo}
   </if>

7、 最后的结果是.data()是否需要,是map还是直接返回,返回的形式

8、 返回的格式可能与hint有关,出现不一样的返回形式是可以查一下hint的内容

9、 sop序列号日期相关,interval后面的参数代表了增或减月份

to_char(to_date(substr(#{sopPlanNo},  5, 6), 'yyyymm') + interval '0 month', 'yyyymm') as month_0,

10、 dataway中百分比的计算

var ratio = @@mybatis(forecastsupplyResult, differenceResult)<%
    <select>
        select (case when #{forecastsupplyResult}=0 then '/' else round(#{differenceResult}*100::numeric/(#{forecastsupplyResult}), 2)||'%' end)
    </select>
    %>;

11、 本月之前最近一期sop号的计算

var lastSop = @@mybatis(sopPlanNo)<%
        <select>
            select ipldi.sop_plan_no 
            from isc_product_line_demand_info ipldi
            where ipldi.sop_plan_no < (substr(#{sopPlanNo},  1, 10) || '001')
            ORDER BY sop_plan_no 
            DESC LIMIT 1
        </select>
    %>;

12、 联表基础信息表时,避免存在脏数据,进行过滤操作

LEFT JOIN (select DISTINCT number, name from md_operate_organize where is_delete = false) mdo on mdo."number" = issp.factory

13、 树结构传参为分类编码(物料分类编码和bpart分类编码)时,分类

<if test="bpartClassCode!=null and bpartClassCode!=''">
     and  issp.bpart in (select product_code from md_bpart_product_base_info where product_class_code = #{bpartClassCode})
</if>

14、 输入筛选框模糊匹配

<if test="bpart!=null and bpart!=''">
    and  icri.bpart  like  '%' || #{bpart} || '%'
</if>

15、 判断列表查询是否为空的情况

var lastSop = @@mybatis(sopPlanNo)<%
        <select>
            select issp.sop_plan_no 
            from isc_safety_stock_plan issp
            where issp.sop_plan_no < (substr(#{sopPlanNo},  1, 10) || '001')
            ORDER BY sop_plan_no 
            DESC LIMIT 1
        </select>
    %>;

var sopList = lastSop(${sopPlanNo});
var sopData = collect.filter(sopList, (dat) -> { return dat.sop_plan_no != null; });