将单据明细中直接的SQL拼接替换为预编译语句

This commit is contained in:
jishenghua
2026-01-30 10:58:35 +08:00
parent e27a424850
commit b8758fb3f2
4 changed files with 13 additions and 13 deletions

View File

@@ -1062,7 +1062,7 @@ public class DepotItemController {
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
String message = ""; String message = "";
try { try {
String barCodes = ""; List<String> barCodeList = new ArrayList<>();
//文件扩展名只能为xls //文件扩展名只能为xls
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
if(StringUtil.isNotEmpty(fileName)) { if(StringUtil.isNotEmpty(fileName)) {
@@ -1118,12 +1118,9 @@ public class DepotItemController {
materialMap.put("taxRate", taxRate); materialMap.put("taxRate", taxRate);
materialMap.put("remark", remark); materialMap.put("remark", remark);
detailList.add(materialMap); detailList.add(materialMap);
barCodes += "'" + barCode + "',"; barCodeList.add(barCode);
} }
if (StringUtil.isNotEmpty(barCodes)) { JSONObject map = depotItemService.parseMapByExcelData(barCodeList, detailList, prefixNo);
barCodes = barCodes.substring(0, barCodes.length() - 1);
}
JSONObject map = depotItemService.parseMapByExcelData(barCodes, detailList, prefixNo);
if (map != null) { if (map != null) {
res.code = 200; res.code = 200;
} else { } else {

View File

@@ -252,7 +252,7 @@ public interface DepotItemMapperEx {
@Param("batchNumber") String batchNumber); @Param("batchNumber") String batchNumber);
List<MaterialVo4Unit> getBillItemByParam( List<MaterialVo4Unit> getBillItemByParam(
@Param("barCodes") String barCodes); @Param("barCodeList") List<String> barCodeList);
BigDecimal getCurrentStockByParam( BigDecimal getCurrentStockByParam(
@Param("depotId") Long depotId, @Param("depotId") Long depotId,

View File

@@ -1341,10 +1341,10 @@ public class DepotItemService {
return depotItemMapperEx.getCountByMaterialAndDepot(mId, depotId); return depotItemMapperEx.getCountByMaterialAndDepot(mId, depotId);
} }
public JSONObject parseMapByExcelData(String barCodes, List<Map<String, String>> detailList, String prefixNo) throws Exception { public JSONObject parseMapByExcelData(List<String> barCodeList, List<Map<String, String>> detailList, String prefixNo) throws Exception {
JSONObject map = new JSONObject(); JSONObject map = new JSONObject();
JSONArray arr = new JSONArray(); JSONArray arr = new JSONArray();
List<MaterialVo4Unit> list = depotItemMapperEx.getBillItemByParam(barCodes); List<MaterialVo4Unit> list = depotItemMapperEx.getBillItemByParam(barCodeList);
Map<String, MaterialVo4Unit> materialMap = new HashMap<>(); Map<String, MaterialVo4Unit> materialMap = new HashMap<>();
Map<String, Long> depotMap = new HashMap<>(); Map<String, Long> depotMap = new HashMap<>();
for (MaterialVo4Unit material: list) { for (MaterialVo4Unit material: list) {

View File

@@ -1122,8 +1122,11 @@
from jsh_material m from jsh_material m
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1' left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
where 1=1 where 1=1
<if test="barCodes != null"> <if test="barCodeList.size()>0">
and me.bar_code in (${barCodes}) and me.bar_code in
<foreach collection="barCodeList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if> </if>
and ifnull(m.delete_flag,'0') !='1' and ifnull(m.delete_flag,'0') !='1'
order by m.id desc order by m.id desc
@@ -1134,10 +1137,10 @@
from jsh_material_current_stock from jsh_material_current_stock
where 1=1 where 1=1
<if test="depotId != null"> <if test="depotId != null">
and depot_id = ${depotId} and depot_id = #{depotId}
</if> </if>
<if test="mId != null"> <if test="mId != null">
and material_id = ${mId} and material_id = #{mId}
</if> </if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
</select> </select>