package cn.besteam.modules.medical.service.impl; import cn.besteam.common.constant.ErrorCode; import cn.besteam.common.exception.BusinessException; import cn.besteam.modules.medical.dto.MwBusinessApprovalHandleDTO; import cn.besteam.modules.medical.entity.MwBusinessApproval; import cn.besteam.modules.medical.entity.MwBusinessApprovalHandle; import cn.besteam.modules.medical.entity.MwWarningConfigItem; import cn.besteam.modules.medical.mapper.MwBusinessApprovalHandleMapper; import cn.besteam.modules.medical.service.IMwBusinessApprovalHandleService; import cn.besteam.modules.medical.service.IMwBusinessApprovalService; import cn.besteam.modules.medical.service.IMwWarningConfigItemService; import cn.besteam.modules.medical.vo.MwBusinessApprovalHandleVO; import cn.besteam.modules.system.entity.SysDepartment; import cn.besteam.modules.system.service.ISysDepartmentService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.commons.lang3.time.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * @Description: 审批记录-处理记录 * @author: besteam * @date: 2022-02-09 * @version: V1.0 */ @Service public class MwBusinessApprovalHandleServiceImpl extends ServiceImpl implements IMwBusinessApprovalHandleService { @Autowired private IMwBusinessApprovalService businessApprovalService; @Autowired private ISysDepartmentService sysDepartmentService; @Autowired private IMwWarningConfigItemService mwWarningConfigItemService; @Override public Boolean businessApprovalHandle(MwBusinessApprovalHandleDTO dto) { List mwBusinessApprovalHandleList=new ArrayList<>(); String ids=dto.getBusinessApprovalIds(); if(ids != null && ids != ""){ String[] ids_=ids.split(","); for(String id:ids_){ MwBusinessApproval businessApproval=businessApprovalService.getById(Integer.valueOf(id)); if(businessApproval.getType()==1){//todo 科室禁用 if(dto.getStatus()==1) {// 审核通过需要改变对应的数据 SysDepartment department = sysDepartmentService.getById(businessApproval.getApplyDataId()); if(department!=null){ department.setStatus(0); sysDepartmentService.updateById(department); } } }else if(businessApproval.getType()==2){// todo 未出医废预警设置时长 if(dto.getStatus()==1) {// 审核通过需要改变对应的数据 MwWarningConfigItem mwWarningConfigItem = mwWarningConfigItemService.getById(businessApproval.getApplyDataId()); if(mwWarningConfigItem.getApplyType()==1){//申请固定时长的话需要,审核通过之后,需要删除之前的旧数据 mwWarningConfigItemService.remove(new QueryWrapper() .eq("custom_hospital_id",mwWarningConfigItem.getCustomHospitalId()) .eq("custom_office_id",mwWarningConfigItem.getCustomOfficeId()) .eq("status",1) .eq("apply_type",1) ); } mwWarningConfigItem.setStatus(1); if(mwWarningConfigItem.getApplyType()==3){//临时需要设置到期时间 Date expiration=DateUtils.addDays(new Date(),mwWarningConfigItem.getCustomValue().intValue()); mwWarningConfigItem.setExpirationTime(expiration); } mwWarningConfigItemService.updateById(mwWarningConfigItem); }else { mwWarningConfigItemService.removeById(id); } } businessApproval.setStatus(dto.getStatus()); businessApprovalService.updateById(businessApproval); MwBusinessApprovalHandle mwBusinessApprovalHandle = new MwBusinessApprovalHandle(); mwBusinessApprovalHandle.setContent(dto.getContent()); mwBusinessApprovalHandle.setStatus(dto.getStatus()); mwBusinessApprovalHandle.setCreateTime(new Date()); mwBusinessApprovalHandle.setBusinessApprovalId(Integer.valueOf(id)); mwBusinessApprovalHandleList.add(mwBusinessApprovalHandle); } } return saveBatch(mwBusinessApprovalHandleList); } @Override public List getBusinessApprovalHandleList(Integer businessApprovalId) { return baseMapper.getBusinessApprovalHandleList(businessApprovalId); } }