bug 处理

This commit is contained in:
13405411873 2025-04-14 23:42:59 +08:00
parent 0f250c71fc
commit 8539cf87a0
5 changed files with 390 additions and 280 deletions

View File

@ -56,9 +56,8 @@ public class PatientScriptController extends BaseController {
* @return 新增结果 * @return 新增结果
*/ */
@PostMapping("/add") @PostMapping("/add")
public AjaxResult insert(@RequestBody PatientScript patientScript) throws IOException, InterruptedException { public AjaxResult insert(@RequestBody List<PatientScript> patientScripts) throws IOException, InterruptedException {
patientScript.setIsAll("1"); return toAjax(this.patientScriptService.saveBatch(patientScripts));
return toAjax(this.patientScriptService.save(patientScript));
} }

View File

@ -25,5 +25,8 @@ public interface PatientScriptService {
void exportReport2(HttpServletResponse response, Long reportId) throws Exception; void exportReport2(HttpServletResponse response, Long reportId) throws Exception;
Boolean saveBatch(List<PatientScript> patientScripts) ;
} }

View File

@ -1,5 +1,6 @@
package com.ruoyi.script.service.impl; package com.ruoyi.script.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.deepoove.poi.XWPFTemplate; import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.Pictures; import com.deepoove.poi.data.Pictures;
@ -9,6 +10,7 @@ import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfChunk; import com.itextpdf.text.pdf.PdfChunk;
import com.itextpdf.text.pdf.PdfContentByte; import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.PdfWriter;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.script.entity.MriInfo; import com.ruoyi.script.entity.MriInfo;
import com.ruoyi.script.entity.PatientScript; import com.ruoyi.script.entity.PatientScript;
import com.ruoyi.script.mapper.PatientScriptMapper; import com.ruoyi.script.mapper.PatientScriptMapper;
@ -30,6 +32,7 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -185,26 +188,23 @@ public class PatientScriptServiceImpl implements PatientScriptService {
@Override @Override
public Boolean save(PatientScript patientScript) throws IOException, InterruptedException { public Boolean save(PatientScript patientScript) throws IOException, InterruptedException {
patientScript.setCreateId(1110L);
patientScript.setCreateTime(new Date());
patientScript.setStatus("生成中"); patientScript.setStatus("生成中");
// 此处可以根据插入的实体信息使用自己的方式获取生成的 ID
scriptMapper.addData(patientScript);
// 多任务同时处理 // 多任务同时处理
taskExecutor.execute(new Runnable() { taskExecutor.execute(new Runnable() {
@SneakyThrows @SneakyThrows
@Override @Override
public void run() { public void run() {
if (!patientScript.getType().equals("mri")){ try {
String unique_id = generateOtp(); if (!patientScript.getType().equals("mri")){
String playground = "playground"+unique_id; String unique_id = generateOtp();
String format = DateUtil.format(new Date(), "yyyy-MM-dd"); String playground = "playground"+unique_id;
//判断是zip还是rar String format = DateUtil.format(new Date(), "yyyy-MM-dd");
if (patientScript.getFilePath().endsWith(".zip")){ //判断是zip还是rar
unzip(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据"); if (patientScript.getFilePath().endsWith(".zip")){
}else if (patientScript.getFilePath().endsWith(".rar")){ unzip(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据");
unRar(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据",null); }else if (patientScript.getFilePath().endsWith(".rar")){
} unRar(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据",null);
}
Map<String, Object> shMap = new LinkedHashMap<>(); Map<String, Object> shMap = new LinkedHashMap<>();
shMap.put("outPath",format+"/output-"+unique_id); shMap.put("outPath",format+"/output-"+unique_id);
shMap.put("filePath", patientScript.getFilePath()); shMap.put("filePath", patientScript.getFilePath());
@ -269,6 +269,11 @@ public class PatientScriptServiceImpl implements PatientScriptService {
scriptMapper.updateStatus(patientScript); scriptMapper.updateStatus(patientScript);
} }
}catch (Exception e){
patientScript.setStatus("生成异常");
scriptMapper.updateStatus(patientScript);
}
} }
}); });
@ -680,6 +685,40 @@ public class PatientScriptServiceImpl implements PatientScriptService {
} }
@Override
public Boolean saveBatch(List<PatientScript> patientScripts) {
for (PatientScript patientScript : patientScripts) {
patientScript.setIsAll("1");
patientScript.setStatus("待生成");
patientScript.setCreateId(SecurityUtils.getUserId());
patientScript.setCreateTime(new Date());
scriptMapper.addData(patientScript);
}
return true;
}
// 每半小时执行一次
@Scheduled(cron = "0 0/3 * * * ?")
public void scanData() throws IOException, InterruptedException {
PatientScript patientScript =new PatientScript();
patientScript.setStatus("生成中");
List<PatientScript> patientScripts = scriptMapper.selectList(patientScript);
if (CollectionUtil.isNotEmpty(patientScripts)){
return;
}
PatientScript patientScript2 =new PatientScript();
patientScript2.setStatus("待生成");
List<PatientScript> patientScriptList = scriptMapper.selectList(patientScript2);
//获取最后一个
if (CollectionUtil.isNotEmpty(patientScriptList)){
PatientScript patientScript1 = patientScriptList.get(patientScriptList.size() - 1);
this.save(patientScript1);
}
}
@Override @Override
public void exportReport(HttpServletResponse response, Long reportId) throws Exception { public void exportReport(HttpServletResponse response, Long reportId) throws Exception {
PatientScript patientScript = scriptMapper.getById(reportId); PatientScript patientScript = scriptMapper.getById(reportId);

View File

@ -59,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="patientCard != null and patientCard != ''"> and patient_card like concat('%',#{patientCard},'%') </if> <if test="patientCard != null and patientCard != ''"> and patient_card like concat('%',#{patientCard},'%') </if>
<if test="scanDoctor != null and scanDoctor != ''"> and scan_doctor like concat('%',#{scanDoctor},'%') </if> <if test="scanDoctor != null and scanDoctor != ''"> and scan_doctor like concat('%',#{scanDoctor},'%') </if>
<if test="isAll != null and isAll != ''"> and is_all= #{isAll} </if> <if test="isAll != null and isAll != ''"> and is_all= #{isAll} </if>
<if test="status != null and status != ''"> and status= #{status} </if>
</where> </where>
order by create_time desc order by create_time desc
</select> </select>

View File

@ -78,109 +78,141 @@
</el-table> </el-table>
</el-dialog> </el-dialog>
<!-- 添加或修改测评记录对话框 --> <el-dialog :title="title" :visible.sync="open" width="1800px" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body> <div class="dialog_box">
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="扫描文件" prop="filePath"> <div v-for="(item, index) in form" :key="index">
<brain-upload :limit="1" v-model="form.filePath" /> <div class="title_">患者{{index+1}}</div>
<el-row :gutter="20">
<el-col :span="6">
<el-form-item :label="'扫描文件' " :prop="'items.' + index + '.filePath'" :rules="rules.filePath">
<brain-upload :limit="1" v-model="item.filePath" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'患者姓名' " :prop="'items.' + index + '.patientName'" :rules="rules.patientName">
<el-input v-model="item.patientName" placeholder="请输入患者姓名" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'患者年龄' " :prop="'items.' + index + '.patientAge'" :rules="rules.patientAge">
<el-input-number v-model="item.patientAge" placeholder="患者年龄" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'性别' " :prop="'items.' + index + '.patientSex'" :rules="rules.patientSex">
<el-radio-group v-model="item.patientSex">
<el-radio label="男"></el-radio>
<el-radio label="女"></el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'证件信息号' " :prop="'items.' + index + '.patientCard'" :rules="rules.patientCard">
<el-input v-model="item.patientCard" placeholder="证件信息号" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'扫描时间' " :prop="'items.' + index + '.scanTime'" :rules="rules.scanTime">
<el-date-picker
v-model="item.scanTime"
type="datetime"
placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'病历号' " :prop="'items.' + index + '.blOrder'" :rules="rules.blOrder">
<el-input v-model="item.blOrder" placeholder="病历号" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'扫描地点' " :prop="'items.' + index + '.scanPosition'" :rules="rules.scanPosition">
<el-input v-model="item.scanPosition" placeholder="扫描地点" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'扫描医生' " :prop="'items.' + index + '.scanDoctor'" :rules="rules.scanDoctor">
<el-input v-model="item.scanDoctor" placeholder="扫描医生" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'诊断医师' " :prop="'items.' + index + '.zdDoctor'" :rules="rules.zdDoctor">
<el-input v-model="item.zdDoctor" placeholder="诊断医师" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="'审核医生' " :prop="'items.' + index + '.shDoctor'" :rules="rules.shDoctor">
<el-input v-model="item.shDoctor" placeholder="审核医生" />
</el-form-item>
</el-col>
<div class="right_button">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="removeItem(index)">删除</el-button>
</div>
</el-row>
</div>
<el-form-item>
<el-button type="primary" @click="addItem">添加行</el-button>
</el-form-item> </el-form-item>
<el-form-item label="患者姓名" prop="patientName">
<el-input v-model="form.patientName" placeholder="请输入患者姓名" />
</el-form-item>
<el-form-item label="患者年龄" prop="patientAge">
<el-input-number v-model="form.patientAge" placeholder="患者年龄" />
</el-form-item>
<el-form-item label="性别" prop="patientSex">
<el-radio-group v-model="form.patientSex">
<el-radio label="男"></el-radio>
<el-radio label="女"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="证件信息号" prop="patientCard">
<el-input v-model="form.patientCard" placeholder="证件信息号" />
</el-form-item>
<el-form-item label="扫描时间" prop="scanTime">
<el-date-picker
v-model="form.scanTime"
type="datetime"
placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
<el-form-item label="病历号" prop="blOrder">
<el-input v-model="form.blOrder" placeholder="病历号" />
</el-form-item>
<el-form-item label="扫描地点" prop="scanPosition">
<el-input v-model="form.scanPosition" placeholder="扫描地点" />
</el-form-item>
<el-form-item label="扫描医生" prop="scanDoctor">
<el-input v-model="form.scanDoctor" placeholder="扫描医生" />
</el-form-item>
<el-form-item label="诊断医师" prop="zdDoctor">
<el-input v-model="form.zdDoctor" placeholder="诊断医师" />
</el-form-item>
<el-form-item label="审核医生" prop="shDoctor">
<el-input v-model="form.shDoctor" placeholder="审核医生" />
</el-form-item>
</el-form> </el-form>
</div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { import {
listRecord, listRecord,
getRecord, getRecord,
delRecord, delRecord,
addRecord, addRecord,
updateRecord, updateRecord,
exportReport exportReport
} from "./scriptSh"; } from "./scriptSh";
import request from '@/utils/request' import request from '@/utils/request'
import dayjs from 'dayjs' import dayjs from 'dayjs'
export default { export default {
name: "Record", name: "Record",
data() { data() {
return { return {
// //
loading: true, loading: true,
// //
ids: [], ids: [],
// //
single: true, single: true,
// //
multiple: true, multiple: true,
// //
showSearch: true, showSearch: true,
// //
total: 0, total: 0,
// //
recordList: [], recordList: [],
options: [{ options: [{
value: 'altplus', value: 'altplus',
label: 'altplus' label: 'altplus'
}, { }, {
value: 'alt+z', value: 'alt+z',
label: 'alt+z' label: 'alt+z'
}, { }, {
value: 'alt+z2', value: 'alt+z2',
label: 'alt+z2' label: 'alt+z2'
}, { }, {
value: 'altminus', value: 'altminus',
label: 'altminus' label: 'altminus'
}, { }, {
value: 'alt-z', value: 'alt-z',
label: 'alt-z' label: 'alt-z'
} }
, { , {
value: 'alt-z2', value: 'alt-z2',
label: 'alt-z2' label: 'alt-z2'
@ -192,186 +224,222 @@
label: 'seqminus' label: 'seqminus'
} }
], ],
// //
title: "", title: "",
// //
open: false, open: false,
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
}, },
// //
form: { form: [
patientSex:'男', {
patientSex: '男',
scanTime: '' scanTime: ''
}, }
// ],
rules: { //
scanPosition: [ rules: {
{ filePath: [
required: true, {
message: "扫描地点不能为空", required: true,
trigger: "blur", message: "扫描文件不能为空",
}, trigger: "blur",
], },
filePath: [ ],
{
required: true, scanPosition: [
message: "扫描文件不能为空", {
trigger: "blur", required: true,
}, message: "扫描地点不能为空",
], trigger: "blur",
}, },
jsonOpen: false, ]
jsonData: {}, },
jsonType: '' jsonOpen: false,
}; jsonData: {},
jsonType: ''
};
},
created() {
this.getList();
},
methods: {
/** 查询测评记录列表 */
getList() {
this.loading = true;
listRecord(this.queryParams).then(response => {
this.recordList = response.rows;
this.total = response.total;
this.loading = false;
console.log(response);
});
}, },
created() { //
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = [
{
patientSex: '男',
scanTime: ''
}
];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList(); this.getList();
}, },
methods: { /** 重置按钮操作 */
/** 查询测评记录列表 */ resetQuery() {
getList() { this.resetForm("queryForm");
this.loading = true; this.handleQuery();
listRecord(this.queryParams).then(response => { },
this.recordList = response.rows; //
this.total = response.total; handleSelectionChange(selection) {
this.loading = false; this.ids = selection.map(item => item.id)
console.log(response); this.single = selection.length !== 1
}); this.multiple = !selection.length
}, },
// /** 新增按钮操作 */
cancel() { handleAdd() {
this.open = false; this.reset();
this.reset(); this.open = true;
}, this.title = "图形处理";
// },
reset() { /** 修改按钮操作 */
this.form = { handleUpdate(row) {
}; this.reset();
this.resetForm("form"); const recordId = row.id || this.ids
}, getRecord(recordId).then(response => {
/** 搜索按钮操作 */ this.form = [response.data];
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true; this.open = true;
this.title = "图形处理"; this.title = "修改测评记录";
}, });
/** 修改按钮操作 */ },
handleUpdate(row) { /** 提交按钮 */
this.reset(); submitForm() {
const recordId = row.id || this.ids let flag = false;
getRecord(recordId).then(response => { this.form.forEach(it=>{
this.form = response.data; if (!it.filePath){
this.open = true; flag = true
this.title = "修改测评记录"; this.$modal.msgError("请上传文件");
}
}); if (!it.scanPosition){
}, flag = true
/** 提交按钮 */ this.$modal.msgError("请输入扫描地点");
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.form.scanTime = dayjs(this.form.scanTime).format('YYYY-MM-DD HH:mm:ss')
this.form.type = 'noDti'
if (this.form.recordId != null) {
updateRecord(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
//this.open = false;
this.getList();
});
} else {
addRecord(this.form).then(response => {
this.$modal.msgSuccess("提交成功,请耐心等待结果");
//this.open = false;
this.getList();
});
} }
}
});
},
downImage(data) {
},
/** 删除按钮操作 */
handleDelete(row) {
const recordIds = row.id || this.ids;
this.$modal.confirm('是否确认删除测评记录编号为"' + recordIds + '"的数据项?').then(function() {
return delRecord(recordIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
if (!this.queryParams.tableType||this.queryParams.tableType==null){
this.$message.warning("请先选择类型")
return
}
this.download('system/record/export', {
...this.queryParams
}, `record_${new Date().getTime()}.xls`)
},
exportReport(data){
let id = data.id
exportReport(id).then(response => {
console.log(response)
let blob = new Blob([response], {
type: 'application/pdf' // pdf MIME
}) })
//console.log(blob)
let fileName = data.patientName+'_'+Date.parse(new Date()) + '.pdf'
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, fileName)
} else {
var link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = fileName
link.click()
//
window.URL.revokeObjectURL(link.href)
}
})
}, if (flag) return;
handleReview(jsonData, jsonType) { const formData = this.form.map(item => ({
this.jsonType = jsonType ...item,
this.jsonOpen = true scanTime: dayjs(item.scanTime).format('YYYY-MM-DD HH:mm:ss'),
this.jsonData = JSON.parse(jsonData) type: 'noDti'
}, }));
displayScore(score) { addRecord(formData).then(response => {
console.log(typeof score); this.$modal.msgSuccess("提交成功,请耐心等待结果");
console.log(score.length); this.open = false;
// 1 this.getList();
if (typeof score == "object") { })
return scoreList
} else { },
return score downImage(data) {
} //
},
/** 删除按钮操作 */
handleDelete(row) {
const recordIds = row.id || this.ids;
this.$modal.confirm('是否确认删除测评记录编号为"' + recordIds + '"的数据项?').then(function() {
return delRecord(recordIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
if (!this.queryParams.tableType || this.queryParams.tableType == null) {
this.$message.warning("请先选择类型")
return
} }
this.download('system/record/export', {
...this.queryParams
}, `record_${new Date().getTime()}.xls`)
},
exportReport(data) {
let id = data.id
exportReport(id).then(response => {
console.log(response)
let blob = new Blob([response], {
type: 'application/pdf' // pdf MIME
})
let fileName = data.patientName + '_' + Date.parse(new Date()) + '.pdf'
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, fileName)
} else {
var link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = fileName
link.click()
//
window.URL.revokeObjectURL(link.href)
}
})
},
handleReview(jsonData, jsonType) {
this.jsonType = jsonType
this.jsonOpen = true
this.jsonData = JSON.parse(jsonData)
},
displayScore(score) {
console.log(typeof score);
console.log(score.length);
// 1
if (typeof score == "object") {
return scoreList
} else {
return score
}
},
addItem() {
this.form.push({
patientSex: '男',
scanTime: ''
});
},
removeItem(index) {
this.form.splice(index, 1);
} }
}; }
};
</script> </script>
<style scoped>
.dialog_box{
width: 100%;
box-sizing: border-box;
padding: 10px;
}
.right_button{
width: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
box-sizing: border-box;
padding-right: 12px;
}
.title_{
font-size: 16px;
font-weight: 600;
margin-left: 45px;
margin-bottom: 10px;
}
</style>