|
@@ -7,7 +7,10 @@ import com.mixsmart.utils.FormulaUtils;
|
|
|
import com.mixsmart.utils.StringUtils;
|
|
|
import lombok.Data;
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springblade.common.utils.BaseUtils;
|
|
|
+import org.springblade.manager.dto.FormEndPayDTO;
|
|
|
+import org.springblade.manager.utils.PeriodContractUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
@@ -17,12 +20,16 @@ import org.springblade.core.tool.utils.StringPool;
|
|
|
import org.springblade.manager.dto.ElementData;
|
|
|
import org.springblade.manager.dto.FormData;
|
|
|
import org.springblade.manager.dto.TreeNode;
|
|
|
+import org.springblade.manager.entity.FormEndPay;
|
|
|
import org.springblade.manager.formula.ElementWriter;
|
|
|
import org.springblade.manager.formula.NodeTable;
|
|
|
+import org.springblade.manager.service.impl.FormEndPayServiceImpl;
|
|
|
+import org.springblade.manager.utils.FormEndPayUtil;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
+import org.springblade.meter.entity.ContractMeterPeriod;
|
|
|
import org.springblade.meter.entity.InterimPayCertificateItem;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
-
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
@@ -32,7 +39,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.function.*;
|
|
|
-import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
@@ -41,6 +47,7 @@ import java.util.stream.IntStream;
|
|
|
* @Date 2023/12/19 17:40
|
|
|
* @description 计量相关报表计算
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@EqualsAndHashCode(callSuper = true)
|
|
|
@Data
|
|
|
public class ExecutorMeter extends FormulaExecutor {
|
|
@@ -1591,6 +1598,7 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
@Data
|
|
|
@EqualsAndHashCode(callSuper = true)
|
|
|
public class SubIPaySum extends BaseSpecial<SubprojectInterimPaymentSummary> implements Special{
|
|
|
+ private FormEndPayServiceImpl formEndPayService;
|
|
|
/*分项工程中期支付汇总表*/
|
|
|
@Override
|
|
|
public boolean ready() {
|
|
@@ -1682,15 +1690,40 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
|
|
|
/*分项工程中期支付汇总表*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public void parse() {
|
|
|
- builderFormDatas(SubprojectInterimPaymentSummary.class);
|
|
|
+ FormEndPayDTO dto = PeriodContractUtil.get();
|
|
|
+ //本期期数ID
|
|
|
+ Long periodId=dto.getPeriodId();
|
|
|
+ //合同段ID
|
|
|
+ Long contractId=dto.getContractId();
|
|
|
+ //项目ID
|
|
|
+ Long projectId=dto.getProjectId();
|
|
|
+ PeriodContractUtil.clear();
|
|
|
+ //上期期数ID
|
|
|
+ Long prePeriodId = null;
|
|
|
+ List<ContractMeterPeriod> list =FormEndPayUtil.selectList(contractId);
|
|
|
+ if(list.size()>0){
|
|
|
+ OptionalInt index=IntStream.range(0, list.size())
|
|
|
+ .filter(i -> list.get(i).getId().equals(periodId))
|
|
|
+ .findFirst();
|
|
|
+ //i大于0 说明需要有上期
|
|
|
+ if(index.isPresent()){
|
|
|
+ int j = index.getAsInt();
|
|
|
+ if(j>0){
|
|
|
+ prePeriodId=list.get(j-1).getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Long finalPrePeriodId = prePeriodId;
|
|
|
+ builderFormDatas(SubprojectInterimPaymentSummary.class);
|
|
|
LinkedHashMap<String,Summary> endSummary = toSummary(paymentsPeriodEnd);
|
|
|
LinkedHashMap<String,Summary> preSummary = toSummary(previous);
|
|
|
LinkedHashMap<String,Summary> curSummary = toSummary(current);
|
|
|
List<SubprojectInterimPaymentSummary> totalList = new ArrayList<>();
|
|
|
/* List<String> numbers= paymentsPeriodEnd.stream().map(Payment::getNumber).distinct().collect(Collectors.toList());*/
|
|
|
LinkedHashMap<String,InventoryForm> numbersGroup= tec.meterInfo.getInventoryForms().stream().filter(e->!tec.meterInfo.getChapter().contains(e)&&StringUtils.isNotEquals(0,e.getParentId())).collect(Collectors.toMap(InventoryForm::getFormNumber,e->e,(v1,v2)->v1,LinkedHashMap::new));
|
|
|
- numbersGroup.forEach((number,itf)->{
|
|
|
+ numbersGroup.forEach((number, itf)->{
|
|
|
SubprojectInterimPaymentSummary sis = new SubprojectInterimPaymentSummary();
|
|
|
/*上期汇总*/
|
|
|
Summary pre =preSummary.get(number);
|
|
@@ -1705,7 +1738,7 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
sis.setContractMoney(itf.getContractMoney());
|
|
|
sis.setChangeMoney(itf.getChangeMoney());
|
|
|
sis.setPrice(itf.getBidPrice());
|
|
|
- if(sis.getFormNumber().equals("405-4")){
|
|
|
+ if(sis.getFormNumber().equals("202-3-3")){
|
|
|
System.out.println("111");
|
|
|
}
|
|
|
/*只要存在累计就显示*/
|
|
@@ -1744,15 +1777,45 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
sis.setPreviousPeriodPay(pre.getMoney().toPlainString());
|
|
|
sis.setPreviousPeriodCompleted(pre.getCompleted().toPlainString());
|
|
|
}
|
|
|
+ if(finalPrePeriodId !=null){
|
|
|
+ FormEndPay preFormEndPay = FormEndPayUtil.selectFoemEndPay(finalPrePeriodId,contractId,sis.getFormNumber());
|
|
|
+ if(ObjectUtil.isNotEmpty(preFormEndPay)){
|
|
|
+ if (preFormEndPay.getCurrentPeriodEndPay() != null) {
|
|
|
+ sis.setPreviousPeriodPay(preFormEndPay.getCurrentPeriodEndPay().toPlainString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
sis.setCompleted(end.getCompleted().toPlainString());
|
|
|
//本期汇总的到本期末完成 //原来=(本期末汇总的本期支付金额) 现在=(上期末汇总的到本期末金额+本期汇总的金额)
|
|
|
BigDecimal add;
|
|
|
if(sis.getCurrentPeriodPay()!=null&&sis.getPreviousPeriodPay()!=null){
|
|
|
add= new BigDecimal(sis.getCurrentPeriodPay()).add(new BigDecimal(sis.getPreviousPeriodPay()));
|
|
|
- }else {
|
|
|
+ }else if(sis.getCurrentPeriodPay() != null){
|
|
|
+ add=new BigDecimal(sis.getCurrentPeriodPay());
|
|
|
+ }else if(sis.getPreviousPeriodPay() != null){
|
|
|
+ add=new BigDecimal(sis.getPreviousPeriodPay());
|
|
|
+ } else {
|
|
|
add=end.getMoney();
|
|
|
}
|
|
|
sis.setCurrentPeriodEndPay(add.toPlainString());
|
|
|
+ FormEndPay formEndPay =FormEndPayUtil.selectFoemEndPay(periodId,contractId, sis.getFormNumber());
|
|
|
+ if(ObjectUtil.isNotEmpty(formEndPay)){
|
|
|
+ if(!add.equals(formEndPay.getCurrentPeriodEndPay())){
|
|
|
+ formEndPay.setCurrentPeriodEndPay(add);
|
|
|
+ FormEndPayUtil.updateFormEndPay(formEndPay);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(!BigDecimal.ZERO.equals(add)){
|
|
|
+ formEndPay=new FormEndPay();
|
|
|
+ formEndPay.setId(SnowFlakeUtil.getId());
|
|
|
+ formEndPay.setProjectId(projectId);
|
|
|
+ formEndPay.setPeriodId(periodId);
|
|
|
+ formEndPay.setContractId(contractId);
|
|
|
+ formEndPay.setFormNumber(sis.getFormNumber());
|
|
|
+ formEndPay.setCurrentPeriodEndPay(add);
|
|
|
+ FormEndPayUtil.insertFormEndPay(formEndPay);
|
|
|
+ }
|
|
|
+ }
|
|
|
BigDecimal percent= BaseUtils.str2BigDecimal(ratioFc.apply(sis.getCurrentPeriodEndPay(), sis.getChangeMoney()));
|
|
|
if(BigDecimal.ZERO.compareTo(percent)<0) {
|
|
|
/*百分比大于零才显示*/
|