| | |
| | | package com.ltkj.hosp.service.impl; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | | import com.ltkj.common.utils.DateUtils; |
| | | import com.ltkj.hosp.idutil.IdUtils; |
| | | import com.ltkj.hosp.service.ITjCustomerService; |
| | | import com.ltkj.hosp.service.ITjOrderService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ltkj.hosp.mapper.TjSamplingMapper; |
| | | import com.ltkj.hosp.domain.TjSampling; |
| | | import com.ltkj.hosp.service.ITjSamplingService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * 体检采样管理Service业务层处理 |
| | |
| | | * @author ltkj_赵佳豪&李格 |
| | | * @date 2023-04-11 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class TjSamplingServiceImpl extends ServiceImpl<TjSamplingMapper,TjSampling> implements ITjSamplingService { |
| | | @Autowired |
| | | private TjSamplingMapper tjSamplingMapper; |
| | | @Autowired |
| | | private IdUtils idUtils; |
| | | @Autowired |
| | | private ITjOrderService orderService; |
| | | @Autowired |
| | | private ITjCustomerService customerService; |
| | | |
| | | /** |
| | | * 查询体检采样管理 |
| | |
| | | public String getBuKeHebingProName(List<String> ids) { |
| | | return tjSamplingMapper.getBuKeHebingProName(ids); |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public AjaxResult mergeCaiYangTran(List<String> ids,String prefix) { |
| | | return mergeCaiYang(ids,prefix); |
| | | } |
| | | |
| | | @Override |
| | | public String mergeCaiYangApi(List<String> ids,String prefix) { |
| | | AjaxResult ajaxResult = mergeCaiYang(ids,prefix); |
| | | log.info("合并采样返回 ->{}",ajaxResult); |
| | | return ajaxResult.get("data").toString(); |
| | | } |
| | | |
| | | private AjaxResult mergeCaiYang(List<String> ids,String prefix) { |
| | | try { |
| | | if (null != ids && !ids.isEmpty()) { |
| | | if(ids.size()==1) return AjaxResult.error("请选择至少两条项目进行合并!"); |
| | | int i = panduanshifoukeyihebing(ids); |
| | | if (i > 1) { |
| | | return AjaxResult.error("标本类型不一致,不可合并"); |
| | | } |
| | | int pdsfczhbxm = pdsfczhbxm(ids); |
| | | if (pdsfczhbxm == ids.size()) return AjaxResult.error("多个合并项目不可再继续合并!"); |
| | | if (pdsfczhbxm > 1) return AjaxResult.error("最多允许选择一个合并过的项目!"); |
| | | // 查询出里面不可合并的化验项目 |
| | | String string = getBuKeHebingProName(ids); |
| | | if(null !=string){ |
| | | return AjaxResult.error(string + "这几个项目不可合并!"); |
| | | } |
| | | if (pdsfczhbxm == 0) { |
| | | TjSampling tjSampling = getById(ids.get(0)); |
| | | Map<String, Object> map = hebingCaiYangInFo(ids); |
| | | TjSampling sampling = new TjSampling(); |
| | | String proId = map.get("proId").toString(); |
| | | String proName = map.get("proName").toString(); |
| | | BeanUtil.copyProperties(tjSampling, sampling, new String[]{"id"}); |
| | | sampling.setProId(proId); |
| | | sampling.setProName(proName); |
| | | sampling.setIsMerge(1); |
| | | sampling.setJyxh(idUtils.generateLisID(prefix)); |
| | | if (save(sampling)) { |
| | | if (updateHeBingXm(ids, sampling.getId())) { |
| | | return AjaxResult.success("合并项目成功!", sampling.getId()); |
| | | } |
| | | } |
| | | return AjaxResult.error("操作失败!"); |
| | | } else { |
| | | TjSampling tjSampling = getTjSamplingByHb(ids); |
| | | List<TjSampling> samplingList = getTjSamplingListByHb(ids); |
| | | if (null != tjSampling && null != samplingList && !samplingList.isEmpty()) { |
| | | List<String> stringList = samplingList.stream().map(TjSampling::getId).collect(Collectors.toList()); |
| | | Map<String, Object> map = hebingCaiYangInFo(stringList); |
| | | String proId = map.get("proId").toString(); |
| | | String proName = map.get("proName").toString(); |
| | | tjSampling.setProId(proId); |
| | | tjSampling.setProName(proName); |
| | | if (updateById(tjSampling)) { |
| | | if (updateHeBingXm(stringList, tjSampling.getParentId())) { |
| | | return AjaxResult.success("合并项目成功!", tjSampling.getId()); |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.error("操作失败!"); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | return AjaxResult.error("请选择你要合并的项目!!!"); |
| | | } |
| | | |
| | | @Override |
| | | public int isMergeItem(String id) { |
| | | return baseMapper.isMergeItem(id); |
| | | } |
| | | |
| | | @Override |
| | | public int isExistProId(String tjh, String proId) { |
| | | return baseMapper.isExistProId(tjh,proId); |
| | | } |
| | | } |