hzd 4 місяців тому
батько
коміт
ff59a14312

+ 207 - 0
application/admin/controller/ConveyCron.php

@@ -0,0 +1,207 @@
+<?php
+namespace app\admin\controller;
+
+use think\App;
+use think\Db;
+use think\Exception;
+
+class ConveyCron extends Auth
+{
+
+    public function __construct(App $app = null) {
+        parent::__construct($app);
+        $this->table='convey_cron';
+        $this->model= new \app\common\model\ConveyCron();
+    }
+
+    private $weeks = ['周日','周一','周二','周三','周四','周五','周六'];
+
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','id','trim');      //排序列
+            $sort = input('sord','desc','trim');        //排序方式
+            $order = $sortRow.' '.$sort;
+
+            $title = input('title','','trim');
+            if($title){
+                $map[] = ['title','like','%'.$title.'%'];
+            }
+            $enable = input('enable','','trim');
+            if($enable != ''){
+                $map[] = ['enable','=',$enable];
+            }
+
+            $map[] = ['del','=',0];
+            $map[] = ['org_id','=',$this->orgId];
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $lists = Db::name($this->table)->where($map)
+                ->limit($start,$length)
+                ->order([$sortRow=>$sort,'id'=>'desc'])
+                ->select();
+            foreach ($lists as $k=>$v){
+                $lists[$k]['dep_title'] = Db::name('dep')->where('id',$v['dep_id'])->value("title");
+                $userIds = empty($v['to_user_ids'])?[]:explode(",",$v['to_user_ids']);
+                $lists[$k]['unames'] = "";
+                if($userIds){
+                    $names = Db::name('user')->where('id','in',$userIds)->column('real_name');
+                    $lists[$k]['unames'] = $names?implode(',',$names):'';
+                }
+                $lists[$k]['type_title'] = Db::name('convey_cate')->where('id',$v['type'])->value("title");
+                $lists[$k]['device_title'] = "";
+                if($v['device_id']){
+                    $lists[$k]['device_title'] = Db::name('convey_device')->where('id',$v['device_id'])->value("title");
+                }
+                $lists[$k]['week_day'] = isset($this->weeks[$v['week']])? $this->weeks[$v['week']]:"";
+
+                $lists[$k]['start_title'] = Db::name('address')->where('id',$v['start'])->value("title");
+                $lists[$k]['end_title'] = Db::name('address')->where('id',$v['start'])->value("title");
+             }
+
+            //数据返回
+            $totalCount = Db::name($this->table)->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0){
+        if(request()->isPost()){
+            $res = $this->model->updates();
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error($this->model->getError());
+            }
+        }else{
+            if($id){
+                $info =db($this->table)->where('id',$id)->find();
+                $this->assign('info',$info);
+            }
+            $depList = (new \app\common\model\Dep())->getList();
+            $this->assign('dep_list', $depList);
+            $address = (new \app\common\model\Address())->getListByType(2);
+            $conveyCate = (new \app\common\model\ConveyCate());
+            $priority = $conveyCate->priority;
+            $order_convey = $conveyCate->getList();
+            $order_device = (new \app\common\model\ConveyDevice())->getList();
+            $this->assign('address', $address);
+            $this->assign('priority', $priority);
+            $this->assign('order_convey_type', $order_convey);
+            $this->assign('order_device', $order_device);
+
+            $this->assign('user_list', (new \app\common\model\WorkTypeMode())->getRolesUserByNum(3, $this->orgId,-1));
+
+            return $this->fetch();
+        }
+    }
+
+    public function getAddr(){
+        $id = input('id/d',0);
+        $info = Db::name('convey_cate')
+            ->where('id',$id)
+            ->find();
+
+        if(!empty($info['starts'])){
+            $st = explode(',',$info['starts']);
+            $s = (new \app\common\model\Address())->getListByTypes($st,2);
+        }else{
+            $s = (new \app\common\model\Address())->getListByType(2);
+        }
+        if(!empty($info['ends'])){
+            $ent = explode(',',$info['ends']);
+            $en = (new \app\common\model\Address())->getListByTypes($ent,2);
+        }else{
+            $en = (new \app\common\model\Address())->getListByType(2);
+        }
+        $a = [
+            's'=>$s,
+            'e'=>$en,
+        ];
+        $this->success('','',$a);
+
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = db($this->table)->where('id',$id)->setField('del',1);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 改变字段值
+     * @param int $fv
+     * @param string $fn
+     * @param int $fv
+     */
+    public function changeField($id=0,$fn='',$fv=0){
+        if(!$fn||!$id){
+            $this->error('参数错误');
+        }
+        $res = db($this->table)->where('id',$id)->setField($fn,$fv);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+    public function plan(){
+        $res = model("ConveyCron")->plan($this->orgId);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+
+    public function batchSort(){
+        $data = input('data','','trim');
+        if(!$data){
+            $this->error('参数错误');
+        }
+        $data = json_decode($data,true);
+        if(!$data){
+            $this->error('参数错误');
+        }
+
+        Db::startTrans();
+        try{
+            foreach ($data as $k=>$v){
+                Db::name('convey_device')->where('id',$v['id'])->setField('sort',$v['sort']);
+            }
+
+            Db::commit();
+        }catch (Exception $e){
+            Db::rollback();
+            $this->error('操作失败');
+        }
+        $this->success('操作成功');
+    }
+
+}

+ 1 - 0
application/admin/controller/Orders.php

@@ -2191,6 +2191,7 @@ class Orders extends Auth {
             $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('H')->setWidth(20);
             //循环刚取出来的数组,将数据逐一添加到excel表格。
             if ($mode == 1) {
+//                halt($lists);
                 for ($i = 0; $i < count($lists); $i++) {
                     $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $lists[$i]['sn']);
                     $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $lists[$i]['create_time']);

+ 399 - 0
application/admin/view/convey_cron/add.html

@@ -0,0 +1,399 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">部门</label></br>
+                            <input type="hidden" name="dep_id" id="dep" value="{$info?$info['dep_id']:''}">
+                            <el-select v-model="dep_id" size="small" clearable style="width: 100%" filterable placeholder="请选择">
+                                <el-option
+                                        v-for="item in dep"
+                                        :key="item.id"
+                                        :label="item.title"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+                    <div class="col-sm-12">
+                        <div class="form-group" id="type2">
+                            <label class="control-label">执行人<span class="text-danger">*</span></label></br>
+                            <input type="hidden" name="to_user_ids" id="user_id" value="{$info?$info['to_user_ids']:''}">
+                            <el-select v-model="user_id" filterable clearable placeholder="请选择" size="small"
+                                       style="width:100%">
+                                <el-option-group
+                                        v-for="group in user"
+                                        :key="group.id"
+                                        :label="group.name">
+                                    <el-option
+                                            v-for="item in group.user"
+                                            :key="item.id"
+                                            :label="item.real_name"
+                                            :value="item.id.toString()">
+                                    </el-option>
+                                </el-option-group>
+                            </el-select>
+                        </div>
+                    </div>
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">运送类型<span class="text-danger">*</span></label></br>
+                            <div class="rr">
+
+                                <input type="hidden" name="type" id="type" value="{$info?$info['type']:''}">
+                                <div>
+                                    <el-select v-model="type" size="small" clearable  style="width: 100%" filterable placeholder="请选择">
+                                        <el-option
+                                                v-for="item in types"
+                                                :key="item.id"
+                                                :label="item.title"
+                                                :value="item.id.toString()">
+                                        </el-option>
+                                    </el-select>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">优  &nbsp;先 &nbsp;级</label></br>
+                            <input type="hidden" name="priority" id="priority">
+                            <div style="padding-right: 10px">
+                                <el-radio v-model="priority" label="2">常规</el-radio>
+                                <el-radio v-model="priority" label="3">紧急</el-radio>
+                            </div>
+
+                        </div>
+                    </div>
+
+                    <div id="patient">
+                        <div class="col-sm-6">
+                            <div class="form-group">
+                                <label class="control-label">床号</label></br>
+                                <div class="rr">
+                                    <input type="text" class="form-control" name="bed_number" value="{$info?$info['bed_number']:''}">
+                                </div>
+                            </div>
+                        </div>
+                        <div class="col-sm-6">
+                            <div class="form-group">
+                                <label class="control-label">姓名</label></br>
+                                <div class="rr">
+                                    <input type="text" class="form-control" name="name" value="{$info?$info['name']:''}">
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="col-sm-6">
+                        <div class="form-group" >
+                            <label class="control-label">开始地点<span class="text-danger">*</span></label></br>
+                            <input type="hidden"  value="" name="start" id="start" value="{$info?$info['start']:''}">
+                            <div class="rr">
+                                <el-select v-model="start" size="small" clearable style="width: 100%" filterable placeholder="请选择">
+                                    <el-option
+                                            v-for="item in starts"
+                                            :key="item.id"
+                                            :label="item.title"
+                                            :value="item.id.toString()">
+                                    </el-option>
+                                </el-select>
+                            </div>
+
+                        </div>
+                    </div>
+
+
+                    <div class="col-sm-6">
+                        <div class="form-group">
+                            <label class="control-label">结束地点<span class="text-danger">*</span></label></br>
+                            <input type="hidden" name="end" id="end" value="{$info?$info['end']:''}">
+                            <el-select v-model="end" size="small" clearable style="width: 100%" filterable placeholder="请选择">
+                                <el-option
+                                        v-for="item in ends"
+                                        :key="item.id"
+                                        :label="item.title"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">途径地点</label></br>
+                            <div style="padding-right: 10px">
+                                <input type="hidden" name="tjaddrs" id="way_addr" value="{$info?$info['tjaddrs']:''}">
+                                <el-select v-model="way_addr" size="small" collapse-tags style="width: 100%" multiple placeholder="请选择">
+                                    <el-option
+                                            v-for="item in way_addrs"
+                                            :key="item.id"
+                                            :label="item.title"
+                                            :value="item.id.toString()">
+                                    </el-option>
+                                </el-select>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">运送设备</label></br>
+                            <input type="hidden" name="device_id" id="device" value="{$info?$info['device_id']:''}">
+                            <el-select v-model="device" size="small" style="width: 100%" clearable filterable placeholder="请选择">
+                                <el-option
+                                        v-for="item in devices"
+                                        :key="item.id"
+                                        :label="item.title"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">需求时间<span class="text-danger">*</span></label></br>
+                            <input type="hidden" name="xq_time" id="xqtime2" value="{$info?$info['xq_time']:''}">
+                            <div class="rr">
+                                <el-time-picker
+                                        style="width: 100%"
+                                        size="small"
+                                        v-model="xq_time"
+                                        type="time"
+                                        :editable="false"
+                                        value-format="HH:mm"
+                                        :clearable="true"
+                                        @change="xqDateChange"
+                                        placeholder="选择日期时间">
+                                </el-time-picker>
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">选择日期</label><span class="text-danger">*</span></br>
+                            <input type="hidden" name="week" id="week" value="{$info?$info['week']:''}">
+                            <el-select v-model="week" size="small" style="width: 100%" clearable filterable placeholder="请选择">
+                                <el-option
+                                        v-for="item in weeks"
+                                        :key="item.id"
+                                        :label="item.title"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">派单备注</label></br>
+                            <textarea name="todo_content" class="form-control" cols="30" rows="3" >{$info?$info['todo_content']:''}</textarea>
+                        </div>
+                    </div>
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">任务备注</label></br>
+                            <input type="text"  class="form-control" name="content" value="{$info?$info['content']:''}">
+
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                            <button  class="btn cancel-btn btn-default" type="button">取 消</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(document).ready(function(){
+
+    });
+
+
+    var vdevices = {:json_encode($order_device)};
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                starts: [],
+                start: '',
+                ends: [],
+                end: '{$info?$info["end"]:""}',
+                week:'{$info?$info["week"]:""}',
+                weeks:[{"id":0,"title":"周日"},{"id":1,"title":"周一"},{"id":2,"title":"周二"},{"id":3,"title":"周三"},{"id":4,"title":"周四"},{"id":5,"title":"周五"},{"id":6,"title":"周六"}],
+                way_addrs: {:json_encode($address)},
+            way_addr:'',
+                types: {:json_encode($order_convey_type)},
+            type:  '',
+                prioritys:{:json_encode($priority)},
+            priority: '',
+                devices: {:json_encode($order_device)},
+            device: '{$info?$info["device_id"]:""}',
+                xq_time: '{$info?$info["xq_time"]:""}',
+                ywc_time:'',
+                dep: {:json_encode($dep_list)},
+            dep_id: '{$info?$info["dep_id"]:""}',
+                user: {:json_encode($user_list)},
+            user_id: '{$info?$info["to_user_ids"]:""}',
+                to_roles: [],
+            to_roles_id: '',
+                roles_id:''
+
+        }
+        },
+        watch: {
+            type: function (newtype, oldtype) {
+                var that  = this;
+                $.post('{:url("getAddr")}',{id:newtype},function (res){
+                    that.starts = res.data.s;
+                    that.ends = res.data.e;
+                },'json')
+                $('#type').val(newtype);
+                this.types.forEach((item) => {
+                    if(item.id == newtype){
+                        console.log(item);
+                        // this.end = item.ends > 0?parseInt(item.ends):'';
+                        if(item.starts >0){
+                            this.start = parseInt(item.starts);
+                        }else {
+                            if(item.startList.length ==0){
+
+                            }
+                        }
+                        if(item.ends >0){
+                            this.end = parseInt(item.ends);
+                        }else {
+                            if(item.endList.length ==0){
+
+                            }
+                        }
+                        // this.xq_time = item.xq_time?item.xq_time:'';
+                        // this.ywc_time = item.ywc_time?item.ywc_time:'';
+                        this.priority = item.priority > 0?item.priority.toString():'';
+                        if(item.cate == 1){
+                            let devices = [];
+                            vdevices.forEach((item) => {
+                                if(item.patient == 1){
+                                    devices.push(item);
+                                }
+                            });
+                            this.devices = devices;
+                            $('#patient').show();
+                        }else{
+                            this.devices = vdevices;
+                            $('#patient').hide();
+                        }
+
+                        $("#yy").css('display','block')
+                        // if(item.cate==4){
+                        //     $("#yy").css('display','block')
+                        // }else {
+                        //     $("#yy").css('display','none')
+                        //
+                        // }
+                    }
+                });
+            },
+            start: function (newtype, oldtype) {
+                $('#start').val(newtype);
+            },
+            end: function (newtype, oldtype) {
+                $('#end').val(newtype);
+            },
+            week: function (newtype, oldtype) {
+                $('#week').val(newtype);
+            },
+            way_addr: function (newtype, oldtype) {
+                console.log('way_addr',newtype);
+                $('#way_addr').val(newtype.join(','));
+            },
+            priority: function (newtype, oldtype) {
+                $('#priority').val(newtype);
+            },
+            device: function (newtype, oldtype) {
+                $('#device').val(newtype);
+            },
+            xq_time: function (newtype, oldtype) {
+                // var that = this;
+                // $.post("{:url('getTime')}",{type:this.type,'start':newtype},function (res){
+                //     if(res.code == 1){
+                //         that.xq_time = res.data.xq_time;
+                //         that.ywc_time = res.data.ywc_time;
+                //     }
+                //
+                // })
+                $('#xqtime2').val(newtype);
+            },
+            ywc_time: function (newtype, oldtype) {
+                $('#ywctime').val(newtype);
+            },
+            dep_id: function (newtype, oldtype) {
+                $('#dep').val(newtype);
+            },
+            user_id: function (newtype, oldtype) {
+                console.log("user_id",newtype);
+                // $('#user_id').val(newtype.join(','));
+                $('#user_id').val(newtype);
+            },
+            roles_id: function (newtype, oldtype) {
+                $('#to_roles_id').val(newtype);
+            },
+        },
+        created(){
+            let t = '{$info?$info["type"]:""}';
+            if(t){
+                this.type = t;
+            }
+
+            let way = '{$info?$info["tjaddrs"]:""}';
+            if(way){
+                this.way_addr = way.split(",");
+            }
+
+            let s = '{$info?$info["start"]:""}';
+            if(s){
+                this.start = s;
+            }
+
+            let e = '{$info?$info["end"]:""}';
+            if(e){
+                this.end = e;
+            }
+
+            let pp = '{$info?$info["priority"]:""}';
+            if(pp){
+                this.priority = pp;
+            }
+        },
+        methods: {
+            xqDateChange(e){
+                var that = this;
+                // $.post("{:url('getTime')}",{type:this.type,'start':e},function (res){
+                //     if(res.code == 1){
+                //         that.xq_time = res.data.xq_time;
+                //         that.ywc_time = res.data.ywc_time;
+                //     }
+                //
+                // })
+                // $('#xqtime').val(e);
+            }
+        }
+
+    })
+
+</script>
+{/block}

+ 105 - 0
application/admin/view/convey_cron/index.html

@@ -0,0 +1,105 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <a href="javascript:;" url="{:url('add')}" data-title="新增任务" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>
+                <a href="{:url('plan')}" data-confirm="确定要执行此计划吗?" data-table="1" class="btn btn-sm btn-primary confirm ajax-get">执行任务</a>
+            </div>
+            <div class="col-xs-9" style="text-align: right;">
+            <form class="form-inline" id="form-search" action="{:url('index')}">
+                <div class="input-group">
+                    <input type="text" class="form-control" name="title" placeholder="名称">
+                </div>
+                <div class="input-group">
+                    <select name="enable" class="form-control">
+                        <option value="">选择状态</option>
+                        <option value="0">禁用</option>
+                        <option value="1">正常</option>
+                    </select>
+                </div>
+                <div class="input-group">
+                    <span class="input-group-btn">
+                        <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                    </span> &nbsp;
+                    <span class="input-group-btn">
+                        <button class="btn-sm btn-warning" type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                    </span>
+                </div>
+            </form>
+        </div>
+        </div>
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                // {label:'ID',name:'id',index:'id', width:30,sortable: false},
+                {label:'科室',name:'dep_title',index:'dep_title',width:100,editable: false,sortable: false},
+                {label:'执行人',name:'unames',index:'unames',width:100,editable: false,sortable: false},
+                {label:'运送类型',name:'type_title',index:'type_title',width:100,editable: false,sortable: false},
+                {label:'优先级',name:'priority',index:'priority',width:50,editable: false,sortable: false,formatter:function (a,b,c){
+                    if(a == 2){
+                        return "常规";
+                    } else if(a == 3) {
+                        return "紧急";
+                    }else{
+                        return "";
+                    }
+                }},
+                {label:'开始地点',name:'start_title',index:'start_title',width:100,editable: false,sortable: false},
+                {label:'结束地点',name:'end_title',index:'end_title',width:100,editable: false,sortable: false},
+                {label:'运送设备',name:'device_title',index:'device_title',width:100,editable: false,sortable: false},
+                {label:'需求时间',name:'xq_time',index:'xq_time',width:100,editable: false,sortable: false},
+                {label:'日期',name:'week_day',index:'week_day',width:100,editable: false,sortable: false},
+                {label:'最新执行日期',name:'update_day',index:'update_day',width:100,editable: false,sortable: false},
+                {label:'操作',width:100,sortable: false,formatter: function (a, b, c) {
+                    var editurl = "{:url('add',[],'')}/id/"+c.id;
+                    var delurl = "{:url('del',[],'')}/id/"+c.id;
+                    var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
+                   btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                    return btn;
+                }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'id',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "desc",
+            caption:"运送任务",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+    });
+
+</script>
+{/block}

+ 173 - 0
application/common/model/ConveyCron.php

@@ -0,0 +1,173 @@
+<?php
+namespace app\common\model;
+
+use think\Db;
+
+class ConveyCron extends Base
+{
+    protected $createTime = 'create_time';
+    protected $updateTime = 'update_time';
+    protected $table = 'convey_cron';
+    protected $validateName = 'ConveyCron';
+    public function updates(){
+        $data = request()->post();
+        $data['org_id'] =cur_org_id();
+        $data['create_user_id'] = is_login();
+//        halt($data);
+        $result = validate($this->validateName)->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate($this->validateName)->getError();
+            return false;
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        if($id > 0){
+            $data['update_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+    public function plan($orgId = 0){
+        $curday = date("Ymd");
+        $week = date("w");
+        $map[] = ['del','=',0];
+        $map[] = ['week','=',$week];
+        $map[] = ['update_day','<',$curday];
+        if($orgId > 0){
+            $map[] = ['org_id','=',$orgId];
+        }
+        $lists = Db::name('convey_cron')->where($map)->limit(100)->fetchSql(false)->select();
+//        halt($lists);
+        $lists = $lists?$lists:[];
+
+        Db::startTrans();
+        try{
+            foreach ($lists as $k=>$v){
+                $conveyCate = Db::name('convey_cate')->where('id',$v['type'])->find();
+                $conveyTime = Db::name('time')->where('id',$conveyCate['time_id'])->find();
+
+                $odata = [
+                    'org_id' => $v['org_id'],
+                    'sn' => get_unique_sn(get_config('sn_prefix')),
+                    'dep_id' => $v['dep_id'],
+                    'user_id' => $v['create_user_id'],
+                    'order_mode' => empty($v['to_user_ids'])?1:4,
+                    'content' => $v['content'],
+                    'create_time' => getTime(),
+                    'source_type' => 2,
+                    'work_type_mode' => 3,
+                    'create_yyyy' => date("Y"),
+                    'create_yyyymm' => date("Ym"),
+                    'create_yyyymmdd' => date("Ymd"),
+                ];
+                if($odata['order_mode'] == 4){
+                    $odata['send_time'] = getTime();
+                }
+
+                $orderId = Db::name('orders')->insertGetId($odata);
+                if($orderId <= 0){
+                    exception("操作失败1");
+                }
+
+                $xqtimeint = strtotime(date("Y-m-d")." ".$v['xq_time']);
+                $xqtime =date("Y-m-d H:i:s",$xqtimeint);
+
+                $ywctimeint = $xqtimeint + $conveyTime['bz_time']*60;
+                $ywctime =date("Y-m-d H:i:s",$ywctimeint);
+                $ocdata = [
+                    'order_id' => $orderId,
+                    'type' => $v['type'],
+                    'start' => $v['start'],
+                    'end' => $v['end'],
+                    'xq_time' => $xqtime,
+                    'ywc_time' => $ywctime,
+                    'device_id' => $v['device_id'],
+                    'priority' => $v['priority'],
+                ];
+                $ocId = Db::name('order_convey')->insertGetId($ocdata);
+                if($ocId <= 0){
+                    exception("操作失败2");
+                }
+
+                if($conveyCate['cate'] == 1){ // 病人运送
+                    $ocpdata = [
+                        'order_id' => $orderId,
+                        'bed_number' => $v['bed_number'],
+                        'name' => $v['name']
+                    ];
+                    $ocpId = Db::name('order_convey_patient')->insertGetId($ocpdata);
+                    if($ocpId <= 0){
+                        exception("操作失败3");
+                    }
+                }
+
+                if($v['tjaddrs']){
+                    $addrs = explode(',',$v['tjaddrs']);
+                    foreach ($addrs as $kk=>$vv){
+                        $ocedata = [
+                            'order_id' => $orderId,
+                            'addr' => $vv,
+                            'order_convey_id' => $ocId,
+                            'create_time' => getTime()
+                        ];
+                        $oceId = Db::name('order_convey_end')->insertGetId($ocedata);
+                        if($oceId <= 0){
+                            exception("操作失败4");
+                        }
+                    }
+                }
+
+                if(!empty($v['to_user_ids'])){
+                    $uids = explode(',',$v['to_user_ids']);
+                    $sns = [];
+                    foreach ($uids as $kk=>$vv){
+                        $tododata = [
+                            'order_id' => $orderId,
+                            'to_user_id' => $vv,
+                            'todo_content' => $v['todo_content'],
+                            'org_id' => $v['org_id'],
+                            'create_time' => getTime(),
+                            'todo_mode' => 1,
+                            'work_type_mode' => 3,
+                            'create_yyyy' => date("Y"),
+                            'create_yyyymm' => date("Ym"),
+                            'create_yyyymmdd' => date("Ymd"),
+                        ];
+
+                        $tododata['sn'] = get_unique_sn(get_config('sn_prefix'));
+                        while (true){
+                            if(in_array($tododata['sn'],$sns)){
+                                $tododata['sn'] = get_unique_sn(get_config('sn_prefix'));
+                            }else{
+                                $sns[] = $tododata['sn'];
+                                break;
+                            }
+                        }
+
+                        $todoId = Db::name('todo')->insertGetId($tododata);
+                        if($todoId<=0){
+                            exception("操作失败5");
+                        }
+                    }
+                }
+
+                Db::name('convey_cron')->where('id',$v['id'])->update(['update_day'=>$curday,'update_time'=>getTime()]);
+            }
+            Db::commit();
+            return true;
+        }catch (\Exception $exception){
+            trace($exception->getMessage());
+            Db::rollback();
+            return false;
+        }
+    }
+
+}

+ 23 - 0
application/common/model/Orders.php

@@ -681,6 +681,29 @@ class Orders extends Base {
             $v['repair_priority'] = $typeInfo ? $typeInfo['repair_priority'] : '';
             $v['task_priority'] = $typeInfo?($typeInfo['repair_priority_index']==3?1:0):0;
 
+            $todo_mate = Db::name('todo_mate')
+                ->where('order_id',$v['id'])
+                ->select();
+
+            if(!empty($todo_mate)){
+                $cons = Db::name('todo_mate_item')
+                    ->alias('a')
+                    ->join('mate_goods b','b.id = a.items_id')
+                    ->where('a.todo_mate_id','in',array_column($todo_mate,'id'))
+                    ->field('a.*,b.title')
+                    ->select();
+                foreach ($cons as $k1=>$v1){
+                    $v['cons'][] = [
+                        'title' =>$v1['title'],
+                        'total' =>$v1['total'],
+                        'money' =>$v1['money'],
+                        'total_money' =>$v1['total_money'],
+                        'realName' =>$this->getTableField('user',['id'=>$v1['user_id']],'real_name'),
+                    ];
+
+                }
+            }
+
 
         }
         $v['type_name'] = '';

+ 1 - 1
application/common/model/WasteRecord.php

@@ -811,7 +811,7 @@ class WasteRecord extends Base {
     }
     public function getByDepDayList($wasteDeviceId,$orgId){
 
-        $typeList = model('WasteType')->getList();
+        $typeList = model('WasteType')->getList($orgId);
         $str  ='';
         foreach ($typeList as $k=>$v){
             $sum = Db::name('waste_record')

+ 35 - 0
application/common/validate/ConveyCron.php

@@ -0,0 +1,35 @@
+<?php
+namespace app\common\validate;
+
+use think\Validate;
+
+class ConveyCron extends Validate{
+
+    protected $rule = [
+        'dep_id'  =>  'require|gt:0',
+        'type'  =>  'require',
+        'start'  =>  'require',
+        'end'  =>  'require',
+        'xq_time'  =>  'require',
+        //'ywc_time'  =>  'require',
+        'priority'  =>  'require',
+        'week'  =>  'require',
+    ];
+
+    protected $message = [
+        'dep_id.require' => '请选择科室',
+        'dep_id.gt' => '请选择科室',
+        'type.require' => '请选择运送类型',
+        'start.require' => '请选择收取地点',
+        'end.require' => '请选择运送地点',
+        'xq_time.require' => '请选择需求时间',
+        'ywc_time.require' => '请选择应完成时间',
+        'priority.require' => '请选择运优先级',
+        'week.require' => '请选择日期',
+    ];
+
+    protected $scene = [
+
+    ];
+
+}

+ 29 - 0
application/cron/ConveyCron.php

@@ -0,0 +1,29 @@
+<?php
+namespace app\cron;
+
+use app\common\util\AppMsg;
+use think\Db;
+use yunwuxin\cron\Task;
+
+class ConveyCron extends Task
+{
+    public function configure()
+    {
+        $this->dailyAt("00:00"); //每天执行一次
+    }
+
+    /**
+     * 执行任务
+     * @return mixed
+     */
+    protected function execute()
+    {
+        try{
+           model("ConveyCron")->plan();
+        }catch (\Exception $e){
+            trace($e->getMessage());
+        }
+
+    }
+
+}

+ 2 - 2
application/h5/controller/Statistics.php

@@ -1260,8 +1260,8 @@ class Statistics extends Controller
 
         $wasteTypes = model("WasteType")->list1($this->orgId);
         foreach ($wasteTypes as $k=>$v){
-            $count = Db::name('waste_record')->where($map)->where('cateid',$v['waste_id'])->count();
-            $wasteTypes[$k]['count'] = $count;
+            $count = Db::name('waste_record')->where($map)->where('cateid',$v['waste_id'])->sum('weight');
+            $wasteTypes[$k]['count'] = round($count/1000,2)."kg";
         }
 
         $this->assign('wasteTypes',$wasteTypes);

+ 0 - 5
application/h5/view/statistics/waste.html

@@ -115,11 +115,6 @@
         <span class="daily-nums">{$v.count}</span>
     </div>
     {/volist}
-<!--    <div class="line"></div>-->
-<!--    <div class="record-data" onclick="deviceRecord(this)" data-day="{$type}" data-orgId="{$orgId}">-->
-<!--        <span class="daily-title">维护次数</span>-->
-<!--        <span class="daily-nums">{$allcount}</span>-->
-<!--    </div>-->
 </div>
 </body>
 </html>