GluingReport.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use think\Request;
  6. class GluingReport extends Api
  7. {
  8. protected $noNeedLogin = ['*'];
  9. protected $noNeedRight = ['*'];
  10. /**
  11. * 设备角色菜单
  12. * @return void
  13. */
  14. public function getGluingcoleTab()
  15. {
  16. if ($this->request->isGet() === false){
  17. $this->error('请求错误');
  18. }
  19. $data = [];
  20. $sist = ['印后糊盒车间','精品自动化车间','数字化车间'];
  21. $department = \db('设备_基本资料')
  22. ->distinct(true)
  23. ->where('使用部门','in',$sist)
  24. ->where('设备编组','<>','')
  25. ->where('sys_sbID','<>','')
  26. ->order('设备编组')
  27. ->column('rtrim(使用部门) as 使用部门');
  28. if (empty($department)){
  29. $this->success('为获取到机台数据');
  30. }
  31. foreach ($department as $value){
  32. $machine = \db('设备_基本资料')->where('使用部门',$value)->where('sys_sbID','<>','')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->order('设备编号')->select();
  33. foreach ($machine as $k=>$v){
  34. $data[rtrim($value)][] = $v['设备编号'].'-->'.$v['设备名称'];
  35. }
  36. }
  37. $this->success('成功',$data);
  38. }
  39. /**
  40. * 设备角色列表
  41. * @return void
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. * @throws \think\exception\DbException
  45. */
  46. public function getGluingcoleList()
  47. {
  48. if ($this->request->isGet() === false){
  49. $this->error('请求错误');
  50. }
  51. $param = $this->request->param();
  52. if (empty($param)){
  53. $this->error('参数错误');
  54. }
  55. $list = db('设备_糊盒班组角色')
  56. ->where('jtbh',$param['machine'])
  57. ->select();
  58. if (empty($list)){
  59. $this->error('未找到数据');
  60. }else{
  61. $this->success('成功',$list);
  62. }
  63. }
  64. /**
  65. * 设备角色资料详情
  66. * @return void
  67. * @throws \think\db\exception\DataNotFoundException
  68. * @throws \think\db\exception\ModelNotFoundException
  69. * @throws \think\exception\DbException
  70. */
  71. public function getGluingcoleDetail()
  72. {
  73. if ($this->request->isGet() === false){
  74. $this->error('请求错误');
  75. }
  76. $param = $this->request->param();
  77. if (empty($param)){
  78. $this->error('参数错误');
  79. }
  80. $list = db('设备_糊盒班组角色')
  81. ->where('id',$param['id'])
  82. ->find();
  83. if (empty($list)){
  84. $this->error('未找到数据详情');
  85. }else{
  86. $this->success('成功',$list);
  87. }
  88. }
  89. /**
  90. * 新增机台班组角色
  91. * @return void
  92. */
  93. public function saveGluingcoleDetail(){
  94. if ($this->request->isPost() === false){
  95. $this->error('请求错误');
  96. }
  97. $param = Request::instance()->post();
  98. if (empty($param)){
  99. $this->error('参数错误');
  100. }
  101. $param['sys_rq'] = date('Y-m-d H:i:s',time());
  102. $res = db('设备_糊盒班组角色')->insert($param);
  103. if (empty($res)){
  104. $this->error('新增失败');
  105. }else{
  106. $this->success('新增成功');
  107. }
  108. }
  109. /**
  110. * 修改设备角色资料
  111. * @return void
  112. * @throws \think\Exception
  113. * @throws \think\exception\PDOException
  114. */
  115. public function getGluingcoleDetaiEdit()
  116. {
  117. if ($this->request->isPost() === false){
  118. $this->error('请求错误');
  119. }
  120. $param = Request::instance()->post();
  121. if (empty($param['id'])){
  122. $this->error('参数错误');
  123. }
  124. $id = intval($param['id']);
  125. $param['mod_rq'] = date('Y-m-d H:i:s',time());
  126. unset($param['id']);
  127. $res = db('设备_糊盒班组角色')
  128. ->where('id',$id)
  129. ->update($param);
  130. if ($res === false){
  131. $this->error('修改失败');
  132. }else{
  133. $this->success('修改成功');
  134. }
  135. }
  136. /**
  137. * 设备当前班组角色
  138. * @return void
  139. * @throws \think\Exception
  140. * @throws \think\exception\PDOException
  141. */
  142. public function UpdateGluingcoleStatus()
  143. {
  144. if ($this->request->isGet() === false){
  145. $this->error('请求错误');
  146. }
  147. $param = $this->request->param();
  148. if (empty($param['id']) || empty($param['jtbh'])){
  149. $this->error('参数错误');
  150. }
  151. $updateRes = db('设备_糊盒班组角色')
  152. ->where('jtbh',$param['jtbh'])
  153. ->update(['status' => 0]);
  154. $res = db('设备_糊盒班组角色')
  155. ->where('id',$param['id'])
  156. ->update(['status' => 1]);
  157. if ($updateRes === false || $res === false){
  158. $this->error('更新失败');
  159. }else{
  160. $this->success('更新成功');
  161. }
  162. }
  163. /**
  164. * 设备班组资料列表
  165. * @return void
  166. * @throws \think\db\exception\DataNotFoundException
  167. * @throws \think\db\exception\ModelNotFoundException
  168. * @throws \think\exception\DbException
  169. */
  170. public function getGluingClassLList()
  171. {
  172. if ($this->request->isGet() === false){
  173. $this->error('请求错误');
  174. }
  175. $param = $this->request->param();
  176. if (empty($param)){
  177. $this->error('参数错误');
  178. }
  179. $list = db('设备_糊盒班组资料')
  180. ->where('jtbh',$param['machine'])
  181. ->select();
  182. foreach ($list as $k=>$v){
  183. for ($i = 1; $i <= 15; $i++){
  184. $bh = $v['bh'.$i];
  185. $list[$k]['name'.$i] = '';
  186. if (!empty($bh) && $bh !== ''){
  187. $name = \db('人事_基本资料')
  188. ->where('员工编号',$bh)
  189. ->value('员工姓名');
  190. $list[$k]['name'.$i] = $name;
  191. }
  192. }
  193. }
  194. if (empty($list)){
  195. $this->error('未找到数据');
  196. }else{
  197. $this->success('成功',$list);
  198. }
  199. }
  200. /**
  201. * 获取设备角色数据
  202. * @return void
  203. * @throws \think\db\exception\DataNotFoundException
  204. * @throws \think\db\exception\ModelNotFoundException
  205. * @throws \think\exception\DbException
  206. */
  207. public function getGluingcole()
  208. {
  209. if ($this->request->isGet() === false){
  210. $this->error('请求错误');
  211. }
  212. $param = $this->request->param();
  213. if (empty($param)){
  214. $this->error('参数错误');
  215. }
  216. $list = db('设备_糊盒班组角色')
  217. ->where('jtbh',$param['machine'])
  218. ->where('status',1)
  219. ->find();
  220. if (empty($list)){
  221. $this->error('未找到角色资料');
  222. }else{
  223. $this->success('成功',$list);
  224. }
  225. }
  226. /**
  227. * 新增糊盒机台班组资料
  228. * @return void
  229. */
  230. public function AddGluingClass()
  231. {
  232. if ($this->request->isPost() === false){
  233. $this->error('请求错误');
  234. }
  235. $param = Request::instance()->post();
  236. if (empty($param)){
  237. $this->error('参数错误');
  238. }
  239. $param['sys_rq'] = date('Y-m-d H:i:s',time());
  240. $res = db('设备_糊盒班组资料')->insert($param);
  241. if ($res === false){
  242. $this->error('新增失败');
  243. }else{
  244. $this->success('新增成功');
  245. }
  246. }
  247. /**
  248. * 修改设备糊盒班组资料
  249. * @return void
  250. * @throws \think\Exception
  251. * @throws \think\exception\PDOException
  252. */
  253. public function UpdateGluingClass()
  254. {
  255. if ($this->request->isPost() === false){
  256. $this->error('请求错误');
  257. }
  258. $param = Request::instance()->post();
  259. if (empty($param['id'])){
  260. $this->error('参数错误');
  261. }
  262. $id = intval($param['id']);
  263. $param['mod_rq'] = date('Y-m-d H:i:s',time());
  264. unset($param['id']);
  265. $res = db('设备_糊盒班组资料')
  266. ->where('id',$id)
  267. ->update($param);
  268. if ($res === false){
  269. $this->error('修改失败');
  270. }else{
  271. $this->success('修改成功');
  272. }
  273. }
  274. /**
  275. * 糊盒机台报工
  276. * @return void
  277. * @throws \think\db\exception\BindParamException
  278. * @throws \think\exception\PDOException
  279. */
  280. public function AddGluingReportData()
  281. {
  282. if ($this->request->isPost() === false){
  283. $this->error('请求错误');
  284. }
  285. $param = Request::instance()->post();
  286. if (empty($param)){
  287. $this->error('参数错误');
  288. }
  289. $param['sys_rq'] = date('Y-m-d H:i:s',time());
  290. $Sql = db('设备_糊盒报工资料')->fetchSql(true)->insert($param);
  291. $res = db()->query($Sql);
  292. if ($res === false){
  293. $this->error('报工失败');
  294. }else{
  295. $this->success('报工成功');
  296. }
  297. }
  298. /**
  299. * 糊盒机台报工数据菜单
  300. * @return void
  301. * @throws \think\db\exception\DataNotFoundException
  302. * @throws \think\db\exception\ModelNotFoundException
  303. * @throws \think\exception\DbException
  304. */
  305. public function getTab()
  306. {
  307. if ($this->request->isGet() === false){
  308. $this->error('请求错误');
  309. }
  310. $data = [];
  311. $date = date('Y-m-d 00:00:00',time()-3888000);
  312. $sist = ['印后糊盒车间','精品自动化车间','数字化车间'];
  313. $department = \db('设备_基本资料')
  314. ->distinct(true)
  315. ->where('使用部门','in',$sist)
  316. ->where('设备编组','<>','')
  317. ->where('sys_sbID','<>','')
  318. ->order('设备编组')
  319. ->column('rtrim(使用部门) as 使用部门');
  320. if (empty($department)){
  321. $this->success('未获取到机台数据');
  322. }
  323. $list = \db('设备_糊盒报工资料')
  324. ->field([
  325. 'DISTINCT(sczl_rq)' => '时间',
  326. 'rtrim(sczl_jtbh)' => '机台编号'
  327. ])
  328. ->where('sczl_rq','>',$date)
  329. ->order('sczl_rq desc')
  330. ->select();
  331. foreach ($department as $value){
  332. $machine = \db('设备_基本资料')->where('使用部门',$value)->where('sys_sbID','<>','')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->order('设备编号')->select();
  333. foreach ($machine as $k=>$v){
  334. $data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']] = [];
  335. foreach ($list as $kk=>$vv){
  336. if ($v['设备编号'] === $vv['机台编号']){
  337. array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
  338. }
  339. }
  340. }
  341. }
  342. $this->success('成功',$data);
  343. }
  344. /**
  345. * 获取当前生产工单
  346. * @return void
  347. * @throws \think\db\exception\DataNotFoundException
  348. * @throws \think\db\exception\ModelNotFoundException
  349. * @throws \think\exception\DbException
  350. */
  351. public function GetProduction()
  352. {
  353. if (Request::instance()->isGet() == false) {
  354. $this->error('非法请求');
  355. }
  356. $params = Request::instance()->param();
  357. if (!isset($params['machine']) || empty($params['machine'])) {
  358. $this->error('参数错误');
  359. }
  360. $machine = $params['machine'];
  361. $machineCode = \db('dic_lzde')->where('适用机型',$machine)->value('sys_bh');
  362. $data = \db('设备_糊盒报工采集')->where('sczl_jtbh',$machine)->order('UID desc')->find();
  363. if (empty($data)){
  364. $this->success('未找到数据');
  365. }
  366. $list = [];
  367. $list['班组ID'] = $data['班组ID'];
  368. $row = [];
  369. if (!empty($data['sczl_gdbh'])){
  370. $endTime = \db('工单_工艺资料')
  371. ->where('Gy0_gdbh',$data['sczl_gdbh'])
  372. ->where('Gy0_yjno',$data['sczl_yjno'])
  373. ->where('Gy0_gxh',$data['sczl_gxh'])
  374. ->find();
  375. $list['工单编号'] = $data['sczl_gdbh'];
  376. if (!empty($endTime)){
  377. $list['印件号'] = $data['sczl_yjno'];
  378. $name = \db('工单_基本资料')->where('Gd_Gdbh',$data['sczl_gdbh'])->value('成品名称');
  379. $code = \db('工单_基本资料')->where('Gd_Gdbh',$data['sczl_gdbh'])->value('成品代号');
  380. $list['产品名称'] = rtrim($name);
  381. $list['产品代号'] = rtrim($code);
  382. $list['工序名称'] = $data['sczl_gxmc'];
  383. $list['联数'] = $endTime['Gy0_ls'];
  384. }
  385. $list['状态'] = rtrim($data['status']);
  386. $list['开工时间'] = $data['sczl_kgsj'];
  387. }else{
  388. $list['工单编号'] = '';
  389. $list['印件号'] = 0;
  390. $list['产品名称'] = '';
  391. $list['工序名称'] = '';
  392. $list['产品代号'] = '';
  393. $list['状态'] = '';
  394. $list['开工时间'] = '';
  395. $list['联数'] = '';
  396. }
  397. $list['班组编号'] = rtrim($data['sczl_bzbh']);
  398. $idList = explode(',',$data['班组ID']);
  399. foreach ($idList as $k=>$v){
  400. $class = \db('设备_糊盒班组资料')
  401. ->where('id',$v)
  402. ->field("role,rate,bh1,bh2,bh3,bh4,bh5,bh6,bh7,bh8,bh9,bh10,bh11,bh12,bh13,bh14,bh15")
  403. ->find();
  404. if (!empty($class)){
  405. for ($i=1;$i<16;$i++) {
  406. if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
  407. $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
  408. $row[] = [
  409. '编号' => $class['bh' . $i],
  410. '姓名' => $name['姓名'],
  411. '比例' => $class['rate'],
  412. '角色' => $class['role'],
  413. ];
  414. }
  415. }
  416. $row = array_values($row);
  417. }
  418. }
  419. $list['班组成员'] = $row;
  420. $list['定额代号'] = $machineCode;
  421. $this->success('成功',$list);
  422. }
  423. /**
  424. * 设置当前工单和当前班组
  425. * @return void
  426. */
  427. public function setMachineTeam()
  428. {
  429. if (Request::instance()->isPost() == false) {
  430. $this->error('非法请求');
  431. }
  432. $params = Request::instance()->post();
  433. if (!isset($params['machine']) || empty($params['machine'] )) {
  434. $this->error('参数不能为空');
  435. }
  436. if (empty($params['team_id']) || empty($params['sczl_bzdh'])){
  437. $this->error('请先选择班组成员');
  438. }
  439. $machine = $params['machine'] . '#';
  440. $data = [];
  441. $data['status'] = $params['status'];
  442. $data['sczl_sj'] = date('Y-m-d H:i:s');
  443. $data['sczl_jtbh'] = $machine;
  444. $data['sczl_gdbh'] = empty($params['order']) ? '':$params['order'];
  445. $data['sczl_yjno'] = empty($params['yjno']) ? '':$params['yjno'];
  446. $data['sczl_gxh'] = empty($params['gy_name']) ? '' : (int)substr($params['gy_name'], 0, 2);
  447. $data['sczl_gxmc'] = empty($params['gy_name']) ? '' : $params['gy_name'];
  448. $data['sczl_bzbh'] = $params['sczl_bzdh'];
  449. $data['班组ID'] = $params['team_id'];
  450. // 获取当前时间
  451. $current_time = time();
  452. // 设置时间范围
  453. $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
  454. $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
  455. $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
  456. $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
  457. $start_time4 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 00:00:00');
  458. // 判断当前时间属于哪个时间范围
  459. if ($current_time >= $start_time1 && $current_time <= $end_time1) {
  460. $data['sczl_kgsj'] = date('Y-m-d') . ' 08:30:00';
  461. } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
  462. $data['sczl_kgsj'] = date('Y-m-d') . ' 20:30:00';
  463. } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
  464. $data['sczl_kgsj'] = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
  465. }elseif ($current_time > $start_time4 && $current_time <= $start_time3){
  466. $data['sczl_kgsj'] = date('Y-m-d') . ' 20:30:00';
  467. }
  468. if (!empty($params['order']) && !empty($params['yjno'])){
  469. $option['Gy0_gdbh'] = $params['order'];
  470. $option['Gy0_yjno'] = $params['yjno'];
  471. $option['Gy0_gxh'] = $data['sczl_gxh'];
  472. $data['任务ID'] = \db('工单_工艺资料')->where($option)->value('UniqId');
  473. }else{
  474. $data['任务ID'] = '';
  475. }
  476. $sql = \db('设备_糊盒报工采集')->fetchSql(true)->insert($data);
  477. $res = Db::query($sql);
  478. if ($res === false) {
  479. $this->error('设置失败');
  480. } else {
  481. $this->success('设置成功');
  482. }
  483. }
  484. /**
  485. * 糊盒设备运行跟踪数据页面显示
  486. * @return void
  487. * @throws \think\db\exception\DataNotFoundException
  488. * @throws \think\db\exception\ModelNotFoundException
  489. * @throws \think\exception\DbException
  490. */
  491. public function getGluingReportDataList()
  492. {
  493. if ($this->request->isGet() === false){
  494. $this->error('请求错误');
  495. }
  496. $params = $this->request->param();
  497. if (empty($params['machine']) || empty($params['day'])){
  498. $this->error('参数错误');
  499. }
  500. $where = [
  501. 'a.sczl_jtbh' => $params['machine'],
  502. 'a.sczl_rq' => ['like',$params['day'].'%']
  503. ];
  504. $field = ['a.sczl_gdbh as 工单编号','a.sczl_yjno as 印件号','a.sczl_gxh as 工序号','a.sczl_gxmc as 工序名称','a.来料数量','a.sczl_cl as 产量',
  505. 'a.sczl_zcfp as 制程废品','a.startTime as 开始时间','a.endTime as 结束时间','a.sczl_ls as 联数','a.sczl_rq as 日期',
  506. 'a.sczl_dedh as 定额代号','a.工价系数','a.保养工时','a.装版工时','a.异常工时','a.异常类型','a.设备运行工时','a.role',
  507. 'a.sys_id as 创建人员','a.sys_rq as 上报时间','a.mod_rq as 修改时间','a.Uid','a.sczl_jtbh as 机台编号',
  508. 'b.yj_Yjdh as 产品代号','yj_yjmc as 产品名称'];
  509. $list = \db('设备_糊盒报工资料')
  510. ->alias('a')
  511. ->join('工单_印件资料 b','a.sczl_gdbh = b.Yj_Gdbh and a.sczl_yjno = b.yj_Yjno','left')
  512. ->field($field)
  513. ->where($where)
  514. ->group('a.Uid')
  515. ->select();
  516. if (empty($list)){
  517. $this->error('未找到报工数据');
  518. }
  519. foreach ($list as $key=>$value){
  520. $list[$key]['class'] = [];
  521. $idList = explode(',',$value['role']);
  522. foreach ($idList as $item){
  523. $class = \db('设备_糊盒班组资料')
  524. ->where('id',$item)
  525. ->field("role,rate,bh1,bh2,bh3,bh4,bh5,bh6,bh7,bh8,bh9,bh10,bh11,bh12,bh13,bh14,bh15")
  526. ->find();
  527. if (!empty($class)){
  528. for ($i=1;$i<16;$i++) {
  529. if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
  530. $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
  531. $list[$key]['class'][] = [
  532. '编号' => $class['bh' . $i],
  533. '姓名' => $name['姓名'],
  534. '比例' => $class['rate'],
  535. '角色' => $class['role'],
  536. ];
  537. }
  538. }
  539. $list[$key]['class'] = array_values($list[$key]['class']);
  540. }
  541. }
  542. unset($list[$key]['role']);
  543. }
  544. $this->success('成功',$list);
  545. }
  546. /**
  547. * 报工数据详情显示
  548. * @return void
  549. * @throws \think\db\exception\DataNotFoundException
  550. * @throws \think\db\exception\ModelNotFoundException
  551. * @throws \think\exception\DbException
  552. */
  553. public function getGluingReportDataDetail()
  554. {
  555. if ($this->request->isGet() === false){
  556. $this->error('请求错误');
  557. }
  558. $params = $this->request->param();
  559. if(!isset($params['id']) || empty($params['id'])){
  560. $this->error('参数错误');
  561. }
  562. $where = ['Uid'=>$params['id']];
  563. $field = ['a.sczl_gdbh as 工单编号','a.sczl_yjno as 印件号','a.sczl_gxh as 工序号','a.sczl_gxmc as 工序名称','a.来料数量','a.sczl_cl as 产量',
  564. 'a.sczl_zcfp as 制程废品','a.startTime as 开始时间','a.endTime as 结束时间','a.sczl_ls as 联数','a.sczl_rq as 日期',
  565. 'a.sczl_dedh as 定额代号','a.工价系数','a.保养工时','a.装版工时','a.异常工时','a.异常类型','a.设备运行工时','a.role',
  566. 'a.sys_id as 创建人员','a.sys_rq as 上报时间','a.mod_rq as 修改时间','a.Uid','a.sczl_jtbh as 机台编号',
  567. 'b.yj_Yjdh as 产品代号','yj_yjmc as 产品名称'];
  568. $list = \db('设备_糊盒报工资料')
  569. ->alias('a')
  570. ->join('工单_印件资料 b','a.sczl_gdbh = b.Yj_Gdbh and a.sczl_yjno = b.yj_Yjno','left')
  571. ->where($where)
  572. ->field($field)
  573. ->find();
  574. $list['class'] = [];
  575. $idList = explode(',',$list['role']);
  576. foreach ($idList as $item){
  577. $class = \db('设备_糊盒班组资料')
  578. ->where('id',$item)
  579. ->field("role,rate,bh1,bh2,bh3,bh4,bh5,bh6,bh7,bh8,bh9,bh10,bh11,bh12,bh13,bh14,bh15")
  580. ->find();
  581. if (!empty($class)){
  582. for ($i=1;$i<16;$i++) {
  583. if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
  584. $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
  585. $list['class'][] = [
  586. '编号' => $class['bh' . $i],
  587. '姓名' => $name['姓名'],
  588. '比例' => $class['rate'],
  589. '角色' => $class['role'],
  590. ];
  591. }
  592. }
  593. $list['class'] = array_values($list['class']);
  594. }
  595. }
  596. $this->success('成功',$list);
  597. }
  598. /**
  599. * 修改糊盒班组报工资料
  600. * @return void
  601. * @throws \think\Exception
  602. * @throws \think\db\exception\BindParamException
  603. * @throws \think\exception\PDOException
  604. */
  605. public function getGluingReportDetailUpdate()
  606. {
  607. if ($this->request->isPost() === false){
  608. $this->error('请求错误');
  609. }
  610. $params = Request::instance()->post();
  611. if(!isset($params['id']) || empty($params['id'])){
  612. $this->error('参数错误');
  613. }
  614. $id = $params['id'];
  615. unset($params['id']);
  616. $params['mod_rq'] = date('Y-m-d H:i:s',time());
  617. $sql = \db('设备_糊盒报工资料')
  618. ->where('Uid',$id)
  619. ->fetchSql(true)
  620. ->update($params);
  621. $res = \db()->query($sql);
  622. if ($res === false) {
  623. $this->error('修改成功');
  624. }else{
  625. $this->success('修改失败');
  626. }
  627. }
  628. /**
  629. * 修改报工数据班组
  630. * @return void
  631. * @throws \think\Exception
  632. * @throws \think\exception\PDOException
  633. */
  634. public function UpdateGluingReportClass()
  635. {
  636. if ($this->request->isPost() === false){
  637. $this->error('请求错误');
  638. }
  639. $params = Request::instance()->post();
  640. if(!isset($params['id']) || empty($params['id'])){
  641. $this->error('参数错误');
  642. }
  643. $id = $params['id'];
  644. $data['role'] = $params['role'];
  645. $res = \db('设备_糊盒报工资料')->where('Uid',$id)->update($data);
  646. if ($res === false) {
  647. $this->error('修改失败');
  648. }else{
  649. $this->success('修改成功');
  650. }
  651. }
  652. }