Browse Source

执法端-修改bug建计划提示失败了,但是查询计划页面还是展示出来了,没有做校验

dev-V1.0.1
niujiyi 5 months ago
parent
commit
a722fc15c4
  1. 55
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/impl/EnforcementInspectionProgramServiceImpl.java

55
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/impl/EnforcementInspectionProgramServiceImpl.java

@ -15,7 +15,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.translation.annotation.Translation;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.zdxt.enforcementcode.domain.bo.EnforcementInspectionProgramBo; import com.zdxt.enforcementcode.domain.bo.EnforcementInspectionProgramBo;
import com.zdxt.enforcementcode.domain.vo.EnforcementInspectionProgramVo; import com.zdxt.enforcementcode.domain.vo.EnforcementInspectionProgramVo;
import com.zdxt.enforcementcode.domain.EnforcementInspectionProgram; import com.zdxt.enforcementcode.domain.EnforcementInspectionProgram;
@ -269,14 +271,22 @@ public class EnforcementInspectionProgramServiceImpl implements IEnforcementInsp
* @return 是否新增成功 * @return 是否新增成功
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Boolean insertByBo(EnforcementInspectionProgramBo bo) { public Boolean insertByBo(EnforcementInspectionProgramBo bo) {
Long userId = LoginHelper.getUserId();
String username = LoginHelper.getUsername();
if (userId == null) {
throw new IllegalArgumentException("用户未登录或登录已过期");
}
EnforcementInspectionProgram add = MapstructUtils.convert(bo, EnforcementInspectionProgram.class); EnforcementInspectionProgram add = MapstructUtils.convert(bo, EnforcementInspectionProgram.class);
add.setCreateTime(DateUtils.getNowDate()); add.setCreateTime(DateUtils.getNowDate());
add.setId(IdUtil.simpleUUID()); add.setId(IdUtil.simpleUUID());
add.setUserId(LoginHelper.getUserId() +""); add.setUserId(userId.toString());
add.setDeptId(LoginHelper.getDeptId()); add.setDeptId(LoginHelper.getDeptId());
add.setCreateBy(LoginHelper.getUserId()); add.setCreateBy(userId);
add.setCreateByName(LoginHelper.getUsername()); add.setCreateByName(username);
validEntityBeforeSave(add); validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0; boolean flag = baseMapper.insert(add) > 0;
if (flag && bo.getFileList() != null && !bo.getFileList().isEmpty()) { if (flag && bo.getFileList() != null && !bo.getFileList().isEmpty()) {
@ -285,25 +295,26 @@ public class EnforcementInspectionProgramServiceImpl implements IEnforcementInsp
ZdxtFile zdxtFile = new ZdxtFile(); ZdxtFile zdxtFile = new ZdxtFile();
zdxtFile.setGuid(IdUtil.simpleUUID()); zdxtFile.setGuid(IdUtil.simpleUUID());
zdxtFile.setBusinessId(add.getId()); zdxtFile.setBusinessId(add.getId());
zdxtFile.setUploadPath(file.getUploadPath());
String uploadPath = file.getUploadPath();
if (StringUtils.isBlank(uploadPath)) {
throw new IllegalArgumentException("文件上传路径不能为空");
}
zdxtFile.setUploadPath(uploadPath);
zdxtFile.setFileName(file.getFileName()); zdxtFile.setFileName(file.getFileName());
// 从文件路径中截取文件名称 // 从文件路径中截取文件名称
String fileUrl = file.getUploadPath();
String fileSaveName = null; String fileSaveName = null;
if (fileUrl != null && !fileUrl.isEmpty()) { int lastSlashIndex = Math.max(uploadPath.lastIndexOf("/"), uploadPath.lastIndexOf("\\"));
// 处理 URL 路径或文件路径 if (lastSlashIndex != -1 && lastSlashIndex < uploadPath.length() - 1) {
int lastSlashIndex = Math.max(fileUrl.lastIndexOf("/"), fileUrl.lastIndexOf("\\")); fileSaveName = uploadPath.substring(lastSlashIndex + 1);
if (lastSlashIndex != -1 && lastSlashIndex < fileUrl.length() - 1) { } else {
fileSaveName = fileUrl.substring(lastSlashIndex + 1); fileSaveName = uploadPath;
} else { }
fileSaveName = fileUrl; // 去除 URL 参数(如果有)
} int questionMarkIndex = fileSaveName.indexOf("?");
// 去除 URL 参数(如果有) if (questionMarkIndex != -1) {
int questionMarkIndex = fileSaveName.indexOf("?"); fileSaveName = fileSaveName.substring(0, questionMarkIndex);
if (questionMarkIndex != -1) {
fileSaveName = fileSaveName.substring(0, questionMarkIndex);
}
} }
zdxtFile.setFileSaveName(fileSaveName); zdxtFile.setFileSaveName(fileSaveName);
@ -316,11 +327,11 @@ public class EnforcementInspectionProgramServiceImpl implements IEnforcementInsp
} }
// 设置上传人信息 // 设置上传人信息
zdxtFile.setUploadPersonId(LoginHelper.getUserId().toString()); zdxtFile.setUploadPersonId(userId.toString());
zdxtFile.setUploadPersonName(LoginHelper.getUsername()); zdxtFile.setUploadPersonName(username);
zdxtFile.setUploadTime(DateUtils.getNowDate()); zdxtFile.setUploadTime(DateUtils.getNowDate());
zdxtFile.setCreateBy(LoginHelper.getUserId()); zdxtFile.setCreateBy(userId);
zdxtFile.setUpdateBy(LoginHelper.getUserId()); zdxtFile.setUpdateBy(userId);
zdxtFile.setCreateTime(DateUtils.getNowDate()); zdxtFile.setCreateTime(DateUtils.getNowDate());
zdxtFile.setUpdateTime(DateUtils.getNowDate()); zdxtFile.setUpdateTime(DateUtils.getNowDate());

Loading…
Cancel
Save