From d49530cc1f8e501bd24bb1a37f6e201a8b2b527e Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Wed, 2 Jun 2021 10:20:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/OtherRecordsService.java | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/wisdomcar/src/main/java/com/ccsens/wisdomcar/service/OtherRecordsService.java b/wisdomcar/src/main/java/com/ccsens/wisdomcar/service/OtherRecordsService.java index 8d8d7570..a3662c3f 100644 --- a/wisdomcar/src/main/java/com/ccsens/wisdomcar/service/OtherRecordsService.java +++ b/wisdomcar/src/main/java/com/ccsens/wisdomcar/service/OtherRecordsService.java @@ -1,5 +1,6 @@ package com.ccsens.wisdomcar.service; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Snowflake; import cn.hutool.core.util.ObjectUtil; import com.ccsens.util.StringUtil; @@ -9,7 +10,9 @@ import com.ccsens.wisdomcar.bean.po.PatientInformationRecordExample; import com.ccsens.wisdomcar.bean.po.PatientWisdomCar; import com.ccsens.wisdomcar.bean.po.PatientWisdomCarExample; import com.ccsens.wisdomcar.bean.vo.OtherRecordsVo; +import com.ccsens.wisdomcar.bean.vo.ProjectVo; import com.ccsens.wisdomcar.persist.dao.PatientWisdomCarDao; +import com.ccsens.wisdomcar.persist.dao.StepTaskDao; import com.ccsens.wisdomcar.persist.mapper.PatientInformationRecordMapper; import com.ccsens.wisdomcar.persist.mapper.PatientWisdomCarMapper; import com.ccsens.wisdomcar.persist.mapper.WisdomCarMapper; @@ -38,6 +41,8 @@ public class OtherRecordsService implements IOtherRecordsService { @Resource private PatientWisdomCarDao patientWisdomCarDao; + @Resource + private StepTaskDao stepTaskDao; @Resource private PatientInformationRecordMapper patientInformationRecordMapper; @@ -48,48 +53,53 @@ public class OtherRecordsService implements IOtherRecordsService { @Override public void upload(OtherRecordsDto.PicturesAndRecords param) { //通过t_patient_information_record里面的分解任务id 找到患者平车id 最新的 拿到患者平车id t_patient_information_record - List longs = patientWisdomCarDao.queryByNew(param.getId()); //拿到患者平车id - if(ObjectUtil.isNotNull(longs)){ - if(param.getPictures().size()!=0){ //判断是否是图片是否为空 - for (int i = 0; i < param.getPictures().size(); i++) { - PatientInformationRecord patientInformationRecord = new PatientInformationRecord(); - patientInformationRecord.setId(snowflake.nextId()); - patientInformationRecord.setPatientCarId(longs.get(0)); - patientInformationRecord.setTaskSubId(param.getId()); - patientInformationRecord.setInformationType((byte) 0); //上传图片 - patientInformationRecord.setContent(param.getPictures().get(i)); //拿到图片 存到库里面 - patientInformationRecord.setRecStatus((byte) 0); - patientInformationRecordMapper.insertSelective(patientInformationRecord); - } - } - if(!StringUtil.isEmpty(param.getRecords())) { //判断是否是记录是否为空 + //拿到患者平车id + ProjectVo.BindCar bindCar = stepTaskDao.getBindCarTaskId(param.getId()); + if (bindCar == null) { + log.info("没有找到绑定的平车信息:{}", param); + return ; + } + //判断是否是图片是否为空 + if (CollectionUtil.isNotEmpty(param.getPictures())){ + for (int i = 0; i < param.getPictures().size(); i++) { PatientInformationRecord patientInformationRecord = new PatientInformationRecord(); patientInformationRecord.setId(snowflake.nextId()); - patientInformationRecord.setPatientCarId(longs.get(0)); + patientInformationRecord.setPatientCarId(bindCar.getId()); patientInformationRecord.setTaskSubId(param.getId()); - patientInformationRecord.setInformationType((byte) 1); //上传记录 - patientInformationRecord.setContent(param.getRecords()); //拿到记录 存到库里面 - patientInformationRecord.setRecStatus((byte) 0); + //上传图片 + patientInformationRecord.setInformationType((byte) 0); + //拿到图片 存到库里面 + patientInformationRecord.setContent(param.getPictures().get(i)); + patientInformationRecordMapper.insertSelective(patientInformationRecord); } } + //判断是否是记录是否为空 + if(!StringUtil.isEmpty(param.getRecords())) { + PatientInformationRecord patientInformationRecord = new PatientInformationRecord(); + patientInformationRecord.setId(snowflake.nextId()); + patientInformationRecord.setPatientCarId(bindCar.getId()); + patientInformationRecord.setTaskSubId(param.getId()); + patientInformationRecord.setInformationType((byte) 1); + patientInformationRecord.setContent(param.getRecords()); + patientInformationRecordMapper.insertSelective(patientInformationRecord); + } + } @Override public List query(OtherRecordsDto.Query param) { List patientInformationRecordList = new ArrayList<>(); //通过任务id 找到创建的最新的 - List longs = patientWisdomCarDao.queryByNew(param.getId()); //拿到患者平车id - if(ObjectUtil.isNotNull(longs)){ - PatientInformationRecordExample patientInformationRecordExample = new PatientInformationRecordExample(); - patientInformationRecordExample.createCriteria().andPatientCarIdEqualTo(longs.get(0)).andTaskSubIdEqualTo(param.getId()); - List patientInformationRecords = patientInformationRecordMapper.selectByExample(patientInformationRecordExample); - for (PatientInformationRecord patientInformationRecord : patientInformationRecords) { - OtherRecordsVo.Query query = new OtherRecordsVo.Query(); - query.setComment(patientInformationRecord.getContent()); - query.setType(patientInformationRecord.getInformationType()); - patientInformationRecordList.add(query); - } + //拿到患者平车id + PatientInformationRecordExample patientInformationRecordExample = new PatientInformationRecordExample(); + patientInformationRecordExample.createCriteria().andTaskSubIdEqualTo(param.getId()); + List patientInformationRecords = patientInformationRecordMapper.selectByExample(patientInformationRecordExample); + for (PatientInformationRecord patientInformationRecord : patientInformationRecords) { + OtherRecordsVo.Query query = new OtherRecordsVo.Query(); + query.setComment(patientInformationRecord.getContent()); + query.setType(patientInformationRecord.getInformationType()); + patientInformationRecordList.add(query); } return patientInformationRecordList; }