|
|
@@ -5,6 +5,7 @@ namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
use Monolog\Handler\IFTTTHandler;
|
|
|
+use Overtrue\Socialite\Providers\WeWorkProvider;
|
|
|
use think\Db;
|
|
|
use think\Request;
|
|
|
use function fast\e;
|
|
|
@@ -900,4 +901,253 @@ class Manufacture extends Api
|
|
|
$this->error('修改失败');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 子订单领料派单
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function processAdd()
|
|
|
+ {
|
|
|
+ if (Request::instance()->post() === false){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $param = Request::instance()->post();
|
|
|
+ if (empty($param)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $data['班组编号'] = $param['班组'];
|
|
|
+ $data['订单编号'] = $param['订单编号'];
|
|
|
+ $data['子订单编号'] = $param['子订单编号'];
|
|
|
+ $data['sys_id'] = $param['Sys_id'];
|
|
|
+ $data['sys_rq'] = date('Y-m-d H:i:s',time());
|
|
|
+ $sql = \db('工单_排程班次')->fetchSql(true)->insert($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res !== false){
|
|
|
+ $this->success('成功');
|
|
|
+ }else{
|
|
|
+ $this->error('失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 车缝班组菜单显示
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function MachineList()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $date = date('Y-m-d 00:00:00',time()-1888000);
|
|
|
+ $arr = \db('设备_产量计酬')
|
|
|
+ ->field([
|
|
|
+ 'DISTINCT(date_format(sczl_rq,"%Y-%m-%d"))' => '时间',
|
|
|
+ 'rtrim(sczl_jtbh)' => '机台编号'
|
|
|
+ ])
|
|
|
+ ->where('sczl_rq','>',$date)
|
|
|
+ ->order('sczl_rq desc')
|
|
|
+ ->select();
|
|
|
+ $MachineList = \db('设备_基本资料')
|
|
|
+ ->where('生产工序','in',['车缝','后道','总检','大烫','包装'])
|
|
|
+ ->select();
|
|
|
+ $list = ['车缝','后道','总检','大烫','包装'];
|
|
|
+ $data =[];
|
|
|
+ foreach ($list as $m=>$n){
|
|
|
+ $data[$n] = [];
|
|
|
+ foreach ($MachineList as $key=>$value){
|
|
|
+ if ($n === $value['生产工序']){
|
|
|
+ $data[$n][$value['设备编号'].'--'.$value['设备编组']] = [];
|
|
|
+ foreach ($arr as $k=>$v){
|
|
|
+ if ($value['设备编号'] === $v['机台编号']){
|
|
|
+ array_push($data[$n][$value['设备编号'].'--'.$value['设备编组']],$v['时间']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->success('成功',$data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 班组生产数据
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function MachineDetail()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = $this->request->param();
|
|
|
+ if (empty($param)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ if (isset($param['date'])){
|
|
|
+ $where['a.sczl_rq'] = $param['date'];
|
|
|
+ }
|
|
|
+ $where['a.sczl_jtbh'] = $param['machine'];
|
|
|
+ $list = \db('设备_产量计酬')
|
|
|
+ ->alias('a')
|
|
|
+ ->join('工单_印件资料 b','b.订单编号 = a.订单编号 AND a.子订单编号 = a.子订单编号')
|
|
|
+ ->field('b.订单编号,b.子订单编号,b.款号,b.颜色,b.船样,a.尺码,b.zdtotal as 制单数,a.数量 as 已完成,a.sys_rq as 上报时间')
|
|
|
+ ->where($where)
|
|
|
+ ->group('a.UniqId')
|
|
|
+ ->select();
|
|
|
+ $this->success('成功',$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工单审核
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function Approval()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = Request::instance()->post();
|
|
|
+ if (empty($param)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ $data['审核'] = $param['sys_id'];
|
|
|
+ $data['审核日期'] = date('Y-m-d H:i:s',time());
|
|
|
+ $sql = \db('工单_基本资料')
|
|
|
+ ->where('Uniqid',$param['Uniqid'])
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update($data);
|
|
|
+ $res = \db()->query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $this->error('审核失败');
|
|
|
+ }else{
|
|
|
+ $this->success('审核成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单未审核列表
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function UnapprovalList()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = $this->request->param();
|
|
|
+ if (isset($param)){
|
|
|
+ $where['订单编号'] = ['like','%'.$param['search'].'%'];
|
|
|
+ }
|
|
|
+ $where['审核'] = null;
|
|
|
+ $where['审核日期'] = null;
|
|
|
+ $where['Mod_rq'] = null;
|
|
|
+ $list = \db('工单_基本资料')
|
|
|
+ ->where($where)
|
|
|
+ ->select();
|
|
|
+ $this->success('成功',$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 月度工序产量列表
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function OrderYieldList()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = $this->request->param();
|
|
|
+// if(empty($param)){
|
|
|
+// $this->error('参数错误');
|
|
|
+// }
|
|
|
+ if (isset($param['search'])){
|
|
|
+ $where['a.订单编号'] = ['like','%'.$param['search'].'%'];
|
|
|
+ }
|
|
|
+ if (isset($param['client'])){
|
|
|
+ $where['b.客户编号'] = $param['client'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $where['b.gd_statu'] = '2-生产中';
|
|
|
+// $time = date('Y-m',strtotime($param['mouth']));
|
|
|
+// $where['b.Sys_rq'] = ['like',$time.'%'];
|
|
|
+ $list = \db('设备_产量计酬')
|
|
|
+ ->alias('a')
|
|
|
+ ->join('工单_基本资料 b','a.订单编号 = b.订单编号')
|
|
|
+ ->join('工单_印件资料 c','a.订单编号 = c.订单编号 AND a.子订单编号 = c.子订单编号')
|
|
|
+ ->field('c.订单编号,c.子订单编号,c.款号,c.颜色,c.zdtotal as 制单总数,c.sctotal as 裁切总数,c.ck_rq as 出库日期,
|
|
|
+ SUM(a.数量) as 产量,a.工序名称')
|
|
|
+ ->where($where)
|
|
|
+ ->whereNotNull('c.sc_rq')
|
|
|
+ ->group('a.订单编号,a.工序名称')
|
|
|
+ ->order('c.Uniqid')
|
|
|
+ ->select();
|
|
|
+ $orderList = \db('工单_印件资料')
|
|
|
+ ->alias('a')
|
|
|
+ ->join('工单_基本资料 b','a.订单编号 = b.订单编号')
|
|
|
+ ->field('a.订单编号,a.子订单编号,a.款号,a.颜色,a.zdtotal as 制单总数,a.sctotal as 裁切总数,a.ck_rq as 出库日期')
|
|
|
+ ->where($where)
|
|
|
+ ->whereNotNull('a.sc_rq')
|
|
|
+ ->group('a.子订单编号')
|
|
|
+ ->order('a.Uniqid')
|
|
|
+ ->select();
|
|
|
+ $data=[];
|
|
|
+ foreach ($orderList as $key=>$value){
|
|
|
+ $data[$key] = $value;
|
|
|
+ foreach ($list as $k=>$v){
|
|
|
+ if ($value['子订单编号'] === $v['子订单编号']){
|
|
|
+ if (isset($data[$key][$v['工序名称']]) === false){
|
|
|
+ $data[$key][$v['工序名称']] = $v['产量'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->success('成功',$data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 月度工序产量左侧菜单
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+// public function dateList()
|
|
|
+// {
|
|
|
+// if ($this->request->isGet() === false){
|
|
|
+// $this->error('请求错误');
|
|
|
+// }
|
|
|
+// // 查询并按月份统计
|
|
|
+// $result = Db::name('工单_基本资料')
|
|
|
+// ->field("DATE_FORMAT(Sys_rq, '%Y-%m') as month")
|
|
|
+// ->group("DATE_FORMAT(Sys_rq, '%Y-%m')")
|
|
|
+// ->select();
|
|
|
+// $list = $this->array_flatten($result);
|
|
|
+// $this->success('成功',$list);
|
|
|
+// }
|
|
|
+//
|
|
|
+// function array_flatten($array) {
|
|
|
+// $result = [];
|
|
|
+// foreach ($array as $value) {
|
|
|
+// if (is_array($value)) {
|
|
|
+// $result = array_merge($result, $this->array_flatten($value));
|
|
|
+// } else {
|
|
|
+// $result[] = $value;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return $result;
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|