mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-07-25 15:17:06 +08:00
feat(CoalInfoService): update ymDetails in CoalWashingDailyAnalysisEntity with new name and code
This commit is contained in:
@@ -16,7 +16,7 @@ public interface CoalInfoRepository extends BaseRepository<CoalInfoEntity> {
|
||||
select exists(
|
||||
select 1 from CoalAnalysisEntity e where e.coalInfo.id in :ids
|
||||
union all
|
||||
select 1 from CoalWashingDailyAnalysisEntity e where e.ymDetails.id in :ids
|
||||
select 1 from CoalWashingDailyAnalysisEntity e join e.ymDetails d where d.id in :ids
|
||||
union all
|
||||
select 1 from PurchaseOrderEntity p where p.coalInfo.id in :ids
|
||||
union all
|
||||
|
||||
@@ -11,6 +11,7 @@ import cn.lihongjie.coal.coalInfo.mapper.CoalInfoMapper;
|
||||
import cn.lihongjie.coal.coalInfo.repository.CoalInfoRepository;
|
||||
import cn.lihongjie.coal.coalPrice.entity.CoalPriceEntity;
|
||||
import cn.lihongjie.coal.coalPrice.service.CoalPriceService;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
@@ -18,6 +19,7 @@ import jakarta.persistence.PersistenceContext;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -92,27 +94,38 @@ public class CoalInfoService extends BaseService<CoalInfoEntity, CoalInfoReposit
|
||||
throw new BizException("煤源信息已存在");
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.repository.save(entity);
|
||||
if (!Objects.equals(old, request.getInitPrice())) {
|
||||
|
||||
updatePrice(entity);
|
||||
}
|
||||
|
||||
// update cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity.ymDetails name and code
|
||||
// update
|
||||
// cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity.ymDetails name and code
|
||||
|
||||
|
||||
int i = em.createQuery(
|
||||
"update CoalWashingDailyAnalysisEntity set ymDetails.name = :name, ymDetails.code = :code where ymDetails.id = :id")
|
||||
.setParameter("name", entity.getName())
|
||||
.setParameter("code", entity.getCode())
|
||||
em.createQuery(
|
||||
"select e from CoalWashingDailyAnalysisEntity e join e.ymDetails d where d.id = :id")
|
||||
.setParameter("id", entity.getId())
|
||||
.executeUpdate();
|
||||
.getResultList()
|
||||
.forEach(
|
||||
e -> {
|
||||
CoalWashingDailyAnalysisEntity analysis =
|
||||
(CoalWashingDailyAnalysisEntity) e;
|
||||
|
||||
log.info("更新煤洗日报分析的煤源信息,影响行数: {}", i);
|
||||
if (CollectionUtils.isNotEmpty(analysis.getYmDetails())) {
|
||||
|
||||
analysis.getYmDetails()
|
||||
.forEach(
|
||||
d -> {
|
||||
if (Objects.equals(d.getId(), entity.getId())) {
|
||||
d.setName(entity.getName());
|
||||
d.setCode(entity.getCode());
|
||||
}
|
||||
});
|
||||
|
||||
em.merge(analysis);
|
||||
}
|
||||
});
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user