白蚁-日志-bug修改

master
yangzhe123 2025-09-08 14:21:48 +08:00
parent aba8027886
commit b22aad5ae8
4 changed files with 46 additions and 14 deletions

View File

@ -14,6 +14,8 @@ import com.gunshi.project.hsz.service.ByLogService;
import com.gunshi.project.hsz.service.FileAssociationsService; import com.gunshi.project.hsz.service.FileAssociationsService;
import com.gunshi.project.hsz.validate.markers.Insert; import com.gunshi.project.hsz.validate.markers.Insert;
import com.gunshi.project.hsz.validate.markers.Update; import com.gunshi.project.hsz.validate.markers.Update;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.service.impl.SysUserServiceImpl;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -42,21 +44,18 @@ public class ByLogController extends AbstractCommonFileController {
@Autowired @Autowired
private FileAssociationsService fileService; private FileAssociationsService fileService;
@Autowired
private SysUserServiceImpl sysUserService;
@Operation(summary = "新增") @Operation(summary = "新增")
@PostMapping("/insert") @PostMapping("/insert")
public R<ByLog> insert(@Validated(Insert.class) @RequestBody ByLog dto) { public R<ByLog> insert(@Validated(Insert.class) @RequestBody ByLog dto) {
dto.setId(IdWorker.getId());
List<ByLogDetail> byLogDetails = dto.getDetails(); boolean flag = byLogService.saveData(dto);
byLogDetails.forEach(detail -> { if (flag) {
detail.setId(IdWorker.getId());
detail.setByLogId(dto.getId());
});
boolean save = byLogService.save(dto);
boolean flag2 = byLogDetailService.saveBatch(byLogDetails);
if (save && flag2) {
fileService.saveFile(dto.getFiles(), getGroupId(), dto.getId().toString()); fileService.saveFile(dto.getFiles(), getGroupId(), dto.getId().toString());
} }
return R.ok(save && flag2 ? dto : null); return R.ok(flag? dto : null);
} }
@Operation(summary = "修改") @Operation(summary = "修改")

View File

@ -15,7 +15,7 @@ public interface ByLogDetailMapper extends BaseMapper<ByLogDetail> {
@Select(""" @Select("""
<script> <script>
select t1.id,t1.by_log_id,t1.pre_place_detail_id as ppdi,t1.pre_person,t1.pre_method,t1.pre_effect, select t1.id,t1.by_log_id,t1.pre_place_detail_id as ppdi,t1.pre_person,t1.pre_method,t1.pre_effect,t1.pre_person_name
t2.detail_name as ppdn,t3.id as ppi,t3.pre_name as ppn t2.detail_name as ppdn,t3.id as ppi,t3.pre_name as ppn
from by_log_detail t1 from by_log_detail t1
join pre_place_detail t2 join pre_place_detail t2
@ -31,7 +31,7 @@ public interface ByLogDetailMapper extends BaseMapper<ByLogDetail> {
List<ByLogDetail> selectDetail(@Param("logId") Long id,@Param("dto") ByLogPageSo pageSo); List<ByLogDetail> selectDetail(@Param("logId") Long id,@Param("dto") ByLogPageSo pageSo);
@Select(""" @Select("""
select t1.id,t1.by_log_id,t1.pre_place_detail_id as ppdi,t1.pre_person,t1.pre_method,t1.pre_effect, select t1.id,t1.by_log_id,t1.pre_place_detail_id as ppdi,t1.pre_person,t1.pre_method,t1.pre_effect,t1.pre_person_name
t2.detail_name as ppdn,t3.id as ppi,t3.pre_name as ppn t2.detail_name as ppdn,t3.id as ppi,t3.pre_name as ppn
from by_log_detail t1 from by_log_detail t1
join pre_place_detail t2 join pre_place_detail t2

View File

@ -54,6 +54,11 @@ public class ByLogDetail {
@Schema(description = "防治人员id") @Schema(description = "防治人员id")
private String prePerson; private String prePerson;
@TableField(value = "pre_person_name")
@Schema(description = "防治人员名称")
private String prePersonName;
@TableField(value = "pre_method") @TableField(value = "pre_method")
@Schema(description = "防治方法") @Schema(description = "防治方法")
private String preMethod; private String preMethod;

View File

@ -9,8 +9,9 @@ import com.gunshi.project.hsz.entity.so.ByLogPageSo;
import com.gunshi.project.hsz.mapper.ByLogDetailMapper; import com.gunshi.project.hsz.mapper.ByLogDetailMapper;
import com.gunshi.project.hsz.mapper.ByLogMapper; import com.gunshi.project.hsz.mapper.ByLogMapper;
import com.gunshi.project.hsz.model.*; import com.gunshi.project.hsz.model.*;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.SysUserMapper;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.executor.BatchResult; import org.apache.ibatis.executor.BatchResult;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
@ -37,6 +38,9 @@ public class ByLogService extends ServiceImpl<ByLogMapper, ByLog> {
@Autowired @Autowired
private ByLogDetailMapper byLogDetailMapper; private ByLogDetailMapper byLogDetailMapper;
@Autowired
private SysUserMapper sysUserMapper;
public boolean update(ByLog dto) { public boolean update(ByLog dto) {
ByLog byId = getById(dto.getId()); ByLog byId = getById(dto.getId());
if(Objects.isNull(byId)){ if(Objects.isNull(byId)){
@ -46,6 +50,13 @@ public class ByLogService extends ServiceImpl<ByLogMapper, ByLog> {
List<ByLogDetail> byLogDetails = dto.getDetails(); List<ByLogDetail> byLogDetails = dto.getDetails();
byLogDetails.forEach(detail -> { byLogDetails.forEach(detail -> {
detail.setId(IdWorker.getId()); detail.setId(IdWorker.getId());
detail.setByLogId(dto.getId());
if(detail.getPrePerson() != null){
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(detail.getPrePerson()));
if(sysUser != null){
detail.setPrePersonName(sysUser.getNickName());
}
}
}); });
LambdaQueryWrapper<ByLogDetail> queryWrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ByLogDetail> queryWrapper2 = new LambdaQueryWrapper<>();
//先删除,再新增 //先删除,再新增
@ -112,6 +123,23 @@ public class ByLogService extends ServiceImpl<ByLogMapper, ByLog> {
} }
} }
public boolean saveData(ByLog dto) {
dto.setId(IdWorker.getId());
List<ByLogDetail> byLogDetails = dto.getDetails();
byLogDetails.forEach(detail -> {
detail.setId(IdWorker.getId());
detail.setByLogId(dto.getId());
if(detail.getPrePerson() != null){
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(detail.getPrePerson()));
if(sysUser != null){
detail.setPrePersonName(sysUser.getNickName());
}
}
});
boolean save = save(dto);
List<BatchResult> insert = byLogDetailMapper.insert(byLogDetails);
return true;
}
private static class StyleGroup { private static class StyleGroup {
@ -285,7 +313,7 @@ public class ByLogService extends ServiceImpl<ByLogMapper, ByLog> {
private void fillDetailInfo(Row row, ByLogDetail detail, CellStyle style) { private void fillDetailInfo(Row row, ByLogDetail detail, CellStyle style) {
createCell(row, 6, detail.getPpdn(), style); // 防治部位 createCell(row, 6, detail.getPpdn(), style); // 防治部位
createCell(row, 7, detail.getPpn(), style); // 防治点 createCell(row, 7, detail.getPpn(), style); // 防治点
createCell(row, 8, detail.getPrePerson(), style); // 防治人员 createCell(row, 8, detail.getPrePersonName(), style); // 防治人员
createCell(row, 9, detail.getPreMethod(), style); // 防治方法 createCell(row, 9, detail.getPreMethod(), style); // 防治方法
createCell(row, 10, detail.getPreEffect(), style); // 防治效果 createCell(row, 10, detail.getPreEffect(), style); // 防治效果
} }