gunshi-project-ss/src/main/java/com/gunshi/project/ss/service/JcskService.java

158 lines
6.0 KiB
Java
Raw Normal View History

2026-01-15 15:51:59 +08:00
package com.gunshi.project.ss.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.project.ss.common.model.JcskGnssB;
import com.gunshi.project.ss.common.model.JcskNormal;
import com.gunshi.project.ss.common.model.JcskSlB;
import com.gunshi.project.ss.common.model.JcskSyB;
import com.gunshi.project.ss.common.model.page.JcskPageSo;
import com.gunshi.project.ss.mapper.JcskMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
@Service
@Transactional(rollbackFor = Exception.class)
public class JcskService {
@Autowired
private JcskSlBService jcskSlBService;
@Autowired
private JcskSyBService jcskSyBService;
@Autowired
private JcskGnssBService jcskGnssBService;
@Autowired
private JcskMapper jcskMapper;
public Page<JcskNormal> page(JcskPageSo pageSo) {
Page<JcskNormal> page = jcskMapper.selectPage(pageSo.getPageSo().toPage(),pageSo);
return page;
}
public JcskNormal update(JcskNormal normal) {
Integer type = normal.getType();
BigDecimal lgtd = normal.getLgtd();
BigDecimal lttd = normal.getLttd();
String dm = normal.getDm();
if(type==1){
//渗流
JcskSlB one = jcskSlBService.lambdaQuery()
.eq(JcskSlB::getDvcd, normal.getCode()).one();
if(one == null){
throw new IllegalArgumentException("对不起,该测点不存在");
}
one.setLgtd(lgtd);
one.setLttd(lttd);
if(normal.getAddress() != null){
one.setAddress(normal.getAddress());
}
if(normal.getBuildUnit() != null){
one.setBuildUnit(normal.getBuildUnit());
}
if(normal.getYear() != null){
one.setYear(normal.getYear());
}
if(normal.getStationStatus() != null){
one.setStationStatus(normal.getStationStatus());
}
if(normal.getRemark() != null){
one.setRemark(normal.getRemark());
}
if(normal.getPipeElevation() != null){
one.setPipeElevation(normal.getPipeElevation());
}
if(normal.getPipeBottomElevation() != null){
one.setPipeBottomElevation(normal.getPipeBottomElevation());
}
if(normal.getDataCollection() != null){
one.setDataCollection(normal.getDataCollection());
}
LambdaQueryWrapper<JcskSlB> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JcskSlB::getDvcd,normal.getCode());
jcskSlBService.update(one,queryWrapper);
}else if(type==2){
//渗压
JcskSyB one = jcskSyBService.lambdaQuery()
.eq(JcskSyB::getDvcd, normal.getCode()).one();
if(one == null){
throw new IllegalArgumentException("对不起,该测点不存在");
}
one.setLgtd(lgtd);
one.setLttd(lttd);
if(normal.getAddress() != null){
one.setAddress(normal.getAddress());
}
if(normal.getBuildUnit() != null){
one.setBuildUnit(normal.getBuildUnit());
}
if(normal.getYear() != null){
one.setYear(normal.getYear());
}
if(normal.getStationStatus() != null){
one.setStationStatus(normal.getStationStatus());
}
if(normal.getRemark() != null){
one.setRemark(normal.getRemark());
}
if(normal.getPipeElevation() != null){
one.setPipeElevation(normal.getPipeElevation());
}
if(normal.getPipeBottomElevation() != null){
one.setPipeBottomElevation(normal.getPipeBottomElevation());
}
if(normal.getDataCollection() != null){
one.setDataCollection(normal.getDataCollection());
}
LambdaQueryWrapper<JcskSyB> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JcskSyB::getDvcd, normal.getCode());
jcskSyBService.update(one,queryWrapper);
}else{
//位移
JcskGnssB one = jcskGnssBService.lambdaQuery()
.eq(JcskGnssB::getCdNm,normal.getCode())
.one();
if(one == null){
throw new IllegalArgumentException("对不起,该测点不存在");
}
one.setLgtd(lgtd);
one.setLttd(lttd);
if(normal.getAddress() != null){
one.setAddress(normal.getAddress());
}
if(normal.getBuildUnit() != null){
one.setBuildUnit(normal.getBuildUnit());
}
if(normal.getYear() != null){
one.setYear(normal.getYear());
}
if(normal.getStationStatus() != null){
one.setStationStatus(normal.getStationStatus());
}
if(normal.getRemark() != null){
one.setRemark(normal.getRemark());
}
if(normal.getPipeElevation() != null){
one.setPipeElevation(normal.getPipeElevation());
}
if(normal.getPipeBottomElevation() != null){
one.setPipeBottomElevation(normal.getPipeBottomElevation());
}
if(normal.getDataCollection() != null){
one.setDataCollection(normal.getDataCollection());
}
LambdaQueryWrapper<JcskGnssB> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JcskGnssB::getCdNm,normal.getCode());
jcskGnssBService.update(one,queryWrapper);
}
return normal;
}
}