Commit 419cf3a8 by HlQ

[add]

1.添加 inet 类型处理器
2.合同付款方式添加新类型
[chg] 修改合同更新时,合同金额计算的顺序
1 parent d11e61c6
package vion.config.mp;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedTypes;
import org.postgresql.util.PGobject;
import java.lang.reflect.Field;
import java.sql.PreparedStatement;
import java.sql.SQLException;
/**
* @author vion
* @date 2024/10/23
*/
@MappedTypes({Object.class})
public class InetTypeHandler extends JacksonTypeHandler {
public InetTypeHandler(Class<?> type) {
super(type);
}
public InetTypeHandler(Class<?> type, Field field) {
super(type, field);
}
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
if (ps != null) {
PGobject jsonObject = new PGobject();
jsonObject.setType("inet");
jsonObject.setValue(parameter.toString());
ps.setObject(i, jsonObject);
}
}
}
...@@ -5,20 +5,25 @@ import org.apache.ibatis.type.JdbcType; ...@@ -5,20 +5,25 @@ import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedTypes; import org.apache.ibatis.type.MappedTypes;
import org.postgresql.util.PGobject; import org.postgresql.util.PGobject;
import java.lang.reflect.Field;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
@MappedTypes({Object.class}) @MappedTypes({Object.class})
public class JsonbTypeHandler extends JacksonTypeHandler { public class JsonbTypeHandler extends JacksonTypeHandler {
private static final PGobject jsonObject = new PGobject();
public JsonbTypeHandler(Class<?> type) { public JsonbTypeHandler(Class<?> type) {
super(type); super(type);
} }
public JsonbTypeHandler(Class<?> type, Field field) {
super(type, field);
}
@Override @Override
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException { public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
if (ps != null) { if (ps != null) {
PGobject jsonObject = new PGobject();
jsonObject.setType("jsonb"); jsonObject.setType("jsonb");
jsonObject.setValue(toJson(parameter)); jsonObject.setValue(toJson(parameter));
ps.setObject(i, jsonObject); ps.setObject(i, jsonObject);
......
...@@ -399,6 +399,24 @@ public class ContractRunner { ...@@ -399,6 +399,24 @@ public class ContractRunner {
contractMaintainPayment3.setPaymentRatio(Opt.ofNullable(contract.getMaintainRatio3()).orElse(BigDecimal.ZERO)); contractMaintainPayment3.setPaymentRatio(Opt.ofNullable(contract.getMaintainRatio3()).orElse(BigDecimal.ZERO));
contractMaintainPayment3.setPaymentDate(contract.getMaintainDate3()); contractMaintainPayment3.setPaymentDate(contract.getMaintainDate3());
contractPaymentList.add(contractMaintainPayment3); contractPaymentList.add(contractMaintainPayment3);
// 维保进度款
ContractPayment maintainProgressPayment = new ContractPayment();
maintainProgressPayment.setId(contractId2PaymentMap.getOrDefault(contract.getId(), new HashMap<>()).get(7));
maintainProgressPayment.setContractId(contract.getId());
maintainProgressPayment.setPaymentType(9);
maintainProgressPayment.setPaymentRatio(Opt.ofNullable(contract.getMaintainProgressRatio()).orElse(BigDecimal.ZERO));
maintainProgressPayment.setPaymentDate(contract.getMaintainDate2());
contractPaymentList.add(maintainProgressPayment);
// 维保验收款
ContractPayment maintainAcceptancePayment = new ContractPayment();
maintainAcceptancePayment.setId(contractId2PaymentMap.getOrDefault(contract.getId(), new HashMap<>()).get(8));
maintainAcceptancePayment.setContractId(contract.getId());
maintainAcceptancePayment.setPaymentType(10);
maintainAcceptancePayment.setPaymentRatio(Opt.ofNullable(contract.getMaintainAcceptanceRatio()).orElse(BigDecimal.ZERO));
maintainAcceptancePayment.setPaymentDate(contract.getMaintainDate3());
contractPaymentList.add(maintainAcceptancePayment);
} }
contractPaymentService.saveOrUpdateBatch(contractPaymentList); contractPaymentService.saveOrUpdateBatch(contractPaymentList);
} }
......
...@@ -303,8 +303,8 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont ...@@ -303,8 +303,8 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
Long contractId = existContract.getId(); Long contractId = existContract.getId();
String existContractNo = existContract.getContractNo(); String existContractNo = existContract.getContractNo();
contract.setId(contractId); contract.setId(contractId);
contractPaymentService.calMoney(existContract, contract);
if (this.updateById(contract)) { if (this.updateById(contract)) {
contractPaymentService.calMoney(existContract, contract);
Opt.ofNullable(dto.getNodeDate()) Opt.ofNullable(dto.getNodeDate())
.ifPresent(date -> contractPaymentService.lambdaUpdate() .ifPresent(date -> contractPaymentService.lambdaUpdate()
.set(ContractPayment::getNodeDate, date) .set(ContractPayment::getNodeDate, date)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!