欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 艺术 > mysql -小计

mysql -小计

2024/11/30 8:34:35 来源:https://blog.csdn.net/weixin_42012939/article/details/142084932  浏览:    关键词:mysql -小计

在这里插入图片描述
//表单某字段值为当前打开文档Id
(function () {
var rdoc = getRelateDocument();
var warehouseName = rdoc.getItemValueAsString(“warehouseName”);
var name = rdoc.getItemValueAsString(“name”);
var color = rdoc.getItemValueAsString(“color”);
var batchNumber = rdoc.getItemValueAsString(“batchNumber”);
var domainid = getDomainid();//获取当前登录用户所属的企业域ID
var sql = “”;
var sql1 = “”;
var sql2 = “”;
var where = “”;

if ((warehouseName != null && !"".equals(warehouseName)) || (name != null && !"".equals(name)) || (color != null && !"".equals(color)) || (batchNumber != null && !"".equals(batchNumber))) {if (isNotNull(warehouseName)) {var strw = warehouseName.replace(';', ',');var str = /,$/.test(strw);if (str == true) {strw = strw.substring(0, strw.lastIndexOf(','));}println('strs=='+strw.substring(0, 1).equals(","));if(strw.substring(0, 1).equals(",")){strw=strw.slice(1)}where += " and ITEM_WAREHOUSE in (" + strw + ")"}if (isNotNull(name)) {where += " and ITEM_COMMODITYNAME='" + name + "'"}if (isNotNull(color)) {where += " and item_颜色='" + color + "'"}if (isNotNull(batchNumber)) {where += " and item_batch like '%" + batchNumber + "%'"}
} else {where += " and  1>1 ";
}
//库存查询
sql1 += " select CREATED,id,DOMAINID,ITEM_COMMODITYNAME,'0' as ITEM_SCOUNT,ITEM_WAREHOUSE,(select ITEM_WAREHOUSENAME from tlk_warehouseinformation where DOMAINID='" + domainid + "' and ITEM_WAREHOUSENO=c.ITEM_WAREHOUSE limit 1) as item_warehouseName, item_颜色,item_batch,SUM(ITEM_INVENTORYQUANTITY) as item_sumCount,SUM(ITEM_入库条数) as item_items  from  tlk_Commodity_Inventory c where   DOMAINID='" + domainid + "' "+where+" GROUP BY item_颜色,item_batch,ITEM_COMMODITYNAME,ITEM_WAREHOUSE  ";
//库存查询(汇总)
sql2 += " select CREATED,id,DOMAINID,ITEM_COMMODITYNAME,'1' as ITEM_SCOUNT,'' as ITEM_WAREHOUSE,'小计:' as item_warehouseName, '' as item_颜色,'' as item_batch,SUM(ITEM_INVENTORYQUANTITY) as item_sumCount,SUM(ITEM_入库条数) as item_items  from  tlk_Commodity_Inventory c where   DOMAINID='" + domainid + "' "+where+" GROUP BY ITEM_COMMODITYNAME  ";sql = "select * from (select * from (" + sql1 + ") t1  UNION ALL select * from (" + sql2 + ") t2 ) as g ORDER BY g.ITEM_COMMODITYNAME DESC,ITEM_SCOUNT  ";return sql;

})()

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com