| | |
| | | |
| | | 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.framework.config.MatchUtils; |
| | | import com.ltkj.hosp.domain.*; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.web.controller.lis.LisApiMethod; |
| | | import com.sun.xml.internal.bind.v2.TODO; |
| | | 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; |
| | |
| | | * @author ltkj_赵佳豪&李格 |
| | | * @date 2023-04-11 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/sampling/sampling") |
| | | @Api(tags = "PC端 体检采样管理") |
| | |
| | | private LisApiMethod lisApiMethod; |
| | | @Autowired |
| | | private IdUtils idUtils; |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | /** |
| | | * 查询体检采样管理列表 |
| | |
| | | */ |
| | | @GetMapping("/getCusCyList") |
| | | @ApiOperation(value = "根据客户获取采样列表") |
| | | public AjaxResult getCusCyList(@RequestParam @ApiParam(value = "客户id") String cusId) { |
| | | public AjaxResult getCusCyList(@RequestParam @ApiParam(value = "客户id") String cusId, |
| | | @RequestParam(defaultValue = "1") @ApiParam(value = "0是1否") Integer isSignFor) { |
| | | if (cusId == null || StrUtil.isBlank(cusId)) |
| | | return AjaxResult.error("参数错误,未传参数"); |
| | | LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TjSampling::getCusId, cusId); |
| | | wrapper.isNull(TjSampling::getParentId).or().eq(TjSampling::getIsMerge,1); |
| | | wrapper.eq(TjSampling::getIsSignFor,isSignFor); |
| | | wrapper.and(i -> i.isNull(TjSampling::getParentId).or().eq(TjSampling::getIsMerge,1)); |
| | | // wrapper.isNull(TjSampling::getParentId).or().eq(TjSampling::getIsMerge,1); |
| | | wrapper.orderByDesc(TjSampling::getIsMerge); |
| | | List<TjSampling> list = tjSamplingService.list(wrapper); |
| | | if (list.isEmpty()){ |
| | |
| | | int pdsfczhbxm = tjSamplingService.pdsfczhbxm(ids); |
| | | if (pdsfczhbxm == ids.size()) return AjaxResult.error("多个合并项目不可再继续合并!"); |
| | | if (pdsfczhbxm > 1) return AjaxResult.error("最多允许选择一个合并过的项目!"); |
| | | String string = tjSamplingService.getBuKeHebingProName(ids); |
| | | if(null !=string){ |
| | | return AjaxResult.error(string+"这几个项目不可合并!"); |
| | | } |
| | | if (pdsfczhbxm == 0) { |
| | | TjSampling tjSampling = tjSamplingService.getById(ids.get(0)); |
| | | Map<String, Object> map = tjSamplingService.hebingCaiYangInFo(ids); |
| | |
| | | @ApiOperation(value = "确认采样接口") |
| | | @Transactional |
| | | public AjaxResult confirmSampling(@RequestBody List<String> ids) { |
| | | if (null == ids || ids.size() == 0) { |
| | | if (null == ids || ids.isEmpty()) { |
| | | 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); |
| | | } |
| | | } |
| | | List<TjSampling> tjSamplings = tjSamplingService.listByIds(ids); |
| | | if (tjSamplings.isEmpty()) |
| | | return AjaxResult.error("请选择要确认项"); |
| | | for (TjSampling sampling : tjSamplings) { |
| | | 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; |
| | | String config = configService.selectConfigByKey("sfkqdyhis"); |
| | | Boolean save; |
| | | if (null != config && config.equals("Y")) { |
| | | save = lisApiMethod.save(sampling, tjOrder, tjCustomer); |
| | | }else { |
| | | save = true; |
| | | } |
| | | if (!tjSamplingService.updateById(sampling)) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return AjaxResult.error("操作失败,请重试"); |
| | | 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("操作失败请重试"); |
| | | } |
| | | } |
| | | |
| | | return AjaxResult.success("操作成功"); |
| | | } |
| | | } |