|
|
@@ -1,9 +1,13 @@
|
|
|
package org.springblade.manager.utils;
|
|
|
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.manager.entity.ChangeInventoryForm;
|
|
|
+import org.springblade.manager.vo.InventoryUnitChange;
|
|
|
import org.springblade.meter.entity.ChangeTokenForm;
|
|
|
import org.springblade.meter.entity.ChangeTokenInventory;
|
|
|
import org.springblade.meter.entity.ContractInventoryForm;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.dao.EmptyResultDataAccessException;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
@@ -15,14 +19,41 @@ import java.util.List;
|
|
|
public class InventoryUCUtil {
|
|
|
private static JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
- public static ContractInventoryForm getInventoryNum(Long contractFormId) {
|
|
|
+ @Autowired
|
|
|
+ public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
|
|
+ InventoryUCUtil.jdbcTemplate = jdbcTemplate;
|
|
|
+ }
|
|
|
+ //获取清单详情
|
|
|
+ public static ContractInventoryForm getInventory(Long contractFormId) {
|
|
|
String sql="select * from s_contract_inventory_form where id ="+contractFormId;
|
|
|
return jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<>(ContractInventoryForm.class));
|
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
|
|
- InventoryUCUtil.jdbcTemplate = jdbcTemplate;
|
|
|
+ //获取变更情况
|
|
|
+ public static ChangeInventoryForm getChangeForm(Long contractId, Long prePeriodId, String formNumber) {
|
|
|
+ String sql="select * from s_change_inventory_form where contract_id="+contractId+" and period_id="+prePeriodId+" and form_number='"+formNumber+"' and is_deleted=0";
|
|
|
+ try {
|
|
|
+ return jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<>(ChangeInventoryForm.class));
|
|
|
+ } catch (EmptyResultDataAccessException e) {
|
|
|
+ return null; // 或者返回默认值
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增或修改当前期 变更情况
|
|
|
+ public static void saveOrUpdate(List<InventoryUnitChange> dataList,Long contractId, Long periodId) {
|
|
|
+ for (InventoryUnitChange change : dataList) {
|
|
|
+ ChangeInventoryForm changeForm = getChangeForm(contractId, periodId, change.getFormNumber());
|
|
|
+ if(changeForm==null){
|
|
|
+ String insertSql = "INSERT INTO s_change_inventory_form(id,contract_id,period_id,form_number,item_name,change_total,change_money,after_change_total,after_change_money,is_deleted) VALUES(?,?,?,?,?,?,?,?,?,?)";
|
|
|
+ jdbcTemplate.update(insertSql, SnowFlakeUtil.getId(), contractId, periodId, change.getFormNumber(), change.getItemName(),
|
|
|
+ change.getChangePeriodUnit(), change.getChangePeriodAmount(), change.getChangeEndPeriodUnit(),
|
|
|
+ change.getChangeEndPeriodAmount(), 0);
|
|
|
+ }else {
|
|
|
+ String updateSql = "UPDATE s_change_inventory_form SET change_total=?, change_money=?, after_change_total=?, after_change_money=? WHERE id=?";
|
|
|
+ jdbcTemplate.update(updateSql, change.getChangePeriodUnit(), change.getChangePeriodAmount(),
|
|
|
+ change.getChangeEndPeriodUnit(), change.getChangeEndPeriodAmount(), changeForm.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 获取当前期变更令
|