Manufacture.php 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use Monolog\Handler\IFTTTHandler;
  5. use think\Db;
  6. use think\Request;
  7. use function fast\e;
  8. /**
  9. *
  10. * 生产排单管理
  11. */
  12. class Manufacture extends Api
  13. {
  14. protected $noNeedLogin = ['*'];
  15. protected $noNeedRight = ['*'];
  16. /**
  17. * 计划中工单
  18. * @ApiMethod (GET)
  19. * @return \think\response\Json
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\ModelNotFoundException
  22. * @throws \think\exception\DbException
  23. */
  24. public function Project()
  25. {
  26. if ($this->request->isGet() === false){
  27. $this->error('请求错误');
  28. }
  29. $param = $this->request->param();
  30. if (empty($param)){
  31. $this->error('参数错误');
  32. }
  33. if ($param['status'] === '计划中'){
  34. $status = '3-计划中';
  35. }else{
  36. $status = '1-已完工';
  37. }
  38. $page = 0;
  39. $limit = 15;
  40. if (isset($param['page'])){
  41. $page = $param['page'];
  42. }
  43. if (isset($param['limit'])){
  44. $limit = $param['limit'];
  45. }
  46. $where = [
  47. 'gd_statu' => $status,
  48. '行号' => '1',
  49. ];
  50. if (isset($param['search'])){
  51. $where['Gd_lx|Gd_gdbh|Gd_客户代号|Gd_客户名称|Gd_khdh|Gd_khmc|Gd_cpdh|Gd_cpmc|成品代号|成品名称|产品版本号'] = ['like','%'.$param['search'].'%'];
  52. }
  53. $field = 'rtrim(Gd_生产分类) as 生产分类,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(成品名称) as 成品名称,
  54. rtrim(接单日期) as 接单日期,rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(Gd_khmc) as 客户名称,
  55. rtrim(Gd_客户代号) as 客户编号,rtrim(Gd_desc) as 备注,rtrim(客户料号) as 客户料号,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,
  56. rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID,rtrim(投料率) as 投料率,rtrim(销售订单号) as 销售订单号';
  57. $list = \db('工单_基本资料')->where($where)->field($field)->limit(($page-1)*$limit,$limit)->order('Uniqid desc')->select();
  58. $total = \db('工单_基本资料')->where($where)->count();
  59. if (empty($list)){
  60. $this->success('',[]);
  61. }
  62. foreach ($list as $key=>$value){
  63. $list[$key]['订单数量'] = rtrim((float)$value['订单数量']);
  64. $list[$key]['产品名称'] = $value['产品名称'] != '' ? $value['产品名称']:$value['成品名称'];
  65. $number = \db('工单_工艺资料')->where('Gy0_gdbh',$value['工单编号'])->count();
  66. if ($number === 0){
  67. $list[$key]['status'] = 0;
  68. }else{
  69. $list[$key]['status'] = 1;
  70. }
  71. unset($list[$key]['成品名称']);
  72. }
  73. $this->success('成功',['data'=>$list,'total'=>$total]);
  74. }
  75. /**
  76. * 计划中工单->工艺资料
  77. * @ApiMethod (GET)
  78. * @param string $Gd_gdbh 工单编号
  79. * @return \think\response\Json
  80. * @throws \think\db\exception\DataNotFoundException
  81. * @throws \think\db\exception\ModelNotFoundException
  82. * @throws \think\exception\DbException
  83. */
  84. public function projectCraft()
  85. {
  86. if ($this->request->isGet() === false){
  87. $this->error('请求错误');
  88. }
  89. $Gd_gdbh = input('Gd_gdbh');
  90. if (empty($Gd_gdbh)){
  91. $this->error('参数错误');
  92. }
  93. $where = [
  94. 'Gy0_gdbh' => $Gd_gdbh
  95. ];
  96. $filed = 'rtrim(Gy0_gdbh) as 工单编号,rtrim(重点工序) as 重点工序,Gy0_yjno,Gy0_gxh,Gy0_gxmc,Add_gxmc,rtrim(工序备注) as 工序备注,
  97. rtrim(Gy0_sbbh) as 机组,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_生产工时) as 生产工时,rtrim(Gy0_辅助工时) as 辅助工时,
  98. rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(UniqId) as UNIQID';
  99. $list = \db('工单_工艺资料')->where($where)->field($filed)->select();
  100. if (empty($list)){
  101. $this->success('',[]);
  102. }
  103. foreach ($list as $key=>$value){
  104. if ((int)$value['Gy0_yjno'] <10){
  105. $value['Gy0_yjno'] = '0'.rtrim($value['Gy0_yjno']);
  106. }
  107. if ((int)$value['Gy0_gxh'] <10){
  108. $value['Gy0_gxh'] = '0'.rtrim($value['Gy0_gxh']);
  109. }
  110. if (rtrim($value['Add_gxmc']) == ''){
  111. $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']);
  112. }else{
  113. $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
  114. }
  115. unset($list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
  116. }
  117. $this->success('成功',$list);
  118. }
  119. /**
  120. * 计划中工单->印件资料
  121. * @ApiMethod (GET)
  122. * @param string $Gd_gdbh 工单编号
  123. * @return \think\response\Json
  124. * @throws \think\db\exception\DataNotFoundException
  125. * @throws \think\db\exception\ModelNotFoundException
  126. * @throws \think\exception\DbException
  127. */
  128. public function projectPrint()
  129. {
  130. if ($this->request->isGet() === false){
  131. $this->error('请求错误');
  132. }
  133. $Gd_gdbh = input('Gd_gdbh');
  134. if (empty($Gd_gdbh)){
  135. $this->error('参数错误');
  136. }
  137. $where = [
  138. 'Yj_Gdbh' => $Gd_gdbh,
  139. ];
  140. $field = 'rtrim(Yj_Gdbh) as 工单编号,rtrim(yj_Yjno) as 印件号,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_yjmc) as 印件名称,
  141. rtrim(yj_zzmc) as 纸张名称,rtrim(yj_tlgg) as 投料规格,rtrim(yj_成品数量) as 成品数量,rtrim(yj_实际投料) as 实际投料,
  142. rtrim(yj_Dw) as 投料单位,rtrim(yj_平张投料) as 平张投料,rtrim(yj_ls) as 联数,rtrim(yj_ks) as 开数,rtrim(Sys_id) as 创建用户,
  143. rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID';
  144. $list = \db('工单_印件资料')->where($where)->field($field)->select();
  145. if (empty($list)){
  146. $this->success('');
  147. }
  148. foreach ($list as $key=>$value){
  149. $list[$key]['成品数量'] = rtrim((float)$value['成品数量']);
  150. $list[$key]['实际投料'] = rtrim((float)$value['实际投料']);
  151. }
  152. $this->success('成功',$list);
  153. }
  154. /**
  155. * 排程中/制程中工单
  156. */
  157. public function Schedule(){
  158. if ($this->request->isGet() === false){
  159. $this->error('请求错误');
  160. }
  161. $param = $this->request->param();
  162. if (empty($param)){
  163. $this->error('参数错误');
  164. }
  165. $where = '';
  166. if (!empty($param['search'])){
  167. $where = "
  168. a.Gd_gdbh LIKE '%{$param['search']}%'
  169. OR a.`成品名称` LIKE '%{$param['search']}%'
  170. ";
  171. }
  172. if ($param['status'] === '排程中'){
  173. $list = db('工单_基本资料')->alias('a')
  174. ->field([
  175. 'rtrim(a.Gd_gdbh)' => '工单编号',
  176. 'rtrim(a.Gd_cpdh)' => '产品代号',
  177. 'rtrim(a.Gd_cpmc)' => '产品名称',
  178. 'rtrim(a.接单日期)' => '接单日期',
  179. 'rtrim(a.交货日期)' => '交货日期',
  180. 'rtrim(a.订单数量)' => '订单数量',
  181. 'rtrim(a.计量单位)' => '计量单位',
  182. 'rtrim(a.销售订单号)' => '销售订单号',
  183. 'rtrim(a.Gd_客户代号)' => '客户编号',
  184. 'rtrim(a.Gd_客户名称)' => '客户名称',
  185. 'rtrim(a.客户料号)' => '客户料号',
  186. 'rtrim(a.Uniqid)' => 'GDUID',
  187. ])
  188. ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
  189. ->where([
  190. 'a.gd_statu' => '2-生产中',
  191. 'a.行号' => '1',
  192. 'b.PD_WG' => '1900-01-01 00:00:00',
  193. ])
  194. ->where($where)
  195. // ->whereNotExists(function ($query) {
  196. // $query->table('工单_工艺资料')->alias('b2')
  197. // ->where('b2.Gy0_gdbh = a.Gd_gdbh')
  198. // ->where('b2.Gy0_sj1 <> "1900-01-01 00:00:00"');
  199. // })
  200. ->group('a.Gd_gdbh')
  201. ->select();
  202. }else{
  203. $list = db('工单_基本资料')->alias('a')
  204. ->field([
  205. 'rtrim(a.Gd_gdbh)' => '工单编号',
  206. 'rtrim(a.Gd_cpdh)' => '产品代号',
  207. 'rtrim(a.Gd_cpmc)' => '产品名称',
  208. 'rtrim(a.接单日期)' => '接单日期',
  209. 'rtrim(a.交货日期)' => '交货日期',
  210. 'rtrim(a.订单数量)' => '订单数量',
  211. 'rtrim(a.计量单位)' => '计量单位',
  212. 'rtrim(a.销售订单号)' => '销售订单号',
  213. 'rtrim(a.Gd_客户代号)' => '客户编号',
  214. 'rtrim(a.Gd_客户名称)' => '客户名称',
  215. 'rtrim(a.客户料号)' => '客户料号',
  216. 'rtrim(a.Uniqid)' => 'GDUID',
  217. ])
  218. ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
  219. ->where([
  220. 'a.gd_statu' => '2-生产中',
  221. 'a.行号' => '1',
  222. 'b.PD_WG' => '1900-01-01 00:00:00',
  223. 'b.Gy0_sj1' => ['<>', '1900-01-01 00:00:00'],
  224. ])
  225. ->where($where)
  226. ->group('a.Gd_gdbh')
  227. ->select();
  228. }
  229. if (empty($list)){
  230. $this->success('未找到工单信息');
  231. }
  232. $this->success('成功',$list);
  233. }
  234. /**
  235. * 排程中/制程中工单->工序列表
  236. * @ApiMethod (GET)
  237. * @param string $Gd_gdbh 工单编号
  238. * @return \think\response\Json
  239. * @throws \think\db\exception\DataNotFoundException
  240. * @throws \think\db\exception\ModelNotFoundException
  241. * @throws \think\exception\DbException
  242. */
  243. public function ScheduleProcess()
  244. {
  245. if ($this->request->isGet() === false){
  246. $this->error('请求错误');
  247. }
  248. $Gd_gdbh = input('Gd_gdbh');
  249. if (empty($Gd_gdbh)){
  250. $this->error('参数错误');
  251. }
  252. $sql = "SELECT rtrim(a.Gy0_gdbh) as 工单编号,a.Gy0_yjno,a.Gy0_gxh,a.Gy0_gxmc,a.Add_gxmc,rtrim(a.Gy0_sbbh) as 设备编号,rtrim(a.Gy0_小时产能) as 小时产能,
  253. rtrim(a.工价系数) as 产能系数,rtrim(a.Gy0_生产工时) as 生产工时,rtrim(a.Gy0_辅助工时) as 辅助工时,rtrim(a.Gy0_最早开工时间) as 最早开工时间,
  254. rtrim(a.Gy0_sj1) as 计划开工时间,rtrim(a.Gy0_sj2) as 计划完工时间,rtrim(a.Gy0_班次安排) as 班次安排,rtrim(a.工序备注) as 排单备注,
  255. rtrim(a.PD_WG) as 工序完工,rtrim(a.UniqId) as UniqId,COALESCE(b.cl, 0) AS 产量, c.设备名称,rtrim(d.计划投料) as 工序产量
  256. FROM `工单_工艺资料` AS a
  257. JOIN `设备_基本资料` AS c ON a.Gy0_sbbh = c.设备编号
  258. JOIN `工单_基本资料` As d ON a.Gy0_gdbh = d.Gd_Gdbh
  259. LEFT JOIN (
  260. SELECT sczl_gdbh, sczl_gxh, SUM(sczl_cl) AS cl
  261. FROM `设备_产量计酬`
  262. GROUP BY sczl_gdbh, sczl_gxh
  263. ) AS b ON a.Gy0_gdbh = b.sczl_gdbh AND (a.Gy0_gxh = b.sczl_gxh OR b.sczl_gxh IS NULL)
  264. WHERE a.Gy0_gdbh = '{$Gd_gdbh}' AND a.Gy0_sbbh != ''
  265. GROUP BY a.Gy0_yjno,a.Gy0_gxh";
  266. $list = Db::query($sql);
  267. if (empty($list)){
  268. $this->success('未找到工序');
  269. }
  270. foreach ($list as $key=>$value){
  271. if ((int)$value['Gy0_yjno'] <10){
  272. $value['Gy0_yjno'] = '0'.rtrim($value['Gy0_yjno']);
  273. }
  274. if ((int)$value['Gy0_gxh'] <10){
  275. $value['Gy0_gxh'] = '0'.rtrim($value['Gy0_gxh']);
  276. }
  277. if (rtrim($value['Add_gxmc']) == ''){
  278. $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']);
  279. }else{
  280. $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
  281. }
  282. unset($list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
  283. $list[$key]['机组'] = $value['设备编号'];
  284. $list[$key]['剩余产量'] = (int)$list[$key]['工序产量']-(int)$list[$key]['产量'];
  285. }
  286. $this->success('成功',$list);
  287. }
  288. /**
  289. * 排单页面左侧车间和机台菜单
  290. * @ApiMethod (GET)
  291. * @return \think\response\Json
  292. * @throws \think\db\exception\DataNotFoundException
  293. * @throws \think\db\exception\ModelNotFoundException
  294. * @throws \think\exception\DbException
  295. */
  296. public function workbench()
  297. {
  298. if ($this->request->isGet() === false){
  299. $this->error('请求错误');
  300. }
  301. $param = $this->request->param();
  302. if (isset($param['sort'])){
  303. $where['使用部门'] = '智能车间';
  304. }else{
  305. $where['使用部门'] = ['in',['印刷车间','印后车间']];
  306. }
  307. $data = [];
  308. $department = \db('设备_基本资料')
  309. ->distinct(true)
  310. ->where('使用部门','<>','研发中心')
  311. ->where('设备编组','<>','')
  312. ->where($where)
  313. ->order('设备编组')
  314. ->column('使用部门');
  315. if (empty($department)){
  316. $this->success('为获取到机台数据');
  317. }
  318. foreach ($department as $value){
  319. $benchClass = \db('设备_基本资料')->where('使用部门',$value)->distinct(true)->order('设备编组')->column('设备编组');
  320. foreach ($benchClass as $v){
  321. if (rtrim($v) !== ''){
  322. $machine = \db('设备_基本资料')->where('使用部门',$value)->where('设备编组',$v)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
  323. foreach ($machine as $kk=>$vv){
  324. $data[rtrim($value)][rtrim($v)][$kk] = $vv['设备编号'].'-->'.$vv['设备名称'];
  325. }
  326. }
  327. }
  328. }
  329. $this->success('成功',$data);
  330. }
  331. /**
  332. * 工单状态设置
  333. * @ApiMethod (GET)
  334. * @param string $workOrder 工单编号
  335. * @param string $status 工单状态
  336. * @return void
  337. * @throws \think\Exception
  338. * @throws \think\exception\PDOException
  339. */
  340. public function StatusEdit()
  341. {
  342. if (Request::instance()->isPost() === false){
  343. $this->error('请求错误');
  344. }
  345. $workOrder = input('workOrder');
  346. $status = input('status');
  347. if (empty($workOrder) || empty($status)){
  348. $this->error('参数错误');
  349. }
  350. $sql = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->fetchSql(true)->update(['gd_statu'=>$status]);
  351. $res = Db::query($sql);
  352. if ($res !== false){
  353. $this->success('成功');
  354. }else{
  355. $this->error('失败');
  356. }
  357. }
  358. /**
  359. * 更改工序状态
  360. * @ApiMethod (GET)
  361. * @param void
  362. * @return void
  363. * @throws \think\Exception
  364. * @throws \think\exception\PDOException
  365. */
  366. public function complete()
  367. {
  368. if ($this->request->isGet() === false){
  369. $this->error('请求错误');
  370. }
  371. $data = $this->request->param();
  372. if (empty($data)){
  373. $this->error('参数错误');
  374. }
  375. $where = [
  376. 'Gy0_gdbh' => $data['workOrder'],
  377. 'Gy0_gxh' => $data['processCode']
  378. ];
  379. $sql = \db('工单_工艺资料')->where($where)->fetchSql(true)->update(['PD_WG'=>date('Y-m-d H:i:s',time())]);
  380. $res = Db::query($sql);
  381. if ($res !== false){
  382. $this->success('成功');
  383. }else{
  384. $this->error('失败');
  385. }
  386. }
  387. /**
  388. * 加入排产
  389. * @ApiMethod (POST)
  390. * @param void $data
  391. * @return void
  392. * @throws \think\Exception
  393. * @throws \think\db\exception\DataNotFoundException
  394. * @throws \think\db\exception\ModelNotFoundException
  395. * @throws \think\exception\DbException
  396. * @throws \think\exception\PDOException
  397. */
  398. public function ProductionSchedulingAdd()
  399. {
  400. if (Request::instance()->isPost() === false){
  401. $this->error('请求错误');
  402. }
  403. $data = Request::instance()->post();
  404. if (empty($data)){
  405. $this->error('参数错误');
  406. }
  407. $where = [
  408. 'Gy0_gdbh' => $data['workOrder'],
  409. 'Gy0_sbbh' => ['like','%'.$data['machine'].'%'],
  410. 'Gy0_yjno' => $data['printCode'],
  411. 'Gy0_gxh' => $data['processCode']
  412. ];
  413. $result = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj1) as sj1')->find();
  414. if ($result['sj1'] != '1900-01-01 00:00:00'){
  415. $this->error('该工单已经是制程中');
  416. }
  417. $lastTime = \db('工单_工艺资料')
  418. ->where(['Gy0_sbbh'=>$where['Gy0_sbbh'],'Gy0_sj2'=>['<>','1900-01-01 00:00:00'],'Gy0_sj2'=>['<','2099-01-01 00:00:00']])
  419. ->field('rtrim(Gy0_sj2) as sj2')
  420. ->order('Gy0_sj2 desc')
  421. ->find();
  422. $date = date('Y-m-d H:i:s',time());
  423. if ($lastTime['sj2'] < $date){
  424. $newTime = $date;
  425. }else{
  426. $newTime = $lastTime['sj2'];
  427. }
  428. $row = \db('工单_工艺资料')
  429. ->where($where)
  430. ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
  431. ->find();
  432. if (empty($row)){
  433. $this->success('未找到该工单工艺资料');
  434. }
  435. $endTime = date('Y-m-d H:i:s',strtotime($newTime) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
  436. $sql = \db('工单_工艺资料')
  437. ->where($where)
  438. ->fetchSql(true)
  439. ->update(['Gy0_sj1'=>$newTime,'Gy0_sj2'=>$endTime,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
  440. $res = Db::query($sql);
  441. if ($res !== false){
  442. $this->success('成功');
  443. }else{
  444. $this->error('失败');
  445. }
  446. }
  447. /**
  448. * 暂停排产
  449. * @ApiMethod (POST)
  450. * @param void $data
  451. * @return void
  452. * @throws \think\Exception
  453. * @throws \think\db\exception\DataNotFoundException
  454. * @throws \think\db\exception\ModelNotFoundException
  455. * @throws \think\exception\DbException
  456. * @throws \think\exception\PDOException
  457. */
  458. public function ProductionSchedulingPause()
  459. {
  460. if (Request::instance()->isPost() === false){
  461. $this->error('请求错误');
  462. }
  463. $data = Request::instance()->post();
  464. if (empty($data)){
  465. $this->error('参数错误');
  466. }
  467. $where = [
  468. 'Gy0_gdbh' => $data['workOrder'],
  469. 'Gy0_sbbh' => ['like','%'.$data['machine'].'%'],
  470. 'Gy0_yjno' => $data['printCode'],
  471. 'Gy0_gxh' => $data['processCode']
  472. ];
  473. $machine = $data['machine'];
  474. $endTime = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2,rtrim(PD_WG) as wg')->find();
  475. if (empty($endTime)){
  476. $this->success('未找到该工序');
  477. }
  478. $time = $endTime['sj2'];
  479. if ($endTime['sj2'] == '1900-01-01 00:00:00' || $endTime['wg'] != '1900-01-01 00:00:00'){
  480. $this->error('该工单不是制程中工单');
  481. }
  482. $sql = \db('工单_工艺资料')
  483. ->where($where)
  484. ->fetchSql(true)
  485. ->update(['Gy0_sj1'=>'1900-01-01 00:00:00','Gy0_sj2'=>'1900-01-01 00:00:00','Mod_rq'=>date('Y-m-d H:i:s')]);
  486. $row = \db('工单_工艺资料')
  487. ->where($where)
  488. ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
  489. ->find();
  490. if (empty($row)){
  491. $this->success('未找到该工序');
  492. }
  493. $number = -(int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'];
  494. $rechSql = "UPDATE `工单_工艺资料` SET Gy0_sj1 = DATE_ADD(Gy0_sj1, INTERVAL {$number} HOUR),Gy0_sj2 = DATE_ADD(Gy0_sj2, INTERVAL {$number} HOUR) WHERE Gy0_sbbh LIKE '%{$machine}%' AND Gy0_sj1 >= '{$time}' AND Gy0_sj1 < '2099-01-01 00:00:00'";
  495. $rechres = Db::query($rechSql);
  496. $res = Db::query($sql);
  497. if ($res !== false && $rechres !== false){
  498. $this->success('成功');
  499. }else{
  500. $this->error('失败');
  501. }
  502. }
  503. /**
  504. * 工序状态更正
  505. * @ApiMethod (GET)
  506. * @param void $param
  507. * @return void
  508. * @throws \think\db\exception\DataNotFoundException
  509. * @throws \think\db\exception\ModelNotFoundException
  510. * @throws \think\exception\DbException
  511. */
  512. public function ProcessStatusCorrection()
  513. {
  514. if ($this->request->isGet() === false){
  515. $this->error('请求错误');
  516. }
  517. $param = $this->request->param();
  518. if (empty($param)){
  519. $this->error('参数错误');
  520. }
  521. $where = [
  522. 'Gy0_gdbh' => $param['workOrder'],
  523. ];
  524. $workOrder = $where['Gy0_gdbh'];
  525. $field = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Gy0_sbbh) as 设备代号,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_ls) as ls,rtrim(PD_WG) as 完工时间,rtrim(UniqId) as UniqId';
  526. $list = \db('工单_工艺资料')->where($where)->field($field)->order('Gy0_yjno,Gy0_gxh')->select();
  527. if (empty($list)){
  528. $this->success('未找到该工单工艺资料');
  529. }
  530. $yieldSql = "SELECT
  531. a.Gy0_yjno AS yjno,
  532. a.Gy0_gxh AS gxh,
  533. SUM( b.sczl_cl ) AS cl
  534. FROM
  535. `工单_工艺资料` AS a
  536. JOIN `设备_产量计酬` AS b ON a.Gy0_gxh = b.sczl_gxh AND a.Gy0_yjno = b.sczl_yjno
  537. WHERE
  538. a.Gy0_gdbh = '{$workOrder}'
  539. GROUP BY
  540. a.Gy0_yjno,a.Gy0_gxh";
  541. $yield = Db::query($yieldSql);
  542. foreach ($list as $key=>$value){
  543. if ($value['yjno']<10){
  544. $value['yjno'] = '0'.$value['yjno'];
  545. }
  546. if ($value['gxh']<10){
  547. $value['gxh'] = '0'.$value['gxh'];
  548. }
  549. $list[$key]['印件及工序'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
  550. foreach ($yield as $k=>$v){
  551. if ($v['yjno'] === $list[$key]['yjno']) {
  552. if ($v['gxh'] === $list[$key]['gxh']){
  553. $list[$key]['计划产量/已完成'] = (int)$value['计划接货数'] . '/' . $v['cl'];
  554. if ($value['计划接货数'] !== 0 && $value['计划接货数'] !== '' && !empty($value['计划接货数'])) {
  555. $num = (float)number_format(intval($v['cl']) / intval($value['计划接货数']), 4);
  556. $list[$key]['完成率'] = $num * 100 . '%';
  557. } else {
  558. $list[$key]['完成率'] = '';
  559. }
  560. }else{
  561. $list[$key]['计划产量/已完成'] = $value['计划接货数'].'/0';
  562. $list[$key]['完成率'] = '';
  563. }
  564. }
  565. }
  566. if ($value['完工时间'] == '1900-01-01 00:00:00') {
  567. $list[$key]['完工时间'] = '';
  568. }
  569. unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['计划接货数'],$list[$key]['ls']);
  570. }
  571. $this->success('成功',$list);
  572. }
  573. /**
  574. * 工序状态更正->工序状态编辑
  575. * @ApiMethod (POST)
  576. * @param void
  577. * @return void
  578. * @throws \think\Exception
  579. * @throws \think\exception\PDOException
  580. */
  581. public function ProcessStatusCorrectionEdit()
  582. {
  583. if (Request::instance()->isPost() === false){
  584. $this->error('请求错误');
  585. }
  586. $param = Request::instance()->post();
  587. if (empty($param)){
  588. $this->error('参数错误');
  589. }
  590. $i = 0;
  591. foreach ($param as $key=>$value){
  592. if ($value['PD_WG'] === null || $value['PD_WG'] === ''){
  593. $endTime = '1900-01-01 00:00:00';
  594. }else{
  595. $endTime = $value['PD_WG'];
  596. }
  597. $sql = \db('工单_工艺资料')
  598. ->where('UniqId',$value['UniqId'])
  599. ->fetchSql(true)
  600. ->update(['PD_WG'=>$endTime]);
  601. $res = Db::query($sql);
  602. if ($res !== false){
  603. $i++;
  604. }
  605. }
  606. if ($i !== 0){
  607. $this->success('成功');
  608. }else{
  609. $this->error('失败');
  610. }
  611. }
  612. /**
  613. * 班次选择
  614. * @ApiMethod (GET)
  615. * @return void
  616. * @throws \think\db\exception\DataNotFoundException
  617. * @throws \think\db\exception\ModelNotFoundException
  618. * @throws \think\exception\DbException
  619. */
  620. public function ScheduleSelection()
  621. {
  622. if ($this->request->isGet() === false){
  623. $this->error('请求错误');
  624. }
  625. $list = \db('工单_排程班次')->field('rtrim(bcdh) as 班次代号,rtrim(desc_) as desc_,rtrim(stdtime) as stdtime')->select();
  626. if (empty($list)){
  627. $this->success('未找到班次数据');
  628. }
  629. foreach ($list as $key=>$value){
  630. $list[$key]['detail'] = $value['班次代号'].'||'.$value['desc_'].'||'.$value['stdtime'];
  631. unset($list[$key]['desc_'],$list[$key]['stdtime']);
  632. }
  633. $this->success('成功',$list);
  634. }
  635. /**
  636. * 车间设备制程展示
  637. * @ApiMethod (GET)
  638. * @param void $param
  639. * @return void
  640. * @throws \think\db\exception\DataNotFoundException
  641. * @throws \think\db\exception\ModelNotFoundException
  642. * @throws \think\exception\DbException
  643. */
  644. public function EquipmentScheduling()
  645. {
  646. if ($this->request->isGet() === false){
  647. $this->error('参数错误');
  648. }
  649. $param = $this->request->param();
  650. if (empty($param)){
  651. $this->error('参数错误');
  652. }
  653. $machine = $param['machine'];
  654. $list = \db('工单_基本资料')
  655. ->alias('a')
  656. ->field([
  657. 'rtrim(b.Gy0_gdbh)' => '工单编号',
  658. 'rtrim(b.Gy0_计划接货数)' => '计划接货数',
  659. 'rtrim(b.Gy0_小时产能)' => '小时产能',
  660. 'rtrim(b.Gy0_生产工时)' => '生产工时',
  661. 'rtrim(b.Gy0_辅助工时)' => '辅助工时',
  662. 'rtrim(b.Gy0_班次安排)' => '班次安排',
  663. 'rtrim(b.工序备注)' => '排单备注',
  664. 'rtrim(b.Gy0_最早开工时间)' => '最早开工时间',
  665. 'rtrim(b.Gy0_sj1)' => '计划开工时间',
  666. 'rtrim(b.Gy0_sj2)' => '计划完工时间',
  667. 'rtrim(b.Gy0_yjno)' => 'yjno',
  668. 'rtrim(b.Gy0_gxh)' => 'gxh',
  669. 'rtrim(b.Gy0_gxmc)' => 'gxmc',
  670. 'rtrim(b.Gy0_ls)' => 'ls',
  671. 'rtrim(b.UniqId)' => 'UniqId',
  672. 'SUM(c.sczl_cl)' => '已完成'
  673. ])
  674. ->join('工单_工艺资料 b','a.Gd_gdbh = b.Gy0_gdbh')
  675. ->join('设备_产量计酬 c','a.Gd_gdbh = c.sczl_gdbh AND b.Gy0_yjno = c.sczl_yjno AND b.Gy0_gxh = c.sczl_gxh','LEFT')
  676. ->where([
  677. 'b.Gy0_sbbh' => $machine,
  678. 'b.Gy0_sj1' => ['>','1900-01-01 00:00:00'],
  679. 'b.PD_WG' => '1900-01-01 00:00:00',
  680. 'a.gd_statu' => '2-生产中'
  681. ])
  682. ->where('b.Gy0_sj1','<','2099-01-01 00:00:00')
  683. ->group('a.Gd_gdbh')
  684. ->select();
  685. foreach ($list as $key=>$value){
  686. $list[$key]['计划接货数'] = (int)round($value['计划接货数']/$value['ls']);
  687. if ($value['yjno']<10){
  688. $value['yjno'] = '0'.$value['yjno'];
  689. }
  690. if ($value['gxh']<10){
  691. $value['gxh'] = '0'.$value['gxh'];
  692. }
  693. $list[$key]['印件/工序'] = $value['yjno'].'-'.$value['gxh'].'-'.$value['gxmc'];
  694. unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['ls']);
  695. }
  696. $this->success('成功',$list);
  697. }
  698. /**
  699. * 车间设备排程编辑
  700. * @ApiMethod (POST)
  701. * @param void $param
  702. * @return void
  703. * @throws \think\Exception
  704. * @throws \think\exception\PDOException
  705. */
  706. public function EquipmentSchedulingEdit()
  707. {
  708. if (Request::instance()->isPost() === false){
  709. $this->error('请求错误');
  710. }
  711. $param = Request::instance()->post();
  712. if (empty($param)){
  713. $this->error('参数错误');
  714. }
  715. $i = 0;
  716. foreach ($param as $key=>$value){
  717. $data = [
  718. 'Gy0_小时产能' => $value['capacity'],
  719. 'Gy0_生产工时' => $value['ProductionHours'],
  720. 'Gy0_辅助工时' => $value['AuxiliaryHours'],
  721. 'Gy0_班次安排' => $value['shift'],
  722. '工序备注' => $value['remark'],
  723. 'Gy0_最早开工时间' => $value['start'] === ''?'1900-01-01 00:00:00':date('Y-m-d H:i:s',strtotime($value['start'])),
  724. 'Gy0_sj1' => date('Y-m-d H:i:s',strtotime($value['projectTime'])),
  725. // 'Gy0_sj2' => date('Y-m-d H:i:s',strtotime($value['projectTime'])+(ceil($value['ProductionHours'])+ceil($value['AuxiliaryHours']))*3600),
  726. 'Gy0_sj2' => date('Y-m-d H:i:s',strtotime($value['endTime'])),
  727. ];
  728. $sql = \db('工单_工艺资料')
  729. ->where('UniqId',$value['UniqId'])
  730. ->fetchSql(true)
  731. ->update($data);
  732. $res = Db::query($sql);
  733. if ($res !== false){
  734. $i++;
  735. }
  736. }
  737. if ($i !== 0){
  738. $this->success('成功');
  739. }else{
  740. $this->error('失败');
  741. }
  742. }
  743. /**
  744. * 机台工单展示
  745. * @ApiMethod ()
  746. * @return void
  747. * @throws \think\db\exception\BindParamException
  748. * @throws \think\exception\PDOException
  749. */
  750. public function MachineWorkOrderList()
  751. {
  752. if ($this->request->isGet() === false){
  753. $this->error('请求失败');
  754. }
  755. $param = $this->request->param();
  756. if (empty($param)){
  757. $this->error('参数错误');
  758. }
  759. $where = '';
  760. if (isset($param['search'])){
  761. $where = "
  762. b.Gd_gdbh LIKE '%{$param['search']}%'
  763. OR b.`成品名称` LIKE '%{$param['search']}%'
  764. ";
  765. }
  766. $list = \db('工单_工艺资料')
  767. ->alias('a')
  768. ->field([
  769. 'RTRIM( a.Gy0_yjno )' =>'yjno',
  770. 'RTRIM( a.Gy0_gxh )' => 'gxh',
  771. 'RTRIM( a.Gy0_gxmc )' => 'gxmc',
  772. 'RTRIM( a.Add_gxmc )' => 'Add_gxmc',
  773. 'RTRIM( c.yj_yjmc )' => '印件名称',
  774. 'RTRIM( a.`Gy0_计划接货数` )' => '计划接货数',
  775. 'RTRIM( a.`Gy0_小时产能` )' => '小时产能',
  776. 'RTRIM( a.`工价系数` )' => '产能系数',
  777. 'RTRIM( a.`Gy0_生产工时` )' => '生产工时',
  778. 'RTRIM( a.Gy0_ls )' => 'ls',
  779. 'RTRIM( a.`Gy0_辅助工时` )' => '辅助工时',
  780. 'RTRIM( a.`Gy0_最早开工时间` )' => '最早开工时间',
  781. 'RTRIM( a.Gy0_sj1 )' => '计划开工时间',
  782. 'RTRIM( a.Gy0_sj2 )' => '计划完工时间',
  783. 'RTRIM( a.`Gy0_班次安排` )' => '班次安排',
  784. 'RTRIM( a.`工序备注` )' => '排单备注',
  785. 'RTRIM( b.Gd_cpmc )' => '产品名称',
  786. 'RTRIM( b.`成品名称` )' => '成品名称',
  787. 'RTRIM( b.`订单数量` )' => '订单数量',
  788. 'RTRIM( b.`计量单位` )' => '计量单位',
  789. 'RTRIM( b.`交货日期` )' => '交货日期',
  790. 'RTRIM( b.Gd_cpdh )' => '产品代号',
  791. 'RTRIM( b.`成品代号` )' => '成品代号',
  792. 'RTRIM( a.Gy0_sbbh )' => '设备编号',
  793. 'RTRIM( a.Gy0_SITE )' => '车间名称',
  794. 'RTRIM( a.UniqId )' => 'GYUID',
  795. 'RTRIM( b.Uniqid )' => 'UNIQID',
  796. 'SUM( d.sczl_cl )' => '已完成产量',
  797. 'RTRIM( b.Gd_gdbh )' => '工单编号',
  798. 'RTRIM( b.`销售订单号` )' => '销售订单号',
  799. ])
  800. ->join('工单_印件资料 c','c.Yj_Gdbh = a.Gy0_gdbh AND c.yj_Yjno = a.Gy0_yjno')
  801. ->join('工单_基本资料 b','b.Gd_gdbh = a.Gy0_gdbh')
  802. ->join('设备_产量计酬 d','a.Gy0_gdbh = d.sczl_gdbh AND a.Gy0_yjno = d.sczl_yjno AND a.Gy0_gxh = d.sczl_gxh AND a.Gy0_sbbh = d.sczl_jtbh','LEFT')
  803. ->where([
  804. 'b.gd_statu' => '2-生产中',
  805. 'a.Gy0_sbbh' => ['LIKE','%'.$param['machine'].'%'],
  806. 'a.PD_WG' => '1900-01-01 00:00:00',
  807. ])
  808. ->where($where)
  809. ->group('a.Gy0_gdbh,a.Gy0_yjno,a.Gy0_gxh')
  810. ->order('Gy0_sj1')
  811. ->select();
  812. if (empty($list)){
  813. $this->success('',[]);
  814. }
  815. $data['制程'] = $data['排程'] = [];
  816. foreach ($list as $key=>$value){
  817. $list[$key]['设备编号'] = $param['machine'];
  818. if ((int)$value['yjno'] <10){
  819. $value['yjno'] = '0'.rtrim($value['yjno']);
  820. }
  821. if ((int)$value['gxh'] <10){
  822. $value['gxh'] = '0'.rtrim($value['gxh']);
  823. }
  824. if (rtrim($value['Add_gxmc']) == ''){
  825. $list[$key]['印件工序及名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.rtrim($value['gxmc']);
  826. }else{
  827. $list[$key]['印件工序及名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.rtrim($value['gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
  828. }
  829. unset($list[$key]['Add_gxmc']);
  830. if ($value['产品名称'] == ''){
  831. $list[$key]['产品名称'] = $value['成品名称'];
  832. }
  833. if ($value['产品代号'] == ''){
  834. $list[$key]['产品代号'] = $value['成品代号'];
  835. }
  836. unset($list[$key]['成品代号'],$list[$key]['成品名称']);
  837. if ($list[$key]['计划开工时间'] !== '1900-01-01 00:00:00'){
  838. array_push($data['制程'],$list[$key]);
  839. }else{
  840. array_push($data['排程'],$list[$key]);
  841. }
  842. }
  843. $this->success('成功',$data);
  844. }
  845. /**
  846. * 机组调整
  847. * @return void
  848. * @throws \think\Exception
  849. * @throws \think\db\exception\BindParamException
  850. * @throws \think\exception\PDOException
  851. */
  852. public function MachineTeamEdit()
  853. {
  854. if ($this->request->isGet() === false){
  855. $this->error('请求错误');
  856. }
  857. $param = $this->request->param();
  858. if (empty($param) || isset($param['UniqId']) === false){
  859. $this->error('参数错误');
  860. }
  861. $sql = \db('工单_工艺资料')
  862. ->where('UniqId',$param['UniqId'])
  863. ->fetchSql(true)
  864. ->update(['Gy0_sbbh'=>$param['machine']]);
  865. $res = \db()->query($sql);
  866. if ($res !== false){
  867. $this->success('修改成功');
  868. }else{
  869. $this->error('修改失败');
  870. }
  871. }
  872. /**
  873. * 子订单领料派单
  874. * @return void
  875. * @throws \think\db\exception\BindParamException
  876. * @throws \think\exception\PDOException
  877. */
  878. public function processAdd()
  879. {
  880. if (Request::instance()->post() === false){
  881. $this->error('参数错误');
  882. }
  883. $param = Request::instance()->post();
  884. if (empty($param)){
  885. $this->error('参数错误');
  886. }
  887. $data['班组编号'] = $param['班组'];
  888. $data['订单编号'] = $param['订单编号'];
  889. $data['子订单编号'] = $param['子订单编号'];
  890. $data['sys_id'] = $param['Sys_id'];
  891. $data['sys_rq'] = date('Y-m-d H:i:s',time());
  892. $sql = \db('工单_排程班次')->fetchSql(true)->insert($data);
  893. $res = \db()->query($sql);
  894. if ($res !== false){
  895. $this->success('成功');
  896. }else{
  897. $this->error('失败');
  898. }
  899. }
  900. /**
  901. * 车缝班组菜单显示
  902. * @return void
  903. */
  904. public function MachineList()
  905. {
  906. if ($this->request->isGet() === false){
  907. $this->error('请求错误');
  908. }
  909. $list = \db('设备_基本资料')
  910. ->where('生产工序','车缝')
  911. ->column('设备编号');
  912. $this->success('成功',$list);
  913. }
  914. /**
  915. * 班组生产数据
  916. * @return void
  917. * @throws \think\db\exception\DataNotFoundException
  918. * @throws \think\db\exception\ModelNotFoundException
  919. * @throws \think\exception\DbException
  920. */
  921. public function MachineDetail()
  922. {
  923. if ($this->request->isGet() === false){
  924. $this->error('请求错误');
  925. }
  926. $param = $this->request->param();
  927. if (empty($param)){
  928. $this->error('参数错误');
  929. }
  930. $list = \db('工单_排程班次')
  931. ->alias('a')
  932. ->join('工单_印件资料 b','b.订单编号 = a.订单编号 AND a.子订单编号 = a.子订单编号')
  933. ->join('设备_产量计酬 c','a.订单编号 = c.订单编号 AND a.子订单编号 = c.子订单编号','LEFT')
  934. ->field('a.订单编号,a.子订单编号,b.款号,b.颜色,b.船样,b.zdtotal as 制单数,SUM(c.数量) as 已完成')
  935. ->where('a.班组编号',$param['machine'])
  936. ->where('a.mod_rq',null)
  937. ->select();
  938. $this->success('成功',$list);
  939. }
  940. /**
  941. * 工单审核
  942. * @return void
  943. * @throws \think\Exception
  944. * @throws \think\db\exception\BindParamException
  945. * @throws \think\exception\PDOException
  946. */
  947. public function Approval()
  948. {
  949. if ($this->request->isPost() === false){
  950. $this->error('请求错误');
  951. }
  952. $param = Request::instance()->post();
  953. if (empty($param)){
  954. $this->error('参数错误');
  955. }
  956. $data['审核'] = $param['sys_id'];
  957. $data['审核日期'] = date('Y-m-d H:i:s',time());
  958. $sql = \db('工单_基本资料')
  959. ->where('Uniqid',$param['Uniqid'])
  960. ->fetchSql(true)
  961. ->update($data);
  962. $res = \db()->query($sql);
  963. if ($res === false){
  964. $this->error('审核失败');
  965. }else{
  966. $this->success('审核成功');
  967. }
  968. }
  969. /**
  970. * 订单未审核列表
  971. * @return void
  972. * @throws \think\db\exception\DataNotFoundException
  973. * @throws \think\db\exception\ModelNotFoundException
  974. * @throws \think\exception\DbException
  975. */
  976. public function UnapprovalList()
  977. {
  978. if ($this->request->isGet() === false){
  979. $this->error('请求错误');
  980. }
  981. $param = $this->request->param();
  982. if (isset($param)){
  983. $where['订单编号'] = ['like','%'.$param['search'].'%'];
  984. }
  985. $where['审核'] = null;
  986. $where['审核日期'] = null;
  987. $where['Mod_rq'] = null;
  988. $list = \db('工单_基本资料')
  989. ->where($where)
  990. ->select();
  991. $this->success('成功',$list);
  992. }
  993. /**
  994. * 月度工序产量列表
  995. * @return void
  996. * @throws \think\db\exception\DataNotFoundException
  997. * @throws \think\db\exception\ModelNotFoundException
  998. * @throws \think\exception\DbException
  999. */
  1000. public function OrderYieldList()
  1001. {
  1002. if ($this->request->isGet() === false){
  1003. $this->error('请求错误');
  1004. }
  1005. $param = $this->request->param();
  1006. if(empty($param)){
  1007. $this->error('参数错误');
  1008. }
  1009. $time = date('Y-m',strtotime($param['mouth']));
  1010. $list = \db('工单_印件资料')
  1011. ->alias('a')
  1012. ->join('工单_基本资料 b','a.订单编号 = b.订单编号')
  1013. ->join('设备_产量计酬 c','a.订单编号 = c.订单编号 AND a.子订单编号 = c.子订单编号','left')
  1014. ->field('a.订单编号,a.子订单编号,a.款号,a.颜色,a.zdtotal as 制单总数,a.sctotal as 裁切总数,a.ck_rq as 出库日期,
  1015. SUM(c.数量) as 车缝产量,c.后道,c.大烫,c.总检,c.包装')
  1016. ->where('b.Sys_rq','like',$time.'%')
  1017. ->group('a.子订单编号')
  1018. ->order('a.Uniqid')
  1019. ->select();
  1020. $this->success('成功',$list);
  1021. }
  1022. }