From dedacd79c93f8ef95e0cb986f5e7fbd27ddbd907 Mon Sep 17 00:00:00 2001
From: zhaowenxuan <chacca165@163.com>
Date: 星期四, 03 七月 2025 09:12:49 +0800
Subject: [PATCH] 2025-07-03

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjXdPictureController.java |  321 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 316 insertions(+), 5 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjXdPictureController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjXdPictureController.java
index 78d6b3e..af53c70 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjXdPictureController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjXdPictureController.java
@@ -1,24 +1,39 @@
 package com.ltkj.web.controller.system;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.Security;
+import java.util.*;
 import java.util.stream.Collectors;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.io.unit.DataUnit;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ltkj.common.core.domain.entity.SysUser;
 import com.ltkj.common.core.redis.RedisCache;
+import com.ltkj.common.utils.SecurityUtils;
 import com.ltkj.framework.config.MatchUtils;
 import com.ltkj.hosp.domain.*;
 import com.ltkj.hosp.service.*;
+import com.ltkj.hosp.sqlDomain.LtkjExamJcbgd;
+import com.ltkj.hosp.sqlDomain.LtkjExamJcsqd;
+import com.ltkj.hosp.vodomain.CsProVo;
 import com.ltkj.system.service.ISysConfigService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import jodd.util.StringUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 import com.ltkj.common.annotation.Log;
 import com.ltkj.common.core.controller.BaseController;
@@ -36,6 +51,7 @@
 @RestController
 @RequestMapping("/picture/picture")
 @Api(tags = "浣撴蹇冪數鍥剧鐞�")
+@Slf4j
 public class TjXdPictureController extends BaseController {
     @Resource
     private ITjXdPictureService tjXdPictureService;
@@ -51,7 +67,14 @@
     private ITjOrderRemarkService remarkService;
     @Resource
     private ITjProjectService projectService;
-
+    @Resource
+    private TjXdtgmdjgService xdtgmdjgService;
+    @Resource
+    private LtkjExamJcbgdService jcbgdService;
+    @Resource
+    private LtkjExamJcsqdService jcsqdService;
+    @Autowired
+    private TjJcycxmService jcycxmService;
     /**
      * 鏌ヨ浣撴蹇冪數鍥剧鐞嗗垪琛�
      */
@@ -189,4 +212,292 @@
     public AjaxResult remove(@PathVariable String[] ids) {
         return toAjax(tjXdPictureService.deleteTjXdPictureByIds(ids));
     }
+
+
+
+    @GetMapping ("/getYxJcList")
+    @ApiOperation (value = "褰卞儚妫�鏌ュ垪琛�(楠ㄥ瘑搴﹀拰蹇冪數鍥�)")//0寰�1宸�
+    @Transactional
+    public AjaxResult getYxJcList(@ApiParam (value = "瀹℃牳鐘舵��  0寰呭鏍�  1宸插鏍�") @RequestParam  Integer checkStatus,
+                                @ApiParam (value = "椤电爜鏁�(榛樿1)") @RequestParam (defaultValue = "1") Integer page,
+                                @ApiParam (value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam (defaultValue = "10") Integer pageSize,
+                                @ApiParam (value = "浣撴鍗曞彿") @RequestParam (required = false) String tjNumber,
+                                @ApiParam (value = "鍗曚綅") @RequestParam (required = false) Long compId,
+                                @ApiParam (value = "濮撳悕)") @RequestParam (required = false) String name,
+                                @ApiParam (value = "濂楅鍚�)") @RequestParam (required = false) String tcm,
+                                @ApiParam (value = "寮�濮嬫椂闂�") @RequestParam (required = false) String beginTime,
+                                @ApiParam (value = "缁撴潫鏃堕棿") @RequestParam (required = false) String endTime) {
+
+//        DateTime beginTimes = null;
+//        DateTime endTimes = null;
+//        if (null != beginTime && null != endTime) {
+//            beginTimes = DateUtil.beginOfDay(DateUtil.parse(beginTime));
+//            endTimes = DateUtil.endOfDay(DateUtil.parse(endTime));
+//        }
+//        //鍒濆鍖栦綋妫�璁㈠崟琛�
+//        List<TjOrder> orderList = null;
+//        List<TjCustomer> customerList = new ArrayList<>();
+//        Map<String, Object> map = new HashMap<>();
+//
+//        if (checkStatus == 0)
+//            asyncService.wCScheckSetCustomerLisByRedis(orderService.getCsTjOrderList(tjNumber, checkStatus, compId, beginTimes, endTimes));
+//        if (checkStatus == 1)
+//            asyncService.yCScheckSetCustomerLisByRedis(orderService.getCsTjOrderList(tjNumber, checkStatus, compId, beginTimes, endTimes));
+//
+//        //鏍规嵁濮撳悕鏌ヨ
+//        if (null != name && !"".equals(name)) {
+//            List<TjCustomer> list = customerService.getTjCustomerList(name);
+//            if (null != list && list.size() > 0) {
+//                List<TjCustomer> lists = new ArrayList<>();
+//                for (TjCustomer customer : list) {
+//                    orderList = orderService.getCsTjOrderListByCusId(customer.getCusId());
+//                    if (null != orderList && orderList.size() > 0) {
+//                        for (TjOrder tjOrder : orderList) {
+//                            customer.setTjNumber(tjOrder.getTjNumber());
+//                            customer.setTjStatus(Long.valueOf(tjOrder.getCheckStatus()));
+//                            customer.setOrderId(tjOrder.getOrderId());
+//                            customer.setTjTime(tjOrder.getCreateTime());
+//                            customer.setFinishTime(tjOrder.getFinishTime());
+//                            customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
+//                            customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
+//                            customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
+//                            customer.setConfirmStatus(String.valueOf(tjOrder.getStatus()));
+//                            if (tjOrder.getFirmId().equals("0")) {
+//                                customer.setTjCompName(null);
+//                            } else {
+//                                customer.setTjCompName(compService.selectDictCompByDrugManufacturerId(tjOrder.getFirmId()).getCnName());
+//                            }
+//                            lists.add(customer);
+//                        }
+//                    }
+//                }
+//                List<TjCustomer> customers = null;
+//                if (lists.size() > 0) {
+//                    customers = lists.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
+//                }
+//                map.put("customers", customers);
+//                map.put("total", lists.size());
+//                return AjaxResult.success(map);
+//            }
+//            return AjaxResult.success("鏆傛棤鏁版嵁");
+//        }
+//
+//        //鏉′欢鏌ヨ
+//        if (null != tjNumber || null != compId || (null != beginTime && null != endTime)) {
+//            orderList = orderService.getCsTjOrderList(tjNumber, checkStatus, compId, beginTimes, endTimes);
+//            return getResult(page, pageSize, orderList, customerList, map);
+//        }
+//
+//        List<TjCustomer> customers = null;
+//        if (checkStatus == 0) {
+//            customers = redisCache.getCacheMapValue("cScheck", "ws");
+//        }
+//        if (checkStatus == 1) {
+//            customers = redisCache.getCacheMapValue("cScheck", "ys");
+//        }
+//        if (customers != null && customers.size() > 0) {
+//            List<TjCustomer> customerLists = customers.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
+//            map.put("customers", customerLists);
+//            map.put("total", customers.size());
+//            return AjaxResult.success(map);
+//        } else {
+//            orderList = orderService.getCsTjOrderList(tjNumber, checkStatus, compId, beginTimes, endTimes);
+//            return getResult(page, pageSize, orderList, customerList, map);
+//        }
+        Long deptId = SecurityUtils.getDeptId();
+        log.info("褰卞儚妫�鏌ュ垪琛�(楠ㄥ瘑搴﹀拰蹇冪數鍥�)鎺ュ彛 褰撳墠鐧诲綍浜虹瀹�"+deptId);
+        String value = String.valueOf(compId);
+        if (tjNumber == null) tjNumber = "";
+        if (compId == null) value = "";
+        if (name == null) name = "";
+        if (beginTime == null) beginTime = "";
+        if (endTime == null) endTime = "";
+        if (tcm == null) tcm = "";
+        return AjaxResult.success(orderService.getYxJcList(checkStatus,tjNumber, page, pageSize, value, beginTime, endTime, name,tcm,deptId.toString()));
+    }
+
+    @GetMapping ("/getYxJcXx")
+    @ApiOperation (value = "褰卞儚妫�鏌ラ瀵嗗害蹇冪數鍥鹃〉闈㈢偣鍑讳綋妫�浜哄憳灞曠ず浣撴椤圭洰鎺ュ彛")
+    public AjaxResult getYxJcXx(@ApiParam (value = "浣撴鍙�") @RequestParam String tjNumber) {
+        Long deptId = SecurityUtils.getDeptId();
+        log.info("褰卞儚妫�鏌ラ瀵嗗害蹇冪數鍥鹃〉闈㈢偣鍑讳綋妫�浜哄憳灞曠ず浣撴椤圭洰鎺ュ彛褰撳墠鐧诲綍浜虹瀹�"+deptId);
+        List<CsProVo> list = remarkService.getYxJcXx(tjNumber,deptId.toString());
+        if(null !=list && !list.isEmpty()){
+            for (CsProVo vo : list) {
+                LambdaQueryWrapper<TjXdtgmdjg> wq=new LambdaQueryWrapper<>();
+                wq.eq(TjXdtgmdjg::getTjh,tjNumber);
+                wq.eq(TjXdtgmdjg::getProId,vo.getProId());
+                TjXdtgmdjg xdtgmdjg = xdtgmdjgService.getOne(wq);
+                if(null !=xdtgmdjg){
+                    if(StringUtil.isNotBlank(xdtgmdjg.getUrl())){
+                        Path path = Paths.get(xdtgmdjg.getUrl());
+                        byte[] data = null;
+                        try {
+                            data = Files.readAllBytes(path);
+                        } catch (IOException e) {
+                            throw new RuntimeException(e);
+                        }
+                        String base64 = Base64.getEncoder().encodeToString(data);
+                        if(StringUtil.isNotBlank(base64)) vo.setImageUrl(base64);
+                    }
+                }
+            }
+
+        }
+        return AjaxResult.success(list);
+    }
+
+    @GetMapping ("/addYxJcXx")
+    @ApiOperation (value = "鎻愪氦褰卞儚妫�鏌ラ瀵嗗害蹇冪數鍥剧粨鏋滄帴鍙�")
+    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
+    public AjaxResult addYxJcXx(@ApiParam (value = "浣撴鍙�") @RequestParam String tjNumber,
+                                @ApiParam (value = "椤圭洰id") @RequestParam String proId,
+                                @ApiParam (value = "妫�鏌ユ墍瑙�") @RequestParam String jcsj,
+                                @ApiParam (value = "妫�鏌ョ粨璁�") @RequestParam String jcjl,
+                                @ApiParam (value = "鍥剧墖鍦板潃") @RequestParam(required = false) String url) {
+        try {
+            SysUser user = SecurityUtils.getLoginUser().getUser();
+            TjOrder order = orderService.getOrderByTjNum(tjNumber);
+            if(null !=order){
+                TjProject project = projectService.getById(proId);
+                if(null !=project){
+                    LambdaQueryWrapper<TjOrderDetail>wq1=new LambdaQueryWrapper<>();
+                    wq1.eq(TjOrderDetail::getProId,proId);
+                    wq1.eq(TjOrderDetail::getOrderId,order.getOrderId());
+                    TjOrderDetail detail = detailService.getOne(wq1);
+                    if(null !=detail){
+                        detail.setProResult(jcjl+"銆�"+jcsj);
+                        detail.setTjStatus(1L);
+                        detailService.updateById(detail);
+                        LambdaQueryWrapper<TjOrderRemark>wq2=new LambdaQueryWrapper<>();
+                        wq2.eq(TjOrderRemark::getProId,proId);
+                        wq2.eq(TjOrderRemark::getTjNumber,tjNumber);
+                        TjOrderRemark orderRemark = remarkService.getOne(wq2);
+                        if(null !=orderRemark){
+                            orderRemark.setType(1);
+                            remarkService.updateById(orderRemark);
+                            xdtgmdjgService.deletedByTJhAndProId(tjNumber, proId);
+                            TjXdtgmdjg xdtgmdjg=new TjXdtgmdjg();
+                            xdtgmdjg.setTjh(tjNumber);
+                            xdtgmdjg.setCardId(order.getCardId());
+                            xdtgmdjg.setProId(proId);
+                            xdtgmdjg.setProName(project.getProName());
+                            xdtgmdjg.setJcsj(jcsj);
+                            xdtgmdjg.setJcjl(jcjl);
+                            xdtgmdjg.setCreateBy(user.getNickName());
+                            xdtgmdjg.setCreateId(user.getUserId().toString());
+                            if(StringUtil.isNotBlank(url)) xdtgmdjg.setUrl(url);
+                            xdtgmdjgService.save(xdtgmdjg);
+                            saveTjXdtgmdjgByJcbgd(xdtgmdjg);
+                        }
+                    }
+                }
+                return AjaxResult.success();
+            }
+            return AjaxResult.error("鏆傛棤浣撴璁板綍");
+        } catch (Exception e) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            log.error("鎻愪氦褰卞儚妫�鏌ラ瀵嗗害蹇冪數鍥剧粨鏋滄帴鍙�"+e.getMessage());
+            throw new RuntimeException("鎻愪氦褰卞儚妫�鏌ラ瀵嗗害蹇冪數鍥剧粨鏋滄帴鍙�");
+        }
+    }
+    @Transactional(propagation = Propagation.REQUIRED) // 鍏变韩浜嬪姟
+    public void saveTjXdtgmdjgByJcbgd(TjXdtgmdjg xdtgmdjg) {
+        try {
+            int length = xdtgmdjg.getProId().length();
+            // 纭繚瀛楃涓查暱搴﹁嚦灏戜负6
+            String last6 = length >= 6 ? xdtgmdjg.getProId().substring(length - 6) : xdtgmdjg.getProId();
+            Date date = new Date();
+            LtkjExamJcbgd jcbgd=new LtkjExamJcbgd();
+            jcsqdService.deletedLtkjJcsqdByTjhandtmh(xdtgmdjg.getCardId(),xdtgmdjg.getTjh()+last6);
+            jcbgdService.deletedLtkjJcbgdByTjhandtmh(xdtgmdjg.getCardId(),xdtgmdjg.getTjh()+last6);
+            jcbgd.setTjh(xdtgmdjg.getCardId());
+            jcbgd.setTmh(xdtgmdjg.getTjh()+last6);
+            jcbgd.setXmdm(xdtgmdjg.getProId());
+            jcbgd.setXmmc(xdtgmdjg.getProName());
+            jcbgd.setBgNr(xdtgmdjg.getJcsj());
+            if(StringUtil.isNotBlank(xdtgmdjg.getUrl())){
+                jcbgd.setBgUrl(xdtgmdjg.getUrl());
+            }else {
+                jcbgd.setBgUrl("");
+            }
+            jcbgd.setShysxm(xdtgmdjg.getCreateBy());
+            jcbgd.setShysdm(xdtgmdjg.getCreateId());
+            jcbgd.setYxzd(xdtgmdjg.getJcjl());
+            jcbgd.setYxbx(xdtgmdjg.getJcjl());
+            jcbgd.setZdsj(DateUtil.format(date,"yyyy-MM-dd"));
+            jcbgd.setJcbw("");
+            jcbgd.setLx("1");
+            jcbgd.setSqsj(DateUtil.format(date,"yyyy-MM-dd"));
+            jcbgd.setCreateTime(date);
+            jcbgdService.save(jcbgd);
+            jcsqdService.saveXdtLtkjExamJcsqd(xdtgmdjg.getCardId(),jcbgd.getTmh());
+
+            LambdaQueryWrapper<TjJcycxm> wq=new LambdaQueryWrapper<>();
+            wq.eq(TjJcycxm::getTjh,xdtgmdjg.getTjh());
+            wq.eq(TjJcycxm::getProId,xdtgmdjg.getProId());
+            jcycxmService.remove(wq);
+            if(StringUtil.isNotBlank(xdtgmdjg.getJcjl())){
+                String s = "銆倈锛泑;|,|锛�";
+                String[] split = xdtgmdjg.getJcjl().replaceAll("\n", "銆�").split(s);
+                for (String jg : split) {
+                    if(StringUtil.isNotBlank(jg) && !jg.contains("鏈寮傚父")
+                            && !jg.contains("鏈鏄庢樉寮傚父") && !jg.contains("鏈鍗犱綅") && !jg.contains("鏈")
+                            && !jg.contains("鏈鏄庢樉")&& !jg.contains("姝e父")&& !jg.contains("鍙屼晶妞庨棿瀛旀棤鐙獎")){
+                        TjJcycxm jcycxm=new TjJcycxm();
+                        jcycxm.setTjh(xdtgmdjg.getTjh());
+                        jcycxm.setYqid("");
+                        jcycxm.setProId(xdtgmdjg.getProId());
+                        jcycxm.setProName(xdtgmdjg.getProName());
+                        jcycxm.setCreateTime(new Date());
+                        jcycxm.setJcjg(jg);
+                        jcycxmService.save(jcycxm);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    @GetMapping ("/getYxJcXxJg")
+    @ApiOperation (value = "鑾峰彇褰卞儚妫�鏌ラ瀵嗗害蹇冪數鍥剧粨鏋滄帴鍙�")
+    @Transactional
+    public AjaxResult getYxJcXxJg(@ApiParam (value = "浣撴鍙�") @RequestParam String tjNumber,
+                                  @ApiParam (value = "椤圭洰id") @RequestParam String proId) {
+        TjOrder order = orderService.getOrderByTjNum(tjNumber);
+        if(null !=order){
+            LambdaQueryWrapper<TjXdtgmdjg> wq=new LambdaQueryWrapper<>();
+            wq.eq(TjXdtgmdjg::getTjh,tjNumber);
+            wq.eq(TjXdtgmdjg::getProId,proId);
+            TjXdtgmdjg xdtgmdjg = xdtgmdjgService.getOne(wq);
+            Map<String,Object>map=new HashMap<>();
+            if(null !=xdtgmdjg ){
+                map.put("jcsj",xdtgmdjg.getJcsj());
+                map.put("jcjl",xdtgmdjg.getJcjl());
+                if(StringUtil.isNotBlank(xdtgmdjg.getUrl())){
+                    Path path = Paths.get(xdtgmdjg.getUrl());
+                    byte[] data = null;
+                    try {
+                        data = Files.readAllBytes(path);
+                    } catch (IOException e) {
+                        throw new RuntimeException(e);
+                    }
+                    String base64 = Base64.getEncoder().encodeToString(data);
+                    map.put("tp",base64);
+                }else {
+                    map.put("tp",null);
+                }
+                return AjaxResult.success(map);
+            }else {
+                TjProject tjProject = projectService.getById(proId);
+                map.put("jcsj","");
+                map.put("jcjl",tjProject.getProDefault()==null ? "":tjProject.getProDefault());
+                map.put("tp",null);
+            }
+            return AjaxResult.success(map);
+        }
+        return AjaxResult.error("鏆傛棤浣撴璁板綍");
+    }
 }

--
Gitblit v1.8.0