rtmatWkoutdService.list(new QueryWrapper<RtmatWkoutd>().eq("spid", matter.getWkoutid()).eq("sMatID", labMat.getSmatid()).eq("irowtype", 2).lambda().apply("and nqty-(nAddOutQty+nreturnqty)>0"));com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'and' 附近有语法错误。
时间: 2023-06-12 16:05:46 浏览: 35
根据错误提示,查询语句中的 'and' 附近有语法错误。请确保查询语句的正确性,比如检查括号是否匹配、关键字是否正确使用等。另外,也可以尝试将 lambda 表达式中的 apply() 方法移动到 lambda 表达式的外面,例如:
```
rtmatWkoutdService.list(new QueryWrapper<RtmatWkoutd>()
.eq("spid", matter.getWkoutid())
.eq("sMatID", labMat.getSmatid())
.eq("irowtype", 2)
.lambda()
.and(q -> q.gt("nqty-(nAddOutQty+nreturnqty)", 0))
);
```
这里使用了 QueryWrapper 的 and() 方法来添加条件,传入一个 Lambda 表达式来构造查询条件。在 Lambda 表达式中,使用 gt() 方法添加大于条件。注意,这里的加号应该写成 "+nreturnqty",而不是 "nreturnqty"。
相关问题
List<SpFinancialInfo> spFinancialInfos = new ArrayList<>(); for (Long financialId : financialIds) { SpFinancialInfo spFinancialInfo = new SpFinancialInfo(); spFinancialInfo.setFinancialId(financialId); spFinancialInfo.setSpId(spId); spFinancialInfo.setCreateTime(new Date()); spFinancialInfo.setUpdateTime(new Date()); spFinancialInfos.add(spFinancialInfo);
这段代码的作用是创建一个空的 `List<SpFinancialInfo>` 对象,并且通过 `for` 循环遍历 `financialIds` 集合中的每一个 `Long` 类型的元素。在循环体内,创建一个新的 `SpFinancialInfo` 对象,设置其 `financialId`、`spId`、`createTime` 和 `updateTime` 属性值,然后将其添加到 `spFinancialInfos` 列表中。这段代码的目的是将一组 `financialIds` 与一个 `spId` 关联起来,生成多个 `SpFinancialInfo` 对象,并将它们存储在一个列表中。
while (rs.next()) { application.setAttribute("id", rs.getString("spid")); application.setAttribute("goods_name", rs.getString("itemname")); application.setAttribute("goodspic", rs.getString("price")); //application.setAttribute("blob", rs.getString("blob")); %> <tr> <td width = "100px" height = "42px"> <input name="one" type="checkbox" onclick="myOne()"/> </label> </td> <td width = "135px" height = "42px"><%=application.getAttribute("id") %></td> <td width = "150px" height = "42px"><%=application.getAttribute("goods_name")%></td> <td width = "150px" height = "42px" id="price"> <img src="yuan.jpg" width="20" heigth="20"> <%=application.getAttribute("goodspic")%> </td> <td width = "240px" height = "42px" id="car"> <input type="button" class="decrease" value="-"> <input type="text" class="quantity" value="1"/> <input type="button" class="increase" value="+"> </td> <td width = "135px" height = "42px"> <input type="button" class="deldet" value="删除此商品"> </td> </tr> <% } %>根据以上代码编写购物车价格总计并当页显示
可以在代码中加入以下部分来实现购物车价格总计并当页显示:
```
<%
double total = 0;
ResultSet rs = ... // 数据库查询代码
while (rs.next()) {
// ... 数据库查询结果处理代码
double price = Double.parseDouble((String)application.getAttribute("goodspic"));
total += price;
// ... HTML代码
}
%>
<tr>
<td colspan="3"></td>
<td>总计:</td>
<td colspan="2"><%= total %></td>
</tr>
```
其中,`total` 变量用来存储购物车中所有商品的价格总和,`price` 变量用来存储当前商品的价格,`Double.parseDouble()` 方法用来将字符串类型的价格转换为浮点数类型。在 HTML 代码中,使用 `<td>` 元素来显示总计价格。这里使用了 `colspan` 属性来让总计这一行占据两列,以便居中显示。