From ec2bb08f0aad10bbf1f133046d8e9943be3a6d72 Mon Sep 17 00:00:00 2001 From: zjh <zjh@888> Date: 星期三, 26 六月 2024 15:34:44 +0800 Subject: [PATCH] zjh 本地 2024/06/26 --3修改签到撤销接口不判断作废状态 --- ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java | 645 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 512 insertions(+), 133 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java index 5a6dff8..192b101 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java +++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java @@ -4,11 +4,14 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.OffsetTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.concurrent.*; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Resource; @@ -20,17 +23,25 @@ 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; 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.*; @@ -53,6 +64,9 @@ import com.ltkj.system.service.ISysConfigService; import com.ltkj.system.service.ISysDeptService; 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.HisMzJysqController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -61,8 +75,10 @@ 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.transaction.interceptor.TransactionAspectSupport; import org.springframework.util.DigestUtils; import org.springframework.web.bind.annotation.*; import com.ltkj.common.annotation.Log; @@ -160,6 +176,18 @@ private LtkjMiddleHeadService headService; @Resource private TjvLtkjvtjpatService tjvLtkjvtjpatService; + @Autowired + private ThreadPoolConfig threadPoolConfig; + + @Autowired + private HisApiMethod hisApiMethod; + + @Autowired + private HisMzJysqController hisMzJysqController; + @Autowired + private HisApiGetMethodService hisApiGetMethodService; + @Autowired + private ISysDeptService sysDeptService; /** @@ -417,9 +445,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.setTjCustomerPhone(tjCustomer.getCusPhone()); // order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); order.setTjCusIdCard(tjCustomer.getCusIdcard()); order.setCareer(tjCustomer.getCareer()); @@ -822,27 +849,29 @@ LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>(); wq.eq(TjCustomer::getCusId, tjOrder.getUserId()); TjCustomer tjCustomer = tjCustomerService.getOne(wq); - if (tjCustomer == null) return AjaxResult.error("璇ュ鎴锋湭鐧昏鎴栦笉瀛樺湪"); + 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()); - } +// 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<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) { - order.setReservationId(tjReservation.getId()); + 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("鏈埌棰勭害鏃堕棿"); @@ -897,6 +926,7 @@ tjOrder.setStatus(TjConstants.TJ_BEGIN); tjOrder.setCardId(tjCustomer.getCardId()); if (tjOrderService.save(tjOrder)) { + //淇濆瓨鏀惰揣鍦板潃 if ("2".equals(tjOrder.getGetType())) { final TjReportGetAddress address = tjOrder.getAddAddress(); @@ -1004,8 +1034,23 @@ // // } // } - tjCustomer.setCardId("0"); - tjCustomerService.updateById(tjCustomer); + + + /*璋冪敤his鎺ュ彛*/ + String config = configService.selectConfigByKey("sfkqdyhis"); + 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); + } return AjaxResult.success(tjNumber); } return AjaxResult.error(); @@ -1015,9 +1060,10 @@ @PostMapping("/addPlOrderAndDetail") @ApiOperation(value = "浣撴鎵归噺绛惧埌鐧昏鎺ュ彛") @Transactional //(鍒囨崲鏁版嵁搴撳嚭閿欙紝鎵�浠ユ敞閲�) - public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto) { + 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) { @@ -1032,21 +1078,78 @@ 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()); +// ExecutorService threadPool = Executors.newFixedThreadPool(list.size()); + ThreadPoolTaskExecutor executor = threadPoolConfig.threadPoolTaskExecutor(); for (Long aLong : list) { - threadPool.execute(new Runnable() { +// 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 void run() { - try { - getAjaxResult(aLong, sysUser, daoDto.getTjCategory()); - threadPool.shutdown(); - } catch (IOException e) { - e.printStackTrace(); - } + 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("鎿嶄綔鎴愬姛"); } @@ -1241,108 +1344,110 @@ tjReservation.setIsExpire(1); tjReservationService.updateById(tjReservation); - //鐢熸垚浣撴鍙� - String tjNumber = (sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmss").format(new Date())); + //鐢熸垚浣撴鍙� + String tjNumber = (sysUser.getUserName() + new SimpleDateFormat("yyMMddHHmmss").format(new Date())); - tjNumber = tjNumber.replaceAll(".{4}$", userId.toString().substring(userId.toString().length() - 4)); + 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); + 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); } } - 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); - } + if (tjOrder.getFirmId() == null) { + tjOrder.setFirmId("0"); } - - //璋冪敤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); - } + if (null == tjOrder.getPacId() && null != transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId()))) { + tjOrder.setPacId(transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId()))); } - 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 (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId())); + tjOrder.setStatus(TjConstants.TJ_BEGIN); + tjOrder.setCardId(tjCustomer.getCardId()); + tjOrder.setTjType("1"); - 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 (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); } - 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(tjNumber); } - } return AjaxResult.error(); } @@ -1439,7 +1544,7 @@ 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) { @@ -1484,7 +1589,7 @@ //鍗曢」 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) { @@ -1531,14 +1636,16 @@ 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 (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(map1); } return AjaxResult.success(); } @@ -1592,7 +1699,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())); @@ -1646,7 +1753,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())); @@ -1708,6 +1815,7 @@ */ @PostMapping("/tjGoOut") @ApiOperation(value = "浣撴绛剧") + @Transactional public AjaxResult tjGoOut(@RequestBody Map<String, Object> map) { Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId()); SysUser sysUser = userService.getById(userId); @@ -1715,6 +1823,7 @@ String jsonString = com.alibaba.fastjson.JSON.toJSONString(domainVos1); List<QjDomainVo> domainVos = com.alibaba.fastjson.JSON.parseArray(jsonString, QjDomainVo.class); String tjNumber = map.get("tjNumber").toString(); + TjOrder tjOrder = tjOrderService.getOrderByTjNum(tjNumber); if (null != domainVos && domainVos.size() > 0) { Set<String> list = new HashSet<>(); for (QjDomainVo domainVo : domainVos) { @@ -1728,7 +1837,6 @@ if (domainVo.getType() == 3) { list.add(String.valueOf(domainVo.getTjNumber())); } else { - TjOrder tjOrder = tjOrderService.getOrderByTjNum(remark.getTjNumber()); if (null != tjOrder) { tjOrder.setFinishTime(new Date()); tjOrder.setStatus(TjConstants.TJ_CONFIRM); @@ -1738,6 +1846,11 @@ } } asyncService.tjGoutAsync(domainVos, sysUser, list); + + TjCustomer customer = tjCustomerService.selectTjCustomerByCusId(tjOrder.getUserId()); + customer.setCardId("0"); + tjCustomerService.updateById(customer); + return AjaxResult.success("绛剧鎴愬姛锛�"); } else { return getAjaxResult(tjNumber); @@ -1750,6 +1863,7 @@ */ @GetMapping("/goOut") @ApiOperation(value = "绛剧") + @Transactional public AjaxResult goOut(@RequestParam @ApiParam(value = "浣撴鍙�") String tjNumber) { return getAjaxResult(tjNumber); } @@ -1808,8 +1922,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) @@ -1822,6 +1938,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) { @@ -1846,13 +2015,17 @@ LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>(); wq0.eq(TjOrder::getTjNumber, tjNumber); TjOrder tjOrder = tjOrderService.getOne(wq0); + if (null != tjOrder) { + TjCustomer customer = tjCustomerService.selectTjCustomerByCusId(tjOrder.getUserId()); + customer.setCardId("0"); + tjCustomerService.updateById(customer); + LambdaQueryWrapper<TjOrderDetail> wq11 = new LambdaQueryWrapper<>(); wq11.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId()); wq11.eq(TjOrderDetail::getTjStatus, 0); wq11.isNotNull(TjOrderDetail::getFlowingWaterId); List<TjOrderDetail> list = tjOrderDetailService.list(wq11); - if (list != null) { Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId()); SysUser sysUser = userService.getById(userId); @@ -2053,6 +2226,65 @@ 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())); @@ -2221,16 +2453,50 @@ 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()); + if (null != customer) { + 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("鎾ら攢澶辫触,闂ㄨ瘖鎮h�呰垂鐢ㄦ竻鍗曚俊鎭笉涓虹┖"); + } else { + boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order); + if (zfHisApiMethods) { + return AjaxResult.success("鎾ら攢鎴愬姛", map); + } else { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return AjaxResult.error("鎾ら攢澶辫触,璋冪敤浣滃簾鍑虹幇澶辫触"); + } + } + } + +// transitionService.updateTbTransitionByTjNum(tjNum); return AjaxResult.success("鎾ら攢鎴愬姛!!!"); } return AjaxResult.success("绛惧埌璁板綍涓嶅瓨鍦�!"); @@ -2296,7 +2562,7 @@ } for (String id : reservationIds) { TjReservation reservation = tjReservationService.getById(id); - if(null !=reservation){ + if (null != reservation) { reservation.setIsExpire(2); tjReservationService.updateById(reservation); } @@ -2307,5 +2573,118 @@ 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()); + } + } + + + @GetMapping("/delTbBycusCardIdAndProId") + @ApiOperation(value = "鏍规嵁瀹㈡埛韬唤璇佸彿鍜岄」鐩埗椤筰d鍒犻櫎涓存椂琛ㄦ暟鎹�") + @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("鎾ら攢澶辫触,闂ㄨ瘖鎮h�呰垂鐢ㄦ竻鍗曚俊鎭笉涓虹┖"); + } 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(); + } } -- Gitblit v1.8.0