| | |
| | | package com.ltkj.web.controller.system; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletSecurityElement; |
| | |
| | | private LisApiMethod lisApiMethod; |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | @Autowired |
| | | private SamplingServiceApi samplingService; |
| | | |
| | | /** |
| | | * 查询体检采样管理列表 |
| | |
| | | /** |
| | | * 根据客户获取采样列表 |
| | | * |
| | | * @param cusId |
| | | * @param tjNumber |
| | | * @return |
| | | */ |
| | | @GetMapping("/getCusCyList") |
| | | @ApiOperation(value = "根据客户获取采样列表") |
| | | public AjaxResult getCusCyList(@RequestParam @ApiParam(value = "客户id") String cusId, |
| | | public AjaxResult getCusCyList(@RequestParam @ApiParam(value = "客户id") String tjNumber, |
| | | @RequestParam(defaultValue = "1") @ApiParam(value = "0是1否") Integer isSignFor) { |
| | | if (cusId == null || StrUtil.isBlank(cusId)) |
| | | if (tjNumber == null || StrUtil.isBlank(tjNumber)) |
| | | return AjaxResult.error("参数错误,未传参数"); |
| | | LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TjSampling::getCusId, cusId); |
| | | wrapper.eq(TjSampling::getTjNum, tjNumber); |
| | | wrapper.eq(TjSampling::getIsSignFor,isSignFor); |
| | | wrapper.and(i -> i.isNull(TjSampling::getParentId).or().eq(TjSampling::getIsMerge,1)); |
| | | wrapper.orderByDesc(TjSampling::getIsMerge); |
| | | List<TjSampling> list = tjSamplingService.list(wrapper); |
| | | if (list.isEmpty()){ |
| | | logger.info("cusId参数传的是:"+cusId); |
| | | logger.info("jtNum ->{}",tjNumber); |
| | | return AjaxResult.error("参数错误,未查询到数据"); |
| | | } |
| | | // for (TjSampling sampling : list) { |
| | | // TjCustomer customer = customerService.getById(sampling.getCusId()); |
| | | // TjOrder order = orderService.getOrderByTjNum(sampling.getTjNum()); |
| | | // if(null !=order)sampling.setCardId(order.getCardId()); |
| | | // sampling.setCustomer(customer); |
| | | // } |
| | | |
| | | if (list.size() >= 2) { |
| | | // 进行合并 |
| | | List<String> stringList = list.stream().map(TjSampling::getId).collect(Collectors.toList()); |
| | | log.info("提取id ->{}",stringList); |
| | | for (String s : stringList) { |
| | | if (tjSamplingService.isMergeItem(s) != 0) { |
| | | list.removeIf(item -> Objects.equals(item.getId(), s)); |
| | | } |
| | | } |
| | | Map<String, List<TjSampling>> map = list.stream().filter(i->StrUtil.isNotBlank(i.getSpecimenTypeCode())).collect(Collectors.groupingBy(item -> item.getSpecimenTypeCode())); |
| | | for (Map.Entry<String, List<TjSampling>> entry : map.entrySet()) { |
| | | List<TjSampling> entryValue = entry.getValue(); |
| | | tjSamplingService.mergeCaiYangTran(entryValue.stream().map(TjSampling::getId).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TjSampling::getTjNum, tjNumber); |
| | | wrapper.eq(TjSampling::getIsSignFor,isSignFor); |
| | | wrapper.and(i -> i.isNull(TjSampling::getParentId).or().eq(TjSampling::getIsMerge,1)); |
| | | // wrapper.orderByDesc(TjSampling::getIsMerge); |
| | | wrapper.orderByAsc(TjSampling::getSpecimenTypeCode,TjSampling::getIsMerge); |
| | | list = tjSamplingService.list(wrapper); |
| | | for (TjSampling sampling : list) { |
| | | TjCustomer customer = customerService.getById(sampling.getCusId()); |
| | | TjOrder order = orderService.getOrderByTjNum(sampling.getTjNum()); |
| | |
| | | public AjaxResult confirmSampling(@RequestBody List<String> ids) { |
| | | String config = configService.selectConfigByKey("sfkqdyhis"); |
| | | String mergeRequest = configService.selectConfigByKey("use_lis_pacs_is_auto_merge_request"); |
| | | return confirm(ids,config,mergeRequest); |
| | | } |
| | | |
| | | /** |
| | | * 确认采样接口 |
| | | */ |
| | | public Boolean confirmSamplingApi(List<String> ids,String sfkqdyhis,String mergeRequest) { |
| | | AjaxResult confirm = confirm(ids, sfkqdyhis, mergeRequest); |
| | | log.info("确认采样返回 ->{}",confirm); |
| | | return confirm.get("code").toString().equals("200"); |
| | | } |
| | | |
| | | private AjaxResult confirm(List<String> ids,String config,String mergeRequest) { |
| | | if (null == ids || ids.isEmpty()) { |
| | | return AjaxResult.error("请选择要确认项"); |
| | | } |
| | | List<TjSampling> tjSamplings = tjSamplingService.listByIds(ids); |
| | | if (tjSamplings.isEmpty()) |
| | | return AjaxResult.error("请选择要确认项"); |
| | | String errorMsg = ""; |
| | | for (TjSampling sampling : tjSamplings) { |
| | | if (sampling.getJyxmdm() == null) |
| | | errorMsg+=sampling.getProName()+"在lis系统未找到对应编码无法发出申请"; |
| | | sampling.setIsSignFor("0"); |
| | | // LambdaQueryWrapper<TjProject> wq = new LambdaQueryWrapper<>(); |
| | | // wq.eq(TjProject::getProParentId, sampling.getProId()); |
| | | // List<TjProject> projectList = projectService.list(wq); |
| | | // List<String> collect = new ArrayList<>(); |
| | | // for (TjProject project : projectList) { |
| | | // Long proId = project.getProId(); |
| | | // collect.add(String.valueOf(proId)); |
| | | // } |
| | | // LambdaQueryWrapper<TjSampling> wq1 = new LambdaQueryWrapper<>(); |
| | | // wq1.eq(TjSampling::getTjNum, sampling.getTjNum()); |
| | | // wq1.in(TjSampling::getProId, collect); |
| | | // List<TjSampling> samplingList = tjSamplingService.list(wq1); |
| | | // if (null != samplingList && samplingList.size() > 0) { |
| | | // for (TjSampling tjSampling : samplingList) { |
| | | // tjSampling.setIsSignFor("0"); |
| | | // tjSamplingService.updateById(tjSampling); |
| | | // } |
| | | // } |
| | | TjOrder tjOrder = orderService.getOrderByTjNum(sampling.getTjNum()); |
| | | if(null==tjOrder) return AjaxResult.error("体检记录不存在"); |
| | | TjCustomer tjCustomer = customerService.getById(tjOrder.getUserId()); |
| | | boolean updChild; |
| | | Boolean save; |
| | | if (null != config && config.equals("Y") && !mergeRequest.equals("Y")) { |
| | | save = lisApiMethod.save(sampling, tjOrder, tjCustomer); |
| | | }else { |
| | | save = true; |
| | | } |
| | | if (save) { |
| | | if (sampling.getIsMerge() == 1) { |
| | | LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TjSampling::getParentId, sampling.getId()); |
| | | List<TjSampling> list = tjSamplingService.list(wrapper); |
| | | for (TjSampling tjSampling : list) { |
| | | tjSampling.setIsSignFor("0"); |
| | | } |
| | | updChild = tjSamplingService.updateBatchById(list); |
| | | } else { |
| | | updChild = true; |
| | | } |
| | | if (!tjSamplingService.updateById(sampling) && !updChild) { |
| | | // lisApiMethod.cancel(sampling.getJyxh(), tjOrder.getCardId(), PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "")); |
| | | // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return AjaxResult.error("操作失败请重试"); |
| | | } |
| | | } else { |
| | | return AjaxResult.error("操作失败请重试"); |
| | | } |
| | | } |
| | | if (StrUtil.isNotBlank(errorMsg)) return AjaxResult.error(errorMsg); |
| | | return AjaxResult.success("操作成功"); |
| | | return samplingService.confirm(ids,config,mergeRequest); |
| | | } |
| | | } |