新增根据用户id获取用户昵称
parent
8dd95ec7d2
commit
1739cfadef
|
|
@ -18,6 +18,7 @@ import com.gunshi.project.hsz.service.FileAssociationsService;
|
|||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
|
@ -44,10 +45,13 @@ public class ByPlanController extends AbstractCommonFileController{
|
|||
@Autowired
|
||||
private ByPlanService byPlanService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ByPlanDetailService byPlanDetailService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<ByPlan> insert(@Validated(Insert.class) @RequestBody ByPlan dto) {
|
||||
|
|
@ -62,12 +66,11 @@ public class ByPlanController extends AbstractCommonFileController{
|
|||
byPlanDetail.forEach(detail -> {
|
||||
detail.setId(IdWorker.getId());
|
||||
});
|
||||
boolean save = byPlanService.save(dto);
|
||||
boolean flag2 = byPlanDetailService.saveBatch(byPlanDetail);
|
||||
if (save && flag2) {
|
||||
boolean save = byPlanService.saveData(dto);
|
||||
if (save) {
|
||||
fileService.saveFile(dto.getFiles(), getGroupId(), dto.getId().toString());
|
||||
}
|
||||
return R.ok(save && flag2 ? dto : null);
|
||||
return R.ok(save ? dto : null);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,9 +35,8 @@ public class PrePlaceController {
|
|||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<PrePlace> insert(@Validated(Insert.class) @RequestBody PrePlace dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setCreateTime(new Date());
|
||||
boolean result = prePlaceService.save(dto);
|
||||
|
||||
boolean result = prePlaceService.saveData(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +117,8 @@ public class PrePlaceController {
|
|||
//查询防治部位 (可根据 防治点查询,也可以根据防治部位查询)
|
||||
@Operation(summary = "查询防治部位(可根据 防治点查询,也可以根据防治部位查询)")
|
||||
@PostMapping("/tree")
|
||||
public List<PrePlace> tree(@RequestBody PrePlacePageSo dto) {
|
||||
public R<List<PrePlace>> tree(@RequestBody PrePlacePageSo dto) {
|
||||
List<PrePlace> res = prePlaceService.tree(dto);
|
||||
return res;
|
||||
return R.ok(res);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import org.bouncycastle.cert.dane.DANEEntry;
|
|||
public class PrePlacePageSo {
|
||||
|
||||
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ public class ByPlan {
|
|||
@Schema(description = "用户id")
|
||||
private String userId;
|
||||
|
||||
@TableField(value = "user_name")
|
||||
@Schema(description = "用户名称")
|
||||
private String userName;
|
||||
|
||||
@TableField(value = "predict_cost")
|
||||
@Schema(description = "预算花费")
|
||||
private BigDecimal predictCost;
|
||||
|
|
|
|||
|
|
@ -39,16 +39,16 @@ public class ByPlanDetail {
|
|||
private Long ppdi;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "防治部位名称")
|
||||
@Schema(description = "防治部位名称 这个是给前端显示看的,不用传数据给后端")
|
||||
private String ppdn;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "防治点id")
|
||||
@Schema(description = "防治点id 这个是给前端显示看的,不用传数据给后端")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long ppi;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "防治点名称")
|
||||
@Schema(description = "防治点名称 这个是给前端显示看的,不用传数据给后端")
|
||||
private String ppn;
|
||||
|
||||
@TableField(value = "pre_method")
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ public class ByLogService extends ServiceImpl<ByLogMapper, ByLog> {
|
|||
}
|
||||
|
||||
|
||||
private static class StyleGroup {
|
||||
|
||||
private static class StyleGroup {
|
||||
CellStyle headerStyle;
|
||||
CellStyle dataStyle;
|
||||
CellStyle detailStyle;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import com.gunshi.project.hsz.mapper.ByPlanMapper;
|
|||
import com.gunshi.project.hsz.model.AlarmSet;
|
||||
import com.gunshi.project.hsz.model.ByPlan;
|
||||
import com.gunshi.project.hsz.model.ByPlanDetail;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.executor.BatchResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -33,6 +35,12 @@ public class ByPlanService extends ServiceImpl<ByPlanMapper, ByPlan> {
|
|||
@Autowired
|
||||
private ByPlanDetailMapper byPlanDetailMapper;
|
||||
|
||||
@Autowired
|
||||
private ByPlanDetailService byPlanDetailService;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
public boolean update(ByPlan dto) {
|
||||
LambdaQueryWrapper<ByPlan> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ByPlan::getPlanId, dto.getPlanId());
|
||||
|
|
@ -40,6 +48,12 @@ public class ByPlanService extends ServiceImpl<ByPlanMapper, ByPlan> {
|
|||
if(Objects.isNull(one)){
|
||||
throw new RuntimeException("该计划不存在,请检查");
|
||||
}
|
||||
if(dto.getUserId() != null){
|
||||
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(dto.getUserId()));
|
||||
if(sysUser != null){
|
||||
dto.setUserName(sysUser.getNickName());
|
||||
}
|
||||
}
|
||||
boolean save = updateById(dto);
|
||||
List<ByPlanDetail> byPlanDetail = dto.getByPlanDetail();
|
||||
byPlanDetail.forEach(detail -> {
|
||||
|
|
@ -70,7 +84,31 @@ public class ByPlanService extends ServiceImpl<ByPlanMapper, ByPlan> {
|
|||
continue;
|
||||
}
|
||||
entity.setByPlanDetail(details);
|
||||
//根据用户id查询用户名称
|
||||
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(entity.getUserId()));
|
||||
if(sysUser != null){
|
||||
entity.setUserName(sysUser.getUserName());
|
||||
}
|
||||
}
|
||||
return byPlanPage;
|
||||
}
|
||||
|
||||
public boolean saveData(ByPlan dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
List<ByPlanDetail> byPlanDetail = dto.getByPlanDetail();
|
||||
if(dto.getUserId() != null){
|
||||
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(dto.getUserId()));
|
||||
if(sysUser != null){
|
||||
dto.setUserName(sysUser.getNickName());
|
||||
}
|
||||
}
|
||||
boolean save = save(dto);
|
||||
byPlanDetail.forEach(detail -> {
|
||||
detail.setId(IdWorker.getId());
|
||||
});
|
||||
if(save){
|
||||
byPlanDetailService.saveBatch(byPlanDetail);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.entity.so.PrePlacePageSo;
|
||||
import com.gunshi.project.hsz.entity.vo.PrePlaceTreeVo;
|
||||
import com.gunshi.project.hsz.mapper.PrePlaceDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.PrePlaceMapper;
|
||||
import com.gunshi.project.hsz.model.PrePlace;
|
||||
|
|
@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -43,14 +44,14 @@ public class PrePlaceService extends ServiceImpl<PrePlaceMapper, PrePlace> {
|
|||
public List<PrePlace> tree(PrePlacePageSo dto) {
|
||||
LambdaQueryWrapper<PrePlace> wrapper = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isBlank(dto.getPreName())){
|
||||
wrapper.like(PrePlace::getId, dto.getPreName());
|
||||
wrapper.eq(PrePlace::getPreName, dto.getPreName());
|
||||
}
|
||||
List<PrePlace> prePlaces = prePlaceMapper.selectList(wrapper);
|
||||
Iterator<PrePlace> iterator = prePlaces.iterator();
|
||||
while(iterator.hasNext()){
|
||||
PrePlace prePlace = iterator.next();
|
||||
LambdaQueryWrapper<PrePlaceDetail> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isBlank(dto.getPreName())){
|
||||
if(!StringUtils.isBlank(dto.getPreDetailName())){
|
||||
queryWrapper.like(PrePlaceDetail::getDetailName, dto.getPreDetailName());
|
||||
}
|
||||
queryWrapper.eq(PrePlaceDetail::getPreId, prePlace.getId());
|
||||
|
|
@ -63,4 +64,18 @@ public class PrePlaceService extends ServiceImpl<PrePlaceMapper, PrePlace> {
|
|||
}
|
||||
return prePlaces;
|
||||
}
|
||||
|
||||
public boolean saveData(PrePlace dto) {
|
||||
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setCreateTime(new Date());
|
||||
LambdaQueryWrapper<PrePlace> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PrePlace::getPreName, dto.getPreName());
|
||||
PrePlace prePlace = prePlaceMapper.selectOne(queryWrapper);
|
||||
if(prePlace != null){
|
||||
throw new IllegalArgumentException("该防治点已存在");
|
||||
}
|
||||
save(dto);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue