| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.OffsetTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.concurrent.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.codec.Base64; |
| | |
| | | import cn.hutool.extra.pinyin.PinyinUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.databind.BeanProperty; |
| | | import com.itextpdf.text.Document; |
| | | import com.itextpdf.text.DocumentException; |
| | | import com.ltkj.common.core.domain.entity.SysDept; |
| | | import com.ltkj.common.core.domain.entity.SysUser; |
| | | import com.ltkj.common.core.redis.RedisCache; |
| | | import com.ltkj.common.enums.DataSourceType; |
| | | import com.ltkj.common.utils.PDFDocumentUtil; |
| | | import com.ltkj.common.utils.SecurityUtils; |
| | | import com.ltkj.framework.config.MatchUtils; |
| | | import com.ltkj.framework.config.ThreadPoolConfig; |
| | | import com.ltkj.framework.config.UserHoder; |
| | | import com.ltkj.framework.datasource.DynamicDataSourceContextHolder; |
| | | import com.ltkj.hosp.domain.*; |
| | | import com.ltkj.hosp.dto.QianDaoDto; |
| | | import com.ltkj.hosp.mapper.TestMapper; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.hosp.sqlDomain.LtkjMiddleDetail; |
| | | import com.ltkj.hosp.sqlDomain.LtkjMiddleHead; |
| | | import com.ltkj.hosp.sqlDomain.LtkjTjPat; |
| | | import com.ltkj.hosp.vodomain.BingZhongVO; |
| | | import com.ltkj.hosp.vodomain.HistoryTjOrder; |
| | | import com.ltkj.hosp.vodomain.QjDomainVo; |
| | |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.system.service.ISysDeptService; |
| | | import com.ltkj.system.service.ISysUserService; |
| | | import com.ltkj.web.controller.his.HisApiMethod; |
| | | import com.ltkj.web.controller.his.HisMzJysqController; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.weaver.ast.Var; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.HttpRequest; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.DigestUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ltkj.common.annotation.Log; |
| | | import com.ltkj.common.core.controller.BaseController; |
| | |
| | | |
| | | @Resource |
| | | private LtkjMiddleHeadService headService; |
| | | @Resource |
| | | private TjvLtkjvtjpatService tjvLtkjvtjpatService; |
| | | @Autowired |
| | | private ThreadPoolConfig threadPoolConfig; |
| | | |
| | | @Autowired |
| | | private HisApiMethod hisApiMethod; |
| | | |
| | | @Autowired |
| | | private HisMzJysqController hisMzJysqController; |
| | | |
| | | |
| | | /** |
| | |
| | | for (TjOrder order : list) { |
| | | TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId()); |
| | | if (null != tjCustomer) { |
| | | order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName())); |
| | | order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone())); |
| | | order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); |
| | | // order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName())); |
| | | order.setTjCustomerName(tjCustomer.getCusName()); |
| | | // order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone())); |
| | | order.setTjCustomerPhone(tjCustomer.getCusPhone()); |
| | | // order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); |
| | | order.setTjCusIdCard(tjCustomer.getCusIdcard()); |
| | | order.setTjCustomerSex(tjCustomer.getCusSex()); |
| | | order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday())); |
| | | order.setCareer(tjCustomer.getCareer()); |
| | |
| | | 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.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); |
| | | order.setTjCusIdCard(tjCustomer.getCusIdcard()); |
| | | order.setCareer(tjCustomer.getCareer()); |
| | | order.setIdType(tjCustomer.getIdType()); |
| | | order.setAgeUnit(tjCustomer.getAgeUnit()); |
| | |
| | | } |
| | | List<TjOrder> collect = null; |
| | | if (list.size() > 0) { |
| | | for (TjOrder order : list) { |
| | | TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId()); |
| | | if (null != tjCustomer) { |
| | | order.setTjCustomerSex(tjCustomer.getCusSex()); |
| | | order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday())); |
| | | order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName())); |
| | | order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone())); |
| | | order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); |
| | | |
| | | for (int i = 0; i < list.size(); i++) { |
| | | TjCustomer tjCustomer = tjCustomerService.getById(list.get(i).getUserId()); |
| | | if (null == tjCustomer) { |
| | | list.remove(list.get(i)); |
| | | continue; |
| | | } |
| | | String firmId = order.getFirmId(); |
| | | if (firmId != null && null != iDictCompService.getById(String.valueOf(order.getFirmId()))) { |
| | | order.setDictCompName(iDictCompService.getById(String.valueOf(order.getFirmId())).getCnName()); |
| | | list.get(i).setTjCustomerSex(tjCustomer.getCusSex()); |
| | | list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday())); |
| | | list.get(i).setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName())); |
| | | list.get(i).setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone())); |
| | | list.get(i).setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); |
| | | |
| | | String firmId = list.get(i).getFirmId(); |
| | | if (firmId != null && null != iDictCompService.getById(String.valueOf(list.get(i).getFirmId()))) { |
| | | list.get(i).setDictCompName(iDictCompService.getById(String.valueOf(list.get(i).getFirmId())).getCnName()); |
| | | } |
| | | if (null != order.getPacId()) { |
| | | if (null != tjPackageService.getById(order.getPacId())) { |
| | | order.setPacName(tjPackageService.getById(order.getPacId()).getPacName()); |
| | | if (null != list.get(i).getPacId()) { |
| | | if (null != tjPackageService.getById(list.get(i).getPacId())) { |
| | | list.get(i).setPacName(tjPackageService.getById(list.get(i).getPacId()).getPacName()); |
| | | } |
| | | if (null != dwDeptService.getById(order.getPacId())) { |
| | | order.setPacName(dwDeptService.getById(order.getPacId()).getDwDeptName()); |
| | | if (null != dwDeptService.getById(list.get(i).getPacId())) { |
| | | list.get(i).setPacName(dwDeptService.getById(list.get(i).getPacId()).getDwDeptName()); |
| | | } |
| | | } |
| | | //从打印记录查出最新打印时间 |
| | | LambdaQueryWrapper<TjReportPrint> wqqq = new LambdaQueryWrapper<>(); |
| | | wqqq.eq(TjReportPrint::getTjNumber, order.getTjNumber()); |
| | | wqqq.eq(TjReportPrint::getTjNumber, list.get(i).getTjNumber()); |
| | | wqqq.orderByDesc(TjReportPrint::getPrintTime); |
| | | wqqq.last("limit 1"); |
| | | TjReportPrint one = tjReportPrintService.getOne(wqqq); |
| | | if (one != null) { |
| | | order.setPrintLastTime(one.getPrintTime()); |
| | | list.get(i).setPrintLastTime(one.getPrintTime()); |
| | | } |
| | | |
| | | } |
| | |
| | | Page<TjOrder> page2 = tjOrderService.page(page1, wq); |
| | | List<TjOrder> list = page2.getRecords(); |
| | | if (list != null) { |
| | | for (TjOrder order : list) { |
| | | TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId()); |
| | | if (null != tjCustomer) { |
| | | order.setTjCustomerSex(tjCustomer.getCusSex()); |
| | | order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday())); |
| | | order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName())); |
| | | order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone())); |
| | | if (tjCustomer.getCusIdcard() != null) { |
| | | order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); |
| | | } |
| | | for (int i = 0; i < list.size(); i++) { |
| | | TjCustomer tjCustomer = tjCustomerService.getById(list.get(i).getUserId()); |
| | | if (null == tjCustomer) { |
| | | list.remove(list.get(i)); |
| | | continue; |
| | | } |
| | | String firmId = order.getFirmId(); |
| | | if (firmId != null && null != iDictCompService.getById(String.valueOf(order.getFirmId()))) { |
| | | order.setDictCompName(iDictCompService.getById(String.valueOf(order.getFirmId())).getCnName()); |
| | | list.get(i).setTjCustomerSex(tjCustomer.getCusSex()); |
| | | list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday())); |
| | | list.get(i).setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName())); |
| | | list.get(i).setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone())); |
| | | if (tjCustomer.getCusIdcard() != null) { |
| | | list.get(i).setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); |
| | | } |
| | | if (null != order.getPacId()) { |
| | | if (null != tjPackageService.getById(order.getPacId())) { |
| | | order.setPacName(tjPackageService.getById(order.getPacId()).getPacName()); |
| | | |
| | | String firmId = list.get(i).getFirmId(); |
| | | if (firmId != null && null != iDictCompService.getById(String.valueOf(list.get(i).getFirmId()))) { |
| | | list.get(i).setDictCompName(iDictCompService.getById(String.valueOf(list.get(i).getFirmId())).getCnName()); |
| | | } |
| | | if (null != list.get(i).getPacId()) { |
| | | if (null != tjPackageService.getById(list.get(i).getPacId())) { |
| | | list.get(i).setPacName(tjPackageService.getById(list.get(i).getPacId()).getPacName()); |
| | | } |
| | | if (null != dwDeptService.getById(order.getPacId())) { |
| | | order.setPacName(dwDeptService.getById(order.getPacId()).getDwDeptName()); |
| | | if (null != dwDeptService.getById(list.get(i).getPacId())) { |
| | | list.get(i).setPacName(dwDeptService.getById(list.get(i).getPacId()).getDwDeptName()); |
| | | } |
| | | } |
| | | //从打印记录查出最新打印时间 |
| | | LambdaQueryWrapper<TjReportPrint> wqqq = new LambdaQueryWrapper<>(); |
| | | wqqq.eq(TjReportPrint::getTjNumber, order.getTjNumber()); |
| | | wqqq.eq(TjReportPrint::getTjNumber, list.get(i).getTjNumber()); |
| | | wqqq.orderByDesc(TjReportPrint::getPrintTime); |
| | | wqqq.last("limit 1"); |
| | | TjReportPrint one = tjReportPrintService.getOne(wqqq); |
| | | if (one != null) { |
| | | order.setPrintLastTime(one.getPrintTime()); |
| | | list.get(i).setPrintLastTime(one.getPrintTime()); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @PostMapping |
| | | @ApiOperation(value = "体检签到登记接口") |
| | | //@Transactional (切换数据库出错,所以注释) |
| | | @Transactional //(切换数据库出错,所以注释) |
| | | public AjaxResult addOrderAndDetail(@RequestBody TjOrder tjOrder) throws Exception { |
| | | Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId()); |
| | | SysUser sysUser = userService.getById(userId); |
| | | |
| | | LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjCustomer::getCusId, tjOrder.getUserId()); |
| | | TjCustomer tjCustomer = tjCustomerService.getOne(wq); |
| | | if (tjCustomer == null) return AjaxResult.error("该客户未登记或不存在"); |
| | | |
| | | LambdaQueryWrapper<TjOrder> wqq = new LambdaQueryWrapper<>(); |
| | | wqq.eq(TjOrder::getUserId, tjOrder.getUserId()); |
| | | wqq.eq(TjOrder::getCheckStatus, 0); |
| | | wqq.isNull(TjOrder::getFinishTime); |
| | | if (!tjCustomer.getCardId().equals("0")) { |
| | | wqq.eq(TjOrder::getCardId, tjCustomer.getCardId()); |
| | | } |
| | | TjOrder order = tjOrderService.getOne(wqq); |
| | | if (null != order) { |
| | | transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId()); |
| | | return AjaxResult.error("不可重复登记"); |
| | | } |
| | | LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjCustomer::getCusId, tjOrder.getUserId()); |
| | | TjCustomer tjCustomer = tjCustomerService.getOne(wq); |
| | | if (tjCustomer == null) return AjaxResult.error("该客户未签到或不存在"); |
| | | LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard()); |
| | | wq1.eq(TjReservation::getIsExpire, 2); |
| | | TjReservation tjReservation = tjReservationService.getOne(wq1); |
| | | MallOrder mallOrder = null; |
| | | if (tjReservation != null) { |
| | | 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 (null != tjReservation.getDepartment()) tjOrder.setFirmDeptName(tjReservation.getDepartment()); |
| | | if (null != tjReservation.getJobNo()) tjOrder.setFirmWorkId(tjReservation.getJobNo()); |
| | | if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId()); |
| | | if (null != tjReservation.getGroupingId()){ |
| | | if (null != tjReservation.getTjCategory()) tjOrder.setTjCategory(tjReservation.getTjCategory()); |
| | | if (null != tjReservation.getGroupingId()) { |
| | | tjOrder.setGroupId(tjReservation.getGroupingId()); |
| | | tjOrder.setFirmDeptId(tjReservation.getPacId()); |
| | | } |
| | |
| | | //判断小程序上预约是否付钱 |
| | | if (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId())); |
| | | tjOrder.setStatus(TjConstants.TJ_BEGIN); |
| | | tjOrder.setCardId(tjCustomer.getCardId()); |
| | | if (tjOrderService.save(tjOrder)) { |
| | | |
| | | //保存收货地址 |
| | | if ("2".equals(tjOrder.getGetType())){ |
| | | if ("2".equals(tjOrder.getGetType())) { |
| | | final TjReportGetAddress address = tjOrder.getAddAddress(); |
| | | if (address!=null){ |
| | | if (address != null) { |
| | | address.setTjNumber(tjNumber); |
| | | tjReportGetAddressService.save(address); |
| | | } |
| | |
| | | Long cusNumber = tjCustomer.getCusNumber(); |
| | | cusNumber += 1; |
| | | tjCustomer.setCusNumber(cusNumber); |
| | | tjCustomerService.updateById(tjCustomer); |
| | | BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount())).divide(BigDecimal.valueOf(10)); |
| | | TjFlowingWater tjFlowingWater = new TjFlowingWater(); |
| | | tjFlowingWater.setPayStasus(0L); |
| | | if ("1".equals(tjOrder.getTjType())) { |
| | | if (null != tjReservation && tjReservation.getPayType() == 1) { |
| | | tjFlowingWater.setPayStasus(3L); |
| | | } |
| | | } |
| | | |
| | | //调用SQL server拿取收费情况 |
| | | //根据配置调取存储过程 将临时表数据存入预约表2023.12.12 |
| | | final String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData"); |
| | | final String isPay = configService.selectConfigByKey("isPay"); |
| | | if ("Y".equals(getInfoFromSqlData)) { |
| | | LtkjMiddleHead middleHead = headService.getMiddleHeadByPartId(tjCustomer.getCardId()); |
| | | if (null != middleHead) { |
| | | tjFlowingWater.setPayStasus(1L); |
| | | } |
| | | } |
| | | tjFlowingWater.setOrderId(tjOrder.getOrderId()); |
| | | Date date1 = new Date(System.currentTimeMillis()); |
| | | String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1); |
| | | tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "") + s1); |
| | | if (null != mallOrder) { |
| | | if (mallOrder.getOrderStatus().equals(201L)) { |
| | | tjFlowingWater.setCopeWith(mallOrder.getActualPrice()); |
| | | tjFlowingWater.setPaidIn(mallOrder.getActualPrice()); |
| | | tjFlowingWater.setDiscount(String.valueOf(1)); |
| | | tjFlowingWater.setPayStasus(1L); |
| | | tjFlowingWater.setPayType(3L); |
| | | MallCheckLog checkLog = new MallCheckLog(); |
| | | checkLog.setCheckBy(sysUser.getNickName()); |
| | | checkLog.setUserId(mallOrder.getUserId()); |
| | | checkLog.setConsignee(mallOrder.getConsignee()); |
| | | checkLog.setIdCard(mallOrder.getIdCard()); |
| | | checkLog.setOrderId(String.valueOf(mallOrder.getId())); |
| | | checkLog.setOrderSn(mallOrder.getOrderSn()); |
| | | checkLog.setCheckTime(new Date()); |
| | | checkLog.setShipSn("HX" + s1); |
| | | mallCheckLogService.save(checkLog); |
| | | mallOrder.setOrderStatus(301L); |
| | | mallOrderService.updateById(mallOrder); |
| | | tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1); |
| | | |
| | | |
| | | tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith()); |
| | | tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn()); |
| | | tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount()); |
| | | |
| | | if (isPay.equals("true")) { |
| | | if (null != mallOrder) { |
| | | if (mallOrder.getOrderStatus().equals(201L)) { |
| | | tjFlowingWater.setCopeWith(mallOrder.getActualPrice()); |
| | | tjFlowingWater.setPaidIn(mallOrder.getActualPrice()); |
| | | tjFlowingWater.setDiscount(String.valueOf(1)); |
| | | tjFlowingWater.setPayStasus(1L); |
| | | tjFlowingWater.setPayType(3L); |
| | | MallCheckLog checkLog = new MallCheckLog(); |
| | | checkLog.setCheckBy(sysUser.getNickName()); |
| | | checkLog.setUserId(mallOrder.getUserId()); |
| | | checkLog.setConsignee(mallOrder.getConsignee()); |
| | | checkLog.setIdCard(mallOrder.getIdCard()); |
| | | checkLog.setOrderId(String.valueOf(mallOrder.getId())); |
| | | checkLog.setOrderSn(mallOrder.getOrderSn()); |
| | | checkLog.setCheckTime(new Date()); |
| | | checkLog.setShipSn("HX" + s1); |
| | | mallCheckLogService.save(checkLog); |
| | | mallOrder.setOrderStatus(301L); |
| | | mallOrderService.updateById(mallOrder); |
| | | } |
| | | } else { |
| | | tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith()); |
| | | tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn()); |
| | | tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount()); |
| | | // tjFlowingWater.setPayStasus(0L); |
| | | } |
| | | } else { |
| | | tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith()); |
| | | tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn()); |
| | | tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount()); |
| | | tjFlowingWater.setPayStasus(0L); |
| | | } |
| | | if (tjFlowingWaterService.save(tjFlowingWater)) { |
| | | tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | tjOrderService.updateById(tjOrder); |
| | | |
| | | |
| | | } |
| | | |
| | | //团体 |
| | | if ("1".equals(tjOrder.getTjType())) { |
| | | asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater); |
| | | } |
| | | |
| | | |
| | | //个人 |
| | | if ("2".equals(tjOrder.getTjType())) { |
| | | |
| | | // asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater); |
| | | //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater); |
| | | newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater); |
| | | } |
| | | |
| | | //调用SQL server拿取收费情况 |
| | | List<LtkjMiddleHead> one = testMapper.saveMiddleHeadByPatId(tjCustomer.getCusIdcard()); |
| | | if (one!=null){ |
| | | for (LtkjMiddleHead ltkjMiddleHead : one) { |
| | | DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.MASTER.name()); |
| | | headService.save(ltkjMiddleHead); |
| | | DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | List<LtkjMiddleDetail> detailList = testMapper.getMiddleDetailByHeadId(ltkjMiddleHead.getFeadId()); |
| | | if (detailList!=null){ |
| | | for (LtkjMiddleDetail ltkjMiddleDetail : detailList) { |
| | | DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.MASTER.name()); |
| | | middleDetailService.save(ltkjMiddleDetail); |
| | | DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | //根据配置调取存储过程 将临时表数据存入预约表2023.12.12 |
| | | // final String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData"); |
| | | // if ("Y".equals(getInfoFromSqlData)){ |
| | | // List<LtkjMiddleHead> one = testMapper.saveMiddleHeadByPatId(tjCustomer.getCusIdcard()); |
| | | // if (one!=null){ |
| | | // for (LtkjMiddleHead ltkjMiddleHead : one) { |
| | | // DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.MASTER.name()); |
| | | // headService.save(ltkjMiddleHead); |
| | | // DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | // List<LtkjMiddleDetail> detailList = testMapper.getMiddleDetailByHeadId(ltkjMiddleHead.getFeadId()); |
| | | // if (detailList!=null){ |
| | | // for (LtkjMiddleDetail ltkjMiddleDetail : detailList) { |
| | | // DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.MASTER.name()); |
| | | // middleDetailService.save(ltkjMiddleDetail); |
| | | // DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // } |
| | | |
| | | |
| | | /*调用his接口*/ |
| | | String config = configService.selectConfigByKey("sfkqdyhis"); |
| | | if(null !=config && config.equals("Y")){ |
| | | hisApiMethod.HisApiMethods(tjCustomer,tjOrder.getOrderId()); |
| | | } |
| | | tjCustomer.setCardId("0"); |
| | | tjCustomerService.updateById(tjCustomer); |
| | | |
| | | return AjaxResult.success(tjNumber); |
| | | } |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/addPlOrderAndDetail") |
| | | @ApiOperation(value = "体检批量签到登记接口") |
| | | @Transactional //(切换数据库出错,所以注释) |
| | | public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto,HttpServletResponse response) { |
| | | SysUser sysUser = UserHoder.getLoginUser().getUser(); |
| | | List<String> cusIds = daoDto.getCusIds(); |
| | | ArrayList<String> tjNumbers = new ArrayList<>(); |
| | | if (null != cusIds && cusIds.size() > 0) { |
| | | ExecutorService threadPools = Executors.newFixedThreadPool(cusIds.size()); |
| | | for (String cusId : cusIds) { |
| | | threadPools.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | getAjaxResults(cusId); |
| | | } |
| | | }); |
| | | } |
| | | LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>(); |
| | | wq.in(TjCustomer::getCusIdcard, cusIds); |
| | | List<Long> list = tjCustomerService.list(wq).stream().map(TjCustomer::getCusId).collect(Collectors.toList()); |
| | | if (list.size() > 0) { |
| | | // ExecutorService threadPool = Executors.newFixedThreadPool(list.size()); |
| | | ThreadPoolTaskExecutor executor = threadPoolConfig.threadPoolTaskExecutor(); |
| | | for (Long aLong : list) { |
| | | // threadPool.execute(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // try { |
| | | // AjaxResult result = getAjaxResult(aLong, sysUser, daoDto.getTjCategory()); |
| | | // threadPool.shutdown(); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }); |
| | | Future<AjaxResult> future = executor.submit(new Callable<AjaxResult>() { |
| | | @Override |
| | | public AjaxResult call() throws Exception { |
| | | return getAjaxResult(aLong, sysUser, daoDto.getTjCategory()); |
| | | } |
| | | }); |
| | | try { |
| | | AjaxResult result = future.get(); |
| | | String tjNumber = result.get("tjNumber").toString(); |
| | | tjNumbers.add(tjNumber); |
| | | } catch (InterruptedException | ExecutionException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | threadPools.shutdown(); |
| | | } |
| | | } |
| | | // TODO 因为有体检号会查出空数据 先使用死数据 |
| | | tjNumbers = new ArrayList<>(); |
| | | tjNumbers.add("02095240229171627"); |
| | | tjNumbers.add("02095240229173104"); |
| | | tjNumbers.add("10001240524172002"); |
| | | tjNumbers.add("10001240304124410"); |
| | | tjNumbers.add("00325240304160123"); |
| | | tjNumbers.add("02095240304162044"); |
| | | tjNumbers.add("02095240304162152"); |
| | | tjNumbers.add("10001240304163505"); |
| | | Map<String, Object> map = null; |
| | | try { |
| | | map = PDFDocumentUtil.getDocument(); |
| | | Document document = (Document) map.get("document"); |
| | | for (int i = 0; i < tjNumbers.size(); i++) { |
| | | try { |
| | | List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumbers.get(i)); |
| | | Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumbers.get(i)); |
| | | LocalDateTime tjsj = (LocalDateTime) userInfo.get("tjsj"); |
| | | DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); |
| | | String time = null; |
| | | if (tjsj != null) { |
| | | time = dateFormat.format(tjsj); |
| | | } |
| | | PDFDocumentUtil.makeUserInfoTable(document, (String) userInfo.get("tjname"), (String) userInfo.get("sex") |
| | | , (String) userInfo.get("tjh"), (String) userInfo.get("lxdh"), (String) userInfo.get("tjname"), time); |
| | | PDFDocumentUtil.makeTjInfo(document, djdInfos); |
| | | // 多条则换页 |
| | | if (i + 1 < tjNumbers.size()) { |
| | | document.newPage(); |
| | | } |
| | | } catch (DocumentException | IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | document.close(); |
| | | ByteArrayOutputStream outputStream = (ByteArrayOutputStream) map.get("stream"); |
| | | String encodeToString = java.util.Base64.getEncoder().encodeToString(outputStream.toByteArray()); |
| | | return AjaxResult.success().put("file", encodeToString); |
| | | } catch (IOException | DocumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return AjaxResult.success("操作成功"); |
| | | } |
| | | |
| | | private void getAjaxResults(String cusIdcard) { |
| | | if (!"".equals(cusIdcard) && cusIdcard != null) { |
| | | //根据配置调取存储过程 将临时表数据存入预约表2023.12.12 |
| | | final String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData"); |
| | | if ("Y".equals(getInfoFromSqlData)) { |
| | | //根据身份证号从his查信息 |
| | | LtkjTjPat tjPatByIdCard = testMapper.getTjPatByIdCard(cusIdcard); |
| | | if (null != tjPatByIdCard) { |
| | | String fcardNo = tjPatByIdCard.getFcardNo(); |
| | | if (null != fcardNo && !fcardNo.equals("")) { |
| | | fcardNo = fcardNo.trim(); |
| | | tjPatByIdCard.setFcardNo(fcardNo); |
| | | } else { |
| | | fcardNo = cusIdcard.trim(); |
| | | tjPatByIdCard.setFcardNo(fcardNo); |
| | | } |
| | | //根据身份证号从数据库拿信息 没有的话保存 |
| | | LtkjTjPat ltkjTjPat = tjvLtkjvtjpatService.getLtkjTjPatByCusIdCard(cusIdcard); |
| | | if (null == ltkjTjPat) { |
| | | tjvLtkjvtjpatService.save(tjPatByIdCard); |
| | | } |
| | | DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | //再根据身份证号写customer表 |
| | | TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(tjPatByIdCard.getFcardNo()); |
| | | if (null == tjCustomer) { |
| | | //为空的话掉存储过程保存到客户表 |
| | | testMapper.getTjPatByCusId(cusIdcard); |
| | | LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>(); |
| | | qw.eq(TjCustomer::getCusIdcard, tjPatByIdCard.getFcardNo()); |
| | | TjCustomer customer = tjCustomerService.getOne(qw); |
| | | customer.setReservationId(customer.getCardId()); |
| | | extracteds(customer); |
| | | } else { |
| | | String cardId = tjPatByIdCard.getFcardId(); |
| | | if (null != cardId && !cardId.equals("0")) { |
| | | int i = tjOrderService.selectTjOrderByCardId(cardId); |
| | | if (i > 0) { |
| | | // return AjaxResult.error("不可重复签到"); |
| | | } |
| | | } |
| | | tjCustomer.setReservationId(tjCustomer.getCardId()); |
| | | tjCustomer.setCardId(tjPatByIdCard.getFcardId()); |
| | | tjCustomerService.updateById(tjCustomer); |
| | | extracteds(tjCustomer); |
| | | } |
| | | |
| | | } |
| | | } |
| | | //end====2023.12.12 |
| | | LambdaQueryWrapper<TjReservation> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjReservation::getIdCard, cusIdcard); |
| | | wq.eq(TjReservation::getIsExpire, 2); |
| | | TjReservation tjReservation = tjReservationService.getOne(wq); |
| | | if (tjReservation != null) { |
| | | /* if (DateUtil.endOfDay(new Date()).before(tjReservation.getReservationTime())) { |
| | | // return AjaxResult.error("未到预约时间"); |
| | | } |
| | | if (null != tjReservation.getReservationTime() && DateUtil.endOfDay(tjReservation.getReservationTime()).before(new Date())) { |
| | | tjReservation.setIsExpire(1); |
| | | tjReservationService.updateById(tjReservation); |
| | | // return AjaxResult.error("对不起您的预约已超时请重新预约"); |
| | | }*/ |
| | | LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>(); |
| | | qw.eq(TjCustomer::getCusIdcard, cusIdcard); |
| | | TjCustomer tjCustomer1 = tjCustomerService.getOne(qw); |
| | | if (tjCustomer1 != null) { |
| | | tjCustomer1.setTjType(tjReservation.getTjType()); |
| | | tjCustomer1.setCusName(tjReservation.getName()); |
| | | tjCustomer1.setCusSex(Long.valueOf(tjReservation.getSex())); |
| | | tjCustomer1.setCusBrithday(tjReservation.getBirthday()); |
| | | tjCustomer1.setCusPhone(tjReservation.getPhoe()); |
| | | tjCustomer1.setCusEmail(tjReservation.getEmail()); |
| | | tjCustomer1.setCusAddr(tjReservation.getAddress()); |
| | | tjCustomer1.setCusMarryStatus(String.valueOf(tjReservation.getMarriage())); |
| | | tjCustomer1.setCusNational(String.valueOf(tjReservation.getNation())); |
| | | tjCustomer1.setIdType(tjReservation.getIdType()); |
| | | tjCustomer1.setAge(tjReservation.getAge()); |
| | | tjCustomer1.setAgeUnit(tjReservation.getAgeUnit()); |
| | | tjCustomer1.setCareer(tjReservation.getCareer()); |
| | | tjCustomerService.updateById(tjCustomer1); |
| | | } else { |
| | | TjCustomer tjCustomer = new TjCustomer(); |
| | | tjCustomer.setCusIdcard(tjReservation.getIdCard()); |
| | | tjCustomer.setCusName(tjReservation.getName()); |
| | | tjCustomer.setCusSex(Long.valueOf(tjReservation.getSex())); |
| | | tjCustomer.setCusBrithday(tjReservation.getBirthday()); |
| | | tjCustomer.setCusPhone(tjReservation.getPhoe()); |
| | | tjCustomer.setCusEmail(tjReservation.getEmail()); |
| | | tjCustomer.setCusAddr(tjReservation.getAddress()); |
| | | tjCustomer.setCusMarryStatus(String.valueOf(tjReservation.getMarriage())); |
| | | tjCustomer.setCusNational(String.valueOf(tjReservation.getNation())); |
| | | tjCustomer.setIdType(tjReservation.getIdType()); |
| | | tjCustomer.setAge(tjReservation.getAge()); |
| | | tjCustomer.setAgeUnit(tjReservation.getAgeUnit()); |
| | | tjCustomer.setCareer(tjReservation.getCareer()); |
| | | tjCustomer.setDwPhone(tjReservation.getDwPhone()); |
| | | tjCustomer.setCardId(tjReservation.getCardId()); |
| | | tjCustomer.setIndexCard(tjReservation.getIndexCard()); |
| | | //截取密码自动生成set进去 |
| | | String substring = cusIdcard.substring(cusIdcard.length() - 6); |
| | | substring = DigestUtils.md5DigestAsHex(substring.getBytes()); |
| | | tjCustomer.setCusPassword(substring); |
| | | tjCustomer.setTjType(tjReservation.getTjType()); |
| | | tjCustomerService.save(tjCustomer); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | private void extracteds(TjCustomer customer) { |
| | | //从his表抓数据 |
| | | LtkjMiddleHead pat = testMapper.getMiddleHeadByPartId(customer.getCardId()); |
| | | if (null != pat) { |
| | | LambdaQueryWrapper<LtkjMiddleHead> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(LtkjMiddleHead::getFeadId, customer.getCardId()); |
| | | headService.remove(wq1); |
| | | LambdaQueryWrapper<LtkjMiddleDetail> wq0 = new LambdaQueryWrapper<>(); |
| | | wq0.eq(LtkjMiddleDetail::getFheadId, pat.getFeadId()); |
| | | middleDetailService.remove(wq0); |
| | | List<LtkjMiddleDetail> list = testMapper.getMiddleDetailByFeadId(pat.getFeadId()); |
| | | DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.MASTER.name()); |
| | | LtkjMiddleHead o = headService.getMiddleHeadByPartId(customer.getCardId()); |
| | | if (o == null) { |
| | | headService.save(pat); |
| | | for (LtkjMiddleDetail ltkjMiddleDetail : list) { |
| | | middleDetailService.save(ltkjMiddleDetail); |
| | | } |
| | | } |
| | | testMapper.saveTjProByCusId(customer.getCardId(), customer.getCusIdcard()); |
| | | } |
| | | DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | } |
| | | |
| | | private AjaxResult getAjaxResult(Long userId, SysUser sysUser, String tjCategory) throws IOException { |
| | | |
| | | LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjCustomer::getCusId, userId); |
| | | TjCustomer tjCustomer = tjCustomerService.getOne(wq); |
| | | if (tjCustomer == null) return AjaxResult.error("该客户未登记或不存在"); |
| | | |
| | | LambdaQueryWrapper<TjOrder> wqq = new LambdaQueryWrapper<>(); |
| | | wqq.eq(TjOrder::getUserId, userId); |
| | | wqq.eq(TjOrder::getCheckStatus, 0); |
| | | wqq.isNull(TjOrder::getFinishTime); |
| | | if (!tjCustomer.getCardId().equals("0")) { |
| | | wqq.eq(TjOrder::getCardId, tjCustomer.getCardId()); |
| | | } |
| | | TjOrder order = tjOrderService.getOne(wqq); |
| | | if (null != order) { |
| | | transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId()); |
| | | return AjaxResult.error("不可重复登记"); |
| | | } |
| | | TjOrder tjOrder = new TjOrder(); |
| | | Date date = new Date(); |
| | | tjOrder.setCreateTime(date); |
| | | tjOrder.setUpdateTime(date); |
| | | tjOrder.setCreateBy(sysUser.getNickName()); |
| | | tjOrder.setUpdateBy(sysUser.getNickName()); |
| | | tjOrder.setUserId(userId); |
| | | tjOrder.setTjCategory(tjCategory); |
| | | LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard()); |
| | | wq1.eq(TjReservation::getIsExpire, 2); |
| | | TjReservation tjReservation = tjReservationService.getOne(wq1); |
| | | MallOrder mallOrder = null; |
| | | if (tjReservation != null) { |
| | | 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(tjReservation.getReservationTime()).before(new Date())) { |
| | | tjReservation.setIsExpire(1); |
| | | tjReservationService.updateById(tjReservation); |
| | | return AjaxResult.error("对不起您的预约已超时请重新预约"); |
| | | } |
| | | if (null != tjReservation.getTeamNo()) tjOrder.setTeamNo(tjReservation.getTeamNo()); |
| | | if (null != tjReservation.getCompanyId()) tjOrder.setFirmId(tjReservation.getCompanyId()); |
| | | if (null != tjReservation.getDepartment()) tjOrder.setFirmDeptName(tjReservation.getDepartment()); |
| | | if (null != tjReservation.getJobNo()) tjOrder.setFirmWorkId(tjReservation.getJobNo()); |
| | | if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId()); |
| | | if (null != tjReservation.getTjCategory()) tjOrder.setTjCategory(tjReservation.getTjCategory()); |
| | | if (null != tjReservation.getGroupingId()) { |
| | | tjOrder.setGroupId(tjReservation.getGroupingId()); |
| | | tjOrder.setFirmDeptId(tjReservation.getPacId()); |
| | | } |
| | | tjReservation.setIsExpire(1); |
| | | tjReservationService.updateById(tjReservation); |
| | | |
| | | //生成体检号 |
| | | String tjNumber = (sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmss").format(new Date())); |
| | | |
| | | tjNumber = tjNumber.replaceAll(".{4}$", userId.toString().substring(userId.toString().length() - 4)); |
| | | |
| | | tjOrder.setTjNumber(tjNumber); |
| | | if (null != tjOrder.getPhoto()) { |
| | | File file = new File(tjOrder.getPhoto()); |
| | | if (file.isFile()) { |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | byte[] bytes = new byte[fileInputStream.available()]; |
| | | fileInputStream.read(bytes); // 读取到 byte 里面 |
| | | fileInputStream.close(); |
| | | // 得到文件 之后转成beye 然后使用base64转码 |
| | | String encode = Base64.encode(bytes); |
| | | tjOrder.setPhoto(encode); |
| | | } |
| | | } |
| | | if (tjOrder.getFirmId() == null) { |
| | | tjOrder.setFirmId("0"); |
| | | } |
| | | if (null == tjOrder.getPacId() && null != transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId()))) { |
| | | tjOrder.setPacId(transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId()))); |
| | | } |
| | | //判断小程序上预约是否付钱 |
| | | if (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId())); |
| | | tjOrder.setStatus(TjConstants.TJ_BEGIN); |
| | | tjOrder.setCardId(tjCustomer.getCardId()); |
| | | tjOrder.setTjType("1"); |
| | | |
| | | if (tjOrderService.save(tjOrder)) { |
| | | |
| | | //保存收货地址 |
| | | if ("2".equals(tjOrder.getGetType())) { |
| | | final TjReportGetAddress address = tjOrder.getAddAddress(); |
| | | if (address != null) { |
| | | address.setTjNumber(tjNumber); |
| | | tjReportGetAddressService.save(address); |
| | | } |
| | | } |
| | | Long cusNumber = tjCustomer.getCusNumber(); |
| | | cusNumber += 1; |
| | | tjCustomer.setCusNumber(cusNumber); |
| | | // BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount())).divide(BigDecimal.valueOf(10)); |
| | | TjFlowingWater tjFlowingWater = new TjFlowingWater(); |
| | | tjFlowingWater.setPayStasus(0L); |
| | | if ("1".equals(tjOrder.getTjType())) { |
| | | if (tjReservation.getPayType() == 1) { |
| | | tjFlowingWater.setPayStasus(3L); |
| | | } |
| | | } |
| | | |
| | | //调用SQL server拿取收费情况 |
| | | //根据配置调取存储过程 将临时表数据存入预约表2023.12.12 |
| | | String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData"); |
| | | String isPay = configService.selectConfigByKey("isPay"); |
| | | if ("Y".equals(getInfoFromSqlData)) { |
| | | LtkjMiddleHead middleHead = headService.getMiddleHeadByPartId(tjCustomer.getCardId()); |
| | | if (null != middleHead) { |
| | | tjFlowingWater.setPayStasus(1L); |
| | | } |
| | | } |
| | | tjFlowingWater.setOrderId(tjOrder.getOrderId()); |
| | | Date date1 = new Date(System.currentTimeMillis()); |
| | | String s1 = sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1); |
| | | tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1); |
| | | |
| | | if (isPay.equals("true")) { |
| | | if (null != mallOrder) { |
| | | if (mallOrder.getOrderStatus().equals(201L)) { |
| | | tjFlowingWater.setCopeWith(mallOrder.getActualPrice()); |
| | | tjFlowingWater.setPaidIn(mallOrder.getActualPrice()); |
| | | tjFlowingWater.setDiscount(String.valueOf(1)); |
| | | tjFlowingWater.setPayStasus(1L); |
| | | tjFlowingWater.setPayType(3L); |
| | | MallCheckLog checkLog = new MallCheckLog(); |
| | | checkLog.setCheckBy(sysUser.getNickName()); |
| | | checkLog.setUserId(mallOrder.getUserId()); |
| | | checkLog.setConsignee(mallOrder.getConsignee()); |
| | | checkLog.setIdCard(mallOrder.getIdCard()); |
| | | checkLog.setOrderId(String.valueOf(mallOrder.getId())); |
| | | checkLog.setOrderSn(mallOrder.getOrderSn()); |
| | | checkLog.setCheckTime(new Date()); |
| | | checkLog.setShipSn("HX" + s1); |
| | | mallCheckLogService.save(checkLog); |
| | | mallOrder.setOrderStatus(301L); |
| | | mallOrderService.updateById(mallOrder); |
| | | } |
| | | } |
| | | } |
| | | if (tjFlowingWaterService.save(tjFlowingWater)) { |
| | | tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | tjOrderService.updateById(tjOrder); |
| | | |
| | | |
| | | } |
| | | asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater); |
| | | |
| | | |
| | | tjCustomer.setCardId("0"); |
| | | tjCustomerService.updateById(tjCustomer); |
| | | return AjaxResult.success().put("tjNumber",tjNumber); |
| | | } |
| | | return AjaxResult.success(tjNumber); |
| | | } |
| | | return AjaxResult.error(); |
| | | } |
| | |
| | | if (null != proIds1 && !proIds1.equals("")) { |
| | | proIds = JSON.parseArray(proIds1.toString(), Long.class); |
| | | } |
| | | TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusId); |
| | | String cardId = "0"; |
| | | if (null != tjCustomer) { |
| | | cardId = tjCustomer.getCardId(); |
| | | } |
| | | if ((null == proIds || proIds.size() == 0) && (null == packId || packId.equals(""))) { |
| | | transitionService.deletedTbTransitionByCusId(cusId); |
| | | if (redisCache.hasKey(cusId)) redisCache.deleteObject(cusId); |
| | | if (redisCache.hasKey(cusId + "cusId")) redisCache.deleteCacheMapValue(cusId + "cusId", cusId); |
| | | |
| | | if (redisCache.hasKey(cardId + cusId)) { |
| | | redisCache.deleteObject(cardId + cusId); |
| | | } |
| | | if (redisCache.hasKey(cardId + cusId + "cusId")) { |
| | | redisCache.deleteCacheMapValue(cardId + cusId + "cusId", cardId + cusId); |
| | | } |
| | | } |
| | | List<TbTransition> tbTransitionList = null; |
| | | if (!redisCache.hasKey(cusId)) { |
| | | if (!redisCache.hasKey(cardId + cusId)) { |
| | | tbTransitionList = new ArrayList<>(); |
| | | } else { |
| | | tbTransitionList = redisCache.getCacheList(cusId); |
| | | 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); |
| | | if (redisCache.hasKey(cusId + "cusId")) redisCache.deleteCacheMapValue(cusId + "cusId", cusId); |
| | | if (redisCache.hasKey(cusId)) { |
| | | 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(cusId); |
| | | redisCache.deleteObject(cardId + cusId); |
| | | } |
| | | List<TjPackageProject> ppList = tjPackageProjectService.getTjPackageProjectListByPacId(String.valueOf(pacId)); |
| | | if (null != ppList && ppList.size() > 0) { |
| | | //异步保存数据库 |
| | | // asyncService.addRedisTransitionPac(cusId, pacId, ppList); |
| | | asyncService.saveRedisTransitionByPacId(cusId, pacId, null); |
| | | asyncService.saveRedisTransitionByPacId(cusId,cardId, pacId, null); |
| | | for (TjPackageProject tjPackageProject : ppList) { |
| | | TjProject project = projectService.getTjProjectById(String.valueOf(tjPackageProject.getProId())); |
| | | if (null != project) { |
| | | BigDecimal divide = tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN); |
| | | |
| | | 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); |
| | |
| | | //单项 |
| | | if (null != proIds && proIds.size() > 0) { |
| | | //异步保存数据库表 |
| | | asyncService.saveRedisTransitionByPacId(cusId, 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) { |
| | |
| | | tbTransition.setParentProId(tjProject.getProParentId()); |
| | | if (tjProject.getProParentId() != null) { |
| | | TjProject byId = projectService.getById(tjProject.getProParentId()); |
| | | if(null !=byId){ |
| | | if (null != byId) { |
| | | tbTransition.setParentProName(byId.getProName()); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if (null != tbTransitionList && tbTransitionList.size() > 0) { |
| | | if (redisCache.hasKey(cusId)) { |
| | | redisCache.deleteObject(cusId); |
| | | redisCache.setCacheList(cusId, tbTransitionList); |
| | | redisCache.setCacheMapValue(cusId + "cusId", cusId, getMaps(cusId)); |
| | | 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(cusId, tbTransitionList); |
| | | redisCache.setCacheMapValue(cusId + "cusId", cusId, getMaps(cusId)); |
| | | redisCache.setCacheList(cardId + cusId, tbTransitionList); |
| | | redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId)); |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | |
| | | List<Map<String, Object>> list = redisCache.getCacheMapValue(cusId + "cusId", cusId); |
| | | return AjaxResult.success(list); |
| | | } |
| | | List<Map<String, Object>> list = getMaps(cusId); |
| | | TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusId); |
| | | String cardId = "0"; |
| | | if (null != tjCustomer) { |
| | | cardId = tjCustomer.getCardId(); |
| | | } |
| | | List<Map<String, Object>> list = getMaps(cusId, cardId); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | |
| | | for (TjOrderRemark remark : remarkList) { |
| | | TjProject project = projectService.getTjProjectById(String.valueOf(remark.getProId())); |
| | | if (null != project) { |
| | | // if ("N".equals(project.getNeedReport())) { |
| | | // continue; |
| | | // } |
| | | remark.setProCheckType(project.getProCheckType()); |
| | | remark.setProName(project.getProName()); |
| | | } |
| | |
| | | if (!handleOption.isCanship()) { |
| | | return AjaxResult.error("订单不能核销"); |
| | | } |
| | | Date date = new Date(); |
| | | order.setOrderStatus(OrderUtil.STATUS_SHIP.longValue()); |
| | | order.setShipTime(new Date()); |
| | | order.setConfirmTime(new Date()); |
| | | order.setShipTime(date); |
| | | order.setConfirmTime(date); |
| | | |
| | | MallCheckLog checkLog = new MallCheckLog(); |
| | | String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()); |
| | | String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date); |
| | | checkLog.setCheckBy(String.valueOf(SecurityUtils.getUserId())); |
| | | checkLog.setUserId(order.getUserId()); |
| | | checkLog.setConsignee(order.getConsignee()); |
| | | checkLog.setIdCard(order.getIdCard()); |
| | | checkLog.setOrderId(String.valueOf(order.getId())); |
| | | checkLog.setOrderSn(order.getOrderSn()); |
| | | checkLog.setCheckTime(new Date()); |
| | | checkLog.setCheckTime(date); |
| | | checkLog.setShipSn("HX" + s1); |
| | | mallCheckLogService.save(checkLog); |
| | | mallOrderService.updateById(order); |
| | |
| | | } |
| | | |
| | | |
| | | private List<Map<String, Object>> getMaps(String cusId) { |
| | | private List<Map<String, Object>> getMaps(String cusId, String cardId) { |
| | | |
| | | List<TbTransition> transitionList = null; |
| | | if (redisCache.hasKey(cusId)) { |
| | | transitionList = redisCache.getCacheList(cusId); |
| | | } else { |
| | | transitionList = transitionService.getTbTransitionListByCusId(cusId); |
| | | } |
| | | // 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<>(); |
| | |
| | | if (null != pacId) { |
| | | TjPackage aPackage = tjPackageService.getById(entry.getValue().get(0).getPacId()); |
| | | 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", transitionService.getTbTransitionDxPriceByPac(cusId, entry.getKey(), cardId, pacId)); |
| | | } else { |
| | | 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<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()); |
| | | // if (tbTransition.getOrdPrice().compareTo(BigDecimal.valueOf(0)) == 0 || tbTransition.getNowPrice().compareTo(BigDecimal.valueOf(0)) == 0) { |
| | | // tbTransition.setDiscount("0"); |
| | | // } else { |
| | | // tbTransition.setDiscount((tbTransition.getNowPrice()).divide(tbTransition.getOrdPrice(), BigDecimal.ROUND_CEILING).toString()); |
| | | // } |
| | | // if (null != tbTransition.getPacId()) { |
| | | // tbTransition.setPacPrice(tjPackageService.getById(tbTransition.getPacId()).getPrice()); |
| | | // } |
| | | // if (null != tbTransition.getParentProId()) { |
| | | // tbTransition.setPacPrice(projectService.getTjProjectById(String.valueOf(tbTransition.getParentProId())).getProPrice()); |
| | | // } |
| | | } |
| | | // map.put("ordPrice", money1.setScale(Integer.parseInt(configService.selectConfigByKey("sys.price.save")), Integer.parseInt(configService.selectConfigByKey("sys.price")))); |
| | | // map.put("nowPrice", money2.setScale(Integer.parseInt(configService.selectConfigByKey("sys.price.save")), Integer.parseInt(configService.selectConfigByKey("sys.price")))); |
| | | map.put("ordPrice", money1); |
| | | map.put("nowPrice", money2); |
| | | } |
| | | list.add(map); |
| | | } |
| | | return list; |
| | |
| | | } |
| | | |
| | | public void newSaveextracted(TjOrder tjOrder, TjCustomer tjCustomer, BigDecimal discount, SysUser sysUser, TjReservation tjReservation, TjFlowingWater tjFlowingWater) { |
| | | long l = System.currentTimeMillis(); |
| | | 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())); |
| | | //修改每项的原价现价 |
| | | transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount); |
| | | 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())); |
| | | //判断是否交钱 |
| | |
| | | sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | } |
| | | } |
| | | if (tjFlowingWater.getPayStasus() == 1) { |
| | | if (tjFlowingWater.getPayStasus() == 1L) { |
| | | tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()), |
| | | sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn()); |
| | | tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith()); |
| | | tjFlowingWater.setPayType(4L); |
| | | tjFlowingWaterService.updateById(tjFlowingWater); |
| | | asyncService.addTjChargingStandard(tjOrder, transitionService.getTbTransitionListByCusId(tjCustomer.getCusIdcard(), tjOrder.getCardId()), sysUser); |
| | | } |
| | | System.out.println("这段代码时间" + (System.currentTimeMillis() - l)); |
| | | // System.out.println("这段代码时间" + (System.currentTimeMillis() - l)); |
| | | } |
| | | |
| | | |
| | |
| | | byId.setHeshouDoctor(UserHoder.getLoginUser().getUserId()); |
| | | byId.setHeshouTime(new DateTime()); |
| | | final boolean b = tjOrderService.updateById(byId); |
| | | if (!b){ |
| | | if (!b) { |
| | | return AjaxResult.error("核收失败"); |
| | | } |
| | | } |
| | |
| | | @Transactional |
| | | public AjaxResult getHistryTjOrderByCusIdCard(@RequestParam String cusIdCard) { |
| | | TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusIdCard); |
| | | List<HistoryTjOrder> list=new ArrayList<>(); |
| | | if(null !=tjCustomer){ |
| | | List<HistoryTjOrder> list = new ArrayList<>(); |
| | | if (null != tjCustomer) { |
| | | List<TjOrder> orderList = tjOrderService.getTjOrderListByCusId(tjCustomer.getCusId()); |
| | | for (TjOrder order : orderList) { |
| | | HistoryTjOrder historyTjOrder=new HistoryTjOrder(); |
| | | HistoryTjOrder historyTjOrder = new HistoryTjOrder(); |
| | | historyTjOrder.setUserName(tjCustomer.getCusName()); |
| | | historyTjOrder.setTjNum(order.getTjNumber()); |
| | | historyTjOrder.setTjTime(order.getCreateTime()); |
| | |
| | | @Transactional |
| | | public AjaxResult getHistryTjOrderProByCusIdCard(@RequestParam String cusIdCard) { |
| | | TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusIdCard); |
| | | if(null !=tjCustomer){ |
| | | TjOrder order= tjOrderService.getLastTjOrderListByCusId(tjCustomer.getCusId()); |
| | | if(null !=order){ |
| | | if (null != tjCustomer) { |
| | | TjOrder order = tjOrderService.getLastTjOrderListByCusId(tjCustomer.getCusId()); |
| | | if (null != order) { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | if(order.getPacId().equals("o")){ |
| | | if (order.getPacId().equals("o")) { |
| | | List<Long> longList = remarkService.getTjProIdsByTjNum(order.getTjNumber()); |
| | | for (Long aLong : longList) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("pacName", "单项"); |
| | | map.put("proId",aLong); |
| | | map.put("pacId",null); |
| | | map.put("proId", aLong); |
| | | map.put("pacId", null); |
| | | map.put("parentName", projectService.getById(aLong).getProName()); |
| | | map.put("list",projectService.getTjProjectListBySoneId(String.valueOf(aLong))); |
| | | map.put("list", projectService.getTjProjectListBySoneId(String.valueOf(aLong))); |
| | | BigDecimal proPrice = projectService.getById(aLong).getProPrice(); |
| | | map.put("ordPrice", proPrice); |
| | | map.put("nowPrice", proPrice); |
| | | list.add(map); |
| | | } |
| | | } |
| | | if(!order.getPacId().equals("o")){ |
| | | List<Long> longList = remarkService.getTjProIdsByTjNumAndPacIc(order.getTjNumber(),order.getPacId()); |
| | | if (!order.getPacId().equals("o")) { |
| | | List<Long> longList = remarkService.getTjProIdsByTjNumAndPacIc(order.getTjNumber(), order.getPacId()); |
| | | TjPackage aPackage = tjPackageService.getById(order.getPacId()); |
| | | for (Long aLong : longList) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("pacName",aPackage.getPacName()); |
| | | map.put("pacId",String.valueOf(aPackage.getPacId())); |
| | | map.put("pacName", aPackage.getPacName()); |
| | | map.put("pacId", String.valueOf(aPackage.getPacId())); |
| | | map.put("parentName", projectService.getById(aLong).getProName()); |
| | | map.put("list",projectService.getTjProjectListBySoneId(String.valueOf(aLong))); |
| | | map.put("list", projectService.getTjProjectListBySoneId(String.valueOf(aLong))); |
| | | BigDecimal proPrice = projectService.getById(aLong).getProPrice(); |
| | | map.put("ordPrice", proPrice); |
| | | map.put("nowPrice",tjPackageProjectService.getPacProPriceByPacIdAndPro(aLong,order.getPacId())); |
| | | map.put("nowPrice", tjPackageProjectService.getPacProPriceByPacIdAndPro(aLong, order.getPacId())); |
| | | list.add(map); |
| | | } |
| | | |
| | | List<Long> longList1 = remarkService.getTjProIdsByTjNumAndPacIc(order.getTjNumber(),order.getPacId()); |
| | | List<Long> longList1 = remarkService.getTjProIdsByTjNumAndPacIc(order.getTjNumber(), order.getPacId()); |
| | | for (Long aLong : longList1) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("pacName", "单项"); |
| | | map.put("proId",aLong); |
| | | map.put("pacId",null); |
| | | map.put("proId", aLong); |
| | | map.put("pacId", null); |
| | | map.put("parentName", projectService.getById(aLong).getProName()); |
| | | map.put("list",projectService.getTjProjectListBySoneId(String.valueOf(aLong))); |
| | | map.put("list", projectService.getTjProjectListBySoneId(String.valueOf(aLong))); |
| | | BigDecimal proPrice = projectService.getById(aLong).getProPrice(); |
| | | map.put("ordPrice", proPrice); |
| | | map.put("nowPrice", proPrice); |
| | |
| | | return AjaxResult.success("暂无历史记录"); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getHistryTjOrderByCusId") |
| | | @ApiOperation(value = "根据客户id查看历史体检记录") |
| | | @Transactional |
| | | public AjaxResult getHistryTjOrderByCusId(@RequestParam String cusId) { |
| | | TjCustomer tjCustomer = tjCustomerService.getById(cusId); |
| | | List<HistoryTjOrder> list = new ArrayList<>(); |
| | | if (null != tjCustomer) { |
| | | List<TjOrder> orderList = tjOrderService.getTjOrderListByCusId(tjCustomer.getCusId()); |
| | | for (TjOrder order : orderList) { |
| | | HistoryTjOrder historyTjOrder = new HistoryTjOrder(); |
| | | historyTjOrder.setUserName(tjCustomer.getCusName()); |
| | | historyTjOrder.setTjNum(order.getTjNumber()); |
| | | historyTjOrder.setTjTime(order.getCreateTime()); |
| | | historyTjOrder.setTjProName(tjOrderService.getHistoryTjOrderProByTjNum(order.getTjNumber())); |
| | | |
| | | //查流水 |
| | | BigDecimal res = new BigDecimal(0); |
| | | LambdaQueryWrapper<TjFlowingWater> wqq = new LambdaQueryWrapper<>(); |
| | | wqq.eq(TjFlowingWater::getOrderId, order.getOrderId()); |
| | | final List<TjFlowingWater> list1 = tjFlowingWaterService.list(wqq); |
| | | if (list1 != null) { |
| | | for (TjFlowingWater tjFlowingWater : list1) { |
| | | if (tjFlowingWater != null && tjFlowingWater.getPaidIn() != null) { |
| | | res.add(tjFlowingWater.getPaidIn()); |
| | | } |
| | | } |
| | | } |
| | | historyTjOrder.setPaidIn(res); |
| | | list.add(historyTjOrder); |
| | | } |
| | | } |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/revokeTjOrderByTjNum") |
| | | @ApiOperation(value = "根据客户体检号撤销体检记录") |
| | | @Transactional |
| | | 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("该用户已收费不可撤销签到!"); |
| | | } |
| | | 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); |
| | | return AjaxResult.success("撤销成功!!!"); |
| | | } |
| | | return AjaxResult.success("签到记录不存在!"); |
| | | } |
| | | |
| | | |
| | | @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); |
| | | if (null != name) wq.eq(TjReservation::getName, name); |
| | | if (null != deptId) wq.eq(TjReservation::getDepartment, deptId); |
| | | if (null != reservationTime) |
| | | wq.between(TjReservation::getReservationTime, DateUtil.beginOfDay(reservationTime), DateUtil.endOfDay(reservationTime)); |
| | | List<TjReservation> reservationList = tjReservationService.list(wq); |
| | | if (null != reservationList && reservationList.size() > 0) { |
| | | LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.in(TjOrder::getReservationId, reservationList.stream().map(TjReservation::getId).collect(Collectors.toList())); |
| | | List<TjOrder> orderList = tjOrderService.list(wq1); |
| | | if (null != orderList && orderList.size() > 0) { |
| | | LambdaQueryWrapper<TjReservation> wq3 = new LambdaQueryWrapper<>(); |
| | | wq3.in(TjReservation::getId, orderList.stream().map(TjOrder::getReservationId).collect(Collectors.toList())); |
| | | // wq3.eq(TjReservation::getTeamNo,reservationList.get(0).getTeamNo()); |
| | | Page<TjReservation> page1 = tjReservationService.page(pages, wq3); |
| | | return AjaxResult.success(page1); |
| | | |
| | | } |
| | | } |
| | | return AjaxResult.success("暂无信息"); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/plRevokeTjOrderByTjNum") |
| | | @ApiOperation(value = "根据客户体检号批量撤销体检记录") |
| | | @Transactional |
| | | 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); |
| | | List<TjOrder> orderList = tjOrderService.list(wq1); |
| | | if (null != orderList && orderList.size() > 0) { |
| | | for (TjOrder order : orderList) { |
| | | // TjOrder order = tjOrderService.getOrderByTjNum(tjNum); |
| | | if (null != order) { |
| | | // String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId())); |
| | | // if (null != payByTjNum) { |
| | | // return AjaxResult.success("该用户已收费不可撤销签到!"); |
| | | // } |
| | | tjOrderService.deleteTjOrderByOrderId(order.getOrderId()); |
| | | tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId())); |
| | | remarkService.deletedOrderRemarkByTjNum(order.getTjNumber()); |
| | | tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId())); |
| | | transitionService.deletedTbTransitionByTjNum(order.getTjNumber()); |
| | | transitionService.updateTbTransitionByTjNum(order.getTjNumber()); |
| | | } |
| | | } |
| | | for (String id : reservationIds) { |
| | | TjReservation reservation = tjReservationService.getById(id); |
| | | if (null != reservation) { |
| | | reservation.setIsExpire(2); |
| | | tjReservationService.updateById(reservation); |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.success("撤销成功!!!"); |
| | | } |
| | | return AjaxResult.error("请选择要撤销的人员!"); |
| | | } |
| | | |
| | | @PostMapping("makeTjPDF") |
| | | @ApiOperation(value = "批量生成PDF") |
| | | public AjaxResult makeTjPDF(@RequestBody List<String> reservations) { |
| | | QueryWrapper<TjOrder> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.in("reservation_id",reservations); |
| | | List<TjOrder> tjNumbers = tjOrderService.list(queryWrapper); |
| | | Map<String, Object> map = null; |
| | | try { |
| | | map = PDFDocumentUtil.getDocument(); |
| | | Document document = (Document) map.get("document"); |
| | | for (int i = 0; i < tjNumbers.size(); i++) { |
| | | String tjNumber = tjNumbers.get(i).getTjNumber(); |
| | | try { |
| | | List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumber); |
| | | Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumber); |
| | | LocalDateTime tjsj = (LocalDateTime) userInfo.get("tjsj"); |
| | | DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); |
| | | String time = null; |
| | | if (tjsj != null) { |
| | | time = dateFormat.format(tjsj); |
| | | } |
| | | PDFDocumentUtil.makeUserInfoTable(document, (String) userInfo.get("tjname"), (String) userInfo.get("sex") |
| | | , (String) userInfo.get("tjh"), (String) userInfo.get("lxdh"), (String) userInfo.get("tjname"), time); |
| | | PDFDocumentUtil.makeTjInfo(document, djdInfos); |
| | | // 多条则换页 |
| | | if (i + 1 < tjNumbers.size()) { |
| | | document.newPage(); |
| | | } |
| | | } catch (DocumentException | IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | document.close(); |
| | | ByteArrayOutputStream outputStream = (ByteArrayOutputStream) map.get("stream"); |
| | | String encodeToString = java.util.Base64.getEncoder().encodeToString(outputStream.toByteArray()); |
| | | return AjaxResult.success().put("file", encodeToString); |
| | | } catch (IOException | DocumentException e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |