Browse Source

分片上传参数修改

wangjun 4 years ago
parent
commit
ecd3add9c6

+ 4 - 8
business/base-service/src/main/java/com/yihu/jw/file_upload/FileManageService.java

@ -23,7 +23,7 @@ import java.util.UUID;
@Service
public class FileManageService {
    private static final Logger logger = LoggerFactory.getLogger(FileManageService.class);
    private String basePath = "/root/tempFile" ;
    private String basePath = "/usr/local" ;
    private String fileUrl ="" ;
@ -78,18 +78,14 @@ public class FileManageService {
        fileChannel.close();
        raf.close();
        //第八步
        while (!copflag){
            boolean isComplete = checkUploadStatus(param,fileName,filePath);
            if(isComplete){
                renameFile(tempFile,fileName);
            }
        }
        boolean isComplete = checkUploadStatus(param,fileName,filePath);
        if(isComplete){
            renameFile(tempFile,fileName);
            return filePath+"/"+fileName;
        }else {
            return "unCompelete";
        }
        return "";
    }
    /**

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java

@ -41,7 +41,7 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    @Query("select count(id) from  WlyyOutpatientDO a where a.outpatientType = ?1 and a.doctor = ?2 and a.admDate >=?3 and a.admDate <=?4")
    Integer countByTime(String type,String doctor,Date startTime,Date endTime);
    @Query("from WlyyOutpatientDO a where a.status = 0 and a.payStatus = 1 and (a.remindCount<=?1 or a.remindCount=null)")
    @Query("from WlyyOutpatientDO a where a.status = 0 and a.payStatus = 1 and a.remindCount<?1 ")
    List<WlyyOutpatientDO> findWaitingOutpatient(Integer remindCount);
    /*@Query("from WlyyOutpatientDO a where a.patient = ?1 and a.outpatientType = 1")

+ 25 - 22
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -798,7 +798,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     */
    @Transactional
    public WlyyOutpatientDO appointmentRevisit(String outpatientJson, String expressageJson, String registerJson, String chargeType) throws Exception {
        //1.保存就诊实体
        WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson, WlyyOutpatientDO.class);
        BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
@ -819,7 +818,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //2.物流信息
        WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
        if (null!=previous.getId()&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
            throw new AdminException(MyErrorCode.take_control);
            WlyyOutpatientDO wlyyOutpatientDO = new WlyyOutpatientDO();
            wlyyOutpatientDO.setRemindCount(previous.getOneselfPickupFlg());
            return wlyyOutpatientDO;
        }
        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("WX_MONEY");
@ -2057,7 +2058,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param diagnosisJson
     * @return
     */
    public Map<String, Object> makeDiagnosis(String outPatientId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson) throws Exception {
    public Map<String, Object> makeDiagnosis(String outPatientId,String prescriptionId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson) throws Exception {
        Map<String, Object> result = new HashedMap();
@ -2068,26 +2069,28 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //========================处方操作=============================================================
        //创建处方记录
        List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);
        WlyyPrescriptionDO prescriptionDO = null;
        if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
            prescriptionDO = prescriptionDOs.get(0);
        } else {
            prescriptionDO = new WlyyPrescriptionDO();
        WlyyPrescriptionDO  prescriptionDO= new WlyyPrescriptionDO();
        /*List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);*/
        List<WlyyPrescriptionDO> wlyyPrescriptionDO1 = new ArrayList<>();
        if(StringUtils.isNotBlank(prescriptionId)){
            wlyyPrescriptionDO1 = prescriptionDao.findById(prescriptionId);
            prescriptionDO =wlyyPrescriptionDO1.get(0);
        }else{
            prescriptionDO.setOutpatientId(outPatientId);
            prescriptionDO.setType(1);
            prescriptionDO.setDept(outpatientDO.getDept());
            prescriptionDO.setCreateTime(new Date());
            prescriptionDO.setStatus(10);
            prescriptionDO.setPatientCode(outpatientDO.getPatient());
            prescriptionDO.setPatientName(outpatientDO.getPatientName());
            prescriptionDO.setDoctor(outpatientDO.getDoctor());
            prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
            prescriptionDO.setPayStatus(0);
            if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                prescriptionDO.setAdmNo(outpatientDO.getAdmNo());
            }
        }
        prescriptionDO.setType(1);
        prescriptionDO.setDept(outpatientDO.getDept());
        prescriptionDO.setCreateTime(new Date());
        prescriptionDO.setStatus(10);
        prescriptionDO.setPatientCode(outpatientDO.getPatient());
        prescriptionDO.setPatientName(outpatientDO.getPatientName());
        prescriptionDO.setDoctor(outpatientDO.getDoctor());
        prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
        prescriptionDO.setPayStatus(0);
        if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
            prescriptionDO.setAdmNo(outpatientDO.getAdmNo());
        }
        WlyyPrescriptionDO prescription = prescriptionDao.save(prescriptionDO);
        //========================处方操作结束=============================================================
@ -2142,7 +2145,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            savePrescriptionCheck(prescription.getDoctor(), "开具处方", 5, prescription.getId());
        }
        if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
        if (wlyyPrescriptionDO1 != null && wlyyPrescriptionDO1.size() > 0) {
            savePrescriptionCheck(prescription.getDoctor(), "处方修改", 3, prescription.getId());
        }

+ 8 - 3
business/base-service/src/main/java/com/yihu/jw/utils/AdminException.java

@ -1,10 +1,15 @@
package com.yihu.jw.utils;
import com.yihu.jw.utils.sfutils.MyErrorCode;
public class AdminException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    private MyErrorCode exceptionEnum;
    public AdminException(MyErrorCode exceptionEnum) {
        this.exceptionEnum = exceptionEnum;
    }
    public AdminException(Object Obj) {
        super(Obj.toString());
    public MyErrorCode getMyErrorCode() {
        return exceptionEnum;
    }
}

+ 15 - 22
business/base-service/src/main/java/com/yihu/jw/utils/sfutils/MyErrorCode.java

@ -1,33 +1,26 @@
package com.yihu.jw.utils.sfutils;
public enum MyErrorCode {
    take_control("wj0001","您今日发起过复诊,不允许更改取药方式");
    private String value;
    private String desc;
    EXCEPTION_ONE(725,"请选择与上次相同的快递方式"),
    EXCEPTION_TWO(400,"异常二提示信息"),
    EXCEPTION_THREE(400,"异常三提示信息")
    ;
    private MyErrorCode(String value, String desc) {
        this.setValue(value);
        this.setDesc(desc);
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    //状态码
    private Integer code;
    //异常提示信息
    private String msg;
    public String getDesc() {
        return desc;
    MyErrorCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    public Integer getCode() {
        return code;
    }
    @Override
    public String toString() {
        return "[" + this.value + "]" + this.desc;
    public String getMsg() {
        return msg;
    }
}

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -239,6 +239,7 @@ public class BaseRequestMapping {
        public static final String PREFIX  = "/open/fileUpload";
        public static final String UPLOAD_STREAM_IMG  = "/upload_stream_img";
        public static final String UPLOAD_STREAM  = "/upload_stream";
        public static final String UPLOAD_STREAM_video  = "/upload_stream_video";
        public static final String UPLOAD_STRING  = "/upload_string";
        public static final String UPLOAD_STREAM_ATTACHMENT  = "/upload_stream_attachment";
    }

+ 5 - 19
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/FileUploadController.java

@ -143,25 +143,11 @@ public class FileUploadController extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(/*@ApiParam(value = "文件", required = true)
                                             @RequestParam(value = "file", required = true) MultipartFile file*/
            @ApiParam(value = "jsonData", required = true)
            @RequestBody MutilFileInfo param, HttpServletResponse response, HttpServletRequest request) throws Exception{
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                             @RequestParam(value = "file", required = true) MultipartFile file
            /*@ApiParam(value = "jsonData", required = true)
            @RequestBody MutilFileInfo param, HttpServletResponse response, HttpServletRequest request*/) throws Exception{
        UploadVO uploadVO = new UploadVO();
        String taskId ="";
        logger.info("上传文件 start...");
        try {
            taskId=filemanage.chunkUploadByMappedByteBuffer(param);
        } catch (IOException e) {
            logger.error("文件上传失败。{}", param.toString());
        }
        if("".equalsIgnoreCase(taskId)){
            return success(param.getChunk()+"上传成功",uploadVO);
        }else {
            File pdfFile = new File(taskId);
            FileInputStream fileInputStream = new FileInputStream(pdfFile);
            MultipartFile file = new MockMultipartFile(pdfFile.getName(), pdfFile.getName(), ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
            if (isClose.equalsIgnoreCase("1")){
                Map<String, Object> map = fileUploadService.uploadImg(file);
                uploadVO.setFullUri(map.get("accessory").toString());
@ -182,6 +168,6 @@ public class FileUploadController extends EnvelopRestEndpoint {
            return success("上传成功", uploadVO);
        }
    }
}

+ 17 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/util/ExceptionHandler.java

@ -0,0 +1,17 @@
package com.yihu.jw.base.util;
import com.yihu.jw.utils.AdminException;
import com.yihu.jw.utils.sfutils.MyErrorCode;
import org.csource.common.MyException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
//该类全局拦截Controller请求
@ControllerAdvice
public class ExceptionHandler {
    //对自定义RuntimeException进行拦截和相关响应的修改
    @org.springframework.web.bind.annotation.ExceptionHandler(AdminException.class)
    public ResponseEntity<ExceptionResult> handlerException(AdminException e) {
        MyErrorCode ee = e.getMyErrorCode();
        return ResponseEntity.status(ee.getCode()).body(new ExceptionResult(ee));
    }}

+ 23 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/util/ExceptionResult.java

@ -0,0 +1,23 @@
package com.yihu.jw.base.util;
import com.yihu.jw.utils.sfutils.MyErrorCode;
public class ExceptionResult {
    private Integer code;
    private String msg;
    private Long timestamp;
    public Integer getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public ExceptionResult(MyErrorCode ee) {
        this.code = ee.getCode();
        this.msg = ee.getMsg();
        this.timestamp = System.currentTimeMillis();
    }
}

+ 2 - 2
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/AutoTimeOutRemind.java

@ -71,10 +71,10 @@ public class AutoTimeOutRemind implements SchedulingConfigurer {
                logger.info("启动发送超时提示消息开始");
                System.out.println(wxId);
                System.out.println("启动发送超时提示消息开始");
                Integer remindCount = 5;
                Integer remindCount = 3;
                List<WlyyHospitalSysDictDO> countList = wlyyHospitalSysDictDao.findByDictName("remind_count");
                if (countList.size()>0){
                    remindCount= null!=countList.get(0).getDictValue()?Integer.parseInt(countList.get(0).getDictValue()):5;
                    remindCount= null!=countList.get(0).getDictValue()?Integer.parseInt(countList.get(0).getDictValue()):remindCount;
                }
                List<WlyyOutpatientDO> wlyyOutpatientDOS= outpatientDao.findWaitingOutpatient(remindCount);
                String senderId ="";

+ 68 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java

@ -3,7 +3,9 @@ package com.yihu.jw.hospital.endpoint.file_upload;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.file_upload.FileManageService;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.restmodel.MutilFileInfo;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -11,17 +13,21 @@ import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Map;
@ -46,6 +52,8 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private FileManageService fileManageService;
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
@ -120,6 +128,66 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
        }
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_video)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStreamVideo(@ApiParam(value = "文件", required = true)
                                             @RequestParam(value = "file", required = true) MultipartFile file,
                                                  @ApiParam(value = "文件", required = false)
                                                  @RequestParam(value = "filename", required = false) String filename,
                                                  @ApiParam(value = "taskId", required = false)
                                                      @RequestParam(value = "taskId", required = false) String taskId,
                                                  @ApiParam(value = "chunk", required = false)
                                                      @RequestParam(value = "chunk", required = false) Integer chunk,
                                                  @ApiParam(value = "文件", required = false)
                                                      @RequestParam(value = "sizesize", required = false) Long size,
                                                  @ApiParam(value = "chunkTotal", required = false)
                                                      @RequestParam(value = "chunkTotal", required = false) Integer chunkTotal,
                                                  @ApiParam(value = "objectType", required = false)
                                                      @RequestParam(value = "objectType", required = false) Integer objectType
                                             ) throws Exception{
        UploadVO uploadVO = new UploadVO();
        MutilFileInfo files = new MutilFileInfo();
        files.setChunk(chunk);
        files.setChunkTotal(chunkTotal);
        files.setFile(file);
        files.setObjectType(objectType);
        files.setSize(file.getSize());
        files.setTaskId(taskId);
        String taskid = fileManageService.chunkUploadByMappedByteBuffer(files);
        if ("unCompelete".equalsIgnoreCase(taskid)){
            System.out.println("第"+files.getChunk());
            return success("未传完",uploadVO);
        }else {
            File file1 = new File(taskid);
            FileInputStream input = new FileInputStream(file1);
            MultipartFile multipartFile = new MockMultipartFile("file", file1.getName(), "text/plain", IOUtils.toByteArray(input));
            if (isClose.equalsIgnoreCase("1")){
                Map<String, Object> map = fileUploadService.uploadImg(multipartFile);
                uploadVO.setFullUri(map.get("accessory").toString());
            }else if(isClose.equals("2")){
                //内网上传
                String rs = fileUploadService.request(remote_inner_url,multipartFile,null);
                logger.info(rs);
                JSONObject json = JSON.parseObject(rs);
                uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
            }else {
                // 得到文件的完整名称  xxx.txt
                String originalFilename = multipartFile.getOriginalFilename();
                //判断文件名称是否有包含后缀,及前端是否有传后缀名称,有的话拼接图片后缀
                if(originalFilename.lastIndexOf(".") == 0 && StringUtils.isNotEmpty(filename)){
                    originalFilename = originalFilename +"."+filename;
                }
                InputStream inputStream = multipartFile.getInputStream();
                uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
                file1.delete();
            }
            return success("上传成功", uploadVO);
        }
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STRING)
    @ApiOperation(value = "base64上传图片",notes = "base64上传图片")

+ 30 - 13
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -345,18 +345,33 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "chargeType", required = false)String chargeType)throws Exception {
        
        WlyyOutpatientDO wlyyOutpatientDO = prescriptionService.appointmentRevisit(outpatientJson,expressageJson,registerJson,chargeType);
        
        //发送系统消息
        SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO,payFlag);
        //发送IM消息
        hospitalSystemMessageService.sendImMessage(systemMessageDO);
        
        //发送医生抢单消息
        if(StringUtils.isBlank(wlyyOutpatientDO.getDoctor())){
            hospitalSystemMessageService.sendImPichCheckMessage(wlyyOutpatientDO);
        if (null==wlyyOutpatientDO.getId()){
            ObjEnvelop objEnvelop =new ObjEnvelop();
            String msg = "";
            if (1==wlyyOutpatientDO.getRemindCount()){
                msg = "自取";
            }else {
                msg = "快递配送";
            }
            objEnvelop.setMessage("您已经选择过"+msg+"方式,请勿修改");
            objEnvelop.setStatus(300);
            return objEnvelop;
        }else {
            //发送系统消息
            SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO,payFlag);
            //发送IM消息
            hospitalSystemMessageService.sendImMessage(systemMessageDO);
            //发送医生抢单消息
            if(StringUtils.isBlank(wlyyOutpatientDO.getDoctor())){
                hospitalSystemMessageService.sendImPichCheckMessage(wlyyOutpatientDO);
            }
            return success(BaseHospitalRequestMapping.Prescription.api_success,wlyyOutpatientDO);
        }
        
        return success(BaseHospitalRequestMapping.Prescription.api_success,wlyyOutpatientDO);
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getICD10)
@ -413,8 +428,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                    @ApiParam(name = "inspectionJson", value = "检查检验")
                                    @RequestParam(value = "inspectionJson", required = false)String inspectionJson,
                                    @ApiParam(name = "emrJson", value = "电子病历")
                                        @RequestParam(value = "emrJson", required = false)String emrJson)throws Exception {
        Map<String,Object> result = prescriptionService.makeDiagnosis(outPatientId,advice,type,infoJsons,diagnosisJson,inspectionJson,emrJson);
                                        @RequestParam(value = "emrJson", required = false)String emrJson,
                                    @ApiParam(name = "prescriptionId", value = "处方id")
                                        @RequestParam(value = "prescriptionId", required = false)String prescriptionId)throws Exception {
        Map<String,Object> result = prescriptionService.makeDiagnosis(outPatientId,prescriptionId,advice,type,infoJsons,diagnosisJson,inspectionJson,emrJson);
        try {
            
            com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();