无关风月
2025-01-20 18bdff5e42bc010f71d4a0820707e29b4c8500f9
bug修改
1 文件已重命名
5个文件已修改
1个文件已删除
12个文件已添加
1064 ■■■■■ 已修改文件
common/lib/commons-codec-1.9.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/commons-logging-1.2.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/fluent-hc-4.5.2.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/httpclient-4.5.2.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/httpclient-cache-4.5.2.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/httpclient-win-4.5.2.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/httpcore-4.4.4.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/httpmime-4.5.2.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/jna-4.1.0.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/jna-platform-4.1.0.jar 补丁 | 查看 | 原始文档 | blame | 历史
common/pom.xml 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/src/main/java/com/jilongda/common/Ticket/TAddOptometryVO.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/src/main/java/com/jilongda/common/Ticket/TOptometryDetailVO.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/src/main/java/com/jilongda/common/Ticket/TicketUtil.java 730 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manage/src/main/java/com/jilongda/manage/controller/TCouponController.java 131 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manage/src/main/java/com/jilongda/manage/controller/TTicketController.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
optometrist/pom.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
optometrist/src/main/java/com/jilongda/optometrist/controller/TOptometristController.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
optometrist/src/main/java/com/jilongda/optometrist/vo/TAddOptometryVO.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/lib/commons-codec-1.9.jar
Binary files differ
common/lib/commons-logging-1.2.jar
Binary files differ
common/lib/fluent-hc-4.5.2.jar
Binary files differ
common/lib/httpclient-4.5.2.jar
Binary files differ
common/lib/httpclient-cache-4.5.2.jar
Binary files differ
common/lib/httpclient-win-4.5.2.jar
Binary files differ
common/lib/httpcore-4.4.4.jar
Binary files differ
common/lib/httpmime-4.5.2.jar
Binary files differ
common/lib/jna-4.1.0.jar
Binary files differ
common/lib/jna-platform-4.1.0.jar
Binary files differ
common/pom.xml
@@ -19,6 +19,76 @@
    <dependencies>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.9</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/commons-codec-1.9.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/commons-logging-1.2.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>fluent-hc</groupId>
            <artifactId>fluent-hc</artifactId>
            <version>4.5.2</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/fluent-hc-4.5.2.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>httpclient</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.2</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/httpclient-4.5.2.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>httpclient-cache</groupId>
            <artifactId>httpclient-cache</artifactId>
            <version>4.5.2</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/httpclient-cache-4.5.2.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>httpclient-win</groupId>
            <artifactId>httpclient-win</artifactId>
            <version>4.5.2</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/httpclient-win-4.5.2.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>httpcore</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.4</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/httpcore-4.4.4.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>httpmime</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.2</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/httpmime-4.5.2.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>jna</groupId>
            <artifactId>jna</artifactId>
            <version>4.1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/jna-4.1.0.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>jna-platform</groupId>
            <artifactId>jna-platform</artifactId>
            <version>4.1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/jna-platform-4.1.0.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>com.alipay.sdk</groupId>
            <artifactId>alipay-sdk-java</artifactId>
            <version>4.8.10.ALL</version>
common/src/main/java/com/jilongda/common/Ticket/TAddOptometryVO.java
New file
@@ -0,0 +1,28 @@
package com.jilongda.common.Ticket;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "添加验光单VO")
public class TAddOptometryVO {
    @ApiModelProperty(value = "预约id")
    private Integer id;
    @ApiModelProperty(value = "验光单详情")
    private List<TOptometryDetailVO> optometryDetailVOS;
    @ApiModelProperty(value = "门店名称")
    private String shopName;
    @ApiModelProperty(value = "验光师名称")
    private String optometristName;
    @ApiModelProperty(value = "验光时间")
    private String time;
    @ApiModelProperty(value = "客户电话")
    private String phone;
    @ApiModelProperty(value = "小票机编号")
    private String sn;
}
common/src/main/java/com/jilongda/common/Ticket/TOptometryDetailVO.java
File was renamed from optometrist/src/main/java/com/jilongda/optometrist/vo/TOptometryDetailVO.java
@@ -1,7 +1,5 @@
package com.jilongda.optometrist.vo;
package com.jilongda.common.Ticket;
import com.baomidou.mybatisplus.annotation.TableField;
import com.jilongda.optometrist.model.TLineUp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -36,6 +34,5 @@
    @ApiModelProperty(value = "左眼右眼 1为L 2为R")
    private Integer status;
}
common/src/main/java/com/jilongda/common/Ticket/TicketUtil.java
New file
@@ -0,0 +1,730 @@
package com.jilongda.common.Ticket;
import cn.hutool.crypto.digest.DigestUtil;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TicketUtil {
        public static final String URL = "http://api.feieyun.cn/Api/Open/";//不需要修改
        public static final String USER = "yanduyanjing@163.com";//*必填*:账号名
        public static final String UKEY = "C8cNbhZ63YWtQDGQ";//*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】
        public static final String SN = "*********";//*必填*:打印机编号,必须要在管理后台里添加打印机或调用API接口添加之后,才能调用API
        //**********测试时,打开下面注释掉方法的即可,更多接口文档信息,请访问官网开放平台查看**********
        public static void main(String[] args) throws Exception{
            //==================添加打印机接口(支持批量)==================
            //***返回值JSON字符串***
            //正确例子:{"msg":"ok","ret":0,"data":{"ok":["sn#key#remark#carnum","316500011#abcdefgh#快餐前台"],"no":["316500012#abcdefgh#快餐前台#13688889999  (错误:识别码不正确)"]},"serverExecutedTime":3}
            //错误:{"msg":"参数错误 : 该帐号未注册.","ret":-2,"data":null,"serverExecutedTime":37}
            //提示:打印机编号(必填) # 打印机识别码(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100行(台)。
//            String snlist = "922440578#XZacTCZT#测试添加打印机";
//            String method = addprinter(snlist);
//            System.out.println(method);
//             String snlist = "922440578#XZacTCZT#测试添加打印机";
//            String method = editprinter("922440578","修改名称");
//            System.out.println(method);
            TAddOptometryVO tAddOptometryVO = new TAddOptometryVO();
            List<TOptometryDetailVO> temp = new ArrayList<>();
            TOptometryDetailVO t1 = new TOptometryDetailVO();
            t1.setType(3);
            t1.setBallMirror(-1.00D);
            t1.setColumnMirror(-0.10D);
            t1.setAxis("30");
            t1.setPupilDistance("33");
            t1.setStatus(1);
            temp.add(t1);
            TOptometryDetailVO t2 = new TOptometryDetailVO();
            t2.setType(3);
            t2.setBallMirror(-1.00D);
            t2.setColumnMirror(-0.10D);
            t2.setAxis("30");
            t2.setPupilDistance("33");
            t2.setStatus(2);
            temp.add(t2);
            TOptometryDetailVO t3 = new TOptometryDetailVO();
            t3.setType(2);
            t3.setBallMirror(-1.00D);
            t3.setColumnMirror(-0.10D);
            t3.setAxis("30");
            t3.setPupilDistance("33");
            t3.setCorrect("1.0");
            t3.setStatus(1);
            temp.add(t3);
            TOptometryDetailVO t4 =  new TOptometryDetailVO();
            t4.setType(2);
            t4.setBallMirror(-1.00D);
            t4.setColumnMirror(-0.10D);
            t4.setAxis("30");
            t4.setPupilDistance("33");
            t4.setCorrect("1.0");
            t4.setStatus(2);
            temp.add(t4);
            TOptometryDetailVO t5 = new TOptometryDetailVO();
            t5.setType(1);
            t5.setBallMirror(-1.00D);
            t5.setColumnMirror(-0.10D);
            t5.setAxis("30");
            t5.setAddS("50");
            t5.setPupilHeight("50");
            t5.setPupilDistance("33");
            t5.setCorrect("1.0");
            t5.setStatus(1);
            temp.add(t5);
            TOptometryDetailVO t6 = new TOptometryDetailVO();
            t6.setType(1);
            t6.setBallMirror(-1.00D);
            t6.setColumnMirror(-0.10D);
            t6.setAxis("30");
            t6.setAddS("50");
            t6.setPupilHeight("50");
            t6.setPupilDistance("33");
            t6.setCorrect("1.0");
            t6.setStatus(2);
            temp.add(t6);
            tAddOptometryVO.setOptometryDetailVOS(temp);
            tAddOptometryVO.setShopName("天府新谷门店");
            tAddOptometryVO.setOptometristName("无关风月");
            tAddOptometryVO.setTime("2025-11-11");
            tAddOptometryVO.setPhone("19983174515");
            tAddOptometryVO.setSn("922440578");
            String method = print(tAddOptometryVO);
            System.out.println(method);
            //==================方法1.小票机打印订单接口==================
            //***返回值JSON字符串***
            //成功:{"msg":"ok","ret":0,"data":"xxxxxxx_xxxxxxxx_xxxxxxxx","serverExecutedTime":5}
            //失败:{"msg":"错误描述","ret":非0,"data":"null","serverExecutedTime":5}
//            String method1 = print(SN);//该接口只能是小票机使用,如购买的是标签机请使用下面方法2,调用打印
//            System.out.println(method1);
            //==================方法2.标签机专用打印订单接口==================
            //***返回值JSON字符串***
            //成功:{"msg":"ok","ret":0,"data":"xxxxxxx_xxxxxxxx_xxxxxxxx","serverExecutedTime":5}
            //失败:{"msg":"错误描述","ret":非0,"data":"null","serverExecutedTime":5}
//            String method2 = printLabelMsg(SN);//打开注释调用标签机打印接口进行打印,该接口只能是标签机使用,其它型号打印机请勿使用该接口
//            System.out.println(method2);
            //===========方法3.查询某订单是否打印成功=============
            //***返回值JSON字符串***
             //成功:{"msg":"ok","ret":0,"data":true,"serverExecutedTime":2}//data:true为已打印,false为未打印
            //失败:{"msg":"错误描述","ret":非0, "data":null,"serverExecutedTime":7}
//            String orderid = "xxxxxxx_xxxxxxxx_xxxxxxxx";//订单ID,从方法1返回值data获取
//            String method3 = queryOrderState(orderid);
//            System.out.println(method3);
            //===========方法4.查询指定打印机某天的订单详情============
            //***返回值JSON字符串***
            //成功:{"msg":"ok","ret":0,"data":{"print":6,"waiting":1},"serverExecutedTime":9}//print已打印,waiting为打印
            //失败:{"msg":"错误描述","ret":非0,"data":"null","serverExecutedTime":5}
//            String strdate = "2016-11-12";//注意时间格式为"yyyy-MM-dd"
//            String method4 = queryOrderInfoByDate(SN,strdate);
//            System.out.println(method4);
            //===========方法5.查询打印机的状态==========================
            //***返回值JSON字符串***
            //成功:{"msg":"ok","ret":0,"data":"状态","serverExecutedTime":4}
            //失败:{"msg":"错误描述","ret":非0,"data":"null","serverExecutedTime":5}
//            String method5 = queryPrinterStatus(SN);
//            System.out.println(method5);
        }
    public static String unescapeUnicode(String input) {
        Pattern pattern = Pattern.compile("\\\\u([0-9a-fA-F]{4})");
        Matcher matcher = pattern.matcher(input);
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            int codePoint = Integer.parseInt(matcher.group(1), 16);
            matcher.appendReplacement(sb, String.valueOf((char) codePoint));
        }
        matcher.appendTail(sb);
        return sb.toString();
    }
        //=====================以下是函数实现部分================================================
        public static  String addprinter(String snlist){
           //通过POST请求,发送打印信息到服务器
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(30000)//读取超时
                    .setConnectTimeout(30000)//连接超时
                    .build();
            CloseableHttpClient httpClient = HttpClients.custom()
                     .setDefaultRequestConfig(requestConfig)
                     .build();
            HttpPost post = new HttpPost(URL);
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("user",USER));
            String STIME = String.valueOf(System.currentTimeMillis()/1000);
            nvps.add(new BasicNameValuePair("stime",STIME));
            nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME)));
            nvps.add(new BasicNameValuePair("apiname","Open_printerAddlist"));//固定值,不需要修改
            nvps.add(new BasicNameValuePair("printerContent",snlist));
            CloseableHttpResponse response = null;
            String result = null;
            try
            {
               post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
               response = httpClient.execute(post);
                  int statecode = response.getStatusLine().getStatusCode();
                  if(statecode == 200){
                    HttpEntity httpentity = response.getEntity();
                    if (httpentity != null){
                        result = EntityUtils.toString(httpentity);
                    }
               }
           }
           catch (Exception e)
           {
               e.printStackTrace();
           }
           finally{
               try {
                   if(response!=null){
                       response.close();
                   }
               } catch (IOException e) {
                   e.printStackTrace();
               }
               try {
                   post.abort();
               } catch (Exception e) {
                   e.printStackTrace();
               }
               try {
                   httpClient.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
            // 解析JSON字符串
           return unescapeUnicode(result);
        }
        public static  String editprinter(String sn,String name){
           //通过POST请求,发送打印信息到服务器
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(30000)//读取超时
                    .setConnectTimeout(30000)//连接超时
                    .build();
            CloseableHttpClient httpClient = HttpClients.custom()
                     .setDefaultRequestConfig(requestConfig)
                     .build();
            HttpPost post = new HttpPost(URL);
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("user",USER));
            String STIME = String.valueOf(System.currentTimeMillis()/1000);
            nvps.add(new BasicNameValuePair("stime",STIME));
            nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME)));
            nvps.add(new BasicNameValuePair("apiname","Open_printerEdit"));//固定值,不需要修改
            nvps.add(new BasicNameValuePair("sn",sn));
            nvps.add(new BasicNameValuePair("name",name));
            CloseableHttpResponse response = null;
            String result = null;
            try
            {
               post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
               response = httpClient.execute(post);
                  int statecode = response.getStatusLine().getStatusCode();
                  if(statecode == 200){
                    HttpEntity httpentity = response.getEntity();
                    if (httpentity != null){
                        result = EntityUtils.toString(httpentity);
                    }
               }
           }
           catch (Exception e)
           {
               e.printStackTrace();
           }
           finally{
               try {
                   if(response!=null){
                       response.close();
                   }
               } catch (IOException e) {
                   e.printStackTrace();
               }
               try {
                   post.abort();
               } catch (Exception e) {
                   e.printStackTrace();
               }
               try {
                   httpClient.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
           return unescapeUnicode(result);
        }
        //方法1
        public static String print(TAddOptometryVO dto){
            //标签说明:
            //单标签:
            //"<BR>"为换行,"<CUT>"为切刀指令(主动切纸,仅限切刀打印机使用才有效果)
            //"<LOGO>"为打印LOGO指令(前提是预先在机器内置LOGO图片),"<PLUGIN>"为钱箱或者外置音响指令
            //成对标签:
            //"<CB></CB>"为居中放大一倍,"<B></B>"为放大一倍,"<C></C>"为居中,<L></L>字体变高一倍
            //<W></W>字体变宽一倍,"<QR></QR>"为二维码,"<BOLD></BOLD>"为字体加粗,"<RIGHT></RIGHT>"为右对齐
            //拼凑订单内容时可参考如下格式
            //根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
            StringBuilder content;
            content=new StringBuilder("<BOLD>");
            content.append("隼目验光单<BR>");
            content.append(dto.getShopName()).append("<BR>");
            content.append("验光师:").append(dto.getOptometristName()).append("<BR>");
            content.append("验光时间:").append(dto.getTime()).append("<BR>");
            content.append("--------------------------------<BR>");
            content.append("客户电话:").append(dto.getPhone()).append("<BR>");
            content.append("--------------------------------<BR>");
            List<TOptometryDetailVO> optometryDetailVOS = dto.getOptometryDetailVOS();
            // 使用 List.sort 和 Comparator 进行多字段倒序排序
            optometryDetailVOS.sort(
                    Comparator.comparingInt(TOptometryDetailVO::getType)
                            .thenComparingInt(TOptometryDetailVO::getStatus).reversed()
            );
            for (TOptometryDetailVO s : optometryDetailVOS) {
                switch (s.getType()){
                    case 3:
                        if (s.getStatus()==2){
                            content.append("<BOLD>旧镜信息<BR>");
                            content.append("R:<BR>");
                            content.append("度数:"+s.getBallMirror()+" 散光:"+s.getColumnMirror()+" 轴位:"+s.getAxis()+"<BR>");
                            content.append("瞳距:"+s.getPupilDistance()+"<BR>");
                        }else if (s.getStatus()==1){
                            content.append("L:<BR>");
                            content.append("度数:"+s.getBallMirror()+" 散光:"+s.getColumnMirror()+" 轴位:"+s.getAxis()+"<BR>");
                            content.append("瞳距:"+s.getPupilDistance()+"<BR>");
                            content.append("--------------------------------<BR>");
                        }
                        break;
                    case 2:
                        if (s.getStatus()==2){
                            content.append("完全矫正<BR>");
                            content.append("R:<BR>");
                            content.append("度数:"+s.getBallMirror()+" 散光:"+s.getColumnMirror()+" 轴位:"+s.getAxis()+"<BR>");
                            content.append("瞳距:"+s.getPupilDistance()+" 矫正:"+s.getCorrect()+"<BR>");
                        }else if (s.getStatus()==1){
                            content.append("L:<BR>");
                            content.append("度数:"+s.getBallMirror()+" 散光:"+s.getColumnMirror()+" 轴位:"+s.getAxis()+"<BR>");
                            content.append("瞳距:"+s.getPupilDistance()+" 矫正:"+s.getCorrect()+"<BR>");
                            content.append("--------------------------------<BR>");
                        }
                        break;
                    case 1:
                        if (s.getStatus()==2){
                            content.append("配镜处方<BR>");
                            content.append("R:<BR>");
                            content.append("度数:"+s.getBallMirror()+" 散光:"+s.getColumnMirror()+" 轴位:"+s.getAxis()+"<BR>");
                            content.append("ADD:"+s.getAddS()+" 瞳距:"+s.getPupilDistance()+" 瞳高:"+s.getPupilHeight()+"<BR>");
                            content.append("矫正:"+s.getCorrect()+"<BR>");
                        }else if (s.getStatus()==1){
                            content.append("L:<BR>");
                            content.append("度数:"+s.getBallMirror()+" 散光:"+s.getColumnMirror()+" 轴位:"+s.getAxis()+"<BR>");
                            content.append("ADD:"+s.getAddS()+" 瞳距:"+s.getPupilDistance()+" 瞳高:"+s.getPupilHeight()+"<BR>");
                            content.append("矫正:"+s.getCorrect()+"<BR>");
                            content.append("--------------------------------<BR>");
                        }
                        break;
                }
            }
            content.append("</BOLD>");
           //通过POST请求,发送打印信息到服务器
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(30000)//读取超时
                    .setConnectTimeout(30000)//连接超时
                    .build();
            CloseableHttpClient httpClient = HttpClients.custom()
                     .setDefaultRequestConfig(requestConfig)
                     .build();
            HttpPost post = new HttpPost(URL);
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("user",USER));
            String STIME = String.valueOf(System.currentTimeMillis()/1000);
            nvps.add(new BasicNameValuePair("stime",STIME));
            nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME)));
            nvps.add(new BasicNameValuePair("apiname","Open_printMsg"));//固定值,不需要修改
            nvps.add(new BasicNameValuePair("sn",dto.getSn()));
            nvps.add(new BasicNameValuePair("content", content.toString()));
            nvps.add(new BasicNameValuePair("times","1"));//打印联数
            CloseableHttpResponse response = null;
            String result = null;
            try
            {
               post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
               response = httpClient.execute(post);
                  int statecode = response.getStatusLine().getStatusCode();
                  if(statecode == 200){
                    HttpEntity httpentity = response.getEntity();
                    if (httpentity != null){
                        //服务器返回的JSON字符串,建议要当做日志记录起来
                        result = EntityUtils.toString(httpentity);
                    }
               }
           }
           catch (Exception e)
           {
               e.printStackTrace();
           }
           finally{
               try {
                   if(response!=null){
                       response.close();
                   }
               } catch (IOException e) {
                   e.printStackTrace();
               }
               try {
                   post.abort();
               } catch (Exception e) {
                   e.printStackTrace();
               }
               try {
                   httpClient.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
            return unescapeUnicode(result);
        }
        //方法2
        public static String printLabelMsg(String sn){
            String content;
            content = "<DIRECTION>1</DIRECTION>";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸,
            content += "<TEXT x='9' y='10' font='12' w='1' h='2' r='0'>#001       五号桌      1/3</TEXT><TEXT x='80' y='80' font='12' w='2' h='2' r='0'>可乐鸡翅</TEXT><TEXT x='9' y='180' font='12' w='1' h='1' r='0'>张三先生       13800138000</TEXT>";//40mm宽度标签纸打印例子,打开注释调用标签打印接口打印
           //通过POST请求,发送打印信息到服务器
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(30000)//读取超时
                    .setConnectTimeout(30000)//连接超时
                    .build();
            CloseableHttpClient httpClient = HttpClients.custom()
                     .setDefaultRequestConfig(requestConfig)
                     .build();
            HttpPost post = new HttpPost(URL);
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("user",USER));
            String STIME = String.valueOf(System.currentTimeMillis()/1000);
            nvps.add(new BasicNameValuePair("stime",STIME));
            nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME)));
            nvps.add(new BasicNameValuePair("apiname","Open_printLabelMsg"));//固定值,不需要修改
            nvps.add(new BasicNameValuePair("sn",sn));
            nvps.add(new BasicNameValuePair("content",content));
            nvps.add(new BasicNameValuePair("times","1"));//打印联数
            CloseableHttpResponse response = null;
            String result = null;
            try
            {
               post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
               response = httpClient.execute(post);
                  int statecode = response.getStatusLine().getStatusCode();
                  if(statecode == 200){
                    HttpEntity httpentity = response.getEntity();
                    if (httpentity != null){
                        //服务器返回的JSON字符串,建议要当做日志记录起来
                        result = EntityUtils.toString(httpentity);
                    }
               }
           }
           catch (Exception e)
           {
               e.printStackTrace();
           }
           finally{
               try {
                   if(response!=null){
                       response.close();
                   }
               } catch (IOException e) {
                   e.printStackTrace();
               }
               try {
                   post.abort();
               } catch (Exception e) {
                   e.printStackTrace();
               }
               try {
                   httpClient.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
           return result;
        }
        //方法3
        public static String queryOrderState(String orderid){
           //通过POST请求,发送打印信息到服务器
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(30000)//读取超时
                    .setConnectTimeout(30000)//连接超时
                    .build();
            CloseableHttpClient httpClient = HttpClients.custom()
                     .setDefaultRequestConfig(requestConfig)
                     .build();
            HttpPost post = new HttpPost(URL);
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("user",USER));
            String STIME = String.valueOf(System.currentTimeMillis()/1000);
            nvps.add(new BasicNameValuePair("stime",STIME));
            nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME)));
            nvps.add(new BasicNameValuePair("apiname","Open_queryOrderState"));//固定值,不需要修改
            nvps.add(new BasicNameValuePair("orderid",orderid));
            CloseableHttpResponse response = null;
            String result = null;
            try
            {
               post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
                  response = httpClient.execute(post);
                  int statecode = response.getStatusLine().getStatusCode();
                  if(statecode == 200){
                    HttpEntity httpentity = response.getEntity();
                    if (httpentity != null){
                        //服务器返回
                        result = EntityUtils.toString(httpentity);
                    }
               }
           }
           catch (Exception e)
           {
               e.printStackTrace();
           }
            finally{
                   try {
                       if(response!=null){
                           response.close();
                       }
                   } catch (IOException e) {
                       e.printStackTrace();
                   }
                   try {
                       post.abort();
                   } catch (Exception e) {
                       e.printStackTrace();
                   }
                   try {
                       httpClient.close();
                   } catch (IOException e) {
                       e.printStackTrace();
                   }
               }
           return result;
       }
        //方法4
        public static String queryOrderInfoByDate(String sn,String strdate){
            //通过POST请求,发送打印信息到服务器
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(30000)//读取超时
                    .setConnectTimeout(30000)//连接超时
                    .build();
            CloseableHttpClient httpClient = HttpClients.custom()
                     .setDefaultRequestConfig(requestConfig)
                     .build();
            HttpPost post = new HttpPost(URL);
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("user",USER));
            String STIME = String.valueOf(System.currentTimeMillis()/1000);
            nvps.add(new BasicNameValuePair("stime",STIME));
            nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME)));
            nvps.add(new BasicNameValuePair("apiname","Open_queryOrderInfoByDate"));//固定值,不需要修改
            nvps.add(new BasicNameValuePair("sn",sn));
            nvps.add(new BasicNameValuePair("date",strdate));//yyyy-MM-dd格式
            CloseableHttpResponse response = null;
            String result = null;
            try
            {
               post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
                  response = httpClient.execute(post);
                  int statecode = response.getStatusLine().getStatusCode();
                  if(statecode == 200){
                    HttpEntity httpentity = response.getEntity();
                    if (httpentity != null){
                        //服务器返回
                        result = EntityUtils.toString(httpentity);
                    }
               }
           }
           catch (Exception e)
           {
               e.printStackTrace();
           }
            finally{
                   try {
                       if(response!=null){
                           response.close();
                       }
                   } catch (IOException e) {
                       e.printStackTrace();
                   }
                   try {
                       post.abort();
                   } catch (Exception e) {
                       e.printStackTrace();
                   }
                   try {
                       httpClient.close();
                   } catch (IOException e) {
                       e.printStackTrace();
                   }
               }
           return result;
       }
        //方法5
        public static String queryPrinterStatus(String sn){
            //通过POST请求,发送打印信息到服务器
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(30000)//读取超时
                    .setConnectTimeout(30000)//连接超时
                    .build();
            CloseableHttpClient httpClient = HttpClients.custom()
                     .setDefaultRequestConfig(requestConfig)
                     .build();
            HttpPost post = new HttpPost(URL);
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("user",USER));
            String STIME = String.valueOf(System.currentTimeMillis()/1000);
            nvps.add(new BasicNameValuePair("stime",STIME));
            nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME)));
            nvps.add(new BasicNameValuePair("apiname","Open_queryPrinterStatus"));//固定值,不需要修改
            nvps.add(new BasicNameValuePair("sn",sn));
            CloseableHttpResponse response = null;
            String result = null;
            try
            {
               post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));
                  response = httpClient.execute(post);
                  int statecode = response.getStatusLine().getStatusCode();
                  if(statecode == 200){
                    HttpEntity httpentity = response.getEntity();
                    if (httpentity != null){
                        //服务器返回
                        result = EntityUtils.toString(httpentity);
                    }
               }
           }
           catch (Exception e)
           {
               e.printStackTrace();
           }
            finally{
                   try {
                       if(response!=null){
                           response.close();
                       }
                   } catch (IOException e) {
                       e.printStackTrace();
                   }
                   try {
                       post.abort();
                   } catch (Exception e) {
                       e.printStackTrace();
                   }
                   try {
                       httpClient.close();
                   } catch (IOException e) {
                       e.printStackTrace();
                   }
               }
           return result;
       }
        //生成签名字符串
        public static String signature(String USER,String UKEY,String STIME){
            String s = DigestUtil.sha1Hex(USER+UKEY+STIME);
            return s;
        }
}
manage/src/main/java/com/jilongda/manage/controller/TCouponController.java
@@ -1,10 +1,18 @@
package com.jilongda.manage.controller;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.oss.model.MatchMode;
import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.PolicyConditions;
import com.aliyun.oss.model.PutObjectResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jilongda.common.basic.ApiResult;
import com.jilongda.common.basic.PageInfo;
import com.jilongda.common.utils.UUIDUtil;
import com.jilongda.manage.component.AliOssMange;
import com.jilongda.manage.dto.TModelDTO;
import com.jilongda.manage.model.TAppUser;
import com.jilongda.manage.model.TCoupon;
@@ -28,22 +36,18 @@
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -188,5 +192,116 @@
        return multipartFile;
    }
    @ApiOperation(value = "服务端上传", notes = "服务端上传")
    @PostMapping(value = "upload")
    public ApiResult<String> fileUpload(@RequestParam(value = "file") MultipartFile file) throws IOException {
        InputStream inputStream = file.getInputStream();
        String filename = System.currentTimeMillis() + file.getOriginalFilename();
        // Endpoint以杭州为例,其它Region请按实际情况填写。
        final String endpoint = AliOssMange.endpoint;
        // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
        final String accessKeyId = AliOssMange.accessKeyId;
        final String accessKeySecret = AliOssMange.accessKeySecret;
        final String bucketName = AliOssMange.bucketName;
        // <yourObjectName>上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
        String objectName = AliOssMange.dir + filename;
        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
        // 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。
        // InputStream inputStream = new FileInputStream("D:\\localpath\\examplefile.txt");
        // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。
        PutObjectResult putObjectResult = ossClient.putObject(bucketName, objectName, inputStream);
        OSSObject ossObject = ossClient.getObject(bucketName, objectName);
        String uri = ossObject.getResponse().getUri();
        // 关闭OSSClient。
        ossClient.shutdown();
//        uri = uri.replace("http://nn-bucket.oss-cn-shanghai.aliyuncs.com",FILE_CDN);
        return ApiResult.okmsg(uri);
    }
    @ApiOperation(value = "服务端签名后直传", notes = "服务端签名后直传")
    @PostMapping("signature")
    public ApiResult<Map<String, String>> signature() {
        OSS builder = new OSSClientBuilder().build(AliOssMange.endpoint, AliOssMange.accessKeyId, AliOssMange.accessKeySecret);
        long expireTime = 30;
        long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
        Date expiration = new Date(expireEndTime);
        PolicyConditions policyConds = new PolicyConditions();
        policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, 1048576000);
        policyConds.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, AliOssMange.dir);
        String postPolicy = builder.generatePostPolicy(expiration, policyConds);
        byte[] binaryData = postPolicy.getBytes(StandardCharsets.UTF_8);
        String encodedPolicy = BinaryUtil.toBase64String(binaryData);
        String postSignature = builder.calculatePostSignature(postPolicy);
        Map<String, String> respMap = new LinkedHashMap<>(6);
        respMap.put("accessid", AliOssMange.accessKeyId);
        respMap.put("policy", encodedPolicy);
        respMap.put("signature", postSignature);
        // 示例为dir
        respMap.put("dir", AliOssMange.dir);
        // 前端为key
        // respMap.put("key", AliOssMange.dir);
        respMap.put("host", AliOssMange.host);
//        respMap.put("cdn", AliOssMange.cdn);
        respMap.put("expire", String.valueOf(expireEndTime / 1000));
//        // 回调
//        if (StringUtils.hasLength(AliOssMange.callbackUrl)) {
//            JSONObject jasonCallback = new JSONObject();
//            jasonCallback.put("callbackUrl", AliOssMange.callbackUrl);
//            String callbackBody = "{\"filename\":${object},\"size\":${size},\"mimeType\":${mimeType}}";
//            jasonCallback.put("callbackBody", callbackBody);
//            jasonCallback.put("callbackBodyType", "application/json");
//            String base64CallbackBody = BinaryUtil.toBase64String(jasonCallback.toString().getBytes());
//            respMap.put("callback", base64CallbackBody);
//        }
//        HttpServletResponse response = WebUtils.response();
//        assert response != null;
//        response.setHeader("Access-Control-Allow-Origin", "*");
//        response.setHeader("Access-Control-Allow-Methods", "GET, POST");
        // 关闭OSSClient。
        builder.shutdown();
        return ApiResult.success(respMap);
    }
    @ApiOperation(value = "服务端上传(二进制字符串)", notes = "服务端上传")
    @PostMapping(value = "str/upload")
    public String strUpload(InputStream inputStream, String filename) throws IOException {
        //String filename = System.currentTimeMillis() + CodeGenerateUtils.generateVolumeSn()+".jpg";
        // Endpoint以杭州为例,其它Region请按实际情况填写。
        final String endpoint = AliOssMange.endpoint;
        // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
        final String accessKeyId = AliOssMange.accessKeyId;
        final String accessKeySecret = AliOssMange.accessKeySecret;
        final String bucketName = AliOssMange.bucketName;
        // <yourObjectName>上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
        String objectName = AliOssMange.dir + filename;
        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
        // 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。
        // InputStream inputStream = new FileInputStream("D:\\localpath\\examplefile.txt");
        // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。
        PutObjectResult putObjectResult = ossClient.putObject(bucketName, objectName, inputStream);
        OSSObject ossObject = ossClient.getObject(bucketName, objectName);
        String uri = ossObject.getResponse().getUri();
        // 关闭OSSClient。
        ossClient.shutdown();
        return uri;
    }
    /**
     * oss上传成功回调
     *
     * @param callback
     * @return
     */
    @ApiOperation(value = "oss回调", notes = "oss回调")
    @PostMapping(value = "/callback")
    public ApiResult callback(@RequestBody Map<String, Object> callback) {
        String filename = "http://".concat(AliOssMange.bucketName).concat(".").concat(AliOssMange.endpoint).concat("/").concat(callback.get("filename").toString());
        return ApiResult.okmsg(filename);
    }
}
manage/src/main/java/com/jilongda/manage/controller/TTicketController.java
@@ -1,21 +1,20 @@
package com.jilongda.manage.controller;
import com.alibaba.fastjson.JSONObject;
import com.jilongda.common.Ticket.TicketUtil;
import com.jilongda.common.basic.ApiResult;
import com.jilongda.common.basic.PageInfo;
import com.jilongda.manage.model.TStore;
import com.jilongda.manage.model.TTicket;
import com.jilongda.manage.query.TWarehousingDetailQuery;
import com.jilongda.manage.query.TicketQuery;
import com.jilongda.manage.service.TStoreService;
import com.jilongda.manage.service.TTicketService;
import com.jilongda.manage.vo.TFrameWarehousingDetailVO;
import com.jilongda.manage.vo.TTicketVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sun.security.krb5.internal.Ticket;
/**
 * <p>
@@ -31,8 +30,11 @@
public class TTicketController {
    @Autowired
    private TTicketService tTicketService;
    @Autowired
    private TStoreService storeService;
    @ApiOperation(value = "小票机列表")
    @PostMapping(value = "/pageList")
@@ -44,6 +46,12 @@
    @ApiOperation(value = "小票机添加")
    @PostMapping(value = "/add")
    public ApiResult<String> add(@RequestBody TTicket dto) {
        TStore store = storeService.getById(dto.getStoreId());
        String res = TicketUtil.addprinter(dto.getCloudId() + "#" + dto.getSecret() + "#" + store.getName());
        JSONObject result = JSONObject.parseObject(res);
        if (!result.getString("msg").equals("ok")){
            return ApiResult.failed(result.getString("msg"));
        }
        tTicketService.save(dto);
        return ApiResult.success();
    }
@@ -55,6 +63,12 @@
    @ApiOperation(value = "小票机编辑")
    @PostMapping(value = "/update")
    public ApiResult<String> update(@RequestBody TTicket dto) {
        TStore store = storeService.getById(dto.getStoreId());
        String res = TicketUtil.editprinter(dto.getCloudId()+"",store.getName());
        JSONObject result = JSONObject.parseObject(res);
        if (!result.getString("msg").equals("ok")){
            return ApiResult.failed(result.getString("msg"));
        }
        tTicketService.updateById(dto);
        return ApiResult.success();
    }
optometrist/pom.xml
@@ -17,6 +17,33 @@
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
optometrist/src/main/java/com/jilongda/optometrist/controller/TOptometristController.java
@@ -1,20 +1,19 @@
package com.jilongda.optometrist.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.jilongda.common.Ticket.TAddOptometryVO;
import com.jilongda.common.Ticket.TOptometryDetailVO;
import com.jilongda.common.Ticket.TicketUtil;
import com.jilongda.common.basic.ApiResult;
import com.jilongda.common.basic.PageInfo;
import com.jilongda.optometrist.authority.model.SecUser;
import com.jilongda.optometrist.authority.service.SecUserService;
import com.jilongda.optometrist.model.*;
import com.jilongda.optometrist.query.TOptometristQuery;
import com.jilongda.optometrist.query.TOptometryQuery;
import com.jilongda.optometrist.query.TicketQuery;
import com.jilongda.optometrist.service.*;
import com.jilongda.optometrist.utils.LoginInfoUtil;
import com.jilongda.optometrist.vo.*;
import com.sun.org.apache.bcel.internal.generic.NEW;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
@@ -22,6 +21,7 @@
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
@@ -57,6 +57,8 @@
    private TOrderService orderService;
    @Autowired
    private TOptometryDetailService optometryDetailService;
    @Autowired
    private TTicketService tTicketService;
    @ApiOperation(value = "获取验光单分页列表",tags = "验光单")
    @PostMapping(value = "/pageList")
    public ApiResult<PageInfo<TOptometryVO>> pageList(@RequestBody TOptometryQuery query) {
@@ -267,6 +269,25 @@
        // 验光完成
        lineUp.setStatus(3);
        tLineUpService.updateById(lineUp);
        dto.setOptometristName(optometrist.getName());
        TStore store = storeService.getById(lineUp.getStoreId());
        dto.setShopName(store.getName());
        TAppUser appUser = appUserService.getById(lineUp.getUserId());
        dto.setPhone(appUser.getPhone());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = simpleDateFormat.format(new Date());
        dto.setTime(format);
        TTicket tTicket = tTicketService.lambdaQuery().eq(TTicket::getStoreId, lineUp.getStoreId())
                .eq(TTicket::getStatus, 1).list().stream().findFirst().orElse(null);
        if (tTicket==null){
            return ApiResult.failed("当前门店未绑定小票机");
        }
        dto.setSn(tTicket.getCloudId()+"");
        String print = TicketUtil.print(dto);
        JSONObject jsonObject = JSONObject.parseObject(print);
        if (!jsonObject.getString("msg").equals("0")){
            return ApiResult.failed(jsonObject.getString("msg"));
        }
        return ApiResult.success();
    }
optometrist/src/main/java/com/jilongda/optometrist/vo/TAddOptometryVO.java
File was deleted