更新
1.更新案件时,添加检材委托类型参数
This commit is contained in:
@@ -2,6 +2,7 @@ package digital.laboratory.platform.entrustment.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -18,6 +19,8 @@ import digital.laboratory.platform.common.log.annotation.SysLog;
|
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
|
||||
import digital.laboratory.platform.common.oss.service.OssFile;
|
||||
//import digital.laboratory.platform.common.security.service.DLPUser;
|
||||
import digital.laboratory.platform.entrustment.convert.CaseEventConvert;
|
||||
import digital.laboratory.platform.entrustment.dto.UpdateCaseAndEntrustTypeDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.*;
|
||||
import digital.laboratory.platform.othersys.vo.EntrustDataVo;
|
||||
import digital.laboratory.platform.entrustment.service.CaseEventService;
|
||||
@@ -180,54 +183,58 @@ public class CaseEventController {
|
||||
/**
|
||||
* 修改案件事件
|
||||
*
|
||||
* @param caseEvent 案件事件
|
||||
* @param dto 案件事件
|
||||
* @return R
|
||||
*/
|
||||
@ApiOperation(value = "修改案件事件", notes = "修改案件事件")
|
||||
@SysLog("修改案件事件")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasAnyPermission('CaseEdit')")
|
||||
public R putUpdateById(@RequestBody CaseEvent caseEvent, HttpServletRequest theHttpServletRequest) {
|
||||
if (StrUtil.isBlank(caseEvent.getId())) {
|
||||
return R.failed(caseEvent, "id 不能为空!");
|
||||
public R putUpdateById(@RequestBody UpdateCaseAndEntrustTypeDTO dto, HttpServletRequest theHttpServletRequest) {
|
||||
if (StrUtil.isBlank(dto.getId())) {
|
||||
return R.failed(dto, "id 不能为空!");
|
||||
}
|
||||
Principal principal = theHttpServletRequest.getUserPrincipal();
|
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal();
|
||||
|
||||
if (!dlpUser.isStaff()) {
|
||||
// 不是鉴定中心员工, 检查一下案件所属机构与用户是不是同一机构
|
||||
CaseEvent oldCase = caseEventService.getById(caseEvent.getId());
|
||||
CaseEvent oldCase = caseEventService.getById(dto.getId());
|
||||
if (oldCase == null || StrUtil.isBlank(oldCase.getCaseOwnOrgId()) || (!StrUtil.equalsIgnoreCase(oldCase.getCaseOwnOrgId(), dlpUser.getOrgId()))) {
|
||||
return R.failed(caseEvent, "只能修改自己单位的案件!");
|
||||
return R.failed(dto, "只能修改自己单位的案件!");
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isEmpty(caseEvent.getCaseName())) {
|
||||
return R.failed(caseEvent, "案件名称不能为空!");
|
||||
if (StrUtil.isEmpty(dto.getCaseName())) {
|
||||
return R.failed(dto, "案件名称不能为空!");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(caseEvent.getCaseNo())) {
|
||||
if (StrUtil.isBlank(dto.getCaseNo())) {
|
||||
// 如果没有提供案件编码, 生成一个
|
||||
|
||||
if ((caseEvent.getHappenTime() != null) && (StrUtil.isNotBlank(caseEvent.getCaseOwnOrgId()))) {
|
||||
if ((dto.getHappenTime() != null) && (StrUtil.isNotBlank(dto.getCaseOwnOrgId()))) {
|
||||
SysOrg caseOwnOrg = null;
|
||||
R r = remoteOrgService.getById(caseEvent.getCaseOwnOrgId());
|
||||
R r = remoteOrgService.getById(dto.getCaseOwnOrgId());
|
||||
if (r.getCode() == CommonConstants.SUCCESS) {
|
||||
caseOwnOrg = (SysOrg) r.getData();
|
||||
|
||||
// Date happenTime = Date.from(caseEvent.getHappenTime().atZone(ZoneId.systemDefault()).toInstant());
|
||||
|
||||
caseEvent.setCaseNo(caseEventService.getNewCaseCode(caseOwnOrg.getOrgCode(), caseEvent.getHappenTime()));
|
||||
dto.setCaseNo(caseEventService.getNewCaseCode(caseOwnOrg.getOrgCode(), dto.getHappenTime()));
|
||||
} else {
|
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认案件所属机构(CaseOwnOrg)的正确性!", caseEvent.getCaseOwnOrgId()));
|
||||
return R.failed(String.format("没有找到 orgId 为 %s 的机构, 请确认案件所属机构(CaseOwnOrg)的正确性!", dto.getCaseOwnOrgId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
caseEvent.setCreateBy(null);
|
||||
caseEvent.setCreateTime(null);
|
||||
caseEvent.setUpdateBy(dlpUser.getId());
|
||||
caseEvent.setUpdateTime(LocalDateTime.now());
|
||||
CaseEvent caseEvent = CaseEventConvert.dtoToEntity(dto);
|
||||
if (caseEventService.updateById(caseEvent)) {
|
||||
// 判断委托需要更新不
|
||||
if (ObjectUtil.isNotNull(dto.getEntrustmentType())) {
|
||||
entrustmentService.update(Wrappers.<Entrustment>lambdaUpdate()
|
||||
.eq(Entrustment::getId, dto.getEntrustId())
|
||||
.set(Entrustment::getEntrustmentType, dto.getEntrustmentType())
|
||||
);
|
||||
}
|
||||
return R.ok(caseEvent, "保存案件信息成功");
|
||||
} else {
|
||||
return R.failed(caseEvent, "保存案件信息失败");
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package digital.laboratory.platform.entrustment.convert;
|
||||
|
||||
import digital.laboratory.platform.entrustment.dto.UpdateCaseAndEntrustTypeDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.CaseEvent;
|
||||
|
||||
/**
|
||||
* 案件实体类信息 转换类
|
||||
*/
|
||||
public class CaseEventConvert {
|
||||
|
||||
public static CaseEvent dtoToEntity(UpdateCaseAndEntrustTypeDTO dto) {
|
||||
if (dto == null) return null;
|
||||
CaseEvent caseEvent = new CaseEvent();
|
||||
caseEvent.setId(dto.getId());
|
||||
caseEvent.setCaseNo(dto.getCaseNo());
|
||||
caseEvent.setThirdPartySysNo(dto.getThirdPartySysNo());
|
||||
caseEvent.setCaseName(dto.getCaseName());
|
||||
caseEvent.setCaseType(dto.getCaseType());
|
||||
caseEvent.setHappenTime(dto.getHappenTime());
|
||||
caseEvent.setCaseAddress(dto.getCaseAddress());
|
||||
caseEvent.setCaseArea(dto.getCaseArea());
|
||||
caseEvent.setCaseOwnOrgId(dto.getCaseOwnOrgId());
|
||||
caseEvent.setCaseRank(dto.getCaseRank());
|
||||
caseEvent.setCaseBrief(dto.getCaseBrief());
|
||||
caseEvent.setComments(dto.getComments());
|
||||
caseEvent.setDataSources(dto.getDataSources());
|
||||
return caseEvent;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package digital.laboratory.platform.entrustment.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "UpdateCaseAndEntrustTypeDTO", description = "更新案件信息和委托类型的DTO请求类")
|
||||
public class UpdateCaseAndEntrustTypeDTO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||
@ApiModelProperty(value="id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 案件编号
|
||||
*/
|
||||
@ApiModelProperty(value="案件编号")
|
||||
private String caseNo;
|
||||
|
||||
/**
|
||||
* 第三方系统(如现勘系统、案事件系统)编号
|
||||
*/
|
||||
@ApiModelProperty(value="第三方系统(如现勘系统、案事件系统)编号")
|
||||
private String thirdPartySysNo;
|
||||
|
||||
/**
|
||||
* 案件名称任务名称
|
||||
*/
|
||||
@ApiModelProperty(value="案件名称任务名称")
|
||||
private String caseName;
|
||||
|
||||
/**
|
||||
* 案件类型
|
||||
*/
|
||||
@ApiModelProperty(value="案件类型")
|
||||
private String caseType;
|
||||
|
||||
/**
|
||||
* 案发时间
|
||||
*/
|
||||
@ApiModelProperty(value="案发时间")
|
||||
private LocalDate happenTime;
|
||||
|
||||
/**
|
||||
* 案发地详细地点
|
||||
*/
|
||||
@ApiModelProperty(value="案发地详细地点")
|
||||
private String caseAddress;
|
||||
|
||||
/**
|
||||
* 案发地行政区划编码(到县一级)
|
||||
*/
|
||||
@ApiModelProperty(value="案发地行政区划编码(到县一级)")
|
||||
private String caseArea;
|
||||
|
||||
/**
|
||||
* 案件所属机构
|
||||
*/
|
||||
@ApiModelProperty(value="案件所属机构")
|
||||
private String caseOwnOrgId;
|
||||
|
||||
/**
|
||||
* 案件级别: 0=普通案件, 1=紧急案件, 2=加急案件
|
||||
*/
|
||||
@ApiModelProperty(value="案件级别: 0=普通案件, 1=紧急案件, 2=加急案件")
|
||||
private Integer caseRank;
|
||||
|
||||
/**
|
||||
* 案情简要
|
||||
*/
|
||||
@ApiModelProperty(value="案情简要")
|
||||
private String caseBrief;
|
||||
|
||||
/**
|
||||
* 案件备注
|
||||
*/
|
||||
@ApiModelProperty(value="案件备注")
|
||||
private String comments;
|
||||
|
||||
/**
|
||||
* 数据来源,用于区别数据来自自身系统还是外部系统
|
||||
*/
|
||||
@ApiModelProperty(value="数据来源")
|
||||
private Integer dataSources;
|
||||
|
||||
@ApiModelProperty(value="委托id")
|
||||
private Integer entrustId;
|
||||
|
||||
@ApiModelProperty(value="委托类型: 0=常规毒品, 1=生物样本")
|
||||
private Integer entrustmentType;
|
||||
}
|
||||
Reference in New Issue
Block a user