feat:报告签名处理
This commit is contained in:
@@ -17,6 +17,7 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
||||
public interface ConfigUserSignatureService {
|
||||
|
||||
ConfigUserSignatureDO getByUserId(Long userId);
|
||||
List<ConfigUserSignatureDO> getByIdList(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 创建手写签名配置
|
||||
|
||||
@@ -43,6 +43,13 @@ public class ConfigUserSignatureServiceImpl implements ConfigUserSignatureServic
|
||||
return CollUtil.isEmpty(list) ? null : list.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigUserSignatureDO> getByIdList(List<Long> ids) {
|
||||
LambdaQueryWrapper<ConfigUserSignatureDO> query = new LambdaQueryWrapper<>();
|
||||
query.in(ConfigUserSignatureDO::getId, ids);
|
||||
return configUserSignatureMapper.selectList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUserSignatureRespVO createConfigUserSignature(ConfigUserSignatureSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigUserSignatureDO;
|
||||
import com.zt.plat.module.qms.business.config.service.ConfigUserSignatureService;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.*;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTypeDO;
|
||||
@@ -24,10 +26,12 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
@@ -51,6 +55,7 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
|
||||
@Resource private ReportDocumentMainService reportDocumentMainService;
|
||||
@Resource private ReportDocumentTypeService reportDocumentTypeService;
|
||||
@Resource private ConfigUserSignatureService configUserSignatureService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建检测报告")
|
||||
@@ -146,7 +151,39 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
//@PreAuthorize("@ss.hasPermission('qms:report-document-main:query')")
|
||||
public CommonResult<ReportDocumentMainRespVO> getReportDocumentMain(@RequestParam("id") Long id) {
|
||||
ReportDocumentMainDO reportDocumentMain = reportDocumentMainService.getReportDocumentMain(id);
|
||||
return success(BeanUtils.toBean(reportDocumentMain, ReportDocumentMainRespVO.class));
|
||||
|
||||
ReportDocumentMainRespVO vo = BeanUtils.toBean(reportDocumentMain, ReportDocumentMainRespVO.class);
|
||||
|
||||
//处理签名
|
||||
String docSig = vo.getDocumentSignature();
|
||||
if(!ObjectUtils.isEmpty(docSig)){
|
||||
JSONObject docSigJson = JSONObject.parseObject(docSig);
|
||||
List<Long> sigIds = new ArrayList<>();
|
||||
docSigJson.forEach((key, value) -> {
|
||||
JSONObject obj = docSigJson.getJSONObject( key);
|
||||
String signatureId = obj.getString("signatureId");
|
||||
if(!ObjectUtils.isEmpty(signatureId))
|
||||
sigIds.add(Long.parseLong(signatureId));
|
||||
});
|
||||
|
||||
if(!sigIds.isEmpty()){
|
||||
List<ConfigUserSignatureDO> sigList = configUserSignatureService.getByIdList(sigIds);
|
||||
docSigJson.forEach((key, value) -> {
|
||||
JSONObject obj = docSigJson.getJSONObject( key);
|
||||
String signatureId = obj.getString("signatureId");
|
||||
if(!ObjectUtils.isEmpty(signatureId)){
|
||||
ConfigUserSignatureDO sig = sigList.stream().filter(item -> item.getId().equals(Long.parseLong(signatureId))).findFirst().orElse(null);
|
||||
if(sig != null){
|
||||
String base64 = sig.getSignatureContent();
|
||||
obj.put("signatureIdBase64", base64);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
vo.setDocumentSignature(docSigJson.toJSONString());
|
||||
}
|
||||
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
|
||||
@@ -337,6 +337,7 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
}
|
||||
|
||||
private void assembleSignature(String currentActivityId, ReportDocumentMainDO entity){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String sign = entity.getDocumentSignature();
|
||||
JSONObject signObj = new JSONObject();
|
||||
if(!ObjectUtils.isEmpty( sign))
|
||||
@@ -350,9 +351,10 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
String nickName = SecurityFrameworkUtils.getLoginUserNickname();
|
||||
ConfigUserSignatureDO configUserSignatureDO = configUserSignatureService.getByUserId(userId);
|
||||
if(configUserSignatureDO != null)
|
||||
obj.put("fileId", configUserSignatureDO.getFileId());
|
||||
obj.put("signatureId", configUserSignatureDO.getId());
|
||||
obj.put("userId", userId);
|
||||
obj.put("userName", nickName);
|
||||
obj.put("signTime", sdf.format(new Date()));
|
||||
signObj.put(currentActivityId, obj);
|
||||
entity.setDocumentSignature(signObj.toJSONString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user