分类目录归档:None

thinkphp 关联查询 with

范例

$info=LeaseModel::with(
            [
                "fapiao"=>function($query) use($time_start,$time_end,$is_created,$is_done,$is_print){
                    $query->where('time_start','>=',$time_start);
                    $query->where('time_end','<=',$time_end);
                    if($is_done>0){
                        $query->where('is_done','>',$is_done);
                    }elseif($is_done==='0'){
                        $query->where('is_done','=',$is_done);
                    }
                    if($is_created>0){
                        $query->where('is_created','>',$is_created);
                    }elseif($is_created==='0'){
                        $query->where('is_created','=',$is_created);
                    }
                    if($is_print>0){
                        $query->where('is_print','>',$is_print);
                    }elseif($is_print==='0'){
                        $query->where('is_print','=',$is_print);
                    }
                },"lease_contract","lease_contract.ca","lease_contract.cb","lease_contract.cc","lease_contract.cd","propertyone","propertyone.property"
            ])->alias("a")
            ->join("lease_contract b","a.lease_id=b.id")
            ->join("property_one c","a.po_id=c.id")
            ->where($where)
            ->leftJoin("co name_a","name_a.id=b.a")
            ->leftJoin("co name_b","name_b.id=b.b")
            ->leftJoin("co name_c","name_c.id=b.c")
            ->leftJoin("co name_d","name_d.id=b.d")
            ->where($where)
            ->whereNull("b.delete_time")
            ->whereNull("c.delete_time")
            ->whereNull("name_a.delete_time")
            ->whereNull("name_b.delete_time")
            ->whereNull("name_c.delete_time")
            ->whereNull("name_d.delete_time")
            ->field("a.*")
            ->select();

多重调用 ,with多级关联 ,join ,

其中fields(a.*) 因为有表格join时候和本表中有键值冲突所以中使用 a.* 反正都用了关联模型

AJAX 本地提交 不跳转修改表格

使用jquery阻止a标签跳转,使用AJXA发起请求 后根据a标签的提示执行js语句来实现动态加载

A标签

 <a  href="{:url('portal/fapiao/print_id',['id'=>$so.id])}" class="ajax-click btn btn-primary btn-sm"  js="ts.parent().parent().parent().attr('class','bg-warning');var span=ts.parent().parent().prev().find('span:first');span.text('已开票');span.attr('class','label label-primary')"data-msg="确定已开票吗?">完成</a>
                                        <a  href="{:url('portal/fapiao/done_id',['id'=>$so.id])}" class="ajax-click btn btn-success btn-sm" js="ts.parent().parent().parent().attr('class','bg-success');var span=ts.parent().parent().prev().find('span').eq(1);span.text('已付款');span.attr('class','label label-success')" data-msg="确定已收款?">收款</a>
                                   

其中的 js 属性为eval执行js语句,其中 ajax-click 用于绑定点击事件来组织跳转a 标签的href,在函数中提前将$(this) 变为局部变量,在函数中使用,(因为ajax请求中$(this) 为请求本身)eval执行

$(".ajax-click").click(function(){
        event.preventDefault();//停止跳转
        var url=$(this).attr('href');
        var ts=$(this);
        var js=$(this).attr('js');
        var jugg=confirm($(this).attr('data-msg'));
        if(jugg){
            $.ajax({
                url:url,
                success:function(data){
                    console.log(data);
                    if(data.code){
                        // c=ts.parent().parent().parent().attr("class","info")
                        eval(js);
                        // console.log(c)
                        // window.location.href=data.url;
                    }
                }
            })
        } 
    })

comfyUI关于P104 显卡设置 tips

  • comfyUI 官方默认安装即可 ( https://www.comfy.org/zh-cn/ ),但是需要安装好CUDA。
  • 不能多卡并行,一个进程只能一张卡上运行,也就是说显存越大越好,P104的8GB,运行Wan2.2 5B 出720P有点不够(勉勉强强运行)官方推荐12GB显存,双卡无用。
    • P104不能开启cudaMallocAsync ,需要在comfyui的设置里面关闭cudaMallocAsync 设置Disable CUDA malloc,这样才能运行
  • 其中的模型下载可能会因为网络问题导致无法下载。

上图是P104 打开时候使用cudaMallocAsync 的启动图片,该配置下是无法完成出图的,需要在设置里关闭cuda malloc

  • https://download.comfy.org/windows/nsis/x64

大模型做OCR不如直接OCR

用Qwen2.5VL 3b和7b做OCR 效果不行,不如直接使用OCR的包,如CnOcr

安装:

pip install cnocr[ort-cpu]

pip install cnocr[ort-cpu] -i https://pypi.tuna.tsinghua.edu.cn/simple

首次安装会去hf上下几个模型,CPU也可以运行,效果不错:

from cnocr import CnOcr

img_fp = 'page_10.png'
ocr = CnOcr()  # 所有参数都使用默认值
out = ocr.ocr(img_fp)

print(out)

返回结果为 文本信息 准确率 位置信息

文档:https://cnocr.readthedocs.io/zh-cn/stable/

解决方向:OCR 结果给大模型处理