GluingReport.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Request;
  5. class GluingReport extends Api
  6. {
  7. protected $noNeedLogin = ['*'];
  8. protected $noNeedRight = ['*'];
  9. /**
  10. * 设备角色菜单
  11. * @return void
  12. */
  13. public function getGluingcoleTab()
  14. {
  15. if ($this->request->isGet() === false){
  16. $this->error('请求错误');
  17. }
  18. $sist = ['印后糊盒车间','精品自动化车间','数字化车间'];
  19. $list = db('设备_基本资料')
  20. ->where('使用部门','in',$sist)
  21. ->whereNotNull('sys_sbID')
  22. ->column('CONCAT(设备编号,"->",设备名称)');
  23. if (empty($list)){
  24. $this->error('未找到设备数据');
  25. }else{
  26. $this->success('成功',$list);
  27. }
  28. }
  29. /**
  30. * 设备角色列表
  31. * @return void
  32. * @throws \think\db\exception\DataNotFoundException
  33. * @throws \think\db\exception\ModelNotFoundException
  34. * @throws \think\exception\DbException
  35. */
  36. public function getGluingcoleList()
  37. {
  38. if ($this->request->isGet() === false){
  39. $this->error('请求错误');
  40. }
  41. $param = $this->request->param();
  42. if (empty($param)){
  43. $this->error('参数错误');
  44. }
  45. $list = db('设备_糊盒班组角色')
  46. ->where('jtbh',$param['machine'])
  47. ->select();
  48. if (empty($list)){
  49. $this->error('未找到数据');
  50. }else{
  51. $this->success('成功',$list);
  52. }
  53. }
  54. /**
  55. * 设备角色资料详情
  56. * @return void
  57. * @throws \think\db\exception\DataNotFoundException
  58. * @throws \think\db\exception\ModelNotFoundException
  59. * @throws \think\exception\DbException
  60. */
  61. public function getGluingcoleDetail()
  62. {
  63. if ($this->request->isGet() === false){
  64. $this->error('请求错误');
  65. }
  66. $param = $this->request->param();
  67. if (empty($param)){
  68. $this->error('参数错误');
  69. }
  70. $list = db('设备_糊盒班组角色')
  71. ->where('id',$param['id'])
  72. ->find();
  73. if (empty($list)){
  74. $this->error('未找到数据详情');
  75. }else{
  76. $this->success('成功',$list);
  77. }
  78. }
  79. /**
  80. * 新增机台班组角色
  81. * @return void
  82. */
  83. public function saveGluingcoleDetail(){
  84. if ($this->request->isPost() === false){
  85. $this->error('请求错误');
  86. }
  87. $param = Request::instance()->post();
  88. if (empty($param)){
  89. $this->error('参数错误');
  90. }
  91. $param['sys_rq'] = date('Y-m-d H:i:s',time());
  92. $res = db('设备_糊盒班组角色')->insert($param);
  93. if (empty($res)){
  94. $this->error('新增失败');
  95. }else{
  96. $this->success('新增成功');
  97. }
  98. }
  99. /**
  100. * 修改设备角色资料
  101. * @return void
  102. * @throws \think\Exception
  103. * @throws \think\exception\PDOException
  104. */
  105. public function getGluingcoleDetaiEdit()
  106. {
  107. if ($this->request->isPost() === false){
  108. $this->error('请求错误');
  109. }
  110. $param = Request::instance()->post();
  111. if (empty($param['id'])){
  112. $this->error('参数错误');
  113. }
  114. $id = intval($param['id']);
  115. $param['mod_rq'] = date('Y-m-d H:i:s',time());
  116. unset($param['id']);
  117. $res = db('设备_糊盒班组角色')
  118. ->where('id',$id)
  119. ->update($param);
  120. if ($res === false){
  121. $this->error('修改失败');
  122. }else{
  123. $this->success('修改成功');
  124. }
  125. }
  126. /**
  127. * 设备当前班组角色
  128. * @return void
  129. * @throws \think\Exception
  130. * @throws \think\exception\PDOException
  131. */
  132. public function UpdateGluingcoleStatus()
  133. {
  134. if ($this->request->isGet() === false){
  135. $this->error('请求错误');
  136. }
  137. $param = $this->request->param();
  138. if (empty($param['id']) || empty($param['jtbh'])){
  139. $this->error('参数错误');
  140. }
  141. $updateRes = db('设备_糊盒班组角色')
  142. ->where('jtbh',$param['jtbh'])
  143. ->update(['status' => 0]);
  144. $res = db('设备_糊盒班组角色')
  145. ->where('id',$param['id'])
  146. ->update(['status' => 1]);
  147. if ($updateRes === false || $res === false){
  148. $this->error('更新失败');
  149. }else{
  150. $this->success('更新成功');
  151. }
  152. }
  153. /**
  154. * 设备班组资料列表
  155. * @return void
  156. * @throws \think\db\exception\DataNotFoundException
  157. * @throws \think\db\exception\ModelNotFoundException
  158. * @throws \think\exception\DbException
  159. */
  160. public function getGluingClassLList()
  161. {
  162. if ($this->request->isGet() === false){
  163. $this->error('请求错误');
  164. }
  165. $param = $this->request->param();
  166. if (empty($param)){
  167. $this->error('参数错误');
  168. }
  169. $list = db('设备_糊盒班组资料')
  170. ->where('jtbh',$param['machine'])
  171. ->select();
  172. if (empty($list)){
  173. $this->error('未找到数据');
  174. }else{
  175. $this->success('成功',$list);
  176. }
  177. }
  178. /**
  179. * 获取设备角色数据
  180. * @return void
  181. * @throws \think\db\exception\DataNotFoundException
  182. * @throws \think\db\exception\ModelNotFoundException
  183. * @throws \think\exception\DbException
  184. */
  185. public function getGluingcole()
  186. {
  187. if ($this->request->isGet() === false){
  188. $this->error('请求错误');
  189. }
  190. $param = $this->request->param();
  191. if (empty($param)){
  192. $this->error('参数错误');
  193. }
  194. $list = db('设备_糊盒班组角色')
  195. ->where('jtbh',$param['machine'])
  196. ->where('status',1)
  197. ->find();
  198. if (empty($list)){
  199. $this->error('未找到角色资料');
  200. }else{
  201. $this->success('成功',$list);
  202. }
  203. }
  204. /**
  205. * 新增糊盒机台班组资料
  206. * @return void
  207. */
  208. public function AddGluingClass()
  209. {
  210. if ($this->request->isPost() === false){
  211. $this->error('请求错误');
  212. }
  213. $param = Request::instance()->post();
  214. if (empty($param)){
  215. $this->error('参数错误');
  216. }
  217. $param['sys_rq'] = date('Y-m-d H:i:s',time());
  218. $res = db('机台_糊盒班组资料')->insert($param);
  219. if ($res === false){
  220. $this->error('新增失败');
  221. }else{
  222. $this->success('新增失败');
  223. }
  224. }
  225. /**
  226. * 修改设备糊盒班组资料
  227. * @return void
  228. * @throws \think\Exception
  229. * @throws \think\exception\PDOException
  230. */
  231. public function UpdateGluingClass()
  232. {
  233. if ($this->request->isPost() === false){
  234. $this->error('请求错误');
  235. }
  236. $param = Request::instance()->post();
  237. if (empty($param['id'])){
  238. $this->error('参数错误');
  239. }
  240. $id = intval($param['id']);
  241. $param['mod_rq'] = date('Y-m-d H:i:s',time());
  242. unset($param['id']);
  243. $res = db('设备_糊盒班组资料')
  244. ->where('id',$id)
  245. ->update($param);
  246. if ($res === false){
  247. $this->error('修改成功');
  248. }else{
  249. $this->success('修改失败');
  250. }
  251. }
  252. // public function AddGluingReportData()
  253. // {
  254. // if ($this->request->isPost() === false){
  255. // $this->error('请求错误');
  256. // }
  257. // $param = Request::instance()->post();
  258. // if (empty($param)){
  259. // $this->error('参数错误');
  260. // }
  261. // }
  262. }