Commit 57da0972 authored by zhangch's avatar zhangch

文件上传相关接口

parent eb2ad4fc
......@@ -23,6 +23,19 @@
<version>2.2.5.RELEASE</version>
</dependency>
<!--feign服务调用-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!--系统服务api-->
<dependency>
<groupId>com.hungraim.ltc</groupId>
<artifactId>system-api</artifactId>
<version>0.0.1</version>
</dependency>
<!--基础包-->
<dependency>
......
......@@ -4,6 +4,7 @@ package com.hungraim.ltc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
......@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement
@EnableFeignClients
public class ApplyApplication {
public static void main(String[] args) {
SpringApplication.run(ApplyApplication.class, args);
......
......@@ -196,6 +196,49 @@ public class DisableController {
if (chDisableApply.getApplyId() == null) {
return Result.failed("请求参数错误");
}
if (StringUtils.isBlank(chDisableApply.getDistrictProvincial()) || StringUtils.isBlank(chDisableApply.getDistrictCity()) || StringUtils.isBlank(chDisableApply.getDistrictArea())) {
return Result.failed("所在省市不能为空!");
}
if (StringUtils.isBlank(chDisableApply.getRealName())) {
return Result.failed("申请人姓名不能为空!");
}
if (StringUtils.isBlank(chDisableApply.getCertiCode())) {
return Result.failed("身份证号码不能为空!");
}
if (chDisableApply.getBirthday() == null) {
return Result.failed("出生年月日不能为空!");
}
if (StringUtils.isBlank(chDisableApply.getGender())) {
return Result.failed("性别不能为空!");
}
if (StringUtils.isBlank(chDisableApply.getTel())) {
return Result.failed("手机号不能为空!");
}
if (chDisableApply.getRegist() == null) {
return Result.failed("所在户籍不能为空!");
}
if (StringUtils.isBlank(chDisableApply.getAcptProvincial()) || StringUtils.isBlank(chDisableApply.getAcptCity()) || StringUtils.isBlank(chDisableApply.getAcptArea()) || StringUtils.isBlank(chDisableApply.getAcptStreet()) || StringUtils.isBlank(chDisableApply.getAcptAddress())) {
return Result.failed("接受评定地址不能为空!");
}
if (StringUtils.isBlank(chDisableApply.getAcptSrvProvincial()) || StringUtils.isBlank(chDisableApply.getAcptSrvCity()) || StringUtils.isBlank(chDisableApply.getAcptSrvArea()) || StringUtils.isBlank(chDisableApply.getAcptSrvStreet()) || StringUtils.isBlank(chDisableApply.getAcptSrvAddress())) {
return Result.failed("接受服务地址不能为空!");
}
if (StringUtils.isBlank(chDisableApply.getAdressDistrictProvincial()) || StringUtils.isBlank(chDisableApply.getAdressDistrictCity()) || StringUtils.isBlank(chDisableApply.getAdressDistrictCode()) || StringUtils.isBlank(chDisableApply.getStreet()) || StringUtils.isBlank(chDisableApply.getAdressDetail())) {
return Result.failed("现住址不能为空!");
}
if (chDisableApply.getDiseTypeF() == null || chDisableApply.getDiseTypeS() == null) {
return Result.failed("诊断疾病不能为空!");
}
if (chDisableApply.getSrvModeId() == null) {
return Result.failed("申请服务方式不能为空!");
}
if (StringUtils.isBlank(chDisableApply.getDiseaseDesc())) {
return Result.failed("疾病描述及诊断不能为空!");
}
if (chDisableApply.getMedicalType() == null) {
return Result.failed("医保类型不能为空!");
}
disableService.updateDisable(chDisableApply);
return Result.success();
}
......
......@@ -4,44 +4,44 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hungraim.ltc.api.AttachFeignService;
import com.hungraim.ltc.dao.*;
import com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach;
import com.hungraim.ltc.pojo.entity.assessment.ChAprTask;
import com.hungraim.ltc.pojo.entity.disable.*;
import com.hungraim.ltc.pojo.entity.serviceManage.ChCfgPara;
import com.hungraim.ltc.pojo.vo.disable.*;
import com.hungraim.ltc.pojo.vo.system.AttachUpdateVo;
import com.hungraim.ltc.pojo.vo.system.AttachVo;
import com.hungraim.ltc.service.DisableService;
import com.hungraim.ltc.util.AttachType;
import com.hungraim.ltc.util.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@Service
@Slf4j
@AllArgsConstructor
public class DisableServiceImpl implements DisableService {
@Autowired
private DisableApplyMapper disableApplyMapper;
@Autowired
private FndDistrictMapper districtMapper;
@Autowired
private FndOrganMapper fndOrganMapper;
@Autowired
private FndStreetMapper fndStreetMapper;
@Autowired
private SrvModeMapper srvModeMapper;
@Autowired
private SrvOrganMapper srvOrganMapper;
@Autowired
private FndDiseaseTypeMapper fndDiseaseTypeMapper;
@Autowired
private DisableApplyHisMapper disableApplyHisMapper;
@Autowired
private DisableInfoMapper disableInfoMapper;
@Autowired
private AprTaskMapper aprTaskMapper;
@Autowired
private CfgParaMapper cfgParaMapper;
private final DisableApplyMapper disableApplyMapper;
private final FndDistrictMapper districtMapper;
private final FndOrganMapper fndOrganMapper;
private final FndStreetMapper fndStreetMapper;
private final SrvModeMapper srvModeMapper;
private final SrvOrganMapper srvOrganMapper;
private final FndDiseaseTypeMapper fndDiseaseTypeMapper;
private final DisableApplyHisMapper disableApplyHisMapper;
private final DisableInfoMapper disableInfoMapper;
private final AprTaskMapper aprTaskMapper;
private final CfgParaMapper cfgParaMapper;
private final AttachFeignService attachFeignService;
/**
* 获取机构ids
......@@ -96,15 +96,46 @@ public class DisableServiceImpl implements DisableService {
DisableExamineInfoVO disableExamineInfoVO = disableApplyMapper.selectDisableExamineInfoByApplyId(applyId);
List<ExamineRecord> examineRecords = disableApplyMapper.listExamineRecordByApplyId(applyId);
disableExamineInfoVO.setExamineRecords(examineRecords);
try {
// zhangch 20210525 新增返回对应的附件列表
Result<List<AttachVo>> listResult = attachFeignService.selectAttachs(Long.valueOf(applyId), (short) 1);
if (listResult.getCode().equals("00000")) {
disableExamineInfoVO.setFileDataList(listResult.getData());
} else {
log.info("请求获取附件列表错误:错误码{},错误信息:{}", listResult.getCode(), listResult.getMsg());
}
} catch (Exception e) {
log.error(e.getMessage());
e.printStackTrace();
}
return disableExamineInfoVO;
}
@Transactional(rollbackFor = Exception.class)
@Override
public void addDisable(ChDisableApply chDisableApply) {
chDisableApply.setEffTime(new Date());
disableApplyMapper.insert(chDisableApply);
this.updateAttachs(chDisableApply);
}
/**
* 调用feign api来修改附件数据
*
* @param chDisableApply
*/
private void updateAttachs(ChDisableApply chDisableApply) {
// zhangch 20210525 新增附件修改逻辑
List<ChFndAttach> fileDataList = chDisableApply.getFileDataList();
AttachUpdateVo attachUpdateVo = new AttachUpdateVo();
attachUpdateVo.setCtrlId(chDisableApply.getApplyId());
attachUpdateVo.setAttachType(AttachType.DISABLE.getUploadType());
attachUpdateVo.setChFndAttachs(fileDataList);
attachFeignService.updateAttachs(attachUpdateVo);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void disableExamine(String applyId, String checkName, Short applyStatus, String checkRemark) {
Date date = new Date();
......@@ -219,9 +250,12 @@ public class DisableServiceImpl implements DisableService {
return sb.toString();
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updateDisable(ChDisableApply chDisableApply) {
disableApplyMapper.updateById(chDisableApply);
// zhangch 20210525 新增附件修改逻辑
this.updateAttachs(chDisableApply);
}
@Override
......
package com.hungraim.ltc.pojo.entity.disable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import com.hungraim.ltc.pojo.entity.PageInfo;
import com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 失能人员申请
......@@ -598,5 +597,8 @@ public class ChDisableApply extends PageInfo implements Serializable {
*/
private Short treatmentType;
@TableField(exist = false)
private List<ChFndAttach> fileDataList;
private static final long serialVersionUID = 1L;
}
package com.hungraim.ltc.pojo.vo.disable;
import com.hungraim.ltc.pojo.vo.system.AttachVo;
import lombok.Data;
import java.util.Date;
......@@ -105,4 +106,6 @@ public class DisableExamineInfoVO {
private String applyStatus;
//备注
private String checkRemark;
private List<AttachVo> fileDataList;
}
package com.hungraim.ltc.pojo.vo.system;
import com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach;
import lombok.Data;
import java.util.List;
@Data
public class AttachUpdateVo {
/**
* 关联id
*/
private Long ctrlId;
/**
* 附件类型(1:失能人员附件;2:鉴定任务附件;3:服务方案附件;4:稽核巡查;5:护理机构基金结算申请新增;6:无锡长护保险自评申请;7:失能信息变更附件;8:评估结论书;9:参保人员及家属;10:评定人员1;11:评定人员2;12:鉴定机构附件;13:护理机构附件;14:鉴定人员附件;15:护理人员附件 16-护理人员服务项目结束附件,17:建床,18:撤床)
*/
private Short attachType;
/**
* 文件对象列表
*/
private List<ChFndAttach> chFndAttachs;
}
package com.hungraim.ltc.pojo.vo.system;
import lombok.Data;
@Data
public class AttachVo {
private Long attachId;
private String fileName;
}
package com.hungraim.ltc.system.controller;
import com.hungraim.ltc.pojo.vo.system.AttachUpdateVo;
import com.hungraim.ltc.pojo.vo.system.AttachVo;
import com.hungraim.ltc.system.config.FileUploadConfig;
import com.hungraim.ltc.system.service.AttachService;
import com.hungraim.ltc.util.FileUtils;
......@@ -7,11 +9,11 @@ import com.hungraim.ltc.util.Result;
import com.hungraim.ltc.util.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@RestController
@RequestMapping("/api.system/resource")
@Slf4j
......@@ -43,4 +45,38 @@ public class FileUploadController {
log.info("保存成功,文件id:{}", attachId);
return Result.success(attachId);
}
/**
* 修改数据库文件表关联数据
* 参数attachUpdateVo对象中,必须要有ctrlId字段的值以及attachType的值,
* 方法会以新传入的这个列表作为ctrlId所关联的所有对象,对于旧的关联数据中这次没有传入的attachId数据进行舍弃
*
* @param attachUpdateVo 文件对象列表
* @return 返回执行结果
*/
@PutMapping("/attachs")
Result updateAttachs(@RequestBody AttachUpdateVo attachUpdateVo) {
if (null == attachUpdateVo || null == attachUpdateVo.getCtrlId() || 0 == attachUpdateVo.getCtrlId() || null == attachUpdateVo.getAttachType() || 0 == attachUpdateVo.getAttachType()) {
return Result.failed(ResultCode.REQUEST_PARAM_ERROR);
}
attachService.updateAttachs(attachUpdateVo);
return Result.success();
}
/**
* 根据ctrlId和attachType查询其对应的数据列表
*
* @param ctrlId 关联id
* @param attachType 附件类型
* @return 返回对应的数据列表
*/
@GetMapping("/attachs")
Result<List<AttachVo>> selectAttachs(Long ctrlId, Short attachType) {
if (null == ctrlId || 0 == ctrlId || null == attachType) {
return Result.failed(ResultCode.REQUEST_PARAM_ERROR);
}
List<AttachVo> attachVos = attachService.selectAttachs(ctrlId, attachType);
return Result.success(attachVos);
}
}
package com.hungraim.ltc.system.service;
import com.hungraim.ltc.pojo.vo.system.AttachUpdateVo;
import com.hungraim.ltc.pojo.vo.system.AttachVo;
import java.util.List;
public interface AttachService {
/**
......@@ -12,4 +17,22 @@ public interface AttachService {
*/
Long saveFileInfo(String originalFilename, String realPath, Short attachType);
/**
* 修改数据库文件表关联数据
* 参数attachUpdateVo对象中,必须要有ctrlId字段的值以及attachType的值,
* 方法会以新传入的这个列表作为ctrlId所关联的所有对象,对于旧的关联数据中这次没有传入的attachId数据进行舍弃
*
* @param attachUpdateVo 文件对象列表
* @return 返回执行结果
*/
void updateAttachs(AttachUpdateVo attachUpdateVo);
/**
* 根据ctrlId和attachType查询其对应的数据列表
*
* @param ctrlId 关联id
* @param attachType 附件类型
* @return 返回对应的数据列表
*/
List<AttachVo> selectAttachs(Long ctrlId, Short attachType);
}
package com.hungraim.ltc.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach;
import com.hungraim.ltc.pojo.vo.system.AttachUpdateVo;
import com.hungraim.ltc.pojo.vo.system.AttachVo;
import com.hungraim.ltc.system.dao.ChFndAttachMapper;
import com.hungraim.ltc.system.service.AttachService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class AttachServiceImpl implements AttachService {
......@@ -27,4 +33,84 @@ public class AttachServiceImpl implements AttachService {
chFndAttachMapper.insert(chFndAttach);
return chFndAttach.getAttachId();
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updateAttachs(AttachUpdateVo attachUpdateVo) {
Long ctrlId = attachUpdateVo.getCtrlId();
Short attachType = attachUpdateVo.getAttachType();
List<ChFndAttach> chFndAttachs = attachUpdateVo.getChFndAttachs();
if (chFndAttachs != null) {
for (ChFndAttach chFndAttach : chFndAttachs) {
chFndAttach.setCtrlId(ctrlId);
chFndAttach.setAttachType(attachType);
}
}
List<ChFndAttach> dbChFndAttachs = this.getChFndAttaches(ctrlId, attachType);
if (dbChFndAttachs != null && dbChFndAttachs.size() > 0) {
/**
* 如果查询到了对应该ctrlId对应的数据,就是更新ctrlId对应的数据集.分2步
* 1->先把原有数据列表中在新数据列表中找不到的数据改为失效状态
* 2->把新数据列表中在原有数据中找不到的数据的增加ctrlId字段的修改
*/
// step 1
for (ChFndAttach dbChFndAttach : dbChFndAttachs) {
boolean deleteFlag = true;
if (chFndAttachs != null) {
for (ChFndAttach chfndAttach : chFndAttachs) {
if (dbChFndAttach.getAttachId().equals(chfndAttach.getAttachId())) {
deleteFlag = false;
}
}
}
if (deleteFlag) {
dbChFndAttach.setStatus((short) 1);
chFndAttachMapper.updateById(dbChFndAttach);
}
}
// step 2
if (chFndAttachs != null) {
for (ChFndAttach chFndAttach : chFndAttachs) {
boolean updateFlag = true;
for (ChFndAttach dbChFndAttach : dbChFndAttachs) {
if (chFndAttach.getAttachId().equals(dbChFndAttach.getAttachId())) {
updateFlag = false;
}
}
if (updateFlag) {
chFndAttachMapper.updateById(chFndAttach);
}
}
}
} else {
if (chFndAttachs != null) {
// 如果没有查询到该ctrlId对应的数据,就是直接更新对应attachId的ctrlId字段
for (ChFndAttach chFndAttach : chFndAttachs) {
chFndAttachMapper.updateById(chFndAttach);
}
}
}
}
private List<ChFndAttach> getChFndAttaches(Long ctrlId, Short attachType) {
// 查询出数据库中原有的该ctrlId关联的数据
QueryWrapper<ChFndAttach> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("CTRL_ID", ctrlId);
queryWrapper.eq("ATTACH_TYPE", attachType);
queryWrapper.eq("STATUS", (short) 0);
List<ChFndAttach> dbChFndAttachs = chFndAttachMapper.selectList(queryWrapper);
return dbChFndAttachs;
}
@Override
public List<AttachVo> selectAttachs(Long ctrlId, Short attachType) {
List<AttachVo> attachVos = new ArrayList<>();
List<ChFndAttach> chFndAttaches = this.getChFndAttaches(ctrlId, attachType);
for (ChFndAttach chFndAttach : chFndAttaches) {
AttachVo attachVo = new AttachVo();
BeanUtils.copyProperties(chFndAttach, attachVo);
attachVos.add(attachVo);
}
return attachVos;
}
}
package com.hungraim.ltc.api;
import com.hungraim.ltc.pojo.vo.system.AttachUpdateVo;
import com.hungraim.ltc.pojo.vo.system.AttachVo;
import com.hungraim.ltc.util.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient("LTC-SYSTEM-ADMIN-SERVICE")
public interface AttachFeignService {
/**
* feign api
* <p>
* 修改数据库文件表关联数据
* 参数chFndAttachs对象列表的对象中,必须要有ctrlId字段的值以及attachType的值,
* 方法会以新传入的这个列表作为ctrlId所关联的所有对象,对于旧的关联数据中这次没有传入的attachId数据进行舍弃
*
* @param attachUpdateVo 文件对象列表
* @return 返回执行结果
*/
@PutMapping("/api.system/resource/attachs")
Result updateAttachs(@RequestBody AttachUpdateVo attachUpdateVo);
/**
* feign api
* <p>
* 根据ctrlId和attachType查询其对应的数据列表
*
* @param ctrlId 关联id
* @param attachType 附件类型
* @return 返回对应的数据列表
*/
@GetMapping("/api.system/resource/attachs")
Result<List<AttachVo>> selectAttachs(@RequestParam("ctrlId") Long ctrlId, @RequestParam("attachType") Short attachType);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment