Kaynağa Gözat

增加打印机设置功能

hurugang 5 yıl önce
ebeveyn
işleme
2861bb14c5

+ 13 - 0
src/main/java/cn/hnthyy/thmz/controller/NavigationController.java

@@ -130,6 +130,19 @@ public class NavigationController {
         return "sfy_config";
     }
 
+    /**
+     * 打印机设置页面
+     * @return
+     */
+    @RequestMapping("/print-config")
+    public String printConfig(HttpServletRequest httpServletRequest) throws Exception {
+        List<String> urls = getUrls(httpServletRequest);
+        if(!urls.contains("/thmz/print-config")){
+            throw new Exception("您没有此模块的权限,请联系管理员开通!");
+        }
+        return "print_config";
+    }
+
     /**
      * 打开发票管理页面
      * @return

+ 2 - 1
src/main/java/cn/hnthyy/thmz/controller/ScheduleOfMedicalController.java

@@ -499,7 +499,8 @@ public class ScheduleOfMedicalController {
 
             //发送取消预约提示消息
             ScheduleOfMedical dbScheduleOfMedical=scheduleOfMedicalService.queryScheduleOfMedicalById(scheduleOfMedical.getId());
-            User applyUser=userService.queryUserById(dbScheduleOfMedical.getUpdateId());
+            ScheduleOfMedicalApply  scheduleOfMedicalApply= scheduleOfMedicalApplyServicve.queryByScheduleId(scheduleOfMedical.getId());
+            User applyUser=userService.queryUserById(scheduleOfMedicalApply.getCreateId());
             if(applyUser!=null && StringUtils.isNotBlank(applyUser.getUserCode())){
                 ZdUnitCode zdUnitCode= zdUnitCodeService.queryByCode(dbScheduleOfMedical.getDepNo());
                 String message= "您申请的科室【"+zdUnitCode.getName()+"】,日期【"+dbScheduleOfMedical.getRecordDate()+"】,开始时间【"+dbScheduleOfMedical.getBeginTime()+"】,结束时间【"+dbScheduleOfMedical.getEndTime()+"】对应的医技排班已经被";

+ 53 - 0
src/main/java/cn/hnthyy/thmz/controller/WindowsController.java

@@ -90,6 +90,59 @@ public class WindowsController {
 
 
 
+    /**
+     * 保存打印机
+     * @param windows
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/savePrint", method = {RequestMethod.POST})
+    public Map<String, Object> savePrint(@RequestBody Windows windows,HttpServletRequest httpServletRequest) {
+        Map<String, Object> resultMap = new HashMap<>();
+        if(windows==null){
+            resultMap.put("code", -1);
+            resultMap.put("message", "保存打印机失败,参数为空");
+            return resultMap;
+        }
+//        if(windows.getPrintIndex()==null){
+//            resultMap.put("code", -1);
+//            resultMap.put("message", "保存打印机失败,打印机下标为空");
+//            return resultMap;
+//        }
+        String token = TokenUtil.getToken(httpServletRequest);
+        if (StringUtils.isBlank(token)) {
+            resultMap.put("code", -1);
+            resultMap.put("message", "保存打印机失败,用户Token不存在");
+            return resultMap;
+        }
+        DecodedJWT decodedJWT=TokenUtil.parseJWT(token);
+        User tokenUser=(User)JsonUtil.jsontoObject(decodedJWT.getSubject(),User.class);
+        try {
+            windows.setUserIdCode(tokenUser.getUserIdCode());
+            windows.setCreateDate(new Date());
+            Windows windowsDb=windowsService.queryLastWindowsByUserIdCode(tokenUser.getUserIdCode());
+            if(windowsDb!=null){
+                windows.setId(windowsDb.getId());
+            }
+            int num =windowsService.saveWindows(windows);
+            if(num==1){
+                resultMap.put("code", 0);
+                resultMap.put("message", "保存打印机成功");
+                return resultMap;
+            }
+            resultMap.put("code", -1);
+            resultMap.put("message", "保存打印机失败");
+            return resultMap;
+        }catch (Exception e){
+            e.printStackTrace();
+            resultMap.put("code", -1);
+            resultMap.put("message", "保存打印机失败,错误信息:【"+e.getMessage()+"】");
+            log.error("保存打印机失败,错误信息:[]",e.getMessage());
+            return resultMap;
+        }
+    }
+
+
 //    /**
 //     * 保存院区号
 //     * @param windows

+ 107 - 0
src/main/resources/static/js/print_config.js

@@ -0,0 +1,107 @@
+//@ sourceURL=print_config.js
+var LODOP; //声明为全局变量
+var printSucess=false;
+$(function (){
+    $(".selectpicker").selectpicker({
+        dropuAuto: false
+    });
+    //延迟触发列表加载,因为一开始打印程序还没有加载成功
+    setTimeout('createPrinterList()',500);
+
+
+
+
+   delay(getLastWindowsByCurrentUser);
+
+
+    /**
+     * 提交按钮点击事件
+     */
+    $("#send").on("click",function (t) {
+        $.ajax({
+            type: "POST",
+            contentType: "application/json;charset=UTF-8",
+            url: "/thmz/savePrint",
+            dataType: 'json',
+            data: JSON.stringify({"cgPrintIndex": $("#printSelect_cg").val()}),
+            headers:{'Accept': 'application/json','Authorization':'Bearer '+ localStorage.getItem("token")},
+            success: function(result) {
+                if(result=='401' || result==401){
+                    window.location.href='/thmz/login/view'
+                    return;
+                }
+                if(result.code == 0) {
+                    successMesage(result);
+                } else {
+                    errorMesage(result);
+                }
+            }
+        });
+    });
+
+});
+
+
+/**
+ * 查询当前用户的基础设置
+ */
+function getLastWindowsByCurrentUser() {
+    /**
+     * 查询收费员参数信息
+     */
+    $.ajax({
+        type: "GET",
+        contentType: "application/json;charset=UTF-8",
+        url: "/thmz/getLastWindowsByCurrentUser",
+        dataType: 'json',
+        headers:{'Accept': 'application/json','Authorization':'Bearer '+ localStorage.getItem("token")},
+        success: function(result) {
+            if(result=='401' || result==401){
+                window.location.href='/thmz/login/view'
+                return;
+            }
+            if(result.code == 0) {
+                if(result.data.cgPrintIndex!=null){
+                    $('#printSelect_cg').selectpicker('val', result.data.cgPrintIndex);
+                    $('#printSelect_cg').selectpicker('refresh');
+                }
+            } else {
+                errorMesage(result);
+            }
+        }
+    });
+}
+
+
+ function delay(callback){
+    if(printSucess){
+        callback();
+        return;
+    }else{setTimeout(function(){delay(callback)}, 100)}
+}
+
+
+
+
+
+
+
+/**
+ * 加载打印机列表
+ * @constructor
+ */
+function createPrinterList() {
+    LODOP = getLodop();
+    LODOP.PRINT_INITA(6, 0, "92mm", "120mm", "泰和门诊医技通知单打印");
+    //获取打印机设备数,用于进行遍历
+    var count = LODOP.GET_PRINTER_COUNT();
+    var html = "";
+    for (var i = 0; i < count; i++) {
+        //根据设备序号获取设备名
+        var msg = LODOP.GET_PRINTER_NAME(i);
+        html += "<option value='" + i + "'>" + msg + "</option>";
+    }
+    $('#printSelect_cg').html(html);
+    $('#printSelect_cg').selectpicker('refresh');
+    printSucess=true;
+}

+ 47 - 0
src/main/resources/templates/print_config.html

@@ -0,0 +1,47 @@
+<link rel="stylesheet" href="/thmz/css/bootstrap/css/bootstrap-select.css"/>
+<script src="/thmz/js/bootstrap-select.js"></script>
+<script src="/thmz/js/LodopFuncs.js"></script>
+<script src="/thmz/js/print_config.js"></script>
+<div class="row">
+    <div class="col-md-12 col-sm-12 col-xs-12">
+        <div class="x_panel">
+            <div class="x_title">
+                <h2>打印机设置<small id="titleInfo">修改</small></h2>
+                <ul class="nav navbar-right panel_toolbox">
+                    <!--    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
+                        </li>-->
+                    <!--<li class="dropdown">-->
+                        <!--<a href="#" onclick="editWindows()" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>-->
+                    <!--</li>-->
+                    <!--   <li><a class="close-link"><i class="fa fa-close"></i></a>
+                       </li>-->
+                </ul>
+                <div class="clearfix"></div>
+            </div>
+            <div class="x_content">
+
+                <form class="form-horizontal form-label-left" novalidate id="sfy_config_form" autocomplete="off">
+                    <span class="section">打印机信息</span>
+                    <div class="item form-group">
+                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="printSelect_cg">常规打印机名称 <span class="required">*</span>
+                        </label>
+                        <div class="col-md-4 col-sm-4 col-xs-12">
+                            <select class="form-control selectpicker show-tick" required="required" id="printSelect_cg">
+                            </select>
+                        </div>
+                    </div>
+                    <div class="ln_solid"></div>
+                    <div class="form-group">
+                        <div class="col-md-6 col-md-offset-3">
+                            <button id="send" type="button" class="btn btn-success">提交</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+
+<object  id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
+    <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
+</object>