wang jun před 3 měsíci
rodič
revize
2d4a91a5c8

+ 97 - 0
application/index/controller/Checkinfo.php

@@ -898,4 +898,101 @@ class Checkinfo extends Controller {
         $res_r['resultData'] = $filename;
         return json_encode($res_r, 320);
     }
+
+    /**
+     * 导出5天类有记工人员的清单
+     * 用户名,身份证号,手机号,工地名
+     *
+     * @return void
+     * @author wj
+     * @date 2025-02-17
+     */
+    public function hasreocdeuserlistexport() {
+
+        $m_cm = new checkmanger();
+        $ispost = request()->isPost();
+        $count = $m_cm->hasreocdeuserlist(true);
+
+        $size = 100;
+        $totalpage = ceil($count / $size);
+        if ($ispost) {
+            if (empty($count)) {
+                $res_r['code'] = 0;
+                $res_r['msg'] = '无数据';
+                $res_r['data'] = [];
+                return json_encode($res_r, 320);
+            }
+            $queryinfo = request()->param();
+            $pageNum = empty($queryinfo['pageNum']) ? 1 : $queryinfo['pageNum'];
+            $pageSize = empty($queryinfo['pageSize']) ? 10 : $queryinfo['pageSize'];
+            $list = $m_cm->hasreocdeuserlist(false, $pageNum, $pageSize);
+            $res_r['code'] = 200;
+            $res_r['msg'] = '查询成功';
+            $data = [
+                'count' => $count,
+                'pageNum' => $pageNum,
+                'pageSize' => $pageSize,
+                'list' => $list,
+            ];
+            $res_r['data'] = $data;
+            return json_encode($res_r, 320);
+        } else {
+            if (empty($count)) {
+                $this->error('无数据');
+            }
+            vendor('PHPExcel.PHPExcel');
+            $objPHPExcel = new \PHPExcel();
+            $pageindex = 0;
+            $objPHPExcel->setActiveSheetIndex($pageindex);
+            //5.设置表格头(即excel表格的第一行)
+            $objPHPExcel->setActiveSheetIndex($pageindex)
+                ->setCellValue('A1', '用户名')
+                ->setCellValue('B1', '身份证号')
+                ->setCellValue('C1', '手机号')
+                ->setCellValue('D1', '工地名');
+            $objPHPExcel->setActiveSheetIndex($pageindex)->getStyle('A')->getAlignment()
+                ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+            $objPHPExcel->setActiveSheetIndex($pageindex)->getStyle('B')->getAlignment()
+                ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+            $objPHPExcel->setActiveSheetIndex($pageindex)->getStyle('C')->getAlignment()
+                ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+            $objPHPExcel->setActiveSheetIndex($pageindex)->getStyle('D')->getAlignment()
+                ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+            $objPHPExcel->setActiveSheetIndex($pageindex)->getColumnDimension('A')->setWidth(20);
+            $objPHPExcel->setActiveSheetIndex($pageindex)->getColumnDimension('B')->setWidth(50);
+            $objPHPExcel->setActiveSheetIndex($pageindex)->getColumnDimension('C')->setWidth(20);
+            $objPHPExcel->setActiveSheetIndex($pageindex)->getColumnDimension('D')->setWidth(50);
+            $rowindex = 2;
+            for ($page = 1; $page <= $totalpage; $page++) {
+                $list = $m_cm->hasreocdeuserlist(false, $page, $size);
+                foreach ($list as $key => $value) {
+                    $wname = $value['wname'];
+                    $shengfengid = " " . $value['shengfengid'];
+                    $telno = $value['telno'];
+                    $pname = $value['pname'];
+                    $objPHPExcel->getActiveSheet()->setCellValue('A' . $rowindex, $wname);
+                    $objPHPExcel->getActiveSheet()->setCellValue('B' . $rowindex, $shengfengid);
+                    $objPHPExcel->getActiveSheet()->setCellValue('C' . $rowindex, $telno);
+                    $objPHPExcel->getActiveSheet()->setCellValue('D' . $rowindex, $pname);
+                    $rowindex += 1;
+                }
+                unset($list);
+            }
+            $title = '记工清单';
+            $objPHPExcel->getActiveSheet()->setTitle($title);
+            $filename = $title . "_" . date('ymd', time()) . '.xls';
+            $filename = urlencode($filename);
+
+            //9.设置浏览器窗口下载表格
+            header("Content-Type: application/force-download");
+            header("Content-Type: application/octet-stream");
+            header("Content-Type: application/download");
+            header('Content-Type: text/html; charset=utf-8');
+            header('Content-Disposition:inline;filename="' . $filename . '"');
+            //生成excel文件
+            $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
+            //下载文件在浏览器窗口
+            $objWriter->save('php://output');
+        }
+    }
 }

+ 140 - 130
application/index/logic/checkmanger.php

@@ -15,56 +15,56 @@ use app\index\model\ginfomodel;
 use app\index\model\wheadmodel;
 use app\index\model\gworkermodel;
 
-class checkmanger{
+class checkmanger {
     //20200203 日起停止使用,改从daycheckinfo中读取
-    public function getchecklistbyhead($checkhead,$checkdate,$checkshift){
-        $check_table=new checkinfomodel();
-        $list=$check_table->getchecklistbyheader($checkhead,$checkdate,$checkshift);
+    public function getchecklistbyhead($checkhead, $checkdate, $checkshift) {
+        $check_table = new checkinfomodel();
+        $list = $check_table->getchecklistbyheader($checkhead, $checkdate, $checkshift);
         return $list;
 
     }
 
     //20200203 日起使用,从daycheckinfo中读取
-    public function getchecklistbyheadwithdate($checkhead,$checkdate){
-        $daycheck_table=new daycheckinfo();
-        $list=$daycheck_table->getchecklistbyheadwithdate($checkhead,$checkdate);
+    public function getchecklistbyheadwithdate($checkhead, $checkdate) {
+        $daycheck_table = new daycheckinfo();
+        $list = $daycheck_table->getchecklistbyheadwithdate($checkhead, $checkdate);
         return $list;
 
     }
 
-  /*
-   *   getprjcheckoprbywid  于20200203日停止使用,仅保留代码
-   * */
+    /*
+     *   getprjcheckoprbywid  于20200203日停止使用,仅保留代码
+     * */
 
-    public function getprjcheckoprbywid($wid,$checkdate,$shift){
+    public function getprjcheckoprbywid($wid, $checkdate, $shift) {
         //获得项目ID
-        $pw_tabel=new pwrelationmodel();
-        $pid=$pw_tabel->getpidbywid($wid);
-        if ($pid>0){
+        $pw_tabel = new pwrelationmodel();
+        $pid = $pw_tabel->getpidbywid($wid);
+        if ($pid > 0) {
             //获取项目下,当天班次所有打分记录
-            $opr_t=new checkoprmodel();
-            $list=$opr_t->getoprinfobypid($pid,$checkdate,$shift);
+            $opr_t = new checkoprmodel();
+            $list = $opr_t->getoprinfobypid($pid, $checkdate, $shift);
             return $list;
-        }else{
+        } else {
             //此人无项目
-            $list=array();
+            $list = array();
             return $list;
         }
 
     }
     //20200203开始使用,按日汇总考勤,参数中去掉了班次参数
-    public function getheadcheckoprwithdate($wid,$checkdate){
+    public function getheadcheckoprwithdate($wid, $checkdate) {
         //获得项目ID
-        $pw_tabel=new pwrelationmodel();
-        $pid=$pw_tabel->getpidbywid($wid);
-        if ($pid>0){
+        $pw_tabel = new pwrelationmodel();
+        $pid = $pw_tabel->getpidbywid($wid);
+        if ($pid > 0) {
             //获取项目下,当天班次所有打分记录
-            $opr_t=new checkoprmodel();
-            $list=$opr_t->getoprinfobypid($pid,$checkdate);
+            $opr_t = new checkoprmodel();
+            $list = $opr_t->getoprinfobypid($pid, $checkdate);
             return $list;
-        }else{
+        } else {
             //此人无项目
-            $list=array();
+            $list = array();
             return $list;
         }
 
@@ -73,16 +73,15 @@ class checkmanger{
      * 20200403
      * 获取项目经理个人所有的记工记录
      */
-    public function getoprinfobyhid($arr){
-        $hid=$arr['hid'];
-        $startdate=date('Y-m-d',strtotime('-60 day'));
-        $opr_t=new checkoprmodel();
-        $list=$opr_t->seloprlistbyhid($hid,$startdate);
+    public function getoprinfobyhid($arr) {
+        $hid = $arr['hid'];
+        $startdate = date('Y-m-d', strtotime('-60 day'));
+        $opr_t = new checkoprmodel();
+        $list = $opr_t->seloprlistbyhid($hid, $startdate);
 
         return $list;
     }
 
-
     /*
      * 20200206
      * steelxu
@@ -91,49 +90,47 @@ class checkmanger{
      * 20200325
      * 加身份证号
      */
-    public function getsumcheckinfo($query_arr){
-        $month=$query_arr['monthinfo'];
-        $year=$query_arr['yearinfo'];
-        $pageNum=$query_arr['pageNum'];
-        $pageSize=$query_arr['pageSize'];
-        $start=($pageNum-1)*$pageSize;
-        if (strlen($month)==1){
-            $month='0'.$month;
+    public function getsumcheckinfo($query_arr) {
+        $month = $query_arr['monthinfo'];
+        $year = $query_arr['yearinfo'];
+        $pageNum = $query_arr['pageNum'];
+        $pageSize = $query_arr['pageSize'];
+        $start = ($pageNum - 1) * $pageSize;
+        if (strlen($month) == 1) {
+            $month = '0' . $month;
         }
-        $strmonth=$year.'-'.$month;
-        $dc_table=new daycheckinfo();
+        $strmonth = $year . '-' . $month;
+        $dc_table = new daycheckinfo();
         //20200421 为统计推荐奖金,启用新方法,
         //$r_list=$dc_table->countcheckbymonth($strmonth,$start,$pageSize);
         //20200421 含 奖励计算的新方法
-        $r_list=$dc_table->countcheckwithawardbymonth($strmonth,$start,$pageSize);
+        $r_list = $dc_table->countcheckwithawardbymonth($strmonth, $start, $pageSize);
 
         //获取所有工人信息
         //todo 此处在数据量大时可优化,可重写model层查询,只返回id和身份证,这样效率更高,现在暂时不用
-        $t_w=new gworkermodel();
-        $w_list=$t_w->selshengfengzhenglist();
-        $sfzlist=array();
-        foreach($w_list as $k){
-            $id=$k['id'];
-            if($k['shengfengid']){
-                $sfzlist[$id]=$k['shengfengid'];
-            }else{
-                $sfzlist[$id]='';
+        $t_w = new gworkermodel();
+        $w_list = $t_w->selshengfengzhenglist();
+        $sfzlist = array();
+        foreach ($w_list as $k) {
+            $id = $k['id'];
+            if ($k['shengfengid']) {
+                $sfzlist[$id] = $k['shengfengid'];
+            } else {
+                $sfzlist[$id] = '';
             }
 
         }
 
-
-
         //获得了总体数据,获取每日数据
         foreach ($r_list as &$v) {
-                $wid=$v['wid'];
-               $v['sfz']=$sfzlist[$wid];
-            $detail_arr=$dc_table->getcheckinfobywidwithmonth($wid,$strmonth);
-            foreach($detail_arr as $k){
-                $daystr=substr($k['checkdate'],-2);
+            $wid = $v['wid'];
+            $v['sfz'] = $sfzlist[$wid];
+            $detail_arr = $dc_table->getcheckinfobywidwithmonth($wid, $strmonth);
+            foreach ($detail_arr as $k) {
+                $daystr = substr($k['checkdate'], -2);
 //                echo $k['checkdate'];
 //                echo $daystr;
-                $v[$daystr]=$k['dayscore'];
+                $v[$daystr] = $k['dayscore'];
             }
         }
         return $r_list;
@@ -143,54 +140,54 @@ class checkmanger{
      * 20230215
      * 加上公司的
      */
-    public function getsumcompanycheckinfo($query_arr){
-        $month=$query_arr['monthinfo'];
-        $year=$query_arr['yearinfo'];
-        $pageNum=$query_arr['pageNum'];
-        $pageSize=$query_arr['pageSize'];
-        $cid=$query_arr['companyid'];
-        $start=($pageNum-1)*$pageSize;
-        if (strlen($month)==1){
-            $month='0'.$month;
+    public function getsumcompanycheckinfo($query_arr) {
+        $month = $query_arr['monthinfo'];
+        $year = $query_arr['yearinfo'];
+        $pageNum = $query_arr['pageNum'];
+        $pageSize = $query_arr['pageSize'];
+        $cid = $query_arr['companyid'];
+        $start = ($pageNum - 1) * $pageSize;
+        if (strlen($month) == 1) {
+            $month = '0' . $month;
         }
-        $strmonth=$year.'-'.$month;
-        $dc_table=new daycheckinfo();
+        $strmonth = $year . '-' . $month;
+        $dc_table = new daycheckinfo();
         //20200421 为统计推荐奖金,启用新方法,
         //$r_list=$dc_table->countcheckbymonth($strmonth,$start,$pageSize);
         //20200421 含 奖励计算的新方法
-       // $r_list=$dc_table->countcheckwithawardbymonth($strmonth,$start,$pageSize);
+        // $r_list=$dc_table->countcheckwithawardbymonth($strmonth,$start,$pageSize);
         //20230215 加上公司
-        $r_list=$dc_table->countcompanycheckwithawardbymonth($strmonth,$start,$pageSize,$cid);
+        $r_list = $dc_table->countcompanycheckwithawardbymonth($strmonth, $start, $pageSize, $cid);
         //获取所有工人信息
         //todo 此处在数据量大时可优化,可重写model层查询,只返回id和身份证,这样效率更高,现在暂时不用
         //身份证还是取全部的,因为人员会流动,无论那种方式都会有问题,最后再看如何优化
         // 问题在于,如果工人数量较多,再和工人身份证做连接,将是a*b的数量级的运算,
         //如果取出来,则是a+b的运算,
-        $t_w=new gworkermodel();
-        $w_list=$t_w->selshengfengzhenglist();
-       // $w_list=$t_w->selcompanyshengfengzhenglist($cid);
-        $sfzlist=array();
-        foreach($w_list as $k){
-            $id=$k['id'];
-            if($k['shengfengid']){
-                $sfzlist[$id]=$k['shengfengid'];
-            }else{
-                $sfzlist[$id]='';
+        $t_w = new gworkermodel();
+        $w_list = $t_w->selshengfengzhenglist();
+        // $w_list=$t_w->selcompanyshengfengzhenglist($cid);
+        $sfzlist = array();
+        foreach ($w_list as $k) {
+            $id = $k['id'];
+            if ($k['shengfengid']) {
+                $sfzlist[$id] = $k['shengfengid'];
+            } else {
+                $sfzlist[$id] = '';
             }
 
         }
 
         //获得了总体数据,获取每日数据
         foreach ($r_list as &$v) {
-            $wid=$v['wid'];
-            if($sfzlist[$wid]){
-                $v['sfz']=$sfzlist[$wid];
-                $detail_arr=$dc_table->getcheckinfobywidwithmonth($wid,$strmonth);
-                foreach($detail_arr as $k){
-                    $daystr=substr($k['checkdate'],-2);
+            $wid = $v['wid'];
+            if ($sfzlist[$wid]) {
+                $v['sfz'] = $sfzlist[$wid];
+                $detail_arr = $dc_table->getcheckinfobywidwithmonth($wid, $strmonth);
+                foreach ($detail_arr as $k) {
+                    $daystr = substr($k['checkdate'], -2);
 //                echo $k['checkdate'];
 //                echo $daystr;
-                    $v[$daystr]=$k['dayscore'];
+                    $v[$daystr] = $k['dayscore'];
                 }
             }
         }
@@ -204,31 +201,31 @@ class checkmanger{
      * 20200209 增加对操作记录的处理,在opr 表中增加一条 -1的记录
      * 20200307,增加对撤销时gid的撤销操作
      */
-    public function invokecheckbywid($query_arr){
-        $wid=$query_arr['wid'];
-        $checkdate=$query_arr['checkdate'];
-        $shift=$query_arr['shift'];
-        $id=$query_arr['id'];
-        $headid=$query_arr['headid'];
-        if (array_key_exists('gid',$query_arr)){
-            $gid=$query_arr['gid'];
-        }else{
-            $t_head=new wheadmodel();
-            $gid=$t_head->getgidbywid($wid);
+    public function invokecheckbywid($query_arr) {
+        $wid = $query_arr['wid'];
+        $checkdate = $query_arr['checkdate'];
+        $shift = $query_arr['shift'];
+        $id = $query_arr['id'];
+        $headid = $query_arr['headid'];
+        if (array_key_exists('gid', $query_arr)) {
+            $gid = $query_arr['gid'];
+        } else {
+            $t_head = new wheadmodel();
+            $gid = $t_head->getgidbywid($wid);
         }
-        $dc_table=new daycheckinfo();
-        $res=$dc_table->revokecheckshift($checkdate,$wid,$shift,$id);
-        $ginfo=new ginfomodel();
-        $pid=$ginfo->getpidbygid($gid);
-        $opr_arr['pid']=$pid;
-        $opr_arr['checkdate']=$checkdate;
-        $opr_arr['checkorder']=$shift;
-        $opr_arr['headid']=$headid;
-        $opr_arr['isopr']=1;
-        $opr_arr['gid']=$gid;
-        $opr_arr['wnum']=-1;
-        $opr_arr['oprtime']=date('Y:m:d H:i:s');
-        $oprtable=new checkoprmodel();
+        $dc_table = new daycheckinfo();
+        $res = $dc_table->revokecheckshift($checkdate, $wid, $shift, $id);
+        $ginfo = new ginfomodel();
+        $pid = $ginfo->getpidbygid($gid);
+        $opr_arr['pid'] = $pid;
+        $opr_arr['checkdate'] = $checkdate;
+        $opr_arr['checkorder'] = $shift;
+        $opr_arr['headid'] = $headid;
+        $opr_arr['isopr'] = 1;
+        $opr_arr['gid'] = $gid;
+        $opr_arr['wnum'] = -1;
+        $opr_arr['oprtime'] = date('Y:m:d H:i:s');
+        $oprtable = new checkoprmodel();
         $oprtable->saveOprRecord($opr_arr);
 
         return $res;
@@ -243,23 +240,23 @@ class checkmanger{
      * 取出时只有当时所在的班组才能修改,换了班组则不可以
      *
      */
-    public function getheadoprwithshift($query_arr){
-        $headid=$query_arr['wid'];
-        $checkdate=$query_arr['checkdate'];
-        $shift=$query_arr['shift'];
+    public function getheadoprwithshift($query_arr) {
+        $headid = $query_arr['wid'];
+        $checkdate = $query_arr['checkdate'];
+        $shift = $query_arr['shift'];
         //获取班组
-        $ghead=new wheadmodel();
-        $gid=$ghead->getgidbywid($headid);
+        $ghead = new wheadmodel();
+        $gid = $ghead->getgidbywid($headid);
 
-        $dc_table=new daycheckinfo();
-        $rlist=$dc_table->getlistbyheadwithshift($checkdate,$shift,$headid,$gid);
+        $dc_table = new daycheckinfo();
+        $rlist = $dc_table->getlistbyheadwithshift($checkdate, $shift, $headid, $gid);
         return $rlist;
     }
 
-    public function getworkovertime($pagenum,$pagesize){
-        $start=($pagenum-1)*$pagesize;
-        $t_dayscore=new daycheckinfo();
-        $rlist=$t_dayscore->selscorewithprjbyscore($start,$pagesize);
+    public function getworkovertime($pagenum, $pagesize) {
+        $start = ($pagenum - 1) * $pagesize;
+        $t_dayscore = new daycheckinfo();
+        $rlist = $t_dayscore->selscorewithprjbyscore($start, $pagesize);
         return $rlist;
     }
 
@@ -267,11 +264,24 @@ class checkmanger{
      * 20230215
      * 修改查加班的功能,只能查本公司的
      */
-    public function getworkovertimebycid($pagenum,$pagesize,$cid){
-        $start=($pagenum-1)*$pagesize;
-        $t_dayscore=new daycheckinfo();
-        $rlist=$t_dayscore->selscorewithprjbyscorecid($start,$pagesize,$cid);
+    public function getworkovertimebycid($pagenum, $pagesize, $cid) {
+        $start = ($pagenum - 1) * $pagesize;
+        $t_dayscore = new daycheckinfo();
+        $rlist = $t_dayscore->selscorewithprjbyscorecid($start, $pagesize, $cid);
         return $rlist;
     }
+    /**
+     * 5天内有记工人员列表
+     *
+     * @return void
+     * @author wj
+     * @date 2025-02-18
+     */
+    public function hasreocdeuserlist($iscount = false, $page = 1, $size = 10) {
+        $day_num = 5;
+        $m_dc = new daycheckinfo();
+        $data = $m_dc->hasreocdeuserlistwithdays($day_num, $iscount, $page, $size);
+        return $data;
+    }
 
 }

+ 193 - 165
application/index/model/daycheckinfo.php

@@ -9,8 +9,8 @@
 namespace app\index\model;
 use think\Model;
 
-class daycheckinfo extends Model{
-    protected $table='t_daycheckinfo';
+class daycheckinfo extends Model {
+    protected $table = 't_daycheckinfo';
 
     //  是否存在相庆的记录
     /*
@@ -19,55 +19,55 @@ class daycheckinfo extends Model{
      * 因为更换工地当天,存在误操作
      * 因在源头解决,所以此修改取消
      */
-    public  function getinfobywid($pid,$checkdate,$wid){
-        $where_arr['wid']=$wid;
+    public function getinfobywid($pid, $checkdate, $wid) {
+        $where_arr['wid'] = $wid;
         //$where_arr['pid']=$pid;//20200416,取消此条件,同一个,同一天只能有一个记录,这样可能导致工地记录不准确,
-        $where_arr['checkdate']=$checkdate;
-        $rec=$this->where($where_arr)->find();
+        $where_arr['checkdate'] = $checkdate;
+        $rec = $this->where($where_arr)->find();
         return $rec;
     }
 
     //新增
-    public function addnewcheck($checkinfo){
+    public function addnewcheck($checkinfo) {
         //判断是否存在
-        $pid=$checkinfo['pid'];
-        $checkdate=$checkinfo['checkdate'];
-        $wid=$checkinfo['wid'];
+        $pid = $checkinfo['pid'];
+        $checkdate = $checkinfo['checkdate'];
+        $wid = $checkinfo['wid'];
 
-        $rec=$this->getinfobywid($pid,$checkdate,$wid);
+        $rec = $this->getinfobywid($pid, $checkdate, $wid);
 
-        if (empty($rec)){
+        if (empty($rec)) {
 
-           $this->isUpdate(false)->setAttr('id',null)->save($checkinfo);
-            $rid=$this->id;
+            $this->isUpdate(false)->setAttr('id', null)->save($checkinfo);
+            $rid = $this->id;
 
-        }else{
-           $rid=$rec['id'];
-            $this->updatebycheck($checkinfo,$rid);
+        } else {
+            $rid = $rec['id'];
+            $this->updatebycheck($checkinfo, $rid);
 
         }
-       $this->addtwoshift($rid);
+        $this->addtwoshift($rid);
         return $rid;
 
     }
 
-    public function updatebycheck($checkinfo,$id){
-        $where_arr['id']=$id;
-        $rid=$this->where($where_arr)->update($checkinfo);
+    public function updatebycheck($checkinfo, $id) {
+        $where_arr['id'] = $id;
+        $rid = $this->where($where_arr)->update($checkinfo);
         return $rid;
     }
 
-    private function addtwoshift($id){
-        $stradd='update t_daycheckinfo ';
-        $stradd=$stradd." set dayscore=if(isnull(score_1),0,score_1)+if(isnull(score_2),0,score_2)";
-        $stradd=$stradd." where id=".$id;
+    private function addtwoshift($id) {
+        $stradd = 'update t_daycheckinfo ';
+        $stradd = $stradd . " set dayscore=if(isnull(score_1),0,score_1)+if(isnull(score_2),0,score_2)";
+        $stradd = $stradd . " where id=" . $id;
         $this->execute($stradd);
 
     }
 
-    public function getusercheckinfobywid($wid){
-        $where_arr['wid']=$wid;
-        $list=$this->where($where_arr)->order('checkdate')->select();
+    public function getusercheckinfobywid($wid) {
+        $where_arr['wid'] = $wid;
+        $list = $this->where($where_arr)->order('checkdate')->select();
         return $list;
     }
     /*
@@ -75,20 +75,20 @@ class daycheckinfo extends Model{
      * steelxu
      * 按月,按人查询的端口
      */
-    public function getusercheckinfobywidwithmonth($wid,$strmonth){
-        $strsql="select *";
-        $strsql=$strsql." from t_daycheckinfo";
-        $strsql=$strsql." where wid=".$wid." and checkdate like '".$strmonth."%'";
-        $strsql=$strsql." order by checkdate";
-        $list=$this->query($strsql);
+    public function getusercheckinfobywidwithmonth($wid, $strmonth) {
+        $strsql = "select *";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where wid=" . $wid . " and checkdate like '" . $strmonth . "%'";
+        $strsql = $strsql . " order by checkdate";
+        $list = $this->query($strsql);
         return $list;
     }
 
-    public function getchecklistbyheadwithdate($headid,$checkdate){
-        $strsql="select *";
-        $strsql=$strsql." from t_daycheckinfo";
-        $strsql=$strsql." where checkdate='".$checkdate."' and ((headid_1=".$headid.") or (headid_2=".$headid."))";
-        $rlist=$this->query($strsql);
+    public function getchecklistbyheadwithdate($headid, $checkdate) {
+        $strsql = "select *";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where checkdate='" . $checkdate . "' and ((headid_1=" . $headid . ") or (headid_2=" . $headid . "))";
+        $rlist = $this->query($strsql);
         return $rlist;
 
     }
@@ -101,16 +101,16 @@ class daycheckinfo extends Model{
      * 20200401
      * 修改,测试项目记录的不导出
      */
-    public function countcheckbymonth($formatmonth,$start,$len){
-        $strsql= "select wid,wname,count(dayscore) as daycount,sum(dayscore) as monthsum ";
-        $strsql=$strsql." from t_daycheckinfo ";
-        $strsql=$strsql." where checkdate like '".$formatmonth."%' and pid>3 and dayscore>0" ;//
-        $strsql=$strsql." group by wid";
-        if ($len>0){
+    public function countcheckbymonth($formatmonth, $start, $len) {
+        $strsql = "select wid,wname,count(dayscore) as daycount,sum(dayscore) as monthsum ";
+        $strsql = $strsql . " from t_daycheckinfo ";
+        $strsql = $strsql . " where checkdate like '" . $formatmonth . "%' and pid>3 and dayscore>0"; //
+        $strsql = $strsql . " group by wid";
+        if ($len > 0) {
             //导出到execl时,传入 $len参数为0,不加此行,导出所有数据
-            $strsql=$strsql." limit ".$start.",".$len;
+            $strsql = $strsql . " limit " . $start . "," . $len;
         }
-        $rlist=$this->query($strsql);
+        $rlist = $this->query($strsql);
         return $rlist;
     }
     /*
@@ -119,16 +119,16 @@ class daycheckinfo extends Model{
      * 从架构上而言,这是一种临时的省事的做法,
      * 再有新的奖励,就必须创建一个奖励类来处理业务逻辑,再合并到输出中
      */
-    public function countcheckwithawardbymonth($formatmonth,$start,$len){
-            $strsql= "select a.wid,a.wname,count(a.dayscore) as daycount,sum(a.dayscore) as monthsum,b.sumaward";
-        $strsql=$strsql." from t_daycheckinfo a left join t_recuitaward b on a.wid=b.recuituser and b.summonth='".$formatmonth."'";
-        $strsql=$strsql." where checkdate like '".$formatmonth."%' and pid>3 and dayscore>0" ;//
-        $strsql=$strsql." group by wid";
-        if ($len>0){
+    public function countcheckwithawardbymonth($formatmonth, $start, $len) {
+        $strsql = "select a.wid,a.wname,count(a.dayscore) as daycount,sum(a.dayscore) as monthsum,b.sumaward";
+        $strsql = $strsql . " from t_daycheckinfo a left join t_recuitaward b on a.wid=b.recuituser and b.summonth='" . $formatmonth . "'";
+        $strsql = $strsql . " where checkdate like '" . $formatmonth . "%' and pid>3 and dayscore>0"; //
+        $strsql = $strsql . " group by wid";
+        if ($len > 0) {
             //导出到execl时,传入 $len参数为0,不加此行,导出所有数据
-            $strsql=$strsql." limit ".$start.",".$len;
+            $strsql = $strsql . " limit " . $start . "," . $len;
         }
-        $rlist=$this->query($strsql);
+        $rlist = $this->query($strsql);
         return $rlist;
     }
 
@@ -136,16 +136,16 @@ class daycheckinfo extends Model{
      * 20230215
      * 在原有的方式上,加上一个公司id来处理
      */
-    public function countcompanycheckwithawardbymonth($formatmonth,$start,$len,$cid){
-        $strsql= "select a.wid,a.wname,count(a.dayscore) as daycount,sum(a.dayscore) as monthsum,b.sumaward";
-        $strsql=$strsql." from t_daycheckinfo a left join t_recuitaward b on a.wid=b.recuituser and b.summonth='".$formatmonth."' left join t_pinfo c on a.pid=c.id";
-        $strsql=$strsql." where checkdate like '".$formatmonth."%' and c.companyid=".$cid." and dayscore>0" ;//
-        $strsql=$strsql." group by wid";
-        if ($len>0){
+    public function countcompanycheckwithawardbymonth($formatmonth, $start, $len, $cid) {
+        $strsql = "select a.wid,a.wname,count(a.dayscore) as daycount,sum(a.dayscore) as monthsum,b.sumaward";
+        $strsql = $strsql . " from t_daycheckinfo a left join t_recuitaward b on a.wid=b.recuituser and b.summonth='" . $formatmonth . "' left join t_pinfo c on a.pid=c.id";
+        $strsql = $strsql . " where checkdate like '" . $formatmonth . "%' and c.companyid=" . $cid . " and dayscore>0"; //
+        $strsql = $strsql . " group by wid";
+        if ($len > 0) {
             //导出到execl时,传入 $len参数为0,不加此行,导出所有数据
-            $strsql=$strsql." limit ".$start.",".$len;
+            $strsql = $strsql . " limit " . $start . "," . $len;
         }
-        $rlist=$this->query($strsql);
+        $rlist = $this->query($strsql);
         return $rlist;
     }
 
@@ -154,12 +154,12 @@ class daycheckinfo extends Model{
      * steelxu
      * 获取某员工某月的记工记录
      */
-    public function getcheckinfobywidwithmonth($wid,$strmonth){
-        $strsql= "select * ";
-        $strsql=$strsql." from t_daycheckinfo ";
-        $strsql=$strsql." where wid=".$wid." and checkdate like '".$strmonth."%' and pid>3";//
-        $strsql=$strsql." order by checkdate ";
-        $rlist=$this->query($strsql);
+    public function getcheckinfobywidwithmonth($wid, $strmonth) {
+        $strsql = "select * ";
+        $strsql = $strsql . " from t_daycheckinfo ";
+        $strsql = $strsql . " where wid=" . $wid . " and checkdate like '" . $strmonth . "%' and pid>3"; //
+        $strsql = $strsql . " order by checkdate ";
+        $rlist = $this->query($strsql);
         return $rlist;
     }
 
@@ -169,11 +169,11 @@ class daycheckinfo extends Model{
      * 取消某员工某班次的记录
      * 本函数未更新操作记录
      */
-    public function revokecheckshift($checkdate,$wid,$shift,$id){
-        $strsql="update t_daycheckinfo";
-        $strsql=$strsql." set score_".$shift."=0,headid_".$shift."=0,gid_".$shift."=0";
-        $strsql=$strsql." where checkdate='".$checkdate."' and wid=".$wid;
-       $res=$this->execute($strsql);
+    public function revokecheckshift($checkdate, $wid, $shift, $id) {
+        $strsql = "update t_daycheckinfo";
+        $strsql = $strsql . " set score_" . $shift . "=0,headid_" . $shift . "=0,gid_" . $shift . "=0";
+        $strsql = $strsql . " where checkdate='" . $checkdate . "' and wid=" . $wid;
+        $res = $this->execute($strsql);
         $this->addtwoshift($id);
         return $res;
     }
@@ -183,11 +183,11 @@ class daycheckinfo extends Model{
      * steelxu
      * 解决班组长可以撤销操作记录的功能
      */
-    public function getlistbyheadwithshift($checkdate,$shift,$headid,$gid){
-        $strsql="select id,wid,wname,checkdate,score_".$shift." as score";
-        $strsql=$strsql." from t_daycheckinfo";
-        $strsql=$strsql." where checkdate='".$checkdate."' and headid_".$shift."=".$headid." and gid_".$shift."=".$gid;
-        $rlist=$this->query($strsql);
+    public function getlistbyheadwithshift($checkdate, $shift, $headid, $gid) {
+        $strsql = "select id,wid,wname,checkdate,score_" . $shift . " as score";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where checkdate='" . $checkdate . "' and headid_" . $shift . "=" . $headid . " and gid_" . $shift . "=" . $gid;
+        $rlist = $this->query($strsql);
 
         return $rlist;
 
@@ -198,31 +198,31 @@ class daycheckinfo extends Model{
      * steelxu
      * 按月给工人汇总工分
      */
-    public function totalcheckbymonthwithwid($wid){
-        $strsql="select wid,wname,left(checkdate,7) as strmonth,count(*) as daycount,sum(dayscore) as monthsum";
-        $strsql=$strsql." from t_daycheckinfo";
-        $strsql=$strsql." where wid=".$wid;
-        $strsql=$strsql." group by left(checkdate,7)";
-        $strsql=$strsql." order by left(checkdate,7) desc";
-        $rlist=$this->query($strsql);
+    public function totalcheckbymonthwithwid($wid) {
+        $strsql = "select wid,wname,left(checkdate,7) as strmonth,count(*) as daycount,sum(dayscore) as monthsum";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where wid=" . $wid;
+        $strsql = $strsql . " group by left(checkdate,7)";
+        $strsql = $strsql . " order by left(checkdate,7) desc";
+        $rlist = $this->query($strsql);
         return $rlist;
     }
 
-     /*
-      * 20200307
-      * 做一个查加班的记录
-      * 此记录是单独记录,但不是
-      *
-      */
-
-    public function selscorewithprjbyscore($start,$len){
-        $strsql="select a.wid,a.wname,a.checkdate,a.score_1,b.wname as mname_1,a.score_2,c.wname as mname_2,d.pname as prjname ";
-        $strsql=$strsql." from t_daycheckinfo a INNER JOIN t_workerinfo b on a.headid_1=b.id INNER JOIN t_workerinfo c on a.headid_2=c.id INNER JOIN t_pinfo d on a.pid=d.id";
-        $strsql=$strsql." where score_1>5 or score_2>5 ";
-        $strsql=$strsql." order by a.pid,a.wid";
-        $strsql=$strsql." limit $start,$len";
-
-        $rlist=$this->query($strsql);
+    /*
+     * 20200307
+     * 做一个查加班的记录
+     * 此记录是单独记录,但不是
+     *
+     */
+
+    public function selscorewithprjbyscore($start, $len) {
+        $strsql = "select a.wid,a.wname,a.checkdate,a.score_1,b.wname as mname_1,a.score_2,c.wname as mname_2,d.pname as prjname ";
+        $strsql = $strsql . " from t_daycheckinfo a INNER JOIN t_workerinfo b on a.headid_1=b.id INNER JOIN t_workerinfo c on a.headid_2=c.id INNER JOIN t_pinfo d on a.pid=d.id";
+        $strsql = $strsql . " where score_1>5 or score_2>5 ";
+        $strsql = $strsql . " order by a.pid,a.wid";
+        $strsql = $strsql . " limit $start,$len";
+
+        $rlist = $this->query($strsql);
         return $rlist;
 
     }
@@ -231,14 +231,14 @@ class daycheckinfo extends Model{
      * 20230215
      * 修改查加班的记录的功能 ,只能查自己公司的
      */
-    public function selscorewithprjbyscorecid($start,$len,$cid){
-        $strsql="select a.wid,a.wname,a.checkdate,a.score_1,b.wname as mname_1,a.score_2,c.wname as mname_2,d.pname as prjname ";
-        $strsql=$strsql." from t_daycheckinfo a INNER JOIN t_workerinfo b on a.headid_1=b.id INNER JOIN t_workerinfo c on a.headid_2=c.id INNER JOIN t_pinfo d on a.pid=d.id";
-        $strsql=$strsql." where (a.score_1>5 or a.score_2>5) and d.companyid=".$cid;
-        $strsql=$strsql." order by a.pid,a.wid";
-        $strsql=$strsql." limit $start,$len";
-
-        $rlist=$this->query($strsql);
+    public function selscorewithprjbyscorecid($start, $len, $cid) {
+        $strsql = "select a.wid,a.wname,a.checkdate,a.score_1,b.wname as mname_1,a.score_2,c.wname as mname_2,d.pname as prjname ";
+        $strsql = $strsql . " from t_daycheckinfo a INNER JOIN t_workerinfo b on a.headid_1=b.id INNER JOIN t_workerinfo c on a.headid_2=c.id INNER JOIN t_pinfo d on a.pid=d.id";
+        $strsql = $strsql . " where (a.score_1>5 or a.score_2>5) and d.companyid=" . $cid;
+        $strsql = $strsql . " order by a.pid,a.wid";
+        $strsql = $strsql . " limit $start,$len";
+
+        $rlist = $this->query($strsql);
         return $rlist;
 
     }
@@ -246,19 +246,18 @@ class daycheckinfo extends Model{
     /*
      * 20200308 完成按班组统计的数据
      */
-    public function selsuminfobygid($gid,$strmonth){
-       // $datenow=date('Y-m-d');
-        $strsql="select checkdate,sum(case when gid_1=$gid then score_1 else 0 end) as d_score_1,sum(case  when gid_2=$gid then score_2 else 0 end) as d_score_2";
-        $strsql=$strsql." from t_daycheckinfo";
-        $strsql=$strsql." where checkdate like '$strmonth%'";
-        $strsql=$strsql." group by checkdate";
+    public function selsuminfobygid($gid, $strmonth) {
+        // $datenow=date('Y-m-d');
+        $strsql = "select checkdate,sum(case when gid_1=$gid then score_1 else 0 end) as d_score_1,sum(case  when gid_2=$gid then score_2 else 0 end) as d_score_2";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where checkdate like '$strmonth%'";
+        $strsql = $strsql . " group by checkdate";
 
 //        echo $strsql;
 //        echo '<br>';
-        $rlist=$this->query($strsql);
+        $rlist = $this->query($strsql);
         return $rlist;
 
-
     }
 
     /*
@@ -266,30 +265,30 @@ class daycheckinfo extends Model{
      * 按项目,起始日期,统计出勤记录
      *
      */
-     public function selcinfowithdate($startday,$endday,$pid){
-         $strsql="select checkdate,pid,count(*) as workernumber ";
-         $strsql=$strsql." from t_daycheckinfo";
-         $strsql=$strsql." where checkdate>='".$startday."' and checkdate<='".$endday."' and pid=".$pid;
-         $strsql=$strsql." group by checkdate";
-
-         $r_list=$this->query($strsql);
-         return $r_list;
-     }
+    public function selcinfowithdate($startday, $endday, $pid) {
+        $strsql = "select checkdate,pid,count(*) as workernumber ";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where checkdate>='" . $startday . "' and checkdate<='" . $endday . "' and pid=" . $pid;
+        $strsql = $strsql . " group by checkdate";
+
+        $r_list = $this->query($strsql);
+        return $r_list;
+    }
 
     /*
      * 20200315
      * 实现按班组按人的统计
      */
-    public function selworksumbygidwithdate($gid,$strmonth){
+    public function selworksumbygidwithdate($gid, $strmonth) {
         // $datenow=date('Y-m-d');
-        $strsql="select checkdate,wid,wname,sum(case when gid_1=$gid then score_1 else 0 end) as d_score_1,sum(case  when gid_2=$gid then score_2 else 0 end) as d_score_2";
-        $strsql=$strsql." from t_daycheckinfo";
-        $strsql=$strsql." where checkdate like '$strmonth%'";
-        $strsql=$strsql." group by checkdate,wid";
-        $strsql=$strsql." having d_score_1>0 or d_score_2>0";
+        $strsql = "select checkdate,wid,wname,sum(case when gid_1=$gid then score_1 else 0 end) as d_score_1,sum(case  when gid_2=$gid then score_2 else 0 end) as d_score_2";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where checkdate like '$strmonth%'";
+        $strsql = $strsql . " group by checkdate,wid";
+        $strsql = $strsql . " having d_score_1>0 or d_score_2>0";
 //        echo $strsql;
 //        echo '<br>';
-        $rlist=$this->query($strsql);
+        $rlist = $this->query($strsql);
         return $rlist;
 
     }
@@ -299,18 +298,18 @@ class daycheckinfo extends Model{
      * 获取某员工某一时间段的工作记录
      *
      */
-    public function selcountbyidwithdate($id,$bdate,$edate){
-        $strsql="select wid,checkdate, sum(dayscore) as sumds";
-        $strsql=$strsql." from t_daycheckinfo";
-        $strsql=$strsql." where wid=$id and checkdate>='".$bdate."' and checkdate<='".$edate."'";
-        $strsql=$strsql." group by checkdate";
-        $strsql=$strsql." having sumds>=10";
-
-        $rlist=$this->query($strsql);
-        if($rlist){
-            $rlist=collection($rlist)->toArray();
+    public function selcountbyidwithdate($id, $bdate, $edate) {
+        $strsql = "select wid,checkdate, sum(dayscore) as sumds";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where wid=$id and checkdate>='" . $bdate . "' and checkdate<='" . $edate . "'";
+        $strsql = $strsql . " group by checkdate";
+        $strsql = $strsql . " having sumds>=10";
+
+        $rlist = $this->query($strsql);
+        if ($rlist) {
+            $rlist = collection($rlist)->toArray();
             return count($rlist);
-        }else{
+        } else {
             return 0;
         }
     }
@@ -319,43 +318,72 @@ class daycheckinfo extends Model{
      * 20200729
      * 根据GID获取已取班次已经记工的人数
      */
-    public function selcountbygid($gid,$checkdate,$shift){
-        $strsql="select count(id) as checkcount";
-        $strsql=$strsql." from t_daycheckinfo";
-        $strsql=$strsql." where gid_$shift=$gid and checkdate='".$checkdate."' and score_$shift>0";
-        $count=$this->query($strsql);
-        $count=collection($count)->toArray();
+    public function selcountbygid($gid, $checkdate, $shift) {
+        $strsql = "select count(id) as checkcount";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where gid_$shift=$gid and checkdate='" . $checkdate . "' and score_$shift>0";
+        $count = $this->query($strsql);
+        $count = collection($count)->toArray();
         return $count;
     }
 
     /*
      * 20210807
      */
-    public function selscorebyidwithdays($id,$bdate){
-        $strsql="select wid,checkdate, sum(dayscore) as sumds";
-        $strsql=$strsql." from t_daycheckinfo";
-        $strsql=$strsql." where wid=$id and checkdate>='".$bdate."'";
-
-
-        $rlist=$this->query($strsql);
-        if($rlist){
-            $rlist=collection($rlist)->toArray();
+    public function selscorebyidwithdays($id, $bdate) {
+        $strsql = "select wid,checkdate, sum(dayscore) as sumds";
+        $strsql = $strsql . " from t_daycheckinfo";
+        $strsql = $strsql . " where wid=$id and checkdate>='" . $bdate . "'";
+
+        $rlist = $this->query($strsql);
+        if ($rlist) {
+            $rlist = collection($rlist)->toArray();
             return count($rlist);
-        }else{
+        } else {
             return 0;
         }
     }
 
-
     /*
      * 20230215
      */
-    public function selinfobyid($id){
-        $where['id']=$id;
-        $rec=$this->where($where)->find();
+    public function selinfobyid($id) {
+        $where['id'] = $id;
+        $rec = $this->where($where)->find();
         return $rec;
 
     }
-
+    /**
+     * N天内有记工人员的清单
+     *
+     * @return void
+     * @author wj
+     * @date 2025-02-17
+     */
+    public function hasreocdeuserlistwithdays($day_num, $iscount = false, $page = 1, $size = 10) {
+        $index = ($page - 1) * $size;
+        $day = date('Y-m-d', strtotime('-' . $day_num . ' day'));
+        $today = date('Y-m-d');
+        $sql1 = "select max(dc_id) from (select dc.id as dc_id,dc.wid,p.id,w.wname,w.shengfengid,w.telno,p.pname from t_daycheckinfo as dc join t_workerinfo as w on w.id=dc.wid join t_pinfo as p on dc.pid = p.id where checkdate BETWEEN '" . $day . "' and '" . $today . "' ORDER BY dc.checkdate desc) as tab
+            GROUP BY wname,pname";
+        if ($iscount) {
+            $sql = "
+            select count(dc.id) as count from t_daycheckinfo as dc join t_workerinfo as w on w.id=dc.wid join t_pinfo as p on dc.pid = p.id where checkdate BETWEEN '" . $day . "' and '" . $today . "' and dc.id in (" . $sql1 . ")";
+            $count = $this->query($sql);
+            $data = $count[0]['count'];
+        } else {
+            $sql = "
+            select dc.id as dc_id,dc.wid,dc.checkdate,p.id,w.wname,w.shengfengid,w.telno,p.pname from t_daycheckinfo as dc join t_workerinfo as w on w.id=dc.wid join t_pinfo as p on dc.pid = p.id where checkdate BETWEEN '" . $day . "' and '" . $today . "' and dc.id in ("
+                . $sql1 .
+                ") ORDER BY dc.checkdate desc limit " . $index . "," . $size;
+            $list = $this->query($sql);
+            if ($list) {
+                $data = collection($list)->toArray();
+            } else {
+                $data = [];
+            }
+        }
+        return $data;
+    }
 
 }