AttendanceMachineCmd.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\common\model;
  3. use app\hander\HelpHander;
  4. use think\Db;
  5. class AttendanceMachineCmd extends Base{
  6. public function add($machine_id,$title,$command){
  7. $data = [
  8. 'machine_id' => $machine_id,
  9. 'title' => $title,
  10. 'command' => $command,
  11. 'create_time' => date('Y-m-d H:i:s'),
  12. 'enable' => 0
  13. ];
  14. $ret = Db::name('attendance_machine_cmd')->insert($data);
  15. if(!$ret){
  16. $this->error = '操作失败';
  17. return false;
  18. }
  19. return true;
  20. }
  21. // 更新超级管理员信息
  22. public function updateAdminInfo($machine_id,$userId,$name,$card){
  23. // C:${CmdID}:DATA${SP}UPDATE${SP}USERINFO${SP}PIN=${XXX}${HT}Name=${XXX}${HT}Pri=${XXX}${HT}Passwd=${XXX}${HT}Card=${XXX}${HT}Grp=${XXX}${HT}TZ=${XXX}${HT}Verify=${XXX}${HT}ViceCard=${XXX}
  24. $command = 'C:${CmdID}'.":DATA UPDATE USERINFO PIN={$userId}\tName={$name}\tPri=14\tPasswd=123456\tCard={$card}\tGrp=1\tTZ=0000000000000000\tVerify=3\tViceCard={$card}";
  25. $title = '更新用户ID:'.$userId.'['.$name.']的信息';
  26. return $this->add($machine_id,$title,$command);
  27. }
  28. // 更新用户信息
  29. public function updateUserInfo($machine_id,$userId,$name,$card){
  30. // C:${CmdID}:DATA${SP}UPDATE${SP}USERINFO${SP}PIN=${XXX}${HT}Name=${XXX}${HT}Pri=${XXX}${HT}Passwd=${XXX}${HT}Card=${XXX}${HT}Grp=${XXX}${HT}TZ=${XXX}${HT}Verify=${XXX}${HT}ViceCard=${XXX}
  31. $command = 'C:${CmdID}'.":DATA UPDATE USERINFO PIN={$userId}\tName={$name}\tPri=0\tPasswd=123456\tCard={$card}\tGrp=1\tTZ=0000000000000000\tVerify=15\tViceCard={$card}";
  32. $title = '更新用户ID:'.$userId.'['.$name.']的信息';
  33. return $this->add($machine_id,$title,$command);
  34. }
  35. // 更新用户比对照片
  36. public function updateUserImg($machine_id,$userId,$name,$img){
  37. //C:${CmdID}:DATA${SP}UPDATE${SP}BIOPHOTO${SP}PIN=${XXX}${HT}Type=${XXX}${HT}Size=${XXX}${HT}Content=${XXX}${HT}Format=${XXX}${HT}Url=${XXX}${HT}PostBackTmpFlag=${XXX}
  38. $command = 'C:${CmdID}'.":DATA UPDATE BIOPHOTO PIN={$userId}\tType=9\tPostBackTmpFlag=0\tFormat=1\tUrl={$img}";
  39. $title = '更新用户ID:'.$userId.'['.$name.']的比对照片';
  40. return $this->add($machine_id,$title,$command);
  41. }
  42. // 标记命令已被使用
  43. public function setUseCmd($id,$error=0){
  44. $ret = $this->where('id',$id)->update(['enable' => 1, 'error' => $error, 'update_time' =>date('Y-m-d H:i:s')]);
  45. if(!$ret){
  46. return false;
  47. }
  48. return true;
  49. }
  50. }