checkmanger.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: sicilon_IT
  5. * Date: 2020/1/30
  6. * Time: 10:59
  7. */
  8. namespace app\index\logic;
  9. use app\index\model\checkinfomodel;
  10. use app\index\model\checkoprmodel;
  11. use app\index\model\pwrelationmodel;
  12. use app\index\model\daycheckinfo;
  13. use app\index\model\ginfomodel;
  14. use app\index\model\wheadmodel;
  15. use app\index\model\gworkermodel;
  16. class checkmanger {
  17. //20200203 日起停止使用,改从daycheckinfo中读取
  18. public function getchecklistbyhead($checkhead, $checkdate, $checkshift) {
  19. $check_table = new checkinfomodel();
  20. $list = $check_table->getchecklistbyheader($checkhead, $checkdate, $checkshift);
  21. return $list;
  22. }
  23. //20200203 日起使用,从daycheckinfo中读取
  24. public function getchecklistbyheadwithdate($checkhead, $checkdate) {
  25. $daycheck_table = new daycheckinfo();
  26. $list = $daycheck_table->getchecklistbyheadwithdate($checkhead, $checkdate);
  27. return $list;
  28. }
  29. /*
  30. * getprjcheckoprbywid 于20200203日停止使用,仅保留代码
  31. * */
  32. public function getprjcheckoprbywid($wid, $checkdate, $shift) {
  33. //获得项目ID
  34. $pw_tabel = new pwrelationmodel();
  35. $pid = $pw_tabel->getpidbywid($wid);
  36. if ($pid > 0) {
  37. //获取项目下,当天班次所有打分记录
  38. $opr_t = new checkoprmodel();
  39. $list = $opr_t->getoprinfobypid($pid, $checkdate, $shift);
  40. return $list;
  41. } else {
  42. //此人无项目
  43. $list = array();
  44. return $list;
  45. }
  46. }
  47. //20200203开始使用,按日汇总考勤,参数中去掉了班次参数
  48. public function getheadcheckoprwithdate($wid, $checkdate) {
  49. //获得项目ID
  50. $pw_tabel = new pwrelationmodel();
  51. $pid = $pw_tabel->getpidbywid($wid);
  52. if ($pid > 0) {
  53. //获取项目下,当天班次所有打分记录
  54. $opr_t = new checkoprmodel();
  55. $list = $opr_t->getoprinfobypid($pid, $checkdate);
  56. return $list;
  57. } else {
  58. //此人无项目
  59. $list = array();
  60. return $list;
  61. }
  62. }
  63. /*
  64. * 20200403
  65. * 获取项目经理个人所有的记工记录
  66. */
  67. public function getoprinfobyhid($arr) {
  68. $hid = $arr['hid'];
  69. $startdate = date('Y-m-d', strtotime('-60 day'));
  70. $opr_t = new checkoprmodel();
  71. $list = $opr_t->seloprlistbyhid($hid, $startdate);
  72. return $list;
  73. }
  74. /*
  75. * 20200206
  76. * steelxu
  77. * 按人汇总表的数据,汇人总的天数,总记分
  78. * 先直接应用daycheckinfo实现
  79. * 20200325
  80. * 加身份证号
  81. */
  82. public function getsumcheckinfo($query_arr) {
  83. $month = $query_arr['monthinfo'];
  84. $year = $query_arr['yearinfo'];
  85. $pageNum = $query_arr['pageNum'];
  86. $pageSize = $query_arr['pageSize'];
  87. $start = ($pageNum - 1) * $pageSize;
  88. if (strlen($month) == 1) {
  89. $month = '0' . $month;
  90. }
  91. $strmonth = $year . '-' . $month;
  92. $dc_table = new daycheckinfo();
  93. //20200421 为统计推荐奖金,启用新方法,
  94. //$r_list=$dc_table->countcheckbymonth($strmonth,$start,$pageSize);
  95. //20200421 含 奖励计算的新方法
  96. $r_list = $dc_table->countcheckwithawardbymonth($strmonth, $start, $pageSize);
  97. //获取所有工人信息
  98. //todo 此处在数据量大时可优化,可重写model层查询,只返回id和身份证,这样效率更高,现在暂时不用
  99. $t_w = new gworkermodel();
  100. $w_list = $t_w->selshengfengzhenglist();
  101. $sfzlist = array();
  102. foreach ($w_list as $k) {
  103. $id = $k['id'];
  104. if ($k['shengfengid']) {
  105. $sfzlist[$id] = $k['shengfengid'];
  106. } else {
  107. $sfzlist[$id] = '';
  108. }
  109. }
  110. //获得了总体数据,获取每日数据
  111. foreach ($r_list as &$v) {
  112. $wid = $v['wid'];
  113. $v['sfz'] = $sfzlist[$wid];
  114. $detail_arr = $dc_table->getcheckinfobywidwithmonth($wid, $strmonth);
  115. foreach ($detail_arr as $k) {
  116. $daystr = substr($k['checkdate'], -2);
  117. // echo $k['checkdate'];
  118. // echo $daystr;
  119. $v[$daystr] = $k['dayscore'];
  120. }
  121. }
  122. return $r_list;
  123. }
  124. /*
  125. * 20230215
  126. * 加上公司的
  127. */
  128. public function getsumcompanycheckinfo($query_arr) {
  129. $month = $query_arr['monthinfo'];
  130. $year = $query_arr['yearinfo'];
  131. $pageNum = $query_arr['pageNum'];
  132. $pageSize = $query_arr['pageSize'];
  133. $cid = $query_arr['companyid'];
  134. $start = ($pageNum - 1) * $pageSize;
  135. if (strlen($month) == 1) {
  136. $month = '0' . $month;
  137. }
  138. $strmonth = $year . '-' . $month;
  139. $dc_table = new daycheckinfo();
  140. //20200421 为统计推荐奖金,启用新方法,
  141. //$r_list=$dc_table->countcheckbymonth($strmonth,$start,$pageSize);
  142. //20200421 含 奖励计算的新方法
  143. // $r_list=$dc_table->countcheckwithawardbymonth($strmonth,$start,$pageSize);
  144. //20230215 加上公司
  145. $r_list = $dc_table->countcompanycheckwithawardbymonth($strmonth, $start, $pageSize, $cid);
  146. //获取所有工人信息
  147. //todo 此处在数据量大时可优化,可重写model层查询,只返回id和身份证,这样效率更高,现在暂时不用
  148. //身份证还是取全部的,因为人员会流动,无论那种方式都会有问题,最后再看如何优化
  149. // 问题在于,如果工人数量较多,再和工人身份证做连接,将是a*b的数量级的运算,
  150. //如果取出来,则是a+b的运算,
  151. $t_w = new gworkermodel();
  152. $w_list = $t_w->selshengfengzhenglist();
  153. // $w_list=$t_w->selcompanyshengfengzhenglist($cid);
  154. $sfzlist = array();
  155. foreach ($w_list as $k) {
  156. $id = $k['id'];
  157. if ($k['shengfengid']) {
  158. $sfzlist[$id] = $k['shengfengid'];
  159. } else {
  160. $sfzlist[$id] = '';
  161. }
  162. }
  163. //获得了总体数据,获取每日数据
  164. foreach ($r_list as &$v) {
  165. $wid = $v['wid'];
  166. if ($sfzlist[$wid]) {
  167. $v['sfz'] = $sfzlist[$wid];
  168. $detail_arr = $dc_table->getcheckinfobywidwithmonth($wid, $strmonth);
  169. foreach ($detail_arr as $k) {
  170. $daystr = substr($k['checkdate'], -2);
  171. // echo $k['checkdate'];
  172. // echo $daystr;
  173. $v[$daystr] = $k['dayscore'];
  174. }
  175. }
  176. }
  177. return $r_list;
  178. }
  179. /*
  180. * 20200208
  181. * steelxu
  182. * 取消某员工,某班次考勤
  183. * 20200209 增加对操作记录的处理,在opr 表中增加一条 -1的记录
  184. * 20200307,增加对撤销时gid的撤销操作
  185. */
  186. public function invokecheckbywid($query_arr) {
  187. $wid = $query_arr['wid'];
  188. $checkdate = $query_arr['checkdate'];
  189. $shift = $query_arr['shift'];
  190. $id = $query_arr['id'];
  191. $headid = $query_arr['headid'];
  192. if (array_key_exists('gid', $query_arr)) {
  193. $gid = $query_arr['gid'];
  194. } else {
  195. $t_head = new wheadmodel();
  196. $gid = $t_head->getgidbywid($wid);
  197. }
  198. $dc_table = new daycheckinfo();
  199. $res = $dc_table->revokecheckshift($checkdate, $wid, $shift, $id);
  200. $ginfo = new ginfomodel();
  201. $pid = $ginfo->getpidbygid($gid);
  202. $opr_arr['pid'] = $pid;
  203. $opr_arr['checkdate'] = $checkdate;
  204. $opr_arr['checkorder'] = $shift;
  205. $opr_arr['headid'] = $headid;
  206. $opr_arr['isopr'] = 1;
  207. $opr_arr['gid'] = $gid;
  208. $opr_arr['wnum'] = -1;
  209. $opr_arr['oprtime'] = date('Y:m:d H:i:s');
  210. $oprtable = new checkoprmodel();
  211. $oprtable->saveOprRecord($opr_arr);
  212. return $res;
  213. }
  214. /*
  215. * 20200208
  216. * steelxu
  217. * 获取班组长某班次的记工记录,
  218. * 以便班组长取消
  219. *20200416
  220. * 取出时只有当时所在的班组才能修改,换了班组则不可以
  221. *
  222. */
  223. public function getheadoprwithshift($query_arr) {
  224. $headid = $query_arr['wid'];
  225. $checkdate = $query_arr['checkdate'];
  226. $shift = $query_arr['shift'];
  227. //获取班组
  228. $ghead = new wheadmodel();
  229. $gid = $ghead->getgidbywid($headid);
  230. $dc_table = new daycheckinfo();
  231. $rlist = $dc_table->getlistbyheadwithshift($checkdate, $shift, $headid, $gid);
  232. return $rlist;
  233. }
  234. public function getworkovertime($pagenum, $pagesize) {
  235. $start = ($pagenum - 1) * $pagesize;
  236. $t_dayscore = new daycheckinfo();
  237. $rlist = $t_dayscore->selscorewithprjbyscore($start, $pagesize);
  238. return $rlist;
  239. }
  240. /*
  241. * 20230215
  242. * 修改查加班的功能,只能查本公司的
  243. */
  244. public function getworkovertimebycid($pagenum, $pagesize, $cid) {
  245. $start = ($pagenum - 1) * $pagesize;
  246. $t_dayscore = new daycheckinfo();
  247. $rlist = $t_dayscore->selscorewithprjbyscorecid($start, $pagesize, $cid);
  248. return $rlist;
  249. }
  250. /**
  251. * 5天内有记工人员列表
  252. *
  253. * @return void
  254. * @author wj
  255. * @date 2025-02-18
  256. */
  257. public function hasreocdeuserlist($iscount = false, $page = 1, $size = 10) {
  258. $day_num = 5;
  259. $m_dc = new daycheckinfo();
  260. $data = $m_dc->hasreocdeuserlistwithdays($day_num, $iscount, $page, $size);
  261. return $data;
  262. }
  263. }