zhaowenxuan
2024-07-26 ff7f564dc6c43384857a80246f72575a40e86cde
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -23,6 +23,9 @@
import cn.hutool.core.date.DateUtil;
import cn.hutool.crypto.symmetric.DES;
import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -43,6 +46,9 @@
import com.ltkj.framework.datasource.DynamicDataSourceContextHolder;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.dto.QianDaoDto;
import com.ltkj.hosp.dto.TjProBlDto;
import com.ltkj.hosp.hisDto.OutpinimpapplyDto;
import com.ltkj.hosp.hisDto.OutpinmedicapplyDto;
import com.ltkj.hosp.mapper.TestMapper;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.sqlDomain.LtkjMiddleDetail;
@@ -63,6 +69,7 @@
import com.ltkj.system.service.ISysUserService;
import com.ltkj.web.controller.his.HisApiGetMethodService;
import com.ltkj.web.controller.his.HisApiMethod;
import com.ltkj.web.controller.his.HisApiMethodService;
import com.ltkj.web.controller.his.HisMzJysqController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -92,8 +99,8 @@
 * @date 2022-11-21
 */
@RestController
@RequestMapping("/hosp/order")
@Api(tags = "PC端 ----体检记录接口")
@RequestMapping ("/hosp/order")
@Api (tags = "PC端 ----体检记录接口")
@Slf4j
public class TjOrderController extends BaseController {
    @Resource
@@ -118,7 +125,7 @@
    private ITbTransitionService transitionService;
    @Resource
    private ISysConfigService configService;
    @Value("${path.filePath}")
    @Value ("${path.filePath}")
    private String value;
    @Resource
    private ITjOrderRemarkService remarkService;
@@ -183,14 +190,35 @@
    private HisMzJysqController hisMzJysqController;
    @Autowired
    private HisApiGetMethodService hisApiGetMethodService;
    @Autowired
    private ISysDeptService sysDeptService;
    @Autowired
    private HisApiMethodService controller;
    @Autowired
    private TjProBlService blService;
    @Autowired
    private LtkjJianchajianyanTreeService ltkjJianchajianyanTreeService;
    @Autowired
    private TjCfService cfService;
    //将方法返回值解析成json格式
    public JSONObject getJSONObject(String builder) {
        String Response = JSONUtil.parseObj(builder).getStr("Response");
        return JSONUtil.parseObj(Response);
    }
    //获取方法返回值信息
    public String getAjaxResult(AjaxResult result) {
        return result.get("data").toString();
    }
    /**
     * 查询体检记录列表
     */
//    @PreAuthorize("@ss.hasPermi('hosp:order:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询体检记录列表(默认)")
    @GetMapping ("/list")
    @ApiOperation (value = "查询体检记录列表(默认)")
    public TableDataInfo list(TjOrder tjOrder) {
        startPage();
        startOrderBy();
@@ -223,16 +251,16 @@
    }
    @GetMapping("/getWenJuanList")
    @ApiOperation(value = "查询体检记录列表")
    public AjaxResult getWenJuanList(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum,
                                     @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                     @ApiParam(value = "体检号") @RequestParam(required = false) String tjNum,
                                     @ApiParam(value = "姓名") @RequestParam(required = false) String name,
                                     @ApiParam(value = "登记开始时间") @RequestParam(required = false) Date djbeginTime,
                                     @ApiParam(value = "登记结束时间") @RequestParam(required = false) Date djendTime,
                                     @ApiParam(value = "报告开始时间") @RequestParam(required = false) Date bgbeginTime,
                                     @ApiParam(value = "报告结束时间") @RequestParam(required = false) Date bgendTime) {
    @GetMapping ("/getWenJuanList")
    @ApiOperation (value = "查询体检记录列表")
    public AjaxResult getWenJuanList(@ApiParam (value = "页码数(默认1)") @RequestParam (defaultValue = "1") Integer pageNum,
                                     @ApiParam (value = "显示条数(默认10)") @RequestParam (defaultValue = "10") Integer pageSize,
                                     @ApiParam (value = "体检号") @RequestParam (required = false) String tjNum,
                                     @ApiParam (value = "姓名") @RequestParam (required = false) String name,
                                     @ApiParam (value = "登记开始时间") @RequestParam (required = false) Date djbeginTime,
                                     @ApiParam (value = "登记结束时间") @RequestParam (required = false) Date djendTime,
                                     @ApiParam (value = "报告开始时间") @RequestParam (required = false) Date bgbeginTime,
                                     @ApiParam (value = "报告结束时间") @RequestParam (required = false) Date bgendTime) {
        Map<String, Object> map = new HashMap<>();
        if (null != name) {
            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
@@ -352,16 +380,17 @@
    }
    @GetMapping("/getOrderList")
    @ApiOperation(value = "查询体检记录列表")
    public AjaxResult getOrderList(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum,
                                   @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                   @ApiParam(value = "体检号)") @RequestParam(required = false) String tjNum,
                                   @ApiParam(value = "姓名)") @RequestParam(required = false) String name,
                                   @ApiParam(value = "登记开始时间") @RequestParam(required = false) Date djbeginTime,
                                   @ApiParam(value = "登记结束时间") @RequestParam(required = false) Date djendTime,
                                   @ApiParam(value = "报告开始时间") @RequestParam(required = false) Date bgbeginTime,
                                   @ApiParam(value = "报告结束时间") @RequestParam(required = false) Date bgendTime) {
    @GetMapping ("/getOrderList")
    @ApiOperation (value = "查询体检记录列表")
    public AjaxResult getOrderList(@ApiParam (value = "页码数(默认1)") @RequestParam (defaultValue = "1") Integer pageNum,
                                   @ApiParam (value = "显示条数(默认10)") @RequestParam (defaultValue = "10") Integer pageSize,
                                   @ApiParam (value = "体检号)") @RequestParam (required = false) String tjNum,
                                   @ApiParam (value = "姓名)") @RequestParam (required = false) String name,
                                   @ApiParam (value = "项目名)") @RequestParam (required = false) String xmmc,
                                   @ApiParam (value = "登记开始时间") @RequestParam (required = false) Date djbeginTime,
                                   @ApiParam (value = "登记结束时间") @RequestParam (required = false) Date djendTime,
                                   @ApiParam (value = "报告开始时间") @RequestParam (required = false) Date bgbeginTime,
                                   @ApiParam (value = "报告结束时间") @RequestParam (required = false) Date bgendTime) {
        Map<String, Object> map = new HashMap<>();
        if (null != name) {
            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
@@ -431,6 +460,12 @@
        if (null != tjNum) {
            wq.eq(TjOrder::getTjNumber, tjNum);
        }
        if (null != xmmc) {
            wq.in(TjOrder::getTjNumber, projectService.getTjNumLIstByXmmx(xmmc));
        }
        wq.orderByDesc(TjOrder::getCreateTime);
        Page<TjOrder> page2 = tjOrderService.page(page1, wq);
        List<TjOrder> list = page2.getRecords();
@@ -440,10 +475,8 @@
                if (null != tjCustomer) {
                    order.setTjCustomerSex(tjCustomer.getCusSex());
                    order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
                    order.setTjCustomerName(tjCustomer.getCusName());
                    order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
//                    order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
                    order.setTjCustomerPhone(tjCustomer.getCusPhone());
                    order.setTjCusIdCard(tjCustomer.getCusIdcard());
                    order.setCareer(tjCustomer.getCareer());
                    order.setIdType(tjCustomer.getIdType());
@@ -457,7 +490,7 @@
                if (null != order.getPacId()) {
                    if (null != tjPackageService.getById(order.getPacId())) {
                        order.setPacName(tjPackageService.getById(order.getPacId()).getPacName());
                    }
                    }else
                    if (null != dwDeptService.getById(order.getPacId())) {
                        order.setPacName(dwDeptService.getById(order.getPacId()).getDwDeptName());
                    }
@@ -470,14 +503,14 @@
    }
    @GetMapping("/getOrderListOO")
    @ApiOperation(value = "体检报告页面——体检记录列表")
    public AjaxResult getOrderListOO(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum,
                                     @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                     @ApiParam(value = "体检号)") @RequestParam(required = false) String tjNum,
                                     @ApiParam(value = "姓名)") @RequestParam(required = false) String name,
                                     @ApiParam(value = "报告开始时间") @RequestParam(required = false) Date bgbeginTime,
                                     @ApiParam(value = "报告结束时间") @RequestParam(required = false) Date bgendTime) {
    @GetMapping ("/getOrderListOO")
    @ApiOperation (value = "体检报告页面——体检记录列表")
    public AjaxResult getOrderListOO(@ApiParam (value = "页码数(默认1)") @RequestParam (defaultValue = "1") Integer pageNum,
                                     @ApiParam (value = "显示条数(默认10)") @RequestParam (defaultValue = "10") Integer pageSize,
                                     @ApiParam (value = "体检号)") @RequestParam (required = false) String tjNum,
                                     @ApiParam (value = "姓名)") @RequestParam (required = false) String name,
                                     @ApiParam (value = "报告开始时间") @RequestParam (required = false) Date bgbeginTime,
                                     @ApiParam (value = "报告结束时间") @RequestParam (required = false) Date bgendTime) {
        Map<String, Object> map = new HashMap<>();
        if (null != name) {
            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
@@ -599,15 +632,15 @@
    }
    @GetMapping("/getPrintOrderList")
    @ApiOperation(value = "体检发票打印接口")
    public AjaxResult getPrintOrderList(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum,
                                        @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                        @ApiParam(value = "体检号)") @RequestParam(required = false) String tjNum,
                                        @ApiParam(value = "已打印未打印0未打印1已打印)") @RequestParam(required = false) Integer type,
                                        @ApiParam(value = "姓名") @RequestParam(required = false) String name,
                                        @ApiParam(value = "报告开始时间") @RequestParam(required = false) Date bgbeginTime,
                                        @ApiParam(value = "报告结束时间") @RequestParam(required = false) Date bgendTime) {
    @GetMapping ("/getPrintOrderList")
    @ApiOperation (value = "体检发票打印接口")
    public AjaxResult getPrintOrderList(@ApiParam (value = "页码数(默认1)") @RequestParam (defaultValue = "1") Integer pageNum,
                                        @ApiParam (value = "显示条数(默认10)") @RequestParam (defaultValue = "10") Integer pageSize,
                                        @ApiParam (value = "体检号)") @RequestParam (required = false) String tjNum,
                                        @ApiParam (value = "已打印未打印0未打印1已打印)") @RequestParam (required = false) Integer type,
                                        @ApiParam (value = "姓名") @RequestParam (required = false) String name,
                                        @ApiParam (value = "报告开始时间") @RequestParam (required = false) Date bgbeginTime,
                                        @ApiParam (value = "报告结束时间") @RequestParam (required = false) Date bgendTime) {
        Map<String, Object> map = new HashMap<>();
        List<TjOrder> collect = null;
        if (null != name) {
@@ -798,9 +831,9 @@
     * 导出体检记录列表
     */
//    @PreAuthorize("@ss.hasPermi('hosp:order:export')")
    @Log(title = "体检记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出体检记录列表")
    @Log (title = "体检记录", businessType = BusinessType.EXPORT)
    @PostMapping ("/export")
    @ApiOperation (value = "导出体检记录列表")
    public void export(HttpServletResponse response, TjOrder tjOrder) {
        //List<TjOrder> list = tjOrderService.selectTjOrderList(tjOrder);
        List<TjOrder> list = tjOrderService.selectExportOrderList(tjOrder);
@@ -812,15 +845,15 @@
     * 获取体检记录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('hosp:order:query')")
    @GetMapping(value = "/{orderId}")
    @ApiOperation(value = "获取体检记录详细信息")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId) {
    @GetMapping (value = "/{orderId}")
    @ApiOperation (value = "获取体检记录详细信息")
    public AjaxResult getInfo(@PathVariable ("orderId") Long orderId) {
        return success(tjOrderService.selectTjOrderByOrderId(orderId));
    }
    @GetMapping("/getIsRequired")
    @ApiOperation(value = "根据参数配置获取是否必填项(身份证、性别、电话、照片、是否直接下单)")
    @GetMapping ("/getIsRequired")
    @ApiOperation (value = "根据参数配置获取是否必填项(身份证、性别、电话、照片、是否直接下单)")
    public AjaxResult getIsRequired() {
        Map<String, String> res = new HashMap<>();
        res.put("has_idcard", configService.selectConfigByKey("has_idcard"));
@@ -836,7 +869,7 @@
     * 体检签到登记接口
     */
    @PostMapping
    @ApiOperation(value = "体检签到登记接口")
    @ApiOperation (value = "体检签到登记接口")
    @Transactional  //(切换数据库出错,所以注释)
    public AjaxResult addOrderAndDetail(@RequestBody TjOrder tjOrder) throws Exception {
        Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId());
@@ -856,7 +889,7 @@
//        }
        TjOrder order = tjOrderService.getOne(wqq);
        if (null != order) {
            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(),tjCustomer.getCardId());
            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
            return AjaxResult.error("不可重复登记");
        }
@@ -869,9 +902,9 @@
        if (null != tjReservation) {
            tjOrder.setReservationId(tjReservation.getId());
            mallOrder = mallOrderService.getOne(new LambdaQueryWrapper<MallOrder>().eq(MallOrder::getReservationId, tjReservation.getId()));
            if (DateUtil.endOfDay(new Date()).before(tjReservation.getReservationTime())) {
                return AjaxResult.error("未到预约时间");
            }
//            if (DateUtil.endOfDay(new Date()).before(tjReservation.getReservationTime())) {
//                return AjaxResult.error("未到预约时间");
//            }
            if (DateUtil.endOfDay(tjReservation.getReservationTime()).before(new Date())) {
                tjReservation.setIsExpire(1);
                tjReservationService.updateById(tjReservation);
@@ -921,6 +954,11 @@
        if (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId()));
        tjOrder.setStatus(TjConstants.TJ_BEGIN);
        tjOrder.setCardId(tjCustomer.getCardId());
        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
            tjOrder.setFinishTime(new Date());
            tjOrder.setCheckStatus(1);
            tjOrder.setStatus(TjConstants.TJ_WAIT);
        }
        if (tjOrderService.save(tjOrder)) {
            //保存收货地址
@@ -934,7 +972,7 @@
            Long cusNumber = tjCustomer.getCusNumber();
            cusNumber += 1;
            tjCustomer.setCusNumber(cusNumber);
            BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount())).divide(BigDecimal.valueOf(10));
            BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount()));
            TjFlowingWater tjFlowingWater = new TjFlowingWater();
            tjFlowingWater.setPayStasus(0L);
            if ("1".equals(tjOrder.getTjType())) {
@@ -1034,22 +1072,29 @@
            /*调用his接口*/
            String config = configService.selectConfigByKey("sfkqdyhis");
            if(null !=config && config.equals("Y")){
                hisApiMethod.HisApiMethods(tjCustomer,tjOrder.getOrderId());
            if (null != config && config.equals("Y")) {
                AjaxResult result = hisApiMethod.HisApiMethods(tjCustomer, tjOrder.getOrderId());
                if (!result.get("code").toString().equals("200")) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("挂号失败!" + result.get("msg").toString());
                }
            } else {
                tjCustomer.setCardId(tjOrder.getTjNumber());
                tjCustomerService.updateById(tjCustomer);
                transitionService.updateCardIdByTjNumAndIdCard(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), tjOrder.getTjNumber());
                tjOrder.setCardId(tjOrder.getTjNumber());
                tjOrderService.updateById(tjOrder);
            }
//            tjCustomer.setCardId("0");
//            tjCustomerService.updateById(tjCustomer);
            return AjaxResult.success(tjNumber);
        }
        return AjaxResult.error();
    }
    @PostMapping("/addPlOrderAndDetail")
    @ApiOperation(value = "体检批量签到登记接口")
    @PostMapping ("/addPlOrderAndDetail")
    @ApiOperation (value = "体检批量签到登记接口")
    @Transactional  //(切换数据库出错,所以注释)
    public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto,HttpServletResponse response) {
    public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto, HttpServletResponse response) {
        SysUser sysUser = UserHoder.getLoginUser().getUser();
        List<String> cusIds = daoDto.getCusIds();
        ArrayList<String> tjNumbers = new ArrayList<>();
@@ -1434,7 +1479,7 @@
                tjCustomer.setCardId("0");
                tjCustomerService.updateById(tjCustomer);
                return AjaxResult.success().put("tjNumber",tjNumber);
                return AjaxResult.success().put("tjNumber", tjNumber);
            }
        }
        return AjaxResult.error();
@@ -1445,9 +1490,9 @@
     * 修改体检记录
     */
//    @PreAuthorize("@ss.hasPermi('hosp:order:edit')")
    @Log(title = "体检记录", businessType = BusinessType.UPDATE)
    @Log (title = "体检记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改体检记录")
    @ApiOperation (value = "修改体检记录")
    public AjaxResult edit(@RequestBody TjOrder tjOrder) {
        return toAjax(tjOrderService.updateTjOrder(tjOrder));
    }
@@ -1456,16 +1501,16 @@
     * 删除体检记录
     */
//    @PreAuthorize("@ss.hasPermi('hosp:order:remove')")
    @Log(title = "体检记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{orderIds}")
    @ApiOperation(value = "删除体检记录")
    @Log (title = "体检记录", businessType = BusinessType.DELETE)
    @DeleteMapping ("/{orderIds}")
    @ApiOperation (value = "删除体检记录")
    public AjaxResult remove(@PathVariable Long[] orderIds) {
        return toAjax(tjOrderService.deleteTjOrderByOrderIds(orderIds));
    }
    @GetMapping("/getOrderDetailByTjNumber")
    @ApiOperation(value = "根据体检号获取体检详情")
    public AjaxResult getOrderDetailByTjNumber(@RequestParam @ApiParam(value = "体检号") String tjNumber) {
    @GetMapping ("/getOrderDetailByTjNumber")
    @ApiOperation (value = "根据体检号获取体检详情")
    public AjaxResult getOrderDetailByTjNumber(@RequestParam @ApiParam (value = "体检号") String tjNumber) {
        LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
        wq0.eq(TjOrder::getTjNumber, tjNumber);
        TjOrder tjOrder = tjOrderService.getOne(wq0);
@@ -1485,8 +1530,8 @@
        return AjaxResult.success("暂无数据");
    }
    @PostMapping("/addtTransition")
    @ApiOperation(value = "添加过渡表数据")
    @PostMapping ("/addtTransition")
    @ApiOperation (value = "添加过渡表数据")
    @Transactional
    public AjaxResult addtTransition(@RequestBody Map<String, Object> map) {
        Object packId = map.get("pacId");
@@ -1511,66 +1556,68 @@
                redisCache.deleteCacheMapValue(cardId + cusId + "cusId", cardId + cusId);
            }
        }
        List<TbTransition> tbTransitionList = null;
        if (!redisCache.hasKey(cardId + cusId)) {
            tbTransitionList = new ArrayList<>();
        } else {
            tbTransitionList = redisCache.getCacheList(cardId + cusId);
        }
//        List<TbTransition> tbTransitionList = null;
//        if (!redisCache.hasKey(cardId + cusId)) {
//            tbTransitionList = new ArrayList<>();
//        } else {
//            tbTransitionList = redisCache.getCacheList(cardId + cusId);
//        }
        //套餐
        /*套餐*/
        if (null != packId && !packId.equals("")) {
            Long pacId = Long.valueOf(packId.toString());
            List<TbTransition> list = transitionService.getTbTransitionListByCusIdAndPac(cusId, String.valueOf(pacId));
            if (null == list || list.size() == 0) {
                transitionService.deletedTbTransitionListByCusIdAndPac(cusId, cardId);
                if (redisCache.hasKey(cardId + cusId + "cusId"))
                    redisCache.deleteCacheMapValue(cardId + cusId + "cusId", cardId + cusId);
                if (redisCache.hasKey(cardId + cusId)) {
                    tbTransitionList = new ArrayList<>();
                    redisCache.deleteObject(cardId + cusId);
                }
//                if (redisCache.hasKey(cardId + cusId + "cusId"))
//                    redisCache.deleteCacheMapValue(cardId + cusId + "cusId", cardId + cusId);
//                if (redisCache.hasKey(cardId + cusId)) {
//                    tbTransitionList = new ArrayList<>();
//                    redisCache.deleteObject(cardId + cusId);
//                }
                List<TjPackageProject> ppList = tjPackageProjectService.getTjPackageProjectListByPacId(String.valueOf(pacId));
                if (null != ppList && ppList.size() > 0) {
                    transitionService.saveRedisTransitionByPacId(cusId, cardId, pacId);
                    //异步保存数据库
//                    asyncService.addRedisTransitionPac(cusId, pacId, ppList);
                    asyncService.saveRedisTransitionByPacId(cusId,cardId, pacId, null);
                    for (TjPackageProject tjPackageProject : ppList) {
                        TjProject project = projectService.getTjProjectById(String.valueOf(tjPackageProject.getProId()));
                        if (null != project) {
                            BigDecimal divide = BigDecimal.valueOf(0);
                            if (tjPackageProject.getPriceNow().compareTo(BigDecimal.valueOf(0)) == 0 || project.getProPrice().compareTo(BigDecimal.valueOf(0)) == 0) {
                                divide = BigDecimal.valueOf(0);
                            } else {
                                divide = tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN);
                            }
                            List<TjProject> tjProSonList = projectService.getTjProjectListBySoneId(String.valueOf(project.getProId()));
                            if (null != tjProSonList && tjProSonList.size() > 0) {
                                //addRedisTransitionPac(cusId, tbTransitionList, pacId, tjPackageProject, project, divide, tjProSonList);
                                for (TjProject tjProject : tjProSonList) {
                                    TbTransition tbTransition = new TbTransition();
                                    tbTransition.setCusId(cusId);
                                    tbTransition.setPacId(pacId);
                                    if (null != tjPackageProject.getPriceNow() && divide.compareTo(BigDecimal.valueOf(0)) > 0) {
                                        tbTransition.setNowPrice(tjProject.getProPrice().multiply(divide).setScale(2, RoundingMode.HALF_DOWN));
                                        tbTransition.setOrdPrice(tjProject.getProPrice().multiply(divide).setScale(2, RoundingMode.HALF_DOWN));
                                    } else {
                                        tbTransition.setNowPrice(BigDecimal.valueOf(0.00));
                                        tbTransition.setOrdPrice(BigDecimal.valueOf(0.00));
                                    }
                                    tbTransition.setParentProId(project.getProId());
                                    tbTransition.setParentProName(project.getProName());
                                    tbTransition.setProId(tjProject.getProId());
                                    tbTransition.setProName(tjProject.getProName());
                                    tbTransition.setPacName(tjPackageService.getById(tbTransition.getPacId()).getPacName());
                                    tbTransition.setProType(tjProject.getProType());
                                    tbTransition.setProCheckMethod(tjProject.getProCheckMethod());
                                    tbTransitionList.add(tbTransition);
                                }
                            }
                        }
                    }
//                    asyncService.saveRedisTransitionByPacId(cusId, cardId, pacId, null);
//                    for (TjPackageProject tjPackageProject : ppList) {
//                        TjProject project = projectService.getTjProjectById(String.valueOf(tjPackageProject.getProId()));
//                        if (null != project) {
//
//                            BigDecimal divide = BigDecimal.valueOf(0);
//                            if (tjPackageProject.getPriceNow().compareTo(BigDecimal.valueOf(0)) == 0 || project.getProPrice().compareTo(BigDecimal.valueOf(0)) == 0) {
//                                divide = BigDecimal.valueOf(0);
//                            } else {
//                                divide = tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN);
//                            }
//                            List<TjProject> tjProSonList = projectService.getTjProjectListBySoneId(String.valueOf(project.getProId()));
//                            if (null != tjProSonList && tjProSonList.size() > 0) {
//                                //addRedisTransitionPac(cusId, tbTransitionList, pacId, tjPackageProject, project, divide, tjProSonList);
//                                for (TjProject tjProject : tjProSonList) {
//                                    TbTransition tbTransition = new TbTransition();
//                                    tbTransition.setCusId(cusId);
//                                    tbTransition.setPacId(pacId);
//                                    if (null != tjPackageProject.getPriceNow() && divide.compareTo(BigDecimal.valueOf(0)) > 0) {
//                                        tbTransition.setNowPrice(tjProject.getProPrice().multiply(divide).setScale(2, RoundingMode.HALF_DOWN));
//                                        tbTransition.setOrdPrice(tjProject.getProPrice().multiply(divide).setScale(2, RoundingMode.HALF_DOWN));
//                                    } else {
//                                        tbTransition.setNowPrice(BigDecimal.valueOf(0.00));
//                                        tbTransition.setOrdPrice(BigDecimal.valueOf(0.00));
//                                    }
//                                    tbTransition.setParentProId(project.getProId());
//                                    tbTransition.setParentProName(project.getProName());
//                                    tbTransition.setProId(tjProject.getProId());
//                                    tbTransition.setProName(tjProject.getProName());
//                                    tbTransition.setPacName(tjPackageService.getById(tbTransition.getPacId()).getPacName());
//                                    tbTransition.setProType(tjProject.getProType());
//                                    tbTransition.setProCheckMethod(tjProject.getProCheckMethod());
//                                    tbTransitionList.add(tbTransition);
//                                }
//
//                            }
//                        }
//                    }
                }
            }
        }
@@ -1578,69 +1625,81 @@
        //单项
        if (null != proIds && proIds.size() > 0) {
            //异步保存数据库表
            asyncService.saveRedisTransitionByPacId(cusId,cardId,null, proIds);
//            asyncService.saveRedisTransitionByPacId(cusId, cardId, null, proIds);
            for (Long proId : proIds) {
                List<TbTransition> transitions = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(proId));
                if (null != transitions && transitions.size() > 0) {
                    continue;
                TjProject project = projectService.selectTjProjectByProId(proId);
                if (null != project) { //&& (!project.getProName().contains("静脉采血")|| !project.getProName().contains("费"))
                    List<TbTransition> transitionList = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(proId));
                    if (null == transitionList || transitionList.size() == 0) {
                        transitionService.saveRedisTransitionByProId(cusId, cardId, proId);
                    }
                }
                TjProject tjProject = projectService.getTjProjectById(String.valueOf(proId));
                if (null != tjProject) {
//                    List<TjProject> tjProSonList = projectService.getTjProjectListBySoneId(String.valueOf(project.getProId()));
//                    if (null != tjProSonList && tjProSonList.size() > 0) {
//                        for (TjProject tjProject : tjProSonList) {
//                    List<TbTransition> transitionss = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(tjProject.getProId()));
//                    if (null != transitionss && transitionss.size() > 0) {
//                        continue;
//            if(null !=project) transitionService.saveRedisTransitionByProId(cusId,cardId, proId);
            }
//            for (Long proId : proIds) {
//                List<TbTransition> transitions = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(proId));
//                if (null != transitions && transitions.size() > 0) {
//                    continue;
//                }
//                TjProject tjProject = projectService.getTjProjectById(String.valueOf(proId));
//                if (null != tjProject) {
////                    List<TjProject> tjProSonList = projectService.getTjProjectListBySoneId(String.valueOf(project.getProId()));
////                    if (null != tjProSonList && tjProSonList.size() > 0) {
////                        for (TjProject tjProject : tjProSonList) {
////                    List<TbTransition> transitionss = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(cusId, String.valueOf(tjProject.getProId()));
////                    if (null != transitionss && transitionss.size() > 0) {
////                        continue;
////                    }
//                    TbTransition tbTransition = new TbTransition();
//                    tbTransition.setCusId(cusId);
//                    tbTransition.setPacId(null);
//                    if (null != tjProject.getProPrice()) {
//                        tbTransition.setOrdPrice(tjProject.getProPrice());
//                        tbTransition.setNowPrice(tjProject.getProPrice());
//                    } else {
//                        tbTransition.setOrdPrice(BigDecimal.valueOf(0.00));
//                        tbTransition.setNowPrice(BigDecimal.valueOf(0.00));
//                    }
                    TbTransition tbTransition = new TbTransition();
                    tbTransition.setCusId(cusId);
                    tbTransition.setPacId(null);
                    if (null != tjProject.getProPrice()) {
                        tbTransition.setOrdPrice(tjProject.getProPrice());
                        tbTransition.setNowPrice(tjProject.getProPrice());
                    } else {
                        tbTransition.setOrdPrice(BigDecimal.valueOf(0.00));
                        tbTransition.setNowPrice(BigDecimal.valueOf(0.00));
                    }
                    tbTransition.setParentProId(tjProject.getProParentId());
                    if (tjProject.getProParentId() != null) {
                        TjProject byId = projectService.getById(tjProject.getProParentId());
                        if (null != byId) {
                            tbTransition.setParentProName(byId.getProName());
                        }
                    }
                    tbTransition.setParentProName("");
                    tbTransition.setProId(tjProject.getProId());
                    tbTransition.setProName(tjProject.getProName());
                    tbTransition.setProType(tjProject.getProType());
                    tbTransition.setProCheckMethod(tjProject.getProCheckMethod());
                    tbTransitionList.add(tbTransition);
//                    tbTransition.setParentProId(tjProject.getProParentId());
//                    if (tjProject.getProParentId() != null) {
//                        TjProject byId = projectService.getById(tjProject.getProParentId());
//                        if (null != byId) {
//                            tbTransition.setParentProName(byId.getProName());
//                        }
//                    }
                }
            }
//                    tbTransition.setParentProName("");
//
//                    tbTransition.setProId(tjProject.getProId());
//                    tbTransition.setProName(tjProject.getProName());
//                    tbTransition.setProType(tjProject.getProType());
//                    tbTransition.setProCheckMethod(tjProject.getProCheckMethod());
//                    tbTransitionList.add(tbTransition);
////                        }
////                    }
//                }
//            }
        }
        if (null != tbTransitionList && tbTransitionList.size() > 0) {
            if (redisCache.hasKey(cardId + cusId)) {
                redisCache.deleteObject(cardId + cusId);
                redisCache.setCacheList(cardId + cusId, tbTransitionList);
                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
            } else {
                redisCache.setCacheList(cardId + cusId, tbTransitionList);
                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
            }
        }
//        if (null != tbTransitionList && tbTransitionList.size() > 0) {
//            if (redisCache.hasKey(cardId + cusId)) {
//                redisCache.deleteObject(cardId + cusId);
//                redisCache.setCacheList(cardId + cusId, tbTransitionList);
//                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
//            } else {
//                redisCache.setCacheList(cardId + cusId, tbTransitionList);
//                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
//            }
//            List<Map<String, Object>> map1 = getMap(cusId, cardId, tbTransitionList);
//            return AjaxResult.success();
//        }
        return AjaxResult.success();
    }
    @GetMapping("/getTransitionList")
    @ApiOperation(value = "查询过渡表数据")
    public AjaxResult getTransitionList(@RequestParam @ApiParam(value = "客户id") String cusId) {
    @GetMapping ("/getTransitionList")
    @ApiOperation (value = "查询过渡表数据")
    public AjaxResult getTransitionList(@RequestParam @ApiParam (value = "客户id") String cusId) {
        if (redisCache.hasKey(cusId + "cusId")) {
            List<Map<String, Object>> list = redisCache.getCacheMapValue(cusId + "cusId", cusId);
            return AjaxResult.success(list);
@@ -1655,16 +1714,16 @@
    }
    @GetMapping("/getQianLiList")
    @ApiOperation(value = "查询体检记录列表")
    public AjaxResult getQianLiList(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum,
                                    @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                    @ApiParam(value = "体检号") @RequestParam(required = false) String tjNum,
                                    @ApiParam(value = "姓名") @RequestParam(required = false) String name,
                                    @ApiParam(value = "登记开始时间") @RequestParam(required = false) Date djbeginTime,
                                    @ApiParam(value = "登记结束时间") @RequestParam(required = false) Date djendTime,
                                    @ApiParam(value = "报告开始时间") @RequestParam(required = false) Date bgbeginTime,
                                    @ApiParam(value = "报告结束时间") @RequestParam(required = false) Date bgendTime) {
    @GetMapping ("/getQianLiList")
    @ApiOperation (value = "查询体检记录列表")
    public AjaxResult getQianLiList(@ApiParam (value = "页码数(默认1)") @RequestParam (defaultValue = "1") Integer pageNum,
                                    @ApiParam (value = "显示条数(默认10)") @RequestParam (defaultValue = "10") Integer pageSize,
                                    @ApiParam (value = "体检号") @RequestParam (required = false) String tjNum,
                                    @ApiParam (value = "姓名") @RequestParam (required = false) String name,
                                    @ApiParam (value = "登记开始时间") @RequestParam (required = false) Date djbeginTime,
                                    @ApiParam (value = "登记结束时间") @RequestParam (required = false) Date djendTime,
                                    @ApiParam (value = "报告开始时间") @RequestParam (required = false) Date bgbeginTime,
                                    @ApiParam (value = "报告结束时间") @RequestParam (required = false) Date bgendTime) {
        Map<String, Object> map = new HashMap<>();
        if (null != name) {
            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
@@ -1686,7 +1745,7 @@
                    for (TjOrder order : list) {
                        TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                        if (null != tjCustomer) {
                            order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
                            order.setTjCustomerName(tjCustomer.getCusName());
                            order.setTjCustomerSex(tjCustomer.getCusSex());
                            order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                            order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
@@ -1740,7 +1799,7 @@
            for (TjOrder order : list) {
                TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                if (null != tjCustomer) {
                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
                    order.setTjCustomerName(tjCustomer.getCusName());
                    order.setTjCustomerSex(tjCustomer.getCusSex());
                    order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                    order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
@@ -1773,9 +1832,9 @@
    /**
     * 签离弃检确认返回数据
     */
    @GetMapping("/abandon")
    @ApiOperation(value = "签离弃检确认返回数据")
    public AjaxResult abandon(@RequestParam @ApiParam(value = "体检号") String tjNumber) {
    @GetMapping ("/abandon")
    @ApiOperation (value = "签离弃检确认返回数据")
    public AjaxResult abandon(@RequestParam @ApiParam (value = "体检号") String tjNumber) {
        LambdaQueryWrapper<TjOrderRemark> wq = new LambdaQueryWrapper<>();
        wq.eq(TjOrderRemark::getTjNumber, tjNumber);
        List<TjOrderRemark> remarkList = remarkService.list(wq);
@@ -1800,8 +1859,8 @@
     *
     * @ApiParam(value = "体检号") String tjNumber
     */
    @PostMapping("/tjGoOut")
    @ApiOperation(value = "体检签离")
    @PostMapping ("/tjGoOut")
    @ApiOperation (value = "体检签离")
    @Transactional
    public AjaxResult tjGoOut(@RequestBody Map<String, Object> map) {
        Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId());
@@ -1837,6 +1896,35 @@
            TjCustomer customer = tjCustomerService.selectTjCustomerByCusId(tjOrder.getUserId());
            customer.setCardId("0");
            tjCustomerService.updateById(customer);
          /*  String config = configService.selectConfigByKey("sfkqdyhis");
            if(null !=config && config.equals("Y")){
                final String date = DateUtil.format(tjOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
                OutpinimpapplyDto dto=new OutpinimpapplyDto();
                dto.setHisRegistrationId(tjOrder.getCardId());
                dto.setMzzdid(1);
                dto.setSqysbm("00029");
                dto.setMzksbm("0101");
                dto.setFbrq(date);
                dto.setZdrq(date);
                dto.setCzybm("00029");
                dto.setCzyksbm("0101");
                dto.setZs("健康查体");
                dto.setBs("不详");
                dto.setClyz("");
                dto.setJws("");
                dto.setTgjc("");
                dto.setGms("");
                dto.setJbbm("Z00.001");
                dto.setJbbm1("");
                dto.setJbbm2("");
                dto.setFzbz("1");
                dto.setHzqx("6");
                dto.setSfqc("0");
                dto.setQchs("");
                dto.setSfqj("0");
                dto.setJzqk(9);
                controller.Outpinimpapply(dto);
            }*/
            return AjaxResult.success("签离成功!");
        } else {
@@ -1848,10 +1936,10 @@
    /**
     * 签离
     */
    @GetMapping("/goOut")
    @ApiOperation(value = "签离")
    @GetMapping ("/goOut")
    @ApiOperation (value = "签离")
    @Transactional
    public AjaxResult goOut(@RequestParam @ApiParam(value = "体检号") String tjNumber) {
    public AjaxResult goOut(@RequestParam @ApiParam (value = "体检号") String tjNumber) {
        return getAjaxResult(tjNumber);
    }
@@ -1859,9 +1947,9 @@
    /**
     * 核销订单接口
     */
    @GetMapping("/orderShip")
    @ApiOperation(value = "PC端手动核销订单接口")
    public AjaxResult orderShip(@RequestParam @ApiParam(value = "体检号") String tjNum) {
    @GetMapping ("/orderShip")
    @ApiOperation (value = "PC端手动核销订单接口")
    public AjaxResult orderShip(@RequestParam @ApiParam (value = "体检号") String tjNum) {
        if (tjNum == null) {
            return AjaxResult.error();
        }
@@ -1909,8 +1997,10 @@
        for (Map.Entry<Long, List<TbTransition>> entry : collect.entrySet()) {
            Map<String, Object> map = new HashMap<>();
            Long pacId = entry.getValue().get(0).getPacId();
            map.put("proPrantId", entry.getKey().toString());
            if (null != pacId) {
                TjPackage aPackage = tjPackageService.getById(entry.getValue().get(0).getPacId());
                map.put("tjCategory", aPackage.getTjCategory());
                map.put("pacName", aPackage.getPacName());
                TjProject tjProject = projectService.getById(entry.getKey());
//                TjPackageProject project = tjPackageProjectService.getOne(new LambdaQueryWrapper<TjPackageProject>().eq(TjPackageProject::getPacId, pacId)
@@ -1923,6 +2013,59 @@
//                }
                map.put("nowPrice", transitionService.getTbTransitionDxPriceByPac(cusId, entry.getKey(), cardId, pacId));
            } else {
                map.put("tjCategory", null);
                map.put("pacName", "单项");
                List<TbTransition> tbTransitionList = entry.getValue();
                if (null != tbTransitionList && tbTransitionList.size() > 0) {
                    BigDecimal money1 = new BigDecimal("0.00");
                    BigDecimal money2 = new BigDecimal("0.00");
                    for (TbTransition tbTransition : tbTransitionList) {
                        money1 = money1.add(tbTransition.getOrdPrice());
                        money2 = money2.add(tbTransition.getNowPrice());
                    }
                    map.put("ordPrice", money1);
                    map.put("nowPrice", money2);
                }
            }
            map.put("parentName", projectService.getById(entry.getKey()).getProName());
            map.put("list", entry.getValue());
            list.add(map);
        }
        return list;
    }
    private List<Map<String, Object>> getMap(String cusId, String cardId, List<TbTransition> transitionList) {
//        List<TbTransition> transitionList = null;
//        if (redisCache.hasKey(cardId + cusId)) {
//            transitionList = redisCache.getCacheList(cardId + cusId);
//        } else {
//        transitionList = transitionService.getTbTransitionListByCusId(cusId, cardId);
//        }
        if (null == transitionList) return null;
        Map<Long, List<TbTransition>> collect = transitionList.stream().collect(Collectors.groupingBy(TbTransition::getParentProId));
        List<Map<String, Object>> list = new ArrayList<>();
        for (Map.Entry<Long, List<TbTransition>> entry : collect.entrySet()) {
            Map<String, Object> map = new HashMap<>();
            Long pacId = entry.getValue().get(0).getPacId();
            map.put("proPrantId", entry.getKey().toString());
            if (null != pacId) {
                TjPackage aPackage = tjPackageService.getById(entry.getValue().get(0).getPacId());
                map.put("tjCategory", aPackage.getTjCategory());
                map.put("pacName", aPackage.getPacName());
                TjProject tjProject = projectService.getById(entry.getKey());
//                TjPackageProject project = tjPackageProjectService.getOne(new LambdaQueryWrapper<TjPackageProject>().eq(TjPackageProject::getPacId, pacId)
//                        .eq(TjPackageProject::getProId, entry.getKey()));
                map.put("ordPrice", tjProject.getProPrice());
//                if (null != project) {
//                    map.put("nowPrice", project.getPriceNow());
//                } else {
//                    map.put("nowPrice", tjProject.getProPrice());
//                }
                map.put("nowPrice", tjProject.getProPrice());
            } else {
                map.put("tjCategory", null);
                map.put("pacName", "单项");
                List<TbTransition> tbTransitionList = entry.getValue();
                if (null != tbTransitionList && tbTransitionList.size() > 0) {
@@ -1973,15 +2116,15 @@
    }
    @GetMapping("/tuanTiListById")
    @ApiOperation(value = "查询团体体检状态")
    public AjaxResult tuanTiListById(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum,
                                     @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                     @ApiParam(value = "单位") @RequestParam String firmId,
                                     @ApiParam(value = "部门") @RequestParam(required = false) String dwDeptId,
                                     @ApiParam(value = "分组") @RequestParam(required = false) String groupId,
                                     @ApiParam(value = "登记开始时间") @RequestParam Date beginTime,
                                     @ApiParam(value = "登记结束时间") @RequestParam Date endTime) {
    @GetMapping ("/tuanTiListById")
    @ApiOperation (value = "查询团体体检状态")
    public AjaxResult tuanTiListById(@ApiParam (value = "页码数(默认1)") @RequestParam (defaultValue = "1") Integer pageNum,
                                     @ApiParam (value = "显示条数(默认10)") @RequestParam (defaultValue = "10") Integer pageSize,
                                     @ApiParam (value = "单位") @RequestParam String firmId,
                                     @ApiParam (value = "部门") @RequestParam (required = false) String dwDeptId,
                                     @ApiParam (value = "分组") @RequestParam (required = false) String groupId,
                                     @ApiParam (value = "登记开始时间") @RequestParam Date beginTime,
                                     @ApiParam (value = "登记结束时间") @RequestParam Date endTime) {
        Map<String, Object> map = new HashMap<>();
        int a = 0;
        int b = 0;
@@ -2046,11 +2189,11 @@
    }
    @GetMapping("/tuanTiBingById")
    @ApiOperation(value = "查询团体体检病种详细信息")
    public AjaxResult tuanTiBingById(@ApiParam(value = "单位") @RequestParam String firmId,
                                     @ApiParam(value = "部门") @RequestParam String firmDeptId,
                                     @ApiParam(value = "病种") @RequestParam(required = false) String bingZhong) {
    @GetMapping ("/tuanTiBingById")
    @ApiOperation (value = "查询团体体检病种详细信息")
    public AjaxResult tuanTiBingById(@ApiParam (value = "单位") @RequestParam String firmId,
                                     @ApiParam (value = "部门") @RequestParam String firmDeptId,
                                     @ApiParam (value = "病种") @RequestParam (required = false) String bingZhong) {
        List<TjOrderDetailRules> res1 = new ArrayList<>();
        List<BingZhongVO> res = new ArrayList<>();
@@ -2109,8 +2252,8 @@
    }
    @PostMapping("/tuanTiBingChart")
    @ApiOperation(value = "查询团体体检病种统计图")
    @PostMapping ("/tuanTiBingChart")
    @ApiOperation (value = "查询团体体检病种统计图")
    public AjaxResult tuanTiBingChart(@RequestBody BingZhongVO bingZhongVO) {
        List<TjOrderDetailRules> res1 = new ArrayList<>();
@@ -2149,23 +2292,93 @@
    }
    @PostMapping("/deletedTbTransitionByCusId")
    @ApiOperation(value = "根据身份证号删除临时表数据")
    public AjaxResult deletedTbTransitionByCusId(@RequestParam @ApiParam(value = "身份证号") String cusId) {
    @PostMapping ("/deletedTbTransitionByCusId")
    @ApiOperation (value = "根据身份证号删除临时表数据")
    public AjaxResult deletedTbTransitionByCusId(@RequestParam @ApiParam (value = "身份证号") String cusId) {
        LambdaQueryWrapper<TbTransition> wq = new LambdaQueryWrapper<>();
        wq.between(TbTransition::getCreateTime, transitionService.getTbTransitionCreateTimeByCusId(cusId), new Date());
        wq.eq(TbTransition::getCusId, cusId);
        return AjaxResult.success(transitionService.remove(wq));
    }
    @GetMapping ("/getTransitionInfo")
    @ApiOperation (value = "根据体检号获取汇总和明细的数据")
    public AjaxResult getTransitionInfo(@RequestParam ("tjNumber") String tjNumber) {
        QueryWrapper<TbTransition> wrapper = new QueryWrapper<>();
        wrapper.select("parent_pro_id", "parent_pro_name", "sum(ord_price) as ord_price")
                .eq("tj_num", tjNumber)
                .groupBy("parent_pro_name");
        List<TbTransition> list = transitionService.list(wrapper);
        List<Long> parentProIds = list.stream().map(item -> item.getParentProId()).collect(Collectors.toList());
        LambdaQueryWrapper<TjProject> projectQueryWrapper = new LambdaQueryWrapper<>();
        projectQueryWrapper.in(TjProject::getProId, parentProIds);
        List<TjProject> projects = projectService.list(projectQueryWrapper);
        JSONArray huiZong = JSONUtil.createArray();
        int index = 1;
        for (TjProject project : projects) {
            LambdaQueryWrapper<SysDept> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(SysDept::getDeptId, project.getDeptId());
            SysDept dept = sysDeptService.getOne(queryWrapper);
            for (TbTransition tbTransition : list) {
                if (tbTransition.getParentProId().toString().equals(project.getProId().toString())) {
                    JSONObject obj = JSONUtil.createObj();
                    obj.putOpt("index", index++);
                    obj.putOpt("parent_pro_name", tbTransition.getParentProName());
                    obj.putOpt("price", tbTransition.getOrdPrice());
                    obj.putOpt("ks", dept.getDeptName());
                    huiZong.add(obj);
                }
            }
        }
        wrapper = new QueryWrapper<>();
        wrapper.eq("tj_num", tjNumber);
        list = transitionService.list(wrapper);
        JSONArray info = JSONUtil.createArray();
        index = 1;
        for (TbTransition tbTransition : list) {
            JSONObject obj = JSONUtil.createObj();
            obj.putOpt("index", index++);
            obj.putOpt("parent_pro_name", tbTransition.getParentProName());
            obj.putOpt("pro_name", tbTransition.getProName());
            BigDecimal ordPrice = tbTransition.getOrdPrice();
            obj.putOpt("zongjia", ordPrice);
            QueryWrapper<TjProject> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("pro_id", tbTransition.getProId());
            TjProject tjProject = projectService.getOne(queryWrapper);
            Integer num = tjProject.getSl();
            obj.putOpt("num", num);
            BigDecimal price = ordPrice.divide(new BigDecimal(num));
            obj.putOpt("danjia", price);
            Date createTime = tbTransition.getCreateTime();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            obj.putOpt("time", dateFormat.format(createTime));
            info.put(obj);
        }
        HashMap<String, Object> map = new HashMap<>();
        map.put("huizong", huiZong);
        map.put("info", info);
        return AjaxResult.success().put("data", map);
    }
    public void newSaveextracted(TjOrder tjOrder, TjCustomer tjCustomer, BigDecimal discount, SysUser sysUser, TjReservation tjReservation, TjFlowingWater tjFlowingWater) {
        tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
        tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
            tjOrderDetailService.saveJSYTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
        } else {
            tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
        }
        tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
        //修改每项的原价现价 //修改临时表体检号
        transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount, tjOrder.getTjNumber());
        //添加remark表数据
        remarkService.saveTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
            remarkService.saveJSYTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
        } else {
            remarkService.saveTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
        }
        //判断是否交钱
        if ("1".equals(tjOrder.getTjType())) {
            if (null != tjReservation && tjReservation.getPayType() == 1) {
@@ -2186,8 +2399,8 @@
    }
    @PostMapping("/heXiaoByIds/{orderIds}")
    @ApiOperation(value = "核收报告——————总检审核通过后可以核销,核收后才能打印")
    @PostMapping ("/heXiaoByIds/{orderIds}")
    @ApiOperation (value = "核收报告——————总检审核通过后可以核销,核收后才能打印")
    @Transactional
    public AjaxResult heXiaoByIds(@PathVariable String[] orderIds) {
        for (String orderId : orderIds) {
@@ -2203,8 +2416,8 @@
        return AjaxResult.success("核收成功");
    }
    @GetMapping("/getHistryTjOrderByCusIdCard")
    @ApiOperation(value = "根据身份证号查看历史体检记录")
    @GetMapping ("/getHistryTjOrderByCusIdCard")
    @ApiOperation (value = "根据身份证号查看历史体检记录")
    @Transactional
    public AjaxResult getHistryTjOrderByCusIdCard(@RequestParam String cusIdCard) {
        TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusIdCard);
@@ -2224,8 +2437,8 @@
    }
    @GetMapping("/getHistryTjOrderProByCusIdCard")
    @ApiOperation(value = "根据身份证号查看历史体检项目记录")
    @GetMapping ("/getHistryTjOrderProByCusIdCard")
    @ApiOperation (value = "根据身份证号查看历史体检项目记录")
    @Transactional
    public AjaxResult getHistryTjOrderProByCusIdCard(@RequestParam String cusIdCard) {
        TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusIdCard);
@@ -2284,8 +2497,8 @@
    }
    @GetMapping("/getHistryTjOrderByCusId")
    @ApiOperation(value = "根据客户id查看历史体检记录")
    @GetMapping ("/getHistryTjOrderByCusId")
    @ApiOperation (value = "根据客户id查看历史体检记录")
    @Transactional
    public AjaxResult getHistryTjOrderByCusId(@RequestParam String cusId) {
        TjCustomer tjCustomer = tjCustomerService.getById(cusId);
@@ -2319,49 +2532,53 @@
    }
    @GetMapping("/revokeTjOrderByTjNum")
    @ApiOperation(value = "根据客户体检号撤销体检记录")
    @GetMapping ("/revokeTjOrderByTjNum")
    @ApiOperation (value = "根据客户体检号撤销体检记录")
    @Transactional
    public AjaxResult revokeTjOrderByTjNum(@RequestParam @ApiParam(value = "体检号") String tjNum) {
    public AjaxResult revokeTjOrderByTjNum(@RequestParam @ApiParam (value = "体检号") String tjNum) {
        TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
        if (null != order) {
            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
            if (null != payByTjNum) {
                return AjaxResult.success("该用户已收费不可撤销签到!");
            }
//            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
//            if (null != payByTjNum) {
//                return AjaxResult.error("该用户已收费不可撤销签到!");
//            }
            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
            remarkService.deletedOrderRemarkByTjNum(tjNum);
            tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
            transitionService.deletedTbTransitionByTjNum(tjNum);
            transitionService.updateTbTransitionByTjNum(tjNum);
            TjCustomer customer = tjCustomerService.getById(order.getUserId());
            customer.setCardId("0");
            tjCustomerService.updateById(customer);
            String configByKey = configService.selectConfigByKey("sfkqdyhis");
            if (configByKey.equals("Y")){
                HashMap<String, Object> map = new HashMap<>();
                map.put("cardtype","4");
                map.put("input",order.getCardId());
                LocalDate currentDate = LocalDate.now();
                LocalDateTime startOfDay = currentDate.atStartOfDay();
                LocalDateTime nineteenOClock = currentDate.atTime(LocalTime.of(19, 0));
                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                String ksrq = startOfDay.format(formatter);
                String jsrq = nineteenOClock.format(formatter);
                map.put("ksrq",ksrq);
                map.put("jsrq",jsrq);
                AjaxResult result = hisApiGetMethodService.getHISDataNew("Getoutpatientcostinfo", map);
                if (Integer.parseInt(String.valueOf(result.get("code"))) == 200){
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("撤销失败,门诊患者费用清单信息不为空");
                }else {
                    boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order);
                    if (zfHisApiMethods) {
                        return AjaxResult.success("撤销成功", map);
                    }else {
            if (configByKey.equals("Y")) {
                HashMap<String, Object> hisRequestParams = new HashMap<>();
                hisRequestParams.put("patientId", order.getCardId());
                AjaxResult queryPay = hisApiGetMethodService.getHISDataNew("QueryPay", hisRequestParams);
                if (Integer.parseInt(queryPay.get("code").toString()) == 200) {
                    List<Map<String, String>> data = (List<Map<String, String>>) queryPay.get("data");
                    BigDecimal cateFeeAll = BigDecimal.ZERO;
                    for (Map<String, String> datum : data) {
                        BigDecimal cateFee = new BigDecimal(datum.get("CateFee"));
                        cateFeeAll = cateFeeAll.add(cateFee);
                    }
                    if (cateFeeAll.compareTo(BigDecimal.ZERO) != 0) {
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        return AjaxResult.error("撤销失败,调用作废出现失败");
                        return AjaxResult.error("撤销失败,该人员已缴费,请先退费!");
                    }
                }
                boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order);
                if (zfHisApiMethods) {
                    return AjaxResult.success("撤销成功");
                } else {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("撤销失败,调用作废出现失败");
                }
            }
            return AjaxResult.success("撤销成功!!!");
        }
@@ -2369,14 +2586,14 @@
    }
    @GetMapping("/getCusTomterListByCompId")
    @ApiOperation(value = "获取单位id体检人信息接口")
    public AjaxResult getCusTomterListByCompId(@RequestParam(required = false) @ApiParam(value = "单位id") String compId,
                                               @RequestParam(required = false) @ApiParam(value = "名字") String name,
                                               @RequestParam(required = false) @ApiParam(value = "部门id") String deptId,
                                               @RequestParam(required = false) @ApiParam(value = "预约时间") Date reservationTime,
                                               @RequestParam(defaultValue = "1") Integer page,
                                               @RequestParam(defaultValue = "10") Integer pageSize) {
    @GetMapping ("/getCusTomterListByCompId")
    @ApiOperation (value = "获取单位id体检人信息接口")
    public AjaxResult getCusTomterListByCompId(@RequestParam (required = false) @ApiParam (value = "单位id") String compId,
                                               @RequestParam (required = false) @ApiParam (value = "名字") String name,
                                               @RequestParam (required = false) @ApiParam (value = "部门id") String deptId,
                                               @RequestParam (required = false) @ApiParam (value = "预约时间") Date reservationTime,
                                               @RequestParam (defaultValue = "1") Integer page,
                                               @RequestParam (defaultValue = "10") Integer pageSize) {
        Page<TjReservation> pages = new Page<>(page, pageSize);
        LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>();
        if (null != compId) wq.eq(TjReservation::getCompanyId, compId);
@@ -2402,10 +2619,10 @@
    }
    @PostMapping("/plRevokeTjOrderByTjNum")
    @ApiOperation(value = "根据客户体检号批量撤销体检记录")
    @PostMapping ("/plRevokeTjOrderByTjNum")
    @ApiOperation (value = "根据客户体检号批量撤销体检记录")
    @Transactional
    public AjaxResult plRevokeTjOrderByTjNum(@RequestBody @ApiParam(value = "预约主键id集合") List<String> reservationIds) {
    public AjaxResult plRevokeTjOrderByTjNum(@RequestBody @ApiParam (value = "预约主键id集合") List<String> reservationIds) {
        if (null != reservationIds && reservationIds.size() > 0) {
            LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>();
            wq1.in(TjOrder::getReservationId, reservationIds);
@@ -2439,11 +2656,11 @@
        return AjaxResult.error("请选择要撤销的人员!");
    }
    @PostMapping("makeTjPDF")
    @ApiOperation(value = "批量生成PDF")
    @PostMapping ("makeTjPDF")
    @ApiOperation (value = "批量生成PDF")
    public AjaxResult makeTjPDF(@RequestBody List<String> reservations) {
        QueryWrapper<TjOrder> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("reservation_id",reservations);
        queryWrapper.in("reservation_id", reservations);
        List<TjOrder> tjNumbers = tjOrderService.list(queryWrapper);
        Map<String, Object> map = null;
        try {
@@ -2480,5 +2697,172 @@
            return AjaxResult.error(e.getMessage());
        }
    }
    @GetMapping ("/delTbBycusCardIdAndProId")
    @ApiOperation (value = "根据客户身份证号和项目父项id删除临时表数据")
    @Transactional
    public AjaxResult delTbBycusCardIdAndProId(@RequestParam @ApiParam (value = "身份证号") String cusCardId,
                                               @RequestParam @ApiParam (value = "父项id") String proId) {
        if (transitionService.delTbBycusCardIdAndProId(cusCardId, proId)) {
            return AjaxResult.success();
        }
        return AjaxResult.error("记录不存在!");
    }
    @GetMapping ("/revokeTjOrderByTjCardId")
    @ApiOperation (value = "根据就诊号撤销申请记录")
    @Transactional
    public AjaxResult revokeTjOrderByTjCardId(@RequestParam @ApiParam (value = "就诊号") String cardId) {
        TjOrder order = new TjOrder();
        order.setCardId(cardId);
        String configByKey = configService.selectConfigByKey("sfkqdyhis");
        if (configByKey.equals("Y")) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("cardtype", "4");
            map.put("input", order.getCardId());
            LocalDate currentDate = LocalDate.now();
            LocalDateTime startOfDay = currentDate.atStartOfDay();
            LocalDateTime nineteenOClock = currentDate.atTime(LocalTime.of(19, 0));
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            String ksrq = startOfDay.format(formatter);
            String jsrq = nineteenOClock.format(formatter);
            map.put("ksrq", ksrq);
            map.put("jsrq", jsrq);
            AjaxResult result = hisApiGetMethodService.getHISDataNew("Getoutpatientcostinfo", map);
            if (Integer.parseInt(String.valueOf(result.get("code"))) == 200) {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return AjaxResult.error("撤销失败,门诊患者费用清单信息不为空");
            } else {
                boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order);
                if (zfHisApiMethods) {
                    return AjaxResult.success("撤销成功", map);
                } else {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("撤销失败,调用作废出现失败");
                }
            }
        }
        return AjaxResult.success();
    }
    @GetMapping ("/revokeTjOrderByTjh")
    @ApiOperation (value = "根据就体检号删除记录")
    @Transactional
    public AjaxResult revokeTjOrderByTjh(@RequestParam @ApiParam (value = "体检号") String tjNum) {
        TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
        if (null != order) {
//            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
//            if (null != payByTjNum) {
//                return AjaxResult.error("该用户已收费不可撤销签到!");
//            }
            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
            remarkService.deletedOrderRemarkByTjNum(tjNum);
            tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
            transitionService.deletedTbTransitionByTjNum(tjNum);
        }
        return AjaxResult.success();
    }
    @GetMapping ("/getBlproByTjh")
    @ApiOperation (value = "根据体检号获取补录项目记录")
    @Transactional
    public AjaxResult getBlproByTjh(@RequestParam @ApiParam (value = "体检号") String tjNum) {
        TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
        if (null != order) {
            LambdaQueryWrapper<TjProBl> wq = new LambdaQueryWrapper<>();
            wq.eq(TjProBl::getTjh, tjNum);
            List<TjProBl> blList = blService.list(wq);
            if (null != blList && blList.size() > 0) {
                for (TjProBl bl : blList) {
                    LambdaQueryWrapper<TjOrderRemark> wqr = new LambdaQueryWrapper<>();
                    wqr.eq(TjOrderRemark::getJxbz, bl.getBldh());
                    List<TjOrderRemark> remarkList = remarkService.list(wqr);
                    if (null != remarkList && remarkList.size() > 0) {
                        List<Long> collect = remarkList.stream().map(TjOrderRemark::getProId).collect(Collectors.toList());
                        LambdaQueryWrapper<TjProject> wqp = new LambdaQueryWrapper<>();
                        wqp.in(TjProject::getProId, collect);
                        List<TjProject> projectList = projectService.list(wqp);
                        for (TjProject project : projectList) {
                            project.setChildren(projectService.getTjProjectListBySoneId(String.valueOf(project.getProId())));
                        }
                        bl.setProjectList(projectList);
                    }
                }
                return AjaxResult.success(blList);
            }
            return AjaxResult.success(null);
        }
        return AjaxResult.error("暂无体检记录");
    }
    @PostMapping ("/revokeBlProByBldhAndTjh")
    @ApiOperation (value = "根据补录单号和体检号删除记录")
    @Transactional
    public AjaxResult revokeBlProByBldhAndTjh(@RequestBody TjProBlDto dto) {
        if (null == dto.getBldhs() || dto.getBldhs().size() == 0) {
            return AjaxResult.error("请选择要撤销的补录项目");
        }
        TjOrder order = tjOrderService.getOrderByTjNum(dto.getTjh());
        if (null != order) {
            String configByKey = configService.selectConfigByKey("sfkqdyhis");
            if (null != configByKey && configByKey.equals("Y")) {
                HashMap<String, Object> hisRequestParams = new HashMap<>();
                hisRequestParams.put("patientId", order.getCardId());
                AjaxResult queryPay = hisApiGetMethodService.getHISDataNew("QueryPay", hisRequestParams);
                if (Integer.parseInt(queryPay.get("code").toString()) == 200) {
                    List<Map<String, String>> data = (List<Map<String, String>>) queryPay.get("data");
                    BigDecimal cateFeeAll = BigDecimal.ZERO;
                    List<String> advIds = new ArrayList<>();
                    for (Map<String, String> datum : data) {
                        String advId = datum.get("Adv_Id").split("_")[1];
                        BigDecimal cateFee = new BigDecimal(datum.get("CateFee"));
                        cateFeeAll = cateFeeAll.add(cateFee);
                        advIds.add(advId);
                    }
                    if (advIds.containsAll(dto.getBldhs()) && cateFeeAll.compareTo(BigDecimal.ZERO) != 0) {
                        return AjaxResult.error("改项目已缴费不可撤销!!!");
                    }
                }
            }
            for (String bldh : dto.getBldhs()) {
                remarkService.deleteTjOrderDetailByjxbz(bldh);
                tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
                tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh);
                transitionService.deleteTjOrderDetailByjxbz(bldh);
                blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, dto.getTjh()).eq(TjProBl::getBldh, bldh));
            }
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
    @PostMapping ("/addYaoPinShenQing")
    @ApiOperation (value = "药品信息申请")
    @Transactional
    public AjaxResult addYaoPinShenQing(@RequestBody OutpinmedicapplyDto dto) {
        AjaxResult result = controller.Outpinmedicapply(dto);
        String result1 = getAjaxResult(result);
        JSONObject object = getJSONObject(result1);
        String code = object.getStr("ResultCode");
        if (null != code && code.equals("200")) {
        }
        return AjaxResult.success();
    }
}