checkoprmodel.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: sicilon_IT
  5. * Date: 2020/1/13
  6. * Time: 9:13
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class checkoprmodel extends Model{
  11. protected $table='t_headcheckrecord';
  12. //
  13. public function getShiftbyWid($wid){
  14. $datenow=date('Y-m-d ');
  15. $datestart=date('Y-m-d',strtotime('-1 day'));
  16. //暂时取今天昨天
  17. $strsql="select * from t_headcheckrecord";
  18. $strsql=$strsql." where checkdate<='".$datenow."' and checkdate>='".$datestart."' and headid=".$wid." and isopr=1";
  19. //$wherearr['checkdate']=$datestart;
  20. $recordlist=$this->query($strsql);
  21. return $recordlist;
  22. }
  23. public function saveOprRecord($oprinfo){
  24. $id=$this->save($oprinfo);
  25. return $id;
  26. }
  27. public function getoprinfobypid($pid,$checkdate){
  28. // $where_arr['pid']=$pid;
  29. // $where_arr['checkdate']=$checkdate;
  30. // $where_arr['checkorder']=$checkshift;
  31. //采用语句查询,
  32. //20200203 改成按日,汇总,不再区分班次
  33. $strsql="select a.checkdate,a.checkorder,a.pid,a.headid,sum(a.wnum) as countwnum,b.wname";
  34. $strsql=$strsql." from t_headcheckrecord a left join t_workerinfo b on a.headid=b.id";
  35. // $strsql=$strsql.' where pid='.$pid." and checkdate='".$checkdate."' and checkorder=".$checkshift;
  36. $strsql=$strsql.' where pid='.$pid." and checkdate='".$checkdate."' ";
  37. $strsql=$strsql." group by headid";
  38. $list=$this->query($strsql);
  39. return $list;
  40. }
  41. /*
  42. * 20200402
  43. * 获取项目经理的记工记录
  44. * 这个功能在这种情况下可能会出现错误,即同一个项目经理,上下午在不同工地的时候
  45. * 需要在获取详情的代码中查看,是否有此问题
  46. * 按大于某一天查询
  47. */
  48. public function seloprlistbyhid($hid,$startdate){
  49. $strsql="select a.checkdate,a.checkorder,a.pid,a.headid,sum(a.wnum) as countwnum,b.wname";
  50. $strsql=$strsql." from t_headcheckrecord a left join t_workerinfo b on a.headid=b.id";
  51. // $strsql=$strsql.' where pid='.$pid." and checkdate='".$checkdate."' and checkorder=".$checkshift;
  52. $strsql=$strsql.' where headid='.$hid." and checkdate > '".$startdate."' ";
  53. $strsql=$strsql." group by checkdate";
  54. $strsql=$strsql." having countwnum>0";
  55. $list=$this->query($strsql);
  56. return $list;
  57. }
  58. /*
  59. * 20230215
  60. */
  61. public function selinfobyid($id){
  62. $where['id']=$id;
  63. $rec=$this->where($where)->find();
  64. return $rec;
  65. }
  66. }