@@ -1,10 +1,14 @@ | |||||
package com.ningdatech.pmapi.gov.convert; | package com.ningdatech.pmapi.gov.convert; | ||||
import cn.hutool.core.bean.BeanUtil; | import cn.hutool.core.bean.BeanUtil; | ||||
import cn.hutool.core.collection.CollUtil; | |||||
import com.ningdatech.pmapi.gov.model.dto.*; | import com.ningdatech.pmapi.gov.model.dto.*; | ||||
import com.ningdatech.pmapi.gov.model.req.*; | import com.ningdatech.pmapi.gov.model.req.*; | ||||
import java.util.Collections; | |||||
import java.util.List; | |||||
import java.util.Objects; | import java.util.Objects; | ||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* @Classname ProjectConvert | * @Classname ProjectConvert | ||||
@@ -26,12 +30,24 @@ public class ProjectConvert { | |||||
req.setApprove(convertApprove(saveDTO.getApprove())); | req.setApprove(convertApprove(saveDTO.getApprove())); | ||||
req.setCimplement(convertCimplement(saveDTO.getCimplement())); | req.setCimplement(convertCimplement(saveDTO.getCimplement())); | ||||
req.setMimplement(convertMimplement(saveDTO.getMimplement())); | req.setMimplement(convertMimplement(saveDTO.getMimplement())); | ||||
req.setProcure(convertProcure(saveDTO.getProcure())); | |||||
req.setProcures(convertProcures(saveDTO.getProcures())); | |||||
return req; | return req; | ||||
} | } | ||||
private static ProjectProcureReq convertProcure(GovBizProjectProcureDTO procure) { | |||||
ProjectProcureReq req = BeanUtil.copyProperties(procure,ProjectProcureReq.class); | |||||
private static List<ProjectProcureReq> convertProcures(List<GovBizProjectProcureDTO> procures) { | |||||
if(CollUtil.isEmpty(procures)){ | |||||
return Collections.emptyList(); | |||||
} | |||||
List<ProjectProcureReq> req = procures.stream() | |||||
.map(p -> { | |||||
ProjectProcureReq r = BeanUtil.copyProperties(p, ProjectProcureReq.class); | |||||
if(Objects.nonNull(p.getId())){ | |||||
r.setTongID(p.getId().intValue()); | |||||
} | |||||
return r; | |||||
}) | |||||
.collect(Collectors.toList()); | |||||
return req; | return req; | ||||
} | } | ||||
@@ -189,12 +189,13 @@ public class GovProjectCollectionManage { | |||||
} | } | ||||
//5.最后查询采购信息 | //5.最后查询采购信息 | ||||
GovBizProjectProcure procure = procureService.getOne(Wrappers.lambdaQuery(GovBizProjectProcure.class) | |||||
List<GovBizProjectProcure> procures = procureService.list(Wrappers.lambdaQuery(GovBizProjectProcure.class) | |||||
.eq(GovBizProjectProcure::getBaseProjId, projId) | .eq(GovBizProjectProcure::getBaseProjId, projId) | ||||
.orderByDesc(GovBizProjectProcure::getBizTime) | |||||
.last(BizConst.LIMIT_1)); | |||||
if(Objects.nonNull(procure)){ | |||||
res.setProcure(BeanUtil.copyProperties(procure, GovBizProjectProcureVO.class)); | |||||
.orderByDesc(GovBizProjectProcure::getBizTime)); | |||||
if(CollUtil.isNotEmpty(procures)){ | |||||
res.setProcures(procures.stream() | |||||
.map(p -> BeanUtil.copyProperties(p, GovBizProjectProcureVO.class)) | |||||
.collect(Collectors.toList())); | |||||
} | } | ||||
return res; | return res; | ||||
@@ -329,27 +330,31 @@ public class GovProjectCollectionManage { | |||||
} | } | ||||
// 6.保存 采购信息 | // 6.保存 采购信息 | ||||
GovBizProjectProcureDTO procure = saveDTO.getProcure(); | |||||
procure.setBaseProjId(baseProjId); | |||||
procure.setBaseProjName(baseProjName); | |||||
if(Objects.nonNull(procure)){ | |||||
GovBizProjectProcure oldProcure = procureService.getOne(Wrappers.lambdaQuery(GovBizProjectProcure.class) | |||||
.eq(GovBizProjectProcure::getBaseProjId, baseProjId) | |||||
.last(BizConst.LIMIT_1)); | |||||
List<GovBizProjectProcureDTO> procures = saveDTO.getProcures(); | |||||
for(GovBizProjectProcureDTO procure : procures){ | |||||
procure.setBaseProjId(baseProjId); | |||||
procure.setBaseProjName(baseProjName); | |||||
GovBizProjectProcure saveProcure = BeanUtil.copyProperties(procure,GovBizProjectProcure.class); | GovBizProjectProcure saveProcure = BeanUtil.copyProperties(procure,GovBizProjectProcure.class); | ||||
saveProcure.setBaseProjId(baseProjId); | saveProcure.setBaseProjId(baseProjId); | ||||
if(Objects.nonNull(oldProcure)){ | |||||
saveProcure.setId(oldProcure.getId()); | |||||
if(Objects.nonNull(saveBase.getBaseAreaCode())){ | |||||
saveProcure.setAreaCode(saveBase.getBaseAreaCode()); | |||||
} | |||||
if(Objects.isNull(procure.getId())){ | |||||
saveProcure.setTongTime(LocalDateTime.now()); | |||||
}else{ | }else{ | ||||
if(Objects.nonNull(saveBase.getBaseAreaCode())){ | |||||
saveProcure.setAreaCode(saveBase.getBaseAreaCode()); | |||||
//如果是修改 那就看下库里是否有 | |||||
Long id = saveProcure.getId(); | |||||
GovBizProjectProcure old = procureService.getById(id); | |||||
if(Objects.isNull(old)){ | |||||
saveProcure.setId(null); | |||||
} | } | ||||
saveProcure.setTongTime(LocalDateTime.now()); | |||||
} | } | ||||
procureService.saveOrUpdate(saveProcure); | procureService.saveOrUpdate(saveProcure); | ||||
} | } | ||||
//7. 推送数据 | //7. 推送数据 | ||||
pushProject(saveDTO); | pushProject(saveDTO); | ||||
@@ -23,6 +23,9 @@ public class GovBizProjectProcureDTO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
@ApiModelProperty("id") | |||||
private Long id; | |||||
@ApiModelProperty("项目编号") | @ApiModelProperty("项目编号") | ||||
private String baseProjId; | private String baseProjId; | ||||
@@ -6,6 +6,7 @@ import lombok.Data; | |||||
import javax.validation.constraints.NotBlank; | import javax.validation.constraints.NotBlank; | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
import java.util.List; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
@@ -43,5 +44,5 @@ public class GovBizProjectSaveDTO implements Serializable { | |||||
private GovBizProjectMimplementDTO mimplement; | private GovBizProjectMimplementDTO mimplement; | ||||
@ApiModelProperty("项目采购信息") | @ApiModelProperty("项目采购信息") | ||||
private GovBizProjectProcureDTO procure; | |||||
private List<GovBizProjectProcureDTO> procures; | |||||
} | } |
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel; | |||||
import lombok.Data; | import lombok.Data; | ||||
import javax.validation.constraints.NotNull; | import javax.validation.constraints.NotNull; | ||||
import java.util.List; | |||||
/** | /** | ||||
* @Classname ProjectPushReq | * @Classname ProjectPushReq | ||||
@@ -28,5 +29,5 @@ public class ProjectPushReq { | |||||
private ProjectMimplementReq mimplement; | private ProjectMimplementReq mimplement; | ||||
private ProjectProcureReq procure; | |||||
private List<ProjectProcureReq> procures; | |||||
} | } |
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
import lombok.Data; | import lombok.Data; | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
import java.util.List; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
@@ -41,5 +42,5 @@ public class GovBizProjectDetailVO implements Serializable { | |||||
private GovBizProjectMimplementVO mimplement; | private GovBizProjectMimplementVO mimplement; | ||||
@ApiModelProperty("项目采购信息") | @ApiModelProperty("项目采购信息") | ||||
private GovBizProjectProcureVO procure; | |||||
private List<GovBizProjectProcureVO> procures; | |||||
} | } |
@@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.List; | |||||
import java.util.Objects; | import java.util.Objects; | ||||
/** | /** | ||||
@@ -127,16 +128,19 @@ public class ProjectReceiveManage { | |||||
} | } | ||||
// 6.保存 采购信息 | // 6.保存 采购信息 | ||||
ProjectProcure procure = dto.getProcure(); | |||||
if(Objects.nonNull(procure)){ | |||||
ProjectProcure oldProcure = procureService.getOne(Wrappers.lambdaQuery(ProjectProcure.class) | |||||
.eq(ProjectProcure::getBaseProjId, baseProjId) | |||||
.last(BizConst.LIMIT_1)); | |||||
List<ProjectProcure> procures = dto.getProcures(); | |||||
for(ProjectProcure procure : procures){ | |||||
ProjectProcure saveProcure = BeanUtil.copyProperties(procure,ProjectProcure.class); | ProjectProcure saveProcure = BeanUtil.copyProperties(procure,ProjectProcure.class); | ||||
saveProcure.setBaseProjId(baseProjId); | saveProcure.setBaseProjId(baseProjId); | ||||
if(Objects.isNull(oldProcure)){ | |||||
if(Objects.isNull(saveProcure.getTongID())){ | |||||
saveProcure.setTongTime(LocalDateTime.now()); | saveProcure.setTongTime(LocalDateTime.now()); | ||||
}else{ | |||||
//如果是修改 那就看下库里是否有 | |||||
Integer tongId = saveProcure.getTongID(); | |||||
ProjectProcure old = procureService.getById(tongId); | |||||
if(Objects.isNull(old)){ | |||||
saveProcure.setTongID(null); | |||||
} | |||||
} | } | ||||
saveProcure.setBizTime(LocalDateTime.now()); | saveProcure.setBizTime(LocalDateTime.now()); | ||||
procureService.saveOrUpdate(saveProcure); | procureService.saveOrUpdate(saveProcure); | ||||
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel; | |||||
import lombok.Data; | import lombok.Data; | ||||
import javax.validation.constraints.NotNull; | import javax.validation.constraints.NotNull; | ||||
import java.util.List; | |||||
/** | /** | ||||
* @Classname ProjectSaveDTO | * @Classname ProjectSaveDTO | ||||
@@ -29,5 +30,5 @@ public class ProjectSaveDTO { | |||||
private ProjectMimplement mimplement; | private ProjectMimplement mimplement; | ||||
private ProjectProcure procure; | |||||
private List<ProjectProcure> procures; | |||||
} | } |