|
|
|
|
package com.docus.bgts.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.docus.bgts.entity.*;
|
|
|
|
|
import com.docus.bgts.enums.Codes;
|
|
|
|
|
import com.docus.bgts.facade.IAfCollectTaskService;
|
|
|
|
|
import com.docus.bgts.mapper.AfCollectTaskMapper;
|
|
|
|
|
import com.docus.bgts.mapper.AfInterfaceCollectMapper;
|
|
|
|
|
import com.docus.bgts.mapper.AfInterfaceCollectSubMapper;
|
|
|
|
|
import com.docus.bgts.utils.FileUtils;
|
|
|
|
|
import com.docus.bgts.utils.HttpUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
|
* 病案采集任务 服务实现类
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @author 曾文和
|
|
|
|
|
* @since 2021-05-07
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, AfCollectTask> implements IAfCollectTaskService {
|
|
|
|
|
|
|
|
|
|
private Logger log = LogManager.getLogger();
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
AfCollectTaskMapper afCollectTaskMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
AfInterfaceCollectMapper afInterfaceCollectMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
AfInterfaceCollectSubMapper afInterfaceCollectSubMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getpatientIdByEmpId(String empId) {
|
|
|
|
|
String patientId = afCollectTaskMapper.getpatientIdByEmpId(empId);
|
|
|
|
|
return patientId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
@Override
|
|
|
|
|
public void insert(ReportDownDto reportDownDto) {
|
|
|
|
|
log.info("新增任务表初始数据:" + reportDownDto);
|
|
|
|
|
AfCollectTask afCollectTask;
|
|
|
|
|
String patientId = getpatientIdByEmpId(reportDownDto.getPatient().getJzh());
|
|
|
|
|
if (StringUtils.isBlank(patientId)) {
|
|
|
|
|
throw new RuntimeException("操作的病案信息不存在");
|
|
|
|
|
}
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
Integer save = null;
|
|
|
|
|
List<ReportDownScanFileDto> scanfiles = reportDownDto.getScanfiles();
|
|
|
|
|
for (ReportDownScanFileDto scanfile : scanfiles) {
|
|
|
|
|
// 判断任务是否已存在
|
|
|
|
|
afCollectTask = afCollectTaskMapper.selectOne(new QueryWrapper<AfCollectTask>().eq("C1", scanfile.getSerialnum()).eq("sysflag", reportDownDto.getCollectorid()));
|
|
|
|
|
if (afCollectTask == null) {
|
|
|
|
|
//不存在 新增
|
|
|
|
|
afCollectTask = new AfCollectTask();
|
|
|
|
|
afCollectTask.setPatientId(patientId);
|
|
|
|
|
afCollectTask.setSysflag(reportDownDto.getCollectorid());
|
|
|
|
|
afCollectTask.setState("0");
|
|
|
|
|
afCollectTask.setSyncTime(date);
|
|
|
|
|
afCollectTask.setC1(scanfile.getSerialnum());
|
|
|
|
|
afCollectTask.setC2(scanfile.getFiletitle());
|
|
|
|
|
afCollectTask.setC3(reportDownDto.getPatient().getJzh());
|
|
|
|
|
save = afCollectTaskMapper.insert(afCollectTask);
|
|
|
|
|
} else {
|
|
|
|
|
//存在就修改
|
|
|
|
|
afCollectTask.setPatientId(patientId);
|
|
|
|
|
afCollectTask.setSysflag(reportDownDto.getCollectorid());
|
|
|
|
|
afCollectTask.setState("0");
|
|
|
|
|
afCollectTask.setSyncTime(date);
|
|
|
|
|
afCollectTask.setC1(scanfile.getSerialnum());
|
|
|
|
|
afCollectTask.setC2(scanfile.getFiletitle());
|
|
|
|
|
afCollectTask.setC3(reportDownDto.getPatient().getJzh());
|
|
|
|
|
save = afCollectTaskMapper.updateById(afCollectTask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (save <= 0) {
|
|
|
|
|
log.info("任务表操作出错");
|
|
|
|
|
throw new RuntimeException("插入病案任务表数据出错");
|
|
|
|
|
}
|
|
|
|
|
scanfile.setTaskid(afCollectTask.getId());
|
|
|
|
|
}
|
|
|
|
|
reportDownDto.setScanfiles(scanfiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateInterfaceCollect(String collectSubId, int state) {
|
|
|
|
|
AfInterfaceCollectSub afInterfaceCollectSub = afInterfaceCollectSubMapper.selectById(collectSubId);
|
|
|
|
|
if (afInterfaceCollectSub == null) {
|
|
|
|
|
throw new RuntimeException("afInterfaceCollectSub表数据为空");
|
|
|
|
|
}
|
|
|
|
|
int i;
|
|
|
|
|
afInterfaceCollectSub.setState(state);
|
|
|
|
|
i = afInterfaceCollectSubMapper.updateById(afInterfaceCollectSub);
|
|
|
|
|
if (i <= 0) {
|
|
|
|
|
throw new RuntimeException("记录任务数时出错");
|
|
|
|
|
}
|
|
|
|
|
if (state == 1) {
|
|
|
|
|
AfInterfaceCollect afInterfaceCollect = afInterfaceCollectMapper.selectById(afInterfaceCollectSub.getAfInterfaceCollectId());
|
|
|
|
|
afInterfaceCollect.setCompleteCount(afInterfaceCollect.getCompleteCount() + 1);
|
|
|
|
|
i = afInterfaceCollectMapper.updateById(afInterfaceCollect);
|
|
|
|
|
if (i <= 0) {
|
|
|
|
|
throw new RuntimeException("记录任务数时出错");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void invokeRepoalFile(CanlcelDto canlcelDto) throws Exception {
|
|
|
|
|
//上传接口地址
|
|
|
|
|
Map<String, Object> headMap = new HashMap<>();
|
|
|
|
|
headMap.put("Content-Type", "application/json");
|
|
|
|
|
log.info("开始文件撤回操作:"+canlcelDto);
|
|
|
|
|
String post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.REPOAL.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(canlcelDto), Map.class));
|
|
|
|
|
Map resMap = JSON.parseObject(post, Map.class);
|
|
|
|
|
if (String.valueOf(resMap.get("code")).equals("500")) {
|
|
|
|
|
throw new RuntimeException(String.valueOf(resMap.get("msg")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getAssortIdByAssortId(String assortId) {
|
|
|
|
|
return afCollectTaskMapper.getAssortIdByAssortId(assortId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getAssortIdByAssortName(String assortId) {
|
|
|
|
|
return afCollectTaskMapper.getAssortIdByAssortName(assortId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void insertZdAssort(ZdAssort zdAssort) {
|
|
|
|
|
afCollectTaskMapper.insertZdAssort(zdAssort);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|