|
@@ -1,13 +1,21 @@
|
|
|
package com.fdkankan.fusion.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
+import com.deepoove.poi.config.Configure;
|
|
|
+import com.deepoove.poi.config.ConfigureBuilder;
|
|
|
import com.deepoove.poi.data.TextRenderData;
|
|
|
import com.deepoove.poi.data.style.Style;
|
|
|
+import com.deepoove.poi.xwpf.NiceXWPFDocument;
|
|
|
import com.fdkankan.fusion.common.ResultCode;
|
|
|
+import com.fdkankan.fusion.common.util.DateUtils;
|
|
|
+import com.fdkankan.fusion.common.util.XwpTemplateUtils;
|
|
|
import com.fdkankan.fusion.entity.*;
|
|
|
import com.fdkankan.fusion.exception.BusinessException;
|
|
|
import com.fdkankan.fusion.mapper.ICaseInquestCriminalMapper;
|
|
@@ -16,6 +24,7 @@ import com.fdkankan.fusion.response.CaseInquestVo;
|
|
|
import com.fdkankan.fusion.response.WitnessVo;
|
|
|
import com.fdkankan.fusion.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.xwpf.usermodel.UnderlinePatterns;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -35,6 +44,7 @@ import java.util.List;
|
|
|
* @since 2024-10-18
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class CaseInquestCriminalServiceImpl extends ServiceImpl<ICaseInquestCriminalMapper, CaseInquestCriminal> implements ICaseInquestCriminalService {
|
|
|
|
|
|
@Autowired
|
|
@@ -100,11 +110,12 @@ public class CaseInquestCriminalServiceImpl extends ServiceImpl<ICaseInquestCrim
|
|
|
if(!byCaseId.isEmpty()){
|
|
|
CaseNumEntity caseNumEntity = byCaseId.get(0);
|
|
|
String num = caseNumEntity.getNum();
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
+ if(scenePlus == null){
|
|
|
+ log.info("设置案件勘验笔录失败-场景不存在:案件id:{},场景码:{}",caseInquestCriminal.getCaseId(),num);
|
|
|
+ return;
|
|
|
+ }
|
|
|
if(caseInquestCriminal.getInquestTime() == null){
|
|
|
- ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
- if(scenePlus == null){
|
|
|
- return;
|
|
|
- }
|
|
|
wrapper.set(CaseInquestCriminal::getInquestTime,scenePlus.getCreateTime());
|
|
|
caseInquestCriminal.setInquestTime(scenePlus.getCreateTime());
|
|
|
}
|
|
@@ -156,21 +167,53 @@ public class CaseInquestCriminalServiceImpl extends ServiceImpl<ICaseInquestCrim
|
|
|
|
|
|
CaseInquestCriminalVo vo = new CaseInquestCriminalVo();
|
|
|
BeanUtils.copyProperties(caseInquest,vo);
|
|
|
- String info = "证人或当事人(签名):%s %s年 %s月 %s日 身份证件号码:%s\n"
|
|
|
- +" 单位或住址:%s\n";
|
|
|
- StringBuilder msg = new StringBuilder();
|
|
|
- for (Object object : vo.getWitnessInfo()) {
|
|
|
+
|
|
|
+ //[{"unit":"四维","name":"张三","typeLabel":"笔录人","type":0,"job":"植物一"}]
|
|
|
+ String recorderInfo = "%s:姓名 %s 单位 %s 职务 %s\n";
|
|
|
+ StringBuilder recorderInfoMsg = new StringBuilder();
|
|
|
+ for (Object object : vo.getRecorderInfo()) {
|
|
|
JSONObject obj = (JSONObject) object;
|
|
|
- WitnessVo witnessVo = JSONObject.toJavaObject(obj,WitnessVo.class);
|
|
|
- String format = String.format(info, witnessVo.getName(), witnessVo.getYear(), witnessVo.getMonth(), witnessVo.getDay(), witnessVo.getId(), witnessVo.getAddress());
|
|
|
- msg.append(format);
|
|
|
+ String format = String.format(recorderInfo,obj.getString("typeLabel"), obj.getString("name"), obj.getString("unit"), obj.getString("job"));
|
|
|
+ recorderInfoMsg.append(format);
|
|
|
}
|
|
|
- TextRenderData text = new TextRenderData("000000",msg.toString());
|
|
|
+ TextRenderData text = new TextRenderData("000000",recorderInfoMsg.toString());
|
|
|
Style style = text.getStyle();
|
|
|
style.setUnderlinePatterns(UnderlinePatterns.SINGLE);
|
|
|
- vo.setText(text);
|
|
|
+ vo.setRecorderInfoText(text);
|
|
|
|
|
|
- XWPFTemplate template = XWPFTemplate.compile(inputStream).render(vo);
|
|
|
- return template;
|
|
|
+ //[{"unit":"四维","job":"植物一"}]
|
|
|
+ String signatureInfo = "本人签名: 单位 %s 职务 %s\n";
|
|
|
+ StringBuilder signatureInfoMsg = new StringBuilder();
|
|
|
+ for (Object object : vo.getSignatureInfo()) {
|
|
|
+ JSONObject obj = (JSONObject) object;
|
|
|
+ String format = String.format(signatureInfo, obj.getString("unit"), obj.getString("job"));
|
|
|
+ signatureInfoMsg.append(format);
|
|
|
+ }
|
|
|
+ TextRenderData text2 = new TextRenderData("000000",signatureInfoMsg.toString());
|
|
|
+ Style style2 = text2.getStyle();
|
|
|
+ style2.setUnderlinePatterns(UnderlinePatterns.SINGLE);
|
|
|
+ vo.setSignatureInfoText(text2);
|
|
|
+
|
|
|
+ //[{"birthday":"2024-10-15T16:00:00.000Z","address":"dfsdfdsdsdsdsds","sex":0}]
|
|
|
+ String witnessInfo = "本人签名 性别 %s 出生日期 %s 住址 %s\n";
|
|
|
+ StringBuilder witnessInfoMsg = new StringBuilder();
|
|
|
+ for (Object object : vo.getWitnessInfo()) {
|
|
|
+ JSONObject obj = (JSONObject) object;
|
|
|
+ String format = String.format(witnessInfo, XwpTemplateUtils.getSexStr(obj.getInteger("sex")), DateUtil.format(obj.getDate("birthday"), DatePattern.CHINESE_DATE_FORMAT),obj.getString("address"));
|
|
|
+ witnessInfoMsg.append(format);
|
|
|
+ }
|
|
|
+ TextRenderData text3 = new TextRenderData("000000",witnessInfoMsg.toString());
|
|
|
+ Style style3 = text3.getStyle();
|
|
|
+ style3.setUnderlinePatterns(UnderlinePatterns.SINGLE);
|
|
|
+ vo.setWitnessInfoText(text3);
|
|
|
+
|
|
|
+ ConfigureBuilder builder = Configure.builder();
|
|
|
+ builder.useSpringEL(false);
|
|
|
+ //builder.setValidErrorHandler(new Configure.DiscardHandler());
|
|
|
+ XWPFTemplate compile = XWPFTemplate.compile(inputStream, builder.build());
|
|
|
+ compile.render(vo);
|
|
|
+ return compile;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|