| | |
| | | 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; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.swing.plaf.basic.BasicScrollPaneUI; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.pinyin.PinyinUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ltkj.common.core.redis.RedisCache; |
| | | import com.ltkj.common.utils.IdUtils; |
| | | import com.ltkj.framework.config.MatchUtils; |
| | | import com.ltkj.hosp.domain.TbTransition; |
| | | import com.ltkj.hosp.domain.TjCustomer; |
| | | import com.ltkj.hosp.domain.TjProject; |
| | | import com.ltkj.hosp.service.ITjCustomerService; |
| | | import com.ltkj.hosp.service.ITjProjectService; |
| | | import com.ltkj.hosp.service.TjAsyncService; |
| | | import com.ltkj.hosp.domain.*; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.web.controller.lis.LisApiMethod; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.weaver.AjAttribute; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ltkj.common.annotation.Log; |
| | | import com.ltkj.common.core.controller.BaseController; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | | import com.ltkj.common.enums.BusinessType; |
| | | import com.ltkj.hosp.domain.TjSampling; |
| | | import com.ltkj.hosp.service.ITjSamplingService; |
| | | import com.ltkj.common.utils.poi.ExcelUtil; |
| | | import com.ltkj.common.core.page.TableDataInfo; |
| | | |
| | |
| | | * @author ltkj_赵佳豪&李格 |
| | | * @date 2023-04-11 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/sampling/sampling") |
| | | @Api(tags = "体检采样管理") |
| | | @Api(tags = "PC端 体检采样管理") |
| | | public class TjSamplingController extends BaseController { |
| | | @Resource |
| | | private ITjSamplingService tjSamplingService; |
| | |
| | | private TjAsyncService asyncService; |
| | | @Resource |
| | | private RedisCache redisCache; |
| | | @Autowired |
| | | private ITjOrderService orderService; |
| | | @Autowired |
| | | private ITbTransitionService tbTransitionService; |
| | | @Autowired |
| | | private LisApiMethod lisApiMethod; |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | @Autowired |
| | | private SamplingServiceApi samplingService; |
| | | |
| | | /** |
| | | * 查询体检采样管理列表 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取采样客户列表 |
| | | * |
| | | * @param isSignFor |
| | | * @param tjNum |
| | | * @param name |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @param beginTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | @GetMapping("/getCusList") |
| | | @ApiOperation(value = "获取采样客户列表") |
| | | public AjaxResult getCusList(@RequestParam(defaultValue = "1") @ApiParam(value = "0是1否") Integer isSignFor, |
| | | @RequestParam(required = false) @ApiParam(value = "体检号") String tjNum, |
| | | @RequestParam(required = false) @ApiParam(value = "客户姓名") String name, |
| | | @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum, |
| | | @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize, |
| | | @ApiParam(value = "开始时间") @RequestParam(required = false) String beginTime, |
| | | @ApiParam(value = "结束时间") @RequestParam(required = false) String endTime) { |
| | | Page<TjSampling> samplingPage = new Page<>(pageNum, pageSize); |
| | | LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TjSampling::getIsSignFor, isSignFor); |
| | | if (null != tjNum && StrUtil.isNotBlank(tjNum)) |
| | | wrapper.eq(TjSampling::getTjNum, tjNum); |
| | | if (null != name && StrUtil.isNotBlank(name)) |
| | | wrapper.eq(TjSampling::getCusName, name); |
| | | if (null != beginTime && null != endTime && StrUtil.isNotBlank(beginTime) && StrUtil.isNotBlank(endTime)) |
| | | wrapper.between(TjSampling::getApplicationTime, beginTime, endTime); |
| | | wrapper.groupBy(TjSampling::getCusId); |
| | | // wrapper.last("LIMIT " + (pageNum - 1) * pageSize + "," + pageSize); |
| | | Page<TjSampling> page = tjSamplingService.page(samplingPage, wrapper); |
| | | List<TjSampling> list = page.getRecords(); |
| | | ArrayList<TjCustomer> tjCustomers = new ArrayList<>(); |
| | | for (TjSampling tjSampling : list) { |
| | | TjCustomer customer = customerService.getById(tjSampling.getCusId()); |
| | | customer.setCusName(customer.getCusName()); |
| | | customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone())); |
| | | customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard())); |
| | | customer.setTjNumber(tjSampling.getTjNum()); |
| | | customer.setApplicationTime(tjSampling.getApplicationTime()); |
| | | tjCustomers.add(customer); |
| | | } |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | hashMap.put("list", tjCustomers); |
| | | hashMap.put("total", page.getTotal()); |
| | | return AjaxResult.success(hashMap); |
| | | } |
| | | |
| | | /** |
| | | * 根据客户获取采样列表 |
| | | * |
| | | * @param tjNumber |
| | | * @return |
| | | */ |
| | | @GetMapping("/getCusCyList") |
| | | @ApiOperation(value = "根据客户获取采样列表") |
| | | public AjaxResult getCusCyList(@RequestParam @ApiParam(value = "客户id") String tjNumber, |
| | | @RequestParam(defaultValue = "1") @ApiParam(value = "0是1否") Integer isSignFor) { |
| | | if (tjNumber == null || StrUtil.isBlank(tjNumber)) |
| | | return AjaxResult.error("参数错误,未传参数"); |
| | | LambdaQueryWrapper<TjSampling> 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); |
| | | List<TjSampling> list = tjSamplingService.list(wrapper); |
| | | if (list.isEmpty()){ |
| | | 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()); |
| | | if(null !=order)sampling.setCardId(order.getCardId()); |
| | | sampling.setCustomer(customer); |
| | | } |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/mergeCaiYang") |
| | | @ApiOperation(value = "采样登记合并项目接口") |
| | | public AjaxResult mergeCaiYang(@RequestBody List<String> ids) { |
| | | return tjSamplingService.mergeCaiYangTran(ids); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/chexiaoCaiYang") |
| | | @ApiOperation(value = "撤销采样登记合并项目接口") |
| | | @Transactional |
| | | public AjaxResult chexiaoCaiYang(@RequestBody List<String> ids) { |
| | | if (null != ids && !ids.isEmpty()) { |
| | | int pdsfczhbxm = tjSamplingService.pdsfczhbxm(ids); |
| | | if (pdsfczhbxm != ids.size()) return AjaxResult.error("存在未合并的项目不可撤销!!!"); |
| | | tjSamplingService.deletedTjSamplingListByHb(ids); |
| | | tjSamplingService.updateHeBingXm(ids); |
| | | return AjaxResult.success("撤销成功!!!"); |
| | | } |
| | | return AjaxResult.error("请选择你要撤销的项目!!!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出体检采样管理列表 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('sampling:sampling:export')") |
| | |
| | | */ |
| | | @PostMapping("/confirmSampling") |
| | | @ApiOperation(value = "确认采样接口") |
| | | @Transactional |
| | | public AjaxResult confirmSampling(@RequestBody List<String> ids) { |
| | | if (null == ids || ids.size() == 0) { |
| | | return AjaxResult.error("请选择要确认项"); |
| | | } |
| | | for (String id : ids) { |
| | | TjSampling sampling = tjSamplingService.getById(id); |
| | | if (null != sampling) { |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | tjSamplingService.updateById(sampling); |
| | | } |
| | | return AjaxResult.success("操作成功"); |
| | | String config = configService.selectConfigByKey("sfkqdyhis"); |
| | | String mergeRequest = configService.selectConfigByKey("use_lis_pacs_is_auto_merge_request"); |
| | | return samplingService.confirm(ids,config,mergeRequest); |
| | | } |
| | | } |