断面渗压树

master
wany 2024-07-10 13:16:22 +08:00
parent f2f8bdd3e8
commit e3ed61daa9
7 changed files with 188 additions and 11 deletions

View File

@ -1,6 +1,7 @@
package com.gunshi.project.xyt.controller; package com.gunshi.project.xyt.controller;
import com.gunshi.core.result.R; import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.vo.ProfilePressTreeVo;
import com.gunshi.project.xyt.model.AttDamProfile; import com.gunshi.project.xyt.model.AttDamProfile;
import com.gunshi.project.xyt.service.AttDamProfileService; import com.gunshi.project.xyt.service.AttDamProfileService;
import com.gunshi.project.xyt.validate.markers.Insert; import com.gunshi.project.xyt.validate.markers.Insert;
@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* : * :
* author: xusan * author: xusan
@ -54,10 +56,17 @@ public class AttDamProfileController {
return R.ok(service.lambdaQuery().list()); return R.ok(service.lambdaQuery().list());
} }
@Operation(summary = "断面渗压树")
@PostMapping("/tree")
public R<List<ProfilePressTreeVo>> tree() {
return R.ok(service.tree());
}
@Operation(summary = "分页") @Operation(summary = "分页")
@PostMapping("/page") @PostMapping("/page")
public R<List<AttDamProfile>> page() { public R<List<AttDamProfile>> page() {
return R.ok(service.page(null,null)); return R.ok(service.page(null,null));
} }
} }

View File

@ -15,7 +15,7 @@ import lombok.Data;
*/ */
@Data @Data
@Schema(description = "渗压/渗流/位移分页查询对象") @Schema(description = "渗压/渗流/位移分页查询对象")
public class OsmoticQueryPageSo extends WarnSo{ public class OsmoticQueryPageSo{
@NotNull(message = "分页参数不能为空") @NotNull(message = "分页参数不能为空")
@Schema(description = "分页参数") @Schema(description = "分页参数")

View File

@ -0,0 +1,26 @@
package com.gunshi.project.xyt.entity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* Description:
* Created by wanyan on 2024/7/10
*
* @author wanyan
* @version 1.0
*/
@Data
public class ProfilePressTreeVo {
@Schema(description="断面编号")
private String profileCode;
@Schema(description="断面名称")
private String profileName;
@Schema(description = "测点")
private List<String> children;
}

View File

@ -18,16 +18,16 @@ public interface OsmoticPressRMapper extends BaseMapper<OsmoticPressR> {
@Select(""" @Select("""
<script> <script>
select t.*,s.* select t.*,m.profile_name
from public.osmotic_press_r t from public.osmotic_press_r t
left join public.att_dam_profile s left join public.osmotic_press_device s on t.station_code = s.station_code
on t.profile_code = s.profile_code left join public.att_dam_profile m on s.profile_code = m.profile_code
<where> <where>
<if test="obj.stationCode != null and obj.stationCode !=''"> <if test="obj.stationCode != null and obj.stationCode !=''">
t.station_code =#{obj.stationCode} t.station_code =#{obj.stationCode}
</if> </if>
<if test="obj.profileCode != null and obj.profileCode !=''"> <if test="obj.profileCode != null and obj.profileCode !=''">
t.profile_code =#{obj.profileCode} s.profile_code =#{obj.profileCode}
</if> </if>
<if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.start != null"> <if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.start != null">
and t.tm <![CDATA[>=]]> #{obj.dateTimeRangeSo.start} and t.tm <![CDATA[>=]]> #{obj.dateTimeRangeSo.start}

View File

@ -5,15 +5,12 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* : * :
@ -56,9 +53,9 @@ public class AttDamProfile implements Serializable {
/** /**
* / * /
*/ */
@TableField(value="desc") @TableField(value="remark")
@Schema(description="备注/描述") @Schema(description="备注/描述")
@Size(max = 250,message = "备注/描述最大长度要小于 250") @Size(max = 250,message = "备注/描述最大长度要小于 250")
private String desc; private String remark;
} }

View File

@ -1,13 +1,20 @@
package com.gunshi.project.xyt.service; package com.gunshi.project.xyt.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.xyt.entity.vo.ProfilePressTreeVo;
import com.gunshi.project.xyt.mapper.AttDamProfileMapper; import com.gunshi.project.xyt.mapper.AttDamProfileMapper;
import com.gunshi.project.xyt.model.AttDamProfile; import com.gunshi.project.xyt.model.AttDamProfile;
import com.gunshi.project.xyt.model.OsmoticPressDevice;
import com.gunshi.project.xyt.model.OsmoticPressDeviceAutoDao;
import com.gunshi.project.xyt.util.MyBeanUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.List;
import java.util.stream.Collectors;
/** /**
* : * :
@ -19,6 +26,19 @@ import java.util.Date;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class AttDamProfileService extends ServiceImpl<AttDamProfileMapper, AttDamProfile> public class AttDamProfileService extends ServiceImpl<AttDamProfileMapper, AttDamProfile>
{ {
@Resource
private OsmoticPressDeviceAutoDao pressDeviceAutoDao;
public List<ProfilePressTreeVo> tree() {
List<AttDamProfile> list = this.list();
List<ProfilePressTreeVo> res = MyBeanUtil.collectionCopy(list,ProfilePressTreeVo.class);
for(ProfilePressTreeVo vo : res){
List<OsmoticPressDevice> pressList = pressDeviceAutoDao.list(new QueryWrapper<OsmoticPressDevice>().eq("profile_code", vo.getProfileCode()));
vo.setChildren(pressList.stream().map(OsmoticPressDevice::getStationCode).collect(Collectors.toList()));
}
return res;
}
} }

View File

@ -0,0 +1,125 @@
package com.gunshi.project.xyt.util;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
/**
* Description:BeanUtils
* Created by wanyan on 2024/7/10
*
* @author wanyan
* @version 1.0
*/
public class MyBeanUtil extends BeanUtils{
public MyBeanUtil() {
}
public static <T> T propertiesCopy(Object source, Class<T> clazz) {
if (null == source) {
return null;
} else {
try {
T obj = clazz.newInstance();
BeanUtils.copyProperties(source, obj);
return obj;
} catch (IllegalAccessException | InstantiationException var3) {
throw new RuntimeException(var3);
}
}
}
/**
* listcopy
* @param source
* @param clazz
* @param <T>
* @return
*/
public static <T> List<T> collectionCopy(Collection source, Class<T> clazz) {
if (null == source) {
return new ArrayList();
} else {
List<T> list = new ArrayList();
Iterator var3 = source.iterator();
while(var3.hasNext()) {
Object o = var3.next();
list.add(propertiesCopy(o, clazz));
}
return list;
}
}
/**
* map
* @param obj
* @return
*/
public static Map<String, Object> object2Map(Object obj) {
Map<String, Object> map = new HashMap();
if (obj == null) {
return map;
} else {
Class clazz = obj.getClass();
Field[] fields = clazz.getDeclaredFields();
try {
Field[] var4 = fields;
int var5 = fields.length;
for(int var6 = 0; var6 < var5; ++var6) {
Field field = var4[var6];
field.setAccessible(true);
map.put(field.getName(), field.get(obj));
}
return map;
} catch (Exception var8) {
throw new RuntimeException(var8);
}
}
}
/**
* map,
* @return
*/
public static Object map2Object(Map<Object,Object> map,Class<?> clzz){
try {
Object target = clzz.newInstance();
if(CollectionUtils.isEmpty(map)){
return target;
}
Field[] fields = clzz.getDeclaredFields();
if(!CollectionUtils.isEmpty(Arrays.asList(fields))){
Arrays.stream(fields).filter((Field field) -> map.containsKey(field.getName())).forEach(var -> {
//获取属性的修饰符
int modifiers = var.getModifiers();
if(Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers)){
//在lambada中结束本次循环是用return,它不支持continue和break
return;
}
//设置权限
var.setAccessible(true);
try {
var.set(target,map.get(var.getName()));
} catch (IllegalAccessException e) {
//属性类型不对,非法操作,跳过本次循环,直接进入下一次循环
throw new RuntimeException(e);
}
});
}
return target;
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
}