|
|
@@ -12,7 +12,11 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Component
|
|
|
@@ -120,6 +124,21 @@ public class InventoryUCUtil {
|
|
|
return jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ChangeInventoryForm.class));
|
|
|
}
|
|
|
|
|
|
+ public static BigDecimal selectChangeMoney(List<Long> idList, String k) {
|
|
|
+ if (idList == null || idList.isEmpty()) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ String placeholders = String.join(",", Collections.nCopies(idList.size(), "?"));
|
|
|
+ String sql = "select sum(change_money) from s_change_inventory_form where period_id in (" + placeholders + ") and inventory_num=?";
|
|
|
+ List<Object> params = new ArrayList<>();
|
|
|
+ params.addAll(idList);
|
|
|
+ params.add(k);
|
|
|
+ List<BigDecimal> result = jdbcTemplate.query(sql, params.toArray(), (rs, rowNum) -> rs.getBigDecimal(1));
|
|
|
+ BigDecimal sum = result.isEmpty() || result.get(0) == null ? BigDecimal.ZERO : result.get(0);
|
|
|
+ // 四舍五入保留整数
|
|
|
+ return sum.setScale(0, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
@Autowired
|
|
|
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
|
|
InventoryUCUtil.jdbcTemplate = jdbcTemplate;
|