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 新增结果
*/
@PostMapping("/add")
public AjaxResult insert(@RequestBody PatientScript patientScript) throws IOException, InterruptedException {
patientScript.setIsAll("1");
return toAjax(this.patientScriptService.save(patientScript));
public AjaxResult insert(@RequestBody List<PatientScript> patientScripts) throws IOException, InterruptedException {
return toAjax(this.patientScriptService.saveBatch(patientScripts));
}

View File

@ -25,5 +25,8 @@ public interface PatientScriptService {
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;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.deepoove.poi.XWPFTemplate;
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.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.script.entity.MriInfo;
import com.ruoyi.script.entity.PatientScript;
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.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -185,26 +188,23 @@ public class PatientScriptServiceImpl implements PatientScriptService {
@Override
public Boolean save(PatientScript patientScript) throws IOException, InterruptedException {
patientScript.setCreateId(1110L);
patientScript.setCreateTime(new Date());
patientScript.setStatus("生成中");
// 此处可以根据插入的实体信息使用自己的方式获取生成的 ID
scriptMapper.addData(patientScript);
// 多任务同时处理
taskExecutor.execute(new Runnable() {
@SneakyThrows
@Override
public void run() {
if (!patientScript.getType().equals("mri")){
String unique_id = generateOtp();
String playground = "playground"+unique_id;
String format = DateUtil.format(new Date(), "yyyy-MM-dd");
//判断是zip还是rar
if (patientScript.getFilePath().endsWith(".zip")){
unzip(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据");
}else if (patientScript.getFilePath().endsWith(".rar")){
unRar(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据",null);
}
try {
if (!patientScript.getType().equals("mri")){
String unique_id = generateOtp();
String playground = "playground"+unique_id;
String format = DateUtil.format(new Date(), "yyyy-MM-dd");
//判断是zip还是rar
if (patientScript.getFilePath().endsWith(".zip")){
unzip(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据");
}else if (patientScript.getFilePath().endsWith(".rar")){
unRar(patientScript.getFilePath(),"/data/" +format+"/"+ playground+"/个体数据",null);
}
Map<String, Object> shMap = new LinkedHashMap<>();
shMap.put("outPath",format+"/output-"+unique_id);
shMap.put("filePath", patientScript.getFilePath());
@ -269,6 +269,11 @@ public class PatientScriptServiceImpl implements PatientScriptService {
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
public void exportReport(HttpServletResponse response, Long reportId) throws Exception {
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="scanDoctor != null and scanDoctor != ''"> and scan_doctor like concat('%',#{scanDoctor},'%') </if>
<if test="isAll != null and isAll != ''"> and is_all= #{isAll} </if>
<if test="status != null and status != ''"> and status= #{status} </if>
</where>
order by create_time desc
</select>

View File

@ -78,109 +78,141 @@
</el-table>
</el-dialog>
<!-- 添加或修改测评记录对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="1800px" append-to-body>
<div class="dialog_box">
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="扫描文件" prop="filePath">
<brain-upload :limit="1" v-model="form.filePath" />
<div v-for="(item, index) in form" :key="index">
<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 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>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listRecord,
getRecord,
delRecord,
addRecord,
updateRecord,
exportReport
} from "./scriptSh";
import request from '@/utils/request'
import {
listRecord,
getRecord,
delRecord,
addRecord,
updateRecord,
exportReport
} from "./scriptSh";
import request from '@/utils/request'
import dayjs from 'dayjs'
export default {
name: "Record",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
recordList: [],
options: [{
value: 'altplus',
label: 'altplus'
}, {
value: 'alt+z',
label: 'alt+z'
}, {
value: 'alt+z2',
label: 'alt+z2'
}, {
value: 'altminus',
label: 'altminus'
}, {
value: 'alt-z',
label: 'alt-z'
}
import dayjs from 'dayjs'
export default {
name: "Record",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
recordList: [],
options: [{
value: 'altplus',
label: 'altplus'
}, {
value: 'alt+z',
label: 'alt+z'
}, {
value: 'alt+z2',
label: 'alt+z2'
}, {
value: 'altminus',
label: 'altminus'
}, {
value: 'alt-z',
label: 'alt-z'
}
, {
value: 'alt-z2',
label: 'alt-z2'
@ -192,186 +224,222 @@
label: 'seqminus'
}
],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
},
//
form: {
patientSex:'男',
],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
},
//
form: [
{
patientSex: '男',
scanTime: ''
},
//
rules: {
scanPosition: [
{
required: true,
message: "扫描地点不能为空",
trigger: "blur",
},
],
filePath: [
{
required: true,
message: "扫描文件不能为空",
trigger: "blur",
},
],
},
jsonOpen: false,
jsonData: {},
jsonType: ''
};
}
],
//
rules: {
filePath: [
{
required: true,
message: "扫描文件不能为空",
trigger: "blur",
},
],
scanPosition: [
{
required: true,
message: "扫描地点不能为空",
trigger: "blur",
},
]
},
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();
},
methods: {
/** 查询测评记录列表 */
getList() {
this.loading = true;
listRecord(this.queryParams).then(response => {
this.recordList = response.rows;
this.total = response.total;
this.loading = false;
console.log(response);
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
};
this.resetForm("form");
},
/** 搜索按钮操作 */
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();
/** 重置按钮操作 */
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.title = "图形处理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const recordId = row.id || this.ids
getRecord(recordId).then(response => {
this.form = [response.data];
this.open = true;
this.title = "图形处理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const recordId = row.id || this.ids
getRecord(recordId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改测评记录";
});
},
/** 提交按钮 */
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();
});
this.title = "修改测评记录";
});
},
/** 提交按钮 */
submitForm() {
let flag = false;
this.form.forEach(it=>{
if (!it.filePath){
flag = true
this.$modal.msgError("请上传文件");
}
if (!it.scanPosition){
flag = true
this.$modal.msgError("请输入扫描地点");
}
}
});
},
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)
}
})
},
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
}
if (flag) return;
const formData = this.form.map(item => ({
...item,
scanTime: dayjs(item.scanTime).format('YYYY-MM-DD HH:mm:ss'),
type: 'noDti'
}));
addRecord(formData).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
})
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>
<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>