GluingReport.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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. }
  384. $list['状态'] = rtrim($data['status']);
  385. $list['开工时间'] = $data['sczl_kgsj'];
  386. }else{
  387. $list['工单编号'] = '';
  388. $list['印件号'] = 0;
  389. $list['产品名称'] = '';
  390. $list['工序名称'] = '';
  391. $list['产品代号'] = '';
  392. $list['状态'] = '';
  393. $list['开工时间'] = '';
  394. }
  395. $list['班组编号'] = rtrim($data['sczl_bzbh']);
  396. $idList = explode(',',$data['班组ID']);
  397. foreach ($idList as $k=>$v){
  398. $class = \db('设备_糊盒班组资料')
  399. ->where('id',$v)
  400. ->field("role,rate,bh1,bh2,bh3,bh4,bh5,bh6,bh7,bh8,bh9,bh10,bh11,bh12,bh13,bh14,bh15")
  401. ->find();
  402. if (!empty($class)){
  403. for ($i=1;$i<16;$i++) {
  404. if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
  405. $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
  406. $row[] = [
  407. '编号' => $class['bh' . $i],
  408. '姓名' => $name['姓名'],
  409. '比例' => $class['rate'],
  410. '角色' => $class['role'],
  411. ];
  412. }
  413. }
  414. $row = array_values($row);
  415. }
  416. }
  417. $list['班组成员'] = $row;
  418. $list['定额代号'] = $machineCode;
  419. $this->success('成功',$list);
  420. }
  421. /**
  422. * 设置当前工单和当前班组
  423. * @return void
  424. */
  425. public function setMachineTeam()
  426. {
  427. if (Request::instance()->isPost() == false) {
  428. $this->error('非法请求');
  429. }
  430. $params = Request::instance()->post();
  431. if (!isset($params['machine']) || empty($params['machine'] )) {
  432. $this->error('参数不能为空');
  433. }
  434. if (empty($params['team_id']) || empty($params['sczl_bzdh'])){
  435. $this->error('请先选择班组成员');
  436. }
  437. $machine = $params['machine'] . '#';
  438. $data = [];
  439. $data['status'] = $params['status'];
  440. $data['sczl_sj'] = date('Y-m-d H:i:s');
  441. $data['sczl_jtbh'] = $machine;
  442. $data['sczl_gdbh'] = empty($params['order']) ? '':$params['order'];
  443. $data['sczl_yjno'] = empty($params['yjno']) ? '':$params['yjno'];
  444. $data['sczl_gxh'] = empty($params['gy_name']) ? '' : (int)substr($params['gy_name'], 0, 2);
  445. $data['sczl_gxmc'] = empty($params['gy_name']) ? '' : $params['gy_name'];
  446. $data['sczl_bzbh'] = $params['sczl_bzdh'];
  447. $data['班组ID'] = $params['team_id'];
  448. // 获取当前时间
  449. $current_time = time();
  450. // 设置时间范围
  451. $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
  452. $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
  453. $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
  454. $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
  455. $start_time4 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 00:00:00');
  456. // 判断当前时间属于哪个时间范围
  457. if ($current_time >= $start_time1 && $current_time <= $end_time1) {
  458. $data['sczl_kgsj'] = date('Y-m-d') . ' 08:30:00';
  459. } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
  460. $data['sczl_kgsj'] = date('Y-m-d') . ' 20:30:00';
  461. } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
  462. $data['sczl_kgsj'] = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
  463. }elseif ($current_time > $start_time4 && $current_time <= $start_time3){
  464. $data['sczl_kgsj'] = date('Y-m-d') . ' 20:30:00';
  465. }
  466. if (!empty($params['order']) && !empty($params['yjno'])){
  467. $option['Gy0_gdbh'] = $params['order'];
  468. $option['Gy0_yjno'] = $params['yjno'];
  469. $option['Gy0_gxh'] = $data['sczl_gxh'];
  470. $data['任务ID'] = \db('工单_工艺资料')->where($option)->value('UniqId');
  471. }else{
  472. $data['任务ID'] = '';
  473. }
  474. $sql = \db('设备_糊盒报工采集')->fetchSql(true)->insert($data);
  475. $res = Db::query($sql);
  476. if ($res === false) {
  477. $this->error('设置失败');
  478. } else {
  479. $this->success('设置成功');
  480. }
  481. }
  482. /**
  483. * 糊盒设备运行跟踪数据页面显示
  484. * @return void
  485. * @throws \think\db\exception\DataNotFoundException
  486. * @throws \think\db\exception\ModelNotFoundException
  487. * @throws \think\exception\DbException
  488. */
  489. public function getGluingReportDataList()
  490. {
  491. if ($this->request->isGet() === false){
  492. $this->error('请求错误');
  493. }
  494. $params = $this->request->param();
  495. if (empty($params['machine']) || empty($params['day'])){
  496. $this->error('参数错误');
  497. }
  498. $where = [
  499. 'a.sczl_jtbh' => $params['machine'],
  500. 'a.sczl_rq' => ['like',$params['day'].'%']
  501. ];
  502. $field = ['a.sczl_gdbh as 工单编号','a.sczl_yjno as 印件号','a.sczl_gxh as 工序号','a.sczl_gxmc as 工序名称','a.来料数量','a.sczl_cl as 产量',
  503. 'a.sczl_zcfp as 制程废品','a.startTime as 开始时间','a.endTime as 结束时间','a.sczl_ls as 联数','a.sczl_rq as 日期',
  504. 'a.sczl_dedh as 定额代号','a.工价系数','a.保养工时','a.装版工时','a.异常工时','a.异常类型','a.设备运行工时','a.role',
  505. 'a.sys_id as 创建人员','a.sys_rq as 上报时间','a.mod_rq as 修改时间','a.Uid','a.sczl_jtbh as 机台编号',
  506. 'b.yj_Yjdh as 产品代号','yj_yjmc as 产品名称'];
  507. $list = \db('设备_糊盒报工资料')
  508. ->alias('a')
  509. ->join('工单_印件资料 b','a.sczl_gdbh = b.Yj_Gdbh and a.sczl_yjno = b.yj_Yjno','left')
  510. ->field($field)
  511. ->where($where)
  512. ->group('a.Uid')
  513. ->select();
  514. if (empty($list)){
  515. $this->error('未找到报工数据');
  516. }
  517. foreach ($list as $key=>$value){
  518. $list[$key]['class'] = [];
  519. $idList = explode(',',$value['role']);
  520. foreach ($idList as $item){
  521. $class = \db('设备_糊盒班组资料')
  522. ->where('id',$item)
  523. ->field("role,rate,bh1,bh2,bh3,bh4,bh5,bh6,bh7,bh8,bh9,bh10,bh11,bh12,bh13,bh14,bh15")
  524. ->find();
  525. if (!empty($class)){
  526. for ($i=1;$i<16;$i++) {
  527. if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
  528. $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
  529. $list[$key]['class'][] = [
  530. '编号' => $class['bh' . $i],
  531. '姓名' => $name['姓名'],
  532. '比例' => $class['rate'],
  533. '角色' => $class['role'],
  534. ];
  535. }
  536. }
  537. $list[$key]['class'] = array_values($list[$key]['class']);
  538. }
  539. }
  540. unset($list[$key]['role']);
  541. }
  542. $this->success('成功',$list);
  543. }
  544. /**
  545. * 报工数据详情显示
  546. * @return void
  547. * @throws \think\db\exception\DataNotFoundException
  548. * @throws \think\db\exception\ModelNotFoundException
  549. * @throws \think\exception\DbException
  550. */
  551. public function getGluingReportDataDetail()
  552. {
  553. if ($this->request->isGet() === false){
  554. $this->error('请求错误');
  555. }
  556. $params = $this->request->param();
  557. if(!isset($params['id']) || empty($params['id'])){
  558. $this->error('参数错误');
  559. }
  560. $where = ['Uid'=>$params['id']];
  561. $field = ['a.sczl_gdbh as 工单编号','a.sczl_yjno as 印件号','a.sczl_gxh as 工序号','a.sczl_gxmc as 工序名称','a.来料数量','a.sczl_cl as 产量',
  562. 'a.sczl_zcfp as 制程废品','a.startTime as 开始时间','a.endTime as 结束时间','a.sczl_ls as 联数','a.sczl_rq as 日期',
  563. 'a.sczl_dedh as 定额代号','a.工价系数','a.保养工时','a.装版工时','a.异常工时','a.异常类型','a.设备运行工时','a.role',
  564. 'a.sys_id as 创建人员','a.sys_rq as 上报时间','a.mod_rq as 修改时间','a.Uid','a.sczl_jtbh as 机台编号',
  565. 'b.yj_Yjdh as 产品代号','yj_yjmc as 产品名称'];
  566. $list = \db('设备_糊盒报工资料')
  567. ->alias('a')
  568. ->join('工单_印件资料 b','a.sczl_gdbh = b.Yj_Gdbh and a.sczl_yjno = b.yj_Yjno','left')
  569. ->where($where)
  570. ->field($field)
  571. ->find();
  572. $list['class'] = [];
  573. $idList = explode(',',$list['role']);
  574. foreach ($idList as $item){
  575. $class = \db('设备_糊盒班组资料')
  576. ->where('id',$item)
  577. ->field("role,rate,bh1,bh2,bh3,bh4,bh5,bh6,bh7,bh8,bh9,bh10,bh11,bh12,bh13,bh14,bh15")
  578. ->find();
  579. if (!empty($class)){
  580. for ($i=1;$i<16;$i++) {
  581. if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
  582. $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
  583. $list['class'][] = [
  584. '编号' => $class['bh' . $i],
  585. '姓名' => $name['姓名'],
  586. '比例' => $class['rate'],
  587. '角色' => $class['role'],
  588. ];
  589. }
  590. }
  591. $list['class'] = array_values($list['class']);
  592. }
  593. }
  594. $this->success('成功',$list);
  595. }
  596. /**
  597. * 修改糊盒班组报工资料
  598. * @return void
  599. * @throws \think\Exception
  600. * @throws \think\db\exception\BindParamException
  601. * @throws \think\exception\PDOException
  602. */
  603. public function getGluingReportDetailUpdate()
  604. {
  605. if ($this->request->isPost() === false){
  606. $this->error('请求错误');
  607. }
  608. $params = Request::instance()->post();
  609. if(!isset($params['id']) || empty($params['id'])){
  610. $this->error('参数错误');
  611. }
  612. $id = $params['id'];
  613. unset($params['id']);
  614. $params['mod_rq'] = date('Y-m-d H:i:s',time());
  615. $sql = \db('设备_糊盒报工资料')
  616. ->where('Uid',$id)
  617. ->fetchSql(true)
  618. ->update($params);
  619. $res = \db()->query($sql);
  620. if ($res === false) {
  621. $this->error('修改成功');
  622. }else{
  623. $this->success('修改失败');
  624. }
  625. }
  626. /**
  627. * 修改报工数据班组
  628. * @return void
  629. * @throws \think\Exception
  630. * @throws \think\exception\PDOException
  631. */
  632. public function UpdateGluingReportClass()
  633. {
  634. if ($this->request->isPost() === false){
  635. $this->error('请求错误');
  636. }
  637. $params = Request::instance()->post();
  638. if(!isset($params['id']) || empty($params['id'])){
  639. $this->error('参数错误');
  640. }
  641. $id = $params['id'];
  642. $data['role'] = $params['role'];
  643. $res = \db('设备_糊盒报工资料')->where('Uid',$id)->update($data);
  644. if ($res === false) {
  645. $this->error('修改失败');
  646. }else{
  647. $this->success('修改成功');
  648. }
  649. }
  650. }