|
|
@@ -6,653 +6,381 @@ use app\common\controller\Api;
|
|
|
use \think\Request;
|
|
|
use \think\Db;
|
|
|
/**
|
|
|
- * 车间报工接口
|
|
|
+ * 车间工分报工
|
|
|
*/
|
|
|
class ReportingWork extends Api
|
|
|
{
|
|
|
protected $noNeedLogin = ['*'];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 首页
|
|
|
- *
|
|
|
+ * 根据机台编号获取大工序和人员信息
|
|
|
+ * @ApiMethod (GET)
|
|
|
+ * @param string $machine 机台编号
|
|
|
+ * @return array
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
*/
|
|
|
- public function index()
|
|
|
+ public function getMajorprocessAndPerson()
|
|
|
{
|
|
|
- $this->success('请求成功');
|
|
|
- }
|
|
|
- /**
|
|
|
- * 设置机台状态
|
|
|
- * @ApiMethod POST
|
|
|
- * @params
|
|
|
- */
|
|
|
- public function setMachineStatus(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
+ $this->error('请求方法错误');
|
|
|
}
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (!isset($params['machine']) || empty($params['machine'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
+ $params = $this->request->param();
|
|
|
+ if (empty($params['machine'])) {
|
|
|
+ $this->error('机台编号不能为空');
|
|
|
}
|
|
|
- $machine = $params['machine'].'#';
|
|
|
- $data = [];
|
|
|
-// $lastData = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
|
|
|
- $lastData = \db('设备_产量采集')
|
|
|
-// ->where('设备编号',$machine)
|
|
|
- ->order('UniqId desc')
|
|
|
+ //获取大工序
|
|
|
+ $majorprocess = db('设备_基本资料')
|
|
|
+ ->where('设备编号', $params['machine'])
|
|
|
+ ->field('生产工序,设备编组')
|
|
|
->find();
|
|
|
- $id = $lastData['UniqId'] + 1;
|
|
|
- if (empty($params['order'])){
|
|
|
- unset($lastData['UniqId']);
|
|
|
- $data = $lastData;
|
|
|
- $data['当前状态'] = $params['status'];
|
|
|
- }else{
|
|
|
- $data['当前状态'] = $params['status'];
|
|
|
- $data['时间'] = date('Y-m-d H:i:s');
|
|
|
- $data['设备编号'] = $machine;
|
|
|
- $data['工单编号'] = $params['order'];
|
|
|
- $data['印件号'] = $params['yjno'];
|
|
|
- $data['工序号'] = (int)substr($params['gy_name'],0,2);
|
|
|
- $data['工序名称'] = $params['gy_name'];
|
|
|
- $data['当班产量'] = $params['production_now'];
|
|
|
- $data['累计产量'] = $params['production_all'];
|
|
|
- $class = explode(',',$params['class']);
|
|
|
- $where = [];
|
|
|
- $where['sczl_jtbh'] = $machine;
|
|
|
- for ($i=1;$i<=count($class);$i++){
|
|
|
- $where['sczl_bh'.$i] = $class[$i-1];
|
|
|
- }
|
|
|
-// $classData = \db('设备_班组资料')->where($where)->field('sczl_bzdh,UniqId')->find();
|
|
|
- $classData = \db('设备_班组资料')->where($where)->field('sczl_bzdh,UniqId')->find();
|
|
|
- $data['班组编号'] = $classData['sczl_bzdh'];
|
|
|
- $data['班组ID'] = $classData['UniqId'];
|
|
|
- // 获取当前时间
|
|
|
- $current_time = time();
|
|
|
- // 设置时间范围
|
|
|
- $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
|
|
|
- $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
|
|
|
- $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
|
|
|
- $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
|
|
|
- // 判断当前时间属于哪个时间范围
|
|
|
- if ($current_time >= $start_time1 && $current_time <= $end_time1) {
|
|
|
- $data['开工时间'] = date('Y-m-d') . ' 08:30:00';
|
|
|
- } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
|
|
|
- $data['开工时间'] = date('Y-m-d') . ' 20:30:00';
|
|
|
-
|
|
|
- } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
|
|
|
- $data['开工时间'] = date('Y-m-d',strtotime('+1 day')) . ' 08:30:00';
|
|
|
- }
|
|
|
- $option['Gy0_gdbh'] = $params['order'];
|
|
|
- $option['Gy0_yjno'] = $params['yjno'];
|
|
|
- $option['Gy0_gxh'] = $data['工序号'];
|
|
|
- $data['任务ID'] = \db('工单_工艺资料')->where($option)->value('UniqId');
|
|
|
- }
|
|
|
- $data['UniqId'] = $id;
|
|
|
-// $sql = \db('设备_产量采集')->fetchSql(true)->insert($data);
|
|
|
- $sql = \db('设备_产量采集')->fetchSql(true)->insert($data);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res === false){
|
|
|
- $this->error('设置失败');
|
|
|
- }else{
|
|
|
- $this->success('设置成功');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 设置工单工序完工
|
|
|
- * @ApiMethod POST
|
|
|
- * @params string order
|
|
|
- * @params string yjno
|
|
|
- * @params string gxh
|
|
|
- */
|
|
|
- public function setProcessStatus(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (!isset($params['order']) || empty($params['order'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- if (!isset($params['yjno']) || empty($params['yjno'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- if (!isset($params['gxh']) || empty($params['gxh'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $where['Gy0_gdbh'] = $params['order'];
|
|
|
- $where['Gy0_yjno'] = $params['yjno'];
|
|
|
- $where['Gy0_gxh'] = $params['gxh'];
|
|
|
- $date = date('Y-m-d H:i:s');
|
|
|
- $res = \db('工单_工艺资料')->where($where)->setField('PD_WG',$date);
|
|
|
- if ($res === false){
|
|
|
- $this->error('设置失败');
|
|
|
- }else{
|
|
|
- $this->success('设置成功');
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 根据机台获取生产信息
|
|
|
- * @ApiMethod GET
|
|
|
- * @params string machine
|
|
|
- */
|
|
|
- public function getProduceInfo(){
|
|
|
- if (Request::instance()->isGet() == false) {
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->param();
|
|
|
- if (!isset($params['machine']) || empty($params['machine'])) {
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $machine = $params['machine'].'#';
|
|
|
- $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
|
|
|
- $list = [];
|
|
|
- $list['order'] = $data['工单编号'];
|
|
|
- $list['yjno'] = $data['印件号'];
|
|
|
- $name = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品名称');
|
|
|
- $list['product_name'] = rtrim($name);
|
|
|
- $where['Gy0_gdbh'] = $data['工单编号'];
|
|
|
- $where['Gy0_yjno'] = $data['印件号'];
|
|
|
- $where['Gy0_gxh'] = $data['工序号'];
|
|
|
- $gxmc = \db('工单_工艺资料')->where($where)->value('Gy0_gxmc');
|
|
|
- $list['gxmc'] = rtrim($gxmc);
|
|
|
- $this->success('请求成功',$list);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 根据员工编号获取姓名
|
|
|
- * @ApiMethod GET
|
|
|
- * @params string code
|
|
|
- */
|
|
|
- public function getStaffName(){
|
|
|
- if (Request::instance()->isGet() == false) {
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->param();
|
|
|
- if (!isset($params['code']) || empty($params['code'])) {
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $data = \db('人事_基本资料')->where('员工编号',$params['code'])->value('员工姓名');
|
|
|
- if (empty($data)){
|
|
|
- $data = \db('人事_基本资料')->where('pycode',$params['code'])->value('员工姓名');
|
|
|
- }
|
|
|
- $this->success('请求成功',rtrim($data));
|
|
|
- }
|
|
|
- /**
|
|
|
- * 根据员工编号获取姓名-优化
|
|
|
- * @ApiMethod GET
|
|
|
- * @params string code
|
|
|
- */
|
|
|
- public function getStaffNameTwo(){
|
|
|
- if (Request::instance()->isGet() == false) {
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->param();
|
|
|
- if (!isset($params['code']) || empty($params['code'])) {
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $data = \db('人事_基本资料')->where('员工编号',$params['code'])->field('员工姓名')->select();
|
|
|
- if (empty($data)){
|
|
|
- $data = \db('人事_基本资料')->where('pycode',$params['code'])->field('rtrim(员工姓名) as 员工姓名')->select();
|
|
|
+ if (empty($majorprocess)) {
|
|
|
+ $this->error('设备信息');
|
|
|
+ }
|
|
|
+ //小组信息
|
|
|
+ $person = db('人员_小组资料')
|
|
|
+ ->where('team_name', $majorprocess['设备编组'])
|
|
|
+ ->where('status', 1)
|
|
|
+ ->field('team_name as 小组名称,staff_no as 员工编号,staff_name as 员工姓名')
|
|
|
+ ->select();
|
|
|
+ if (empty($person)) {
|
|
|
+ $this->error('未找到人员信息');
|
|
|
}
|
|
|
- $num = count($data);
|
|
|
- $res['total'] = $num;
|
|
|
- $res['data'] = $data;
|
|
|
- $this->success('请求成功',$res);
|
|
|
+ $data['majorprocess'] = $majorprocess;
|
|
|
+ $data['person'] = $person;
|
|
|
+ $this->success('成功', $data);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * 提交巡查记录
|
|
|
- * @ApiMethod POST
|
|
|
- * @params
|
|
|
+ * 获取订单工艺数据
|
|
|
+ * @ApiMethod (GET)
|
|
|
+ * @param string $workorder 工单编号
|
|
|
+ * @param string $majorprocess 大工序
|
|
|
+ * @return array
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ *
|
|
|
*/
|
|
|
- public function submitPatrolRecord(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
+ public function GetOrderProcess()
|
|
|
+ {
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
+ $this->error('请求方法错误');
|
|
|
}
|
|
|
- $params = Request::instance()->post();
|
|
|
- if (empty($params['machine']) || empty($params['type']) || empty($params['order'])) {
|
|
|
- $this->error('参数错误');
|
|
|
+ $params = $this->request->param();
|
|
|
+ if (empty($params['workorder'])) {
|
|
|
+ $this->error('工单编号不能为空');
|
|
|
}
|
|
|
- if (empty($params['yjno']) || empty($params['process']) || empty($params['no'])) {
|
|
|
- $this->error('参数错误');
|
|
|
+ if (empty($params['majorprocess'])) {
|
|
|
+ $this->error('大工序不能为空');
|
|
|
}
|
|
|
$data = [];
|
|
|
- $data['类别'] = $params['type'];
|
|
|
- $data['工单编号'] = $params['order'];
|
|
|
- $data['印件号'] = $params['yjno'];
|
|
|
- $data['工序名称'] = '';
|
|
|
- $data['班组编号'] = '';
|
|
|
- $data['开工时间'] = '';
|
|
|
- $data['流程单号'] = $params['process'];
|
|
|
- $data['设备编号'] = $params['machine'].'#';
|
|
|
- $data['检验项目'] = '['.$params['no'].'/'.$params['name'].']';
|
|
|
- $data['检验备注'] = $params['remark'];
|
|
|
- $data['提交时间'] = date('Y-m-d H:i:s');
|
|
|
- $data['sys_rq'] = date('Y-m-d H:i:s');
|
|
|
- $produce = \db('设备_产量采集')->where('设备编号',$params['machine'].'#')->where('工单编号',$params['order'])->order('UniqId desc')->find();
|
|
|
-// $produce = \db('设备_产量采集')->where('设备编号',$params['machine'].'#')->where('工单编号',$params['order'])->order('UniqId desc')->find();
|
|
|
- if (!empty($produce)){
|
|
|
- $data['工序名称'] = $produce['工序名称'];
|
|
|
- $data['班组编号'] = rtrim($produce['班组编号']);
|
|
|
- $data['开工时间'] = $produce['开工时间'];
|
|
|
- }
|
|
|
-// $res = \db('制程检验_记录')->field('UniqId')->order('UniqId desc')->find();
|
|
|
- $res = \db('制程检验_记录')->field('UniqId')->order('UniqId desc')->find();
|
|
|
- if (empty($res['UniqId'])){
|
|
|
- $data['UniqId'] = 1;
|
|
|
- }else{
|
|
|
- $data['UniqId'] = $res['UniqId'] + 1;
|
|
|
- }
|
|
|
-// $sql = \db('制程检验_记录')->fetchSql(true)->insert($data);
|
|
|
- $sql = \db('制程检验_记录')->fetchSql(true)->insert($data);
|
|
|
- $result = Db::query($sql);
|
|
|
- if ($result === false){
|
|
|
- $this->error('提交失败');
|
|
|
+ if($params['majorprocess'] == '车缝'){
|
|
|
+ //获取部件资料
|
|
|
+ $data = db('工单_部件资料')
|
|
|
+ ->where('work_order', $params['workorder'])
|
|
|
+ ->where('del_rq', null)
|
|
|
+ ->where('status', 1)
|
|
|
+ ->field('part_code as 部件编号,part_name as 部件名称')
|
|
|
+ ->order('part_code')
|
|
|
+ ->select();
|
|
|
+ if (empty($data)) {
|
|
|
+ $this->error('未找到部件资料');
|
|
|
+ }
|
|
|
}else{
|
|
|
- $this->success('提交成功');
|
|
|
+ $data = db('工单_基础工艺资料')
|
|
|
+ ->where('work_order', $params['workorder'])
|
|
|
+ ->where('big_process', $params['majorprocess'])
|
|
|
+ ->where('del_rq', null)
|
|
|
+ ->field('process_code as 工艺编号,process_name as 工艺名称,standard_hour as 标准工时,
|
|
|
+ standard_score as 标准工分,coefficient as 系数,remark as 备注')
|
|
|
+ ->order('process_code')
|
|
|
+ ->select();
|
|
|
+ if (empty($process)) {
|
|
|
+ $this->error('未找到工艺数据');
|
|
|
+ }
|
|
|
}
|
|
|
+ $this->success('成功', $data);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * 获取报工单其他信息
|
|
|
- * @ApiMethod Get
|
|
|
- * @params string machine
|
|
|
+ * 获取车缝部件的工艺资料
|
|
|
+ * @ApiMethod (GET)
|
|
|
+ * @param string $part_code 部件编号
|
|
|
+ * @param string $workorder 工单编号
|
|
|
+ * @return array
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
*/
|
|
|
- public function getMachineReportInfo(){
|
|
|
- if (Request::instance()->isGet() == false) {
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->param();
|
|
|
- if (!isset($params['machine']) || empty($params['machine'])) {
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $machine = $params['machine'].'#';
|
|
|
- $data = [];
|
|
|
- $produce = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
|
|
|
- if (empty($produce)){
|
|
|
- $this->error('无此设备数据');
|
|
|
- }
|
|
|
- $data['order_info']['order'] = $produce['工单编号'];
|
|
|
- $data['order_info']['yjno'] = $produce['印件号'];
|
|
|
- $data['order_info']['gxh'] = $produce['工序号'];
|
|
|
- $data['order_info']['gxmc'] = $produce['工序名称'];
|
|
|
- $data['order_info']['dedh'] = \db('dic_lzde')->where('适用机型',$machine)->value('sys_bh');
|
|
|
- $product = \db('工单_基本资料')->alias('a')
|
|
|
- ->join('工单_工艺资料 b','a.Gd_Gdbh = b.Gy0_gdbh','left')
|
|
|
- ->join('工单_印件资料 c','a.Gd_Gdbh = c.Yj_gdbh','left')
|
|
|
- ->field('a.成品名称,b.Gy0_gxmc,b.Gy0_ms,b.Gy0_ls,c.yj_yjmc')
|
|
|
- ->where('a.Gd_Gdbh',$produce['工单编号'])
|
|
|
- ->where('b.Gy0_yjno',$produce['印件号'])
|
|
|
- ->where('b.Gy0_gxh',$produce['工序号'])
|
|
|
- ->where('c.Yj_yjno',$produce['印件号'])
|
|
|
- ->select();
|
|
|
- if (empty($product)){
|
|
|
- $this->error('无此工单数据');
|
|
|
- }
|
|
|
- $data['order_info']['product_name'] = '';
|
|
|
- $data['order_info']['yj_name'] = '';
|
|
|
- $data['order_info']['gy_name'] = '';
|
|
|
- if (!empty($product)){
|
|
|
- $data['order_info']['product_name'] = rtrim($product[0]['成品名称']);
|
|
|
- $data['order_info']['yj_name'] = rtrim($product[0]['yj_yjmc']);
|
|
|
- $data['order_info']['gy_name'] = rtrim($product[0]['Gy0_gxmc']);
|
|
|
- $data['order_info']['Gy0_ms'] = rtrim($product[0]['Gy0_ms']);
|
|
|
- $data['order_info']['Gy0_ls'] = rtrim($product[0]['Gy0_ls']);
|
|
|
- }
|
|
|
- $class = \db('设备_班组资料')->where('UniqId',$produce['班组ID'])->find();
|
|
|
- for ($i=1;$i<11;$i++){
|
|
|
- $name = '';
|
|
|
- if (!empty($class['sczl_bh'.$i])){
|
|
|
- $name = \db('人事_基本资料')->where('员工编号',$class['sczl_bh'.$i])->value('员工姓名');
|
|
|
- }
|
|
|
- $class['sczl_name'.$i] = rtrim($name);
|
|
|
- }
|
|
|
- $data['class'] = $class;
|
|
|
- $where['st_gdbh'] = $produce['工单编号'];
|
|
|
- $machine = substr($machine,0,2);
|
|
|
- if ($machine == 'JY' || $machine == 'QZ'){
|
|
|
- $where['st_dpt'] = '胶印车间';
|
|
|
- }elseif ($machine == 'WY' || $machine == 'DW'){
|
|
|
- $where['st_dpt'] = '凹印车间';
|
|
|
- }elseif ($machine == 'SY' || $machine == 'PM'){
|
|
|
- $where['st_dpt'] = '丝印车间';
|
|
|
- }elseif ($machine == 'MQ' || $machine == 'TJ'){
|
|
|
- $where['st_dpt'] = '烫模车间';
|
|
|
- }elseif ($machine == 'JP'){
|
|
|
- $where['st_dpt'] = '检验车间';
|
|
|
- }
|
|
|
- $material = \db('物料_收发记录')
|
|
|
- ->alias('a')
|
|
|
- ->join('工单_bom资料 b', 'a.st_gdbh = b.BOM_工单编号 AND a.st_wlbh = b.BOM_物料编码','left')
|
|
|
- ->where($where)
|
|
|
- ->field('RTRIM(a.供方批次) as batch, rtrim(采购单号) as 采购单号, st_wlbh, MIN(a.Uniqid) AS Uniqid, rtrim(b.BOM_物料名称) as BOM_物料名称')
|
|
|
- ->group('batch')
|
|
|
- ->order('a.st_wlbh')
|
|
|
+ public function GetCarProcess()
|
|
|
+ {
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
+ $this->error('请求方法错误');
|
|
|
+ }
|
|
|
+ $params = $this->request->param();
|
|
|
+ if (empty($params['workorder'])) {
|
|
|
+ $this->error('工单编号不能为空');
|
|
|
+ }
|
|
|
+ if (empty($params['part_code'])) {
|
|
|
+ $this->error('部件编号不能为空');
|
|
|
+ }
|
|
|
+ $data = db('工单_基础工艺资料')
|
|
|
+ ->where('work_order', $params['workorder'])
|
|
|
+ ->where('part_code', $params['part_code'])
|
|
|
+ ->where('big_process', '车缝')
|
|
|
+ ->where('del_rq', null)
|
|
|
+ ->field('process_code as 工艺编号,process_name as 工艺名称,standard_hour as 标准工时,
|
|
|
+ standard_score as 标准工分,coefficient as 系数,remark as 备注')
|
|
|
+ ->order('process_code')
|
|
|
->select();
|
|
|
- $data['bom'] = $material;
|
|
|
- $this->success('请求成功',$data);
|
|
|
+ $this->success('成功', $data);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * 日产量上报
|
|
|
- * @ApiMethod POST
|
|
|
- * @params array data
|
|
|
+ * 工分报工接口
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param array $list 报工数据
|
|
|
+ * @return array
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
*/
|
|
|
- public function submitDailyProduction(){
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->post();
|
|
|
- $time = date('Y-m-d 00:00:00',time()-86400);
|
|
|
- if ($params['sczl_sj2']<date('Y-m-d 08:30:00',time()) && $params['sczl_sj2']>date('Y-m-d 00:00:00')){
|
|
|
- $params['sczl_rq'] = $time;
|
|
|
+ public function ReportingWork()
|
|
|
+ {
|
|
|
+ if (!$this->request->isPost()) {
|
|
|
+ $this->error('请求方法错误');
|
|
|
}
|
|
|
- $machine = $params['sczl_jtbh'].'#';
|
|
|
- $batchData = []; //批次追踪数据
|
|
|
- $batch = $params['bom'];
|
|
|
- $data = $params;//产量数据
|
|
|
- $data['sczl_type'] = $params['sczl_gxmc'];
|
|
|
- $data['sczl_前工序废'] = $params['last_fp'];
|
|
|
- $data['sczl_来料少数'] = $params['less_sl'];
|
|
|
- $data['sczl_装版总工时'] = $params['zb_time'];
|
|
|
- $data['sczl_打样总工时'] = $params['dy_time'];
|
|
|
- $data['sczl_设备运行工时'] = $params['run_time'];
|
|
|
- $data['sczl_jtbh'] = $machine;
|
|
|
- $data['码包'] = $params['code'];
|
|
|
- $data['主电表'] = $params['main_meter'];
|
|
|
- $data['辅电表'] = $params['auxiliary_meter'];
|
|
|
- unset($data['last_fp']);
|
|
|
- unset($data['less_sl']);
|
|
|
- unset($data['zb_time']);
|
|
|
- unset($data['dy_time']);
|
|
|
- unset($data['run_time']);
|
|
|
- unset($data['code']);
|
|
|
- unset($data['main_meter']);
|
|
|
- unset($data['auxiliary_meter']);
|
|
|
- unset($data['bom']);
|
|
|
- $start_time = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
|
|
|
- if (!empty($start_time)){
|
|
|
- $data['开工时间'] = $start_time['开工时间'];
|
|
|
- }else{
|
|
|
- $data['开工时间'] = '';
|
|
|
+ $params = $this->request->post();
|
|
|
+ $reportList = [];
|
|
|
+
|
|
|
+ if (isset($params[0]) && is_array($params[0])) {
|
|
|
+ $reportList = $params;
|
|
|
+ } elseif (!empty($params['list']) && is_array($params['list'])) {
|
|
|
+ $reportList = $params['list'];
|
|
|
+ } elseif (!empty($params['data']) && is_array($params['data'])) {
|
|
|
+ $reportList = $params['data'];
|
|
|
+ } else {
|
|
|
+ $rawBody = file_get_contents('php://input');
|
|
|
+ $decoded = json_decode($rawBody, true);
|
|
|
+ if (is_array($decoded)) {
|
|
|
+ if (isset($decoded[0]) && is_array($decoded[0])) {
|
|
|
+ $reportList = $decoded;
|
|
|
+ } elseif (!empty($decoded['list']) && is_array($decoded['list'])) {
|
|
|
+ $reportList = $decoded['list'];
|
|
|
+ } elseif (!empty($decoded['data']) && is_array($decoded['data'])) {
|
|
|
+ $reportList = $decoded['data'];
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- $sys_id = \db('设备_基本资料')->where('设备编号',$machine)->value('sys_sbID');
|
|
|
- $data['sys_id'] = '['.$sys_id.'/'.$machine.']';
|
|
|
- $UniqId = \db('设备_产量计酬')->order('UniqId desc')->value('UniqId');
|
|
|
- if ($UniqId < 10000000){
|
|
|
- $data['UniqId'] = 10000000;
|
|
|
- }else{
|
|
|
- $data['UniqId'] = $UniqId + 1;
|
|
|
+
|
|
|
+ if (empty($reportList)) {
|
|
|
+ $this->error('请传入报工数据');
|
|
|
}
|
|
|
- $data['sczl_Pgcl'] = 0;
|
|
|
- $data['sczl_oil'] = 0;
|
|
|
- $data['sczl_计产系数'] = 0;
|
|
|
- $data['sczl_工价系数'] = 0;
|
|
|
- $data['sczl_装版工时'] = 0;
|
|
|
- $data['sczl_保养工时'] = 0;
|
|
|
- $data['sczl_打样工时'] = 0;
|
|
|
- $data['sczl_异常停机工时'] = 0;
|
|
|
- $data['sczl_异常工时1'] = 0;
|
|
|
- $data['sczl_异常类型1'] = '';
|
|
|
- $data['sczl_废品率系数'] = '';
|
|
|
- $data['sczl_desc'] = '';
|
|
|
- $data['sczl_wgsj'] = '1900-01-01 00:00:00';
|
|
|
- $data['码开始行'] = 0;
|
|
|
- $data['码结束行'] = 0;
|
|
|
- $data['mod_rq'] = '1900-01-01 00:00:00';
|
|
|
- $data['sys_rq'] = date('Y-m-d H:i:s');
|
|
|
- if (!empty($batch)){
|
|
|
- $batchData = explode(',',$batch);
|
|
|
- $newData = [];
|
|
|
- $batchUniqId = \db('物料_批次跟踪')->order('UniqId desc')->value('UniqId');
|
|
|
- if ($batchUniqId < 10000000){
|
|
|
- $batchUniqId = 10000000;
|
|
|
+
|
|
|
+ $insertData = [];
|
|
|
+ $now = date('Y-m-d H:i:s');
|
|
|
+ foreach ($reportList as $idx => $item) {
|
|
|
+ $rowNo = $idx + 1;
|
|
|
+ if (empty($item['staff_no'])) {
|
|
|
+ $this->error('第' . $rowNo . '条员工编号不能为空');
|
|
|
+ }
|
|
|
+ if (empty($item['staff_name'])) {
|
|
|
+ $this->error('第' . $rowNo . '条员工姓名不能为空');
|
|
|
+ }
|
|
|
+ if (empty($item['work_order']) && empty($item['workorder'])) {
|
|
|
+ $this->error('第' . $rowNo . '条订单编号不能为空');
|
|
|
+ }
|
|
|
+ if (empty($item['majorprocess'])) {
|
|
|
+ $this->error('第' . $rowNo . '条大工序不能为空');
|
|
|
+ }
|
|
|
+ $isSewing = $item['majorprocess'] === '车缝';
|
|
|
+ if ($isSewing && (!isset($item['part_code']) || $item['part_code'] === '')) {
|
|
|
+ $this->error('第' . $rowNo . '条车缝工序必须填写部件编号');
|
|
|
+ }
|
|
|
+ if (empty($item['process_code'])) {
|
|
|
+ $this->error('第' . $rowNo . '条工艺编号不能为空');
|
|
|
+ }
|
|
|
+ if (empty($item['process_name'])) {
|
|
|
+ $this->error('第' . $rowNo . '条工艺名称不能为空');
|
|
|
+ }
|
|
|
+ if (!isset($item['standard_hour']) || $item['standard_hour'] === '') {
|
|
|
+ $this->error('第' . $rowNo . '条标准工时不能为空');
|
|
|
+ }
|
|
|
+ if (!isset($item['standard_score']) || $item['standard_score'] === '') {
|
|
|
+ $this->error('第' . $rowNo . '条标准工分不能为空');
|
|
|
+ }
|
|
|
+ if (!isset($item['number']) || $item['number'] === '') {
|
|
|
+ $this->error('第' . $rowNo . '条产量不能为空');
|
|
|
}
|
|
|
- foreach ($batchData as $key=>$item){
|
|
|
- $batchUniqId++;
|
|
|
- $val = explode('-',$item);
|
|
|
- $newData[$key]['wlbh'] = $val[0];
|
|
|
- $newData[$key]['wlBatch'] = $val[1];
|
|
|
- $newData[$key]['sczl_gdbh'] = $data['sczl_gdbh'];
|
|
|
- $newData[$key]['sczl_yjno'] = $data['sczl_yjno'];
|
|
|
- $newData[$key]['sczl_gxh'] = $data['sczl_gxh'];
|
|
|
- $newData[$key]['sczl_gxmc'] = $data['sczl_gxmc'];
|
|
|
- $newData[$key]['sczl_num'] = $data['sczl_num'];
|
|
|
- $newData[$key]['sys_id'] = $data['sys_id'];
|
|
|
- $newData[$key]['sys_rq'] = $data['sys_rq'];
|
|
|
- $newData[$key]['UniqID'] = $batchUniqId;
|
|
|
+
|
|
|
+ $standardHour = floatval($item['standard_hour']);
|
|
|
+ $standardScore = floatval($item['standard_score']);
|
|
|
+ $coefficient = isset($item['coefficient']) && $item['coefficient'] !== '' ? floatval($item['coefficient']) : 1;
|
|
|
+ $number = floatval($item['number']);
|
|
|
+
|
|
|
+ $productionHour = $standardHour * $number * $coefficient;
|
|
|
+ $productionScore = $standardScore * $number * $coefficient;
|
|
|
+
|
|
|
+ $partCode = null;
|
|
|
+ if (isset($item['part_code']) && $item['part_code'] !== '') {
|
|
|
+ $partCode = intval($item['part_code']);
|
|
|
}
|
|
|
+
|
|
|
+ $insertData[] = [
|
|
|
+ 'staff_no' => $item['staff_no'],
|
|
|
+ 'staff_name' => $item['staff_name'],
|
|
|
+ 'work_order' => !empty($item['work_order']) ? $item['work_order'] : $item['workorder'],
|
|
|
+ 'date' => !empty($item['date']) ? $item['date'] : date('Y-m-d'),
|
|
|
+ 'majorprocess' => $item['majorprocess'],
|
|
|
+ 'part_code' => $partCode,
|
|
|
+ 'process_code' => $item['process_code'],
|
|
|
+ 'process_name' => $item['process_name'],
|
|
|
+ 'standard_hour' => $standardHour,
|
|
|
+ 'standard_score' => $standardScore,
|
|
|
+ 'coefficient' => $coefficient,
|
|
|
+ 'number' => $number,
|
|
|
+ 'production_hour' => round($productionHour, 4),
|
|
|
+ 'production_score' => round($productionScore, 4),
|
|
|
+ 'machine' => isset($item['machine']) ? $item['machine'] : '',
|
|
|
+ 'sys_id' => isset($item['sys_id']) ? $item['sys_id'] : '',
|
|
|
+ 'sys_rq' => $now,
|
|
|
+ 'mod_id' => isset($item['mod_id']) ? $item['mod_id'] : '',
|
|
|
+ 'mod_rq' => null,
|
|
|
+ 'del_rq' => null,
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
- $res = false;
|
|
|
- $batch_res = false;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- $sql = \db('设备_产量计酬')->fetchSql(true)->insert($data);
|
|
|
- $res = Db::query($sql);
|
|
|
- if (!empty($batch)){
|
|
|
- $batch_sql = \db('物料_批次跟踪')->fetchSql(true)->insertAll($newData);
|
|
|
- $batch_res = Db::query($batch_sql);
|
|
|
- }else{
|
|
|
- $batch_res = true;
|
|
|
+ $result = db('设备_工分计酬')->insertAll($insertData);
|
|
|
+ if ($result === false) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('报工失败');
|
|
|
}
|
|
|
-
|
|
|
Db::commit();
|
|
|
- cache('MachineProductReport-getList',null);
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
|
- }
|
|
|
- if ($res === false || $batch_res === false){
|
|
|
- $this->error('报工失败');
|
|
|
- }else{
|
|
|
- $this->success('报工成功');
|
|
|
+ $this->error('报工失败:' . $e->getMessage());
|
|
|
}
|
|
|
|
|
|
+ $this->success('报工成功', ['count' => count($insertData)]);
|
|
|
}
|
|
|
- /**
|
|
|
- * 获取机台编号
|
|
|
- * @ApiMethod POST
|
|
|
- * @params string addr
|
|
|
- */
|
|
|
- public function getMachineMac(){
|
|
|
- if (Request::instance()->isGet() == false){
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->get();
|
|
|
- if (empty($params['addr'])){
|
|
|
- $this->error('参数不能为空');
|
|
|
- }
|
|
|
- $data = \db('设备_基本资料')->where('sys_sbID',$params['addr'])->field('设备编号,rtrim(使用部门) as 使用部门')->find();
|
|
|
- $this->success('请求成功',$data);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 6获取拉料人员
|
|
|
- * @ApiMethod GET
|
|
|
- * @params department
|
|
|
- */
|
|
|
- public function getMaterialStrippingPeople(){
|
|
|
- if (Request::instance()->isGet() == false) {
|
|
|
- $this->error('非法请求');
|
|
|
- }
|
|
|
- $params = Request::instance()->param();
|
|
|
- $where = [];
|
|
|
- if (!isset($params['department']) || empty($params['department'])) {
|
|
|
- $this->error('参数错误');
|
|
|
- }if (!isset($params['search']) || !empty($params['search'])) {
|
|
|
- $where['员工编号|员工姓名'] = array('like','%'.$params['search'].'%');
|
|
|
- }
|
|
|
- $where['职称职务'] = '拉纸工';
|
|
|
- $where['在职状态'] = '在职';
|
|
|
- $where['U8在职'] = '在职';
|
|
|
- if ($params['department'] == 1){
|
|
|
- $where['所在部门'] = '生产部';
|
|
|
- }else{
|
|
|
- $where['所在部门'] = '检验车间';
|
|
|
- }
|
|
|
- $list[0]['员工编号'] = '000000';
|
|
|
- $list[0]['员工姓名'] = '自备';
|
|
|
- $data = \db('人事_基本资料')->where($where)->field('rtrim(员工编号) as 员工编号,rtrim(员工姓名) as 员工姓名')->order('班组代号 desc')->select();
|
|
|
- if (!empty($data)){
|
|
|
- foreach ($data as $item){
|
|
|
- array_push($list,$item);
|
|
|
- }
|
|
|
- }
|
|
|
- $this->success('请求成功',$list);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- /**
|
|
|
- * 设置当前生产工单
|
|
|
- * @return void
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\BindParamException
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function MachineWorkOrderEdit()
|
|
|
+ //报工工分数据表左侧菜单栏
|
|
|
+ public function GetReportingWorkLeft()
|
|
|
{
|
|
|
- if (Request::instance()->isPost() === false) {
|
|
|
- $this->error('非法请求');
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
+ $this->error('请求方法错误');
|
|
|
}
|
|
|
- $params = Request::instance()->post();
|
|
|
- $list = \db('工单_基本资料')
|
|
|
- ->alias('a')
|
|
|
- ->field([
|
|
|
- 'RTRIM( b.Gy0_sj1 )' => 'sj1',
|
|
|
- 'RTRIM( b.Gy0_sj2 )' => 'sj2',
|
|
|
- 'RTRIM( b.UniqId )' => 'id'
|
|
|
- ])
|
|
|
- ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
|
|
|
- ->where([
|
|
|
- 'a.gd_statu' => '2-生产中',
|
|
|
- 'a.行号' => '1',
|
|
|
- 'b.Gy0_sbbh' => ['LIKE', '%' . $params['machine'] . '%'],
|
|
|
- 'b.PD_WG' => '1900-01-01 00:00:00',
|
|
|
- 'b.Gy0_sj1' => ['>', '1900-01-01 00:00:00'],
|
|
|
- ])
|
|
|
- ->where('b.Gy0_sj1', '<', '2099-01-01 00:00:00')
|
|
|
- ->group('a.Gd_gdbh,b.Gy0_yjno,b.Gy0_gxh')
|
|
|
- ->order('Gy0_sj1')
|
|
|
+ $startDate = date('Y-m-d', strtotime('-39 day'));
|
|
|
+ $endDate = date('Y-m-d');
|
|
|
+
|
|
|
+ $list = db('设备_工分计酬')
|
|
|
+ ->where('del_rq', null)
|
|
|
+ ->where('date', 'between time', [$startDate, $endDate])
|
|
|
+ ->where('machine', '<>', '')
|
|
|
+ ->field('machine,date')
|
|
|
+ ->order('machine asc,date desc')
|
|
|
->select();
|
|
|
- $start = date('Y-m-d H:i:s', time());
|
|
|
- if ($start < date('Y-m-d H:15:00', time())) {
|
|
|
- $start = date('Y-m-d H:00:00', time());
|
|
|
- } elseif ($start > date('Y-m-d H:45:00', time())) {
|
|
|
- $start = date('Y-m-d H:00:00', time());
|
|
|
- } else {
|
|
|
- $start = date('Y-m-d H:30:00', time());
|
|
|
+
|
|
|
+ $menuMap = [];
|
|
|
+ foreach ($list as $row) {
|
|
|
+ $machine = $row['machine'];
|
|
|
+ $date = $row['date'];
|
|
|
+ if (!isset($menuMap[$machine])) {
|
|
|
+ $menuMap[$machine] = [];
|
|
|
+ }
|
|
|
+ if (!in_array($date, $menuMap[$machine])) {
|
|
|
+ $menuMap[$machine][] = $date;
|
|
|
+ }
|
|
|
}
|
|
|
- $data = $time = [];
|
|
|
- $i = 0;
|
|
|
- foreach ($list as $key => $value) {
|
|
|
- if ($value['id'] === $params['UniqId']) {
|
|
|
- $time = [
|
|
|
- 'Gy0_sj1' => $start,
|
|
|
- 'Gy0_sj2' => date('Y-m-d H:i:s', strtotime($start) + (strtotime($value['sj1']) - strtotime($value['sj2']))),
|
|
|
- 'id' => $value['id']
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ foreach ($menuMap as $machine => $dateList) {
|
|
|
+ $children = [];
|
|
|
+ foreach ($dateList as $date) {
|
|
|
+ $children[] = [
|
|
|
+ 'date' => $date,
|
|
|
];
|
|
|
- unset($list[$key]);
|
|
|
}
|
|
|
- }
|
|
|
- $arr = array_values($list);
|
|
|
- $data[0] = $time;
|
|
|
- foreach ($arr as $key => $value){
|
|
|
- $workTime = [
|
|
|
- 'Gy0_sj1' => $data[$key]['Gy0_sj2'],
|
|
|
- 'Gy0_sj2' => date('Y-m-d H:i:s', strtotime($data[$key]['Gy0_sj2']) + (strtotime($value['sj1']) - strtotime($value['sj2']))),
|
|
|
- 'id' => $value['id']
|
|
|
+ $data[] = [
|
|
|
+ 'machine' => $machine,
|
|
|
+ 'children' => $children,
|
|
|
];
|
|
|
- array_push($data,$workTime);
|
|
|
- }
|
|
|
- foreach ($data as $key=>$value){
|
|
|
- unset($value['id']);
|
|
|
- $sql = \db('工单_工艺资料')
|
|
|
- ->where('UniqId',$data[$key]['id'])
|
|
|
- ->fetchSql(true)
|
|
|
- ->update($value);
|
|
|
- $res = \db()->query($sql);
|
|
|
- if ($res === false){
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($i !== 0){
|
|
|
- $this->error('失败');
|
|
|
- }else{
|
|
|
- $this->success('成功');
|
|
|
}
|
|
|
+
|
|
|
+ $this->success('成功', $data);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 检品机报工
|
|
|
- * @return void
|
|
|
- * @throws \think\db\exception\BindParamException
|
|
|
+ * 机台报工数据
|
|
|
+ * @ApiMethod (GET)
|
|
|
+ * @param string $date 日期
|
|
|
+ * @param string $machine 机台编号
|
|
|
+ * @return array
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
*/
|
|
|
-
|
|
|
- public function JpUploade()
|
|
|
+ public function GetReportingWorkData()
|
|
|
{
|
|
|
- if (Request::instance()->isPost() == false){
|
|
|
- $this->error('非法请求');
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
+ $this->error('请求方法错误');
|
|
|
}
|
|
|
- $params = Request::instance()->post();
|
|
|
- $time = date('Y-m-d 00:00:00',time()-86400);
|
|
|
- $data = $params;
|
|
|
- $data['sczl_装版总工时'] = $params['sczl_装版工时'];
|
|
|
- $data['sczl_sj1'] = '1900-01-01 00:00:00';
|
|
|
- $data['sczl_sj2'] = date('Y-m-d H:i:s',time());
|
|
|
- if ($data['sczl_sj2']<date('Y-m-d 08:30:00',time()) && $data['sczl_sj2']>date('Y-m-d 00:00:00')){
|
|
|
- $data['sczl_rq'] = $time;
|
|
|
+ $params = $this->request->param();
|
|
|
+ if (empty($params['date'])) {
|
|
|
+ $this->error('日期不能为空');
|
|
|
}
|
|
|
-
|
|
|
- $start_time = \db('设备_产量采集')->where('设备编号',$data['sczl_jtbh'])->order('UniqId desc')->find();
|
|
|
- if (!empty($start_time)){
|
|
|
- $data['开工时间'] = $start_time['开工时间'];
|
|
|
- }else{
|
|
|
- $data['开工时间'] = '1900-01-01 00:00:00';
|
|
|
+ if (empty($params['machine'])) {
|
|
|
+ $this->error('机台编号不能为空');
|
|
|
}
|
|
|
- $sys_id = \db('设备_基本资料')->where('设备编号',$data['sczl_jtbh'])->value('sys_sbID');
|
|
|
- $data['sys_id'] = '['.$sys_id.'/'.$data['sczl_jtbh'].']';
|
|
|
- $UniqId = \db('设备_产量计酬')->order('UniqId desc')->value('UniqId');
|
|
|
- $data['UniqId'] = $UniqId + 1;
|
|
|
- $data['sczl_ls'] = 1;
|
|
|
- $data['sczl_zcfp'] = 0;
|
|
|
- $data['sczl_zccp'] = 0;
|
|
|
- $data['sczl_前工序废'] = 0;
|
|
|
- $data['sczl_来料少数'] = 0;
|
|
|
- $data['sczl_ms'] = 0;
|
|
|
- $data['sczl_oil'] = 0;
|
|
|
- $data['sczl_计产系数'] = 0;
|
|
|
- $data['sczl_工价系数'] = 0;
|
|
|
- $data['sczl_保养工时'] = 0;
|
|
|
- $data['sczl_打样工时'] = 0;
|
|
|
- $data['sczl_异常停机工时'] = 0;
|
|
|
- $data['sczl_异常工时1'] = 0;
|
|
|
- $data['sczl_异常类型1'] = '';
|
|
|
- $data['sczl_desc'] = '';
|
|
|
- $data['sczl_wgsj'] = '1900-01-01 00:00:00';
|
|
|
- $data['码开始行'] = 0;
|
|
|
- $data['码结束行'] = 0;
|
|
|
- $data['码包'] = 0;
|
|
|
- $data['主电表'] = 0;
|
|
|
- $data['辅电表'] = 0;
|
|
|
- $data['mod_rq'] = '1900-01-01 00:00:00';
|
|
|
- $data['sys_rq'] = date('Y-m-d H:i:s');
|
|
|
- $sql = \db('设备_产量计酬')->fetchSql(true)->insert($data);
|
|
|
- $res = \db()->query($sql);
|
|
|
- if ($res === false){
|
|
|
- $this->error('添加失败');
|
|
|
- }else{
|
|
|
- $this->success('成功');
|
|
|
+
|
|
|
+ $rows = db('设备_工分计酬')
|
|
|
+ ->where('del_rq', null)
|
|
|
+ ->where('date', $params['date'])
|
|
|
+ ->where('machine', $params['machine'])
|
|
|
+ ->field('work_order,majorprocess,part_code,process_code,process_name,staff_no,staff_name,standard_hour,standard_score,coefficient,number,production_hour,production_score,machine,sys_id,sys_rq')
|
|
|
+ ->order('process_code asc,staff_no asc')
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $processMap = [];
|
|
|
+ foreach ($rows as $row) {
|
|
|
+ $groupKey = $row['majorprocess'] . '|' . $row['process_code'] . '|' . $row['process_name'] . '|' . $row['part_code'];
|
|
|
+ if (!isset($processMap[$groupKey])) {
|
|
|
+ $processMap[$groupKey] = [
|
|
|
+ 'work_order' => $row['work_order'],
|
|
|
+ 'majorprocess' => $row['majorprocess'],
|
|
|
+ 'part_code' => $row['part_code'],
|
|
|
+ 'process_code' => $row['process_code'],
|
|
|
+ 'process_name' => $row['process_name'],
|
|
|
+ 'machine' => $row['machine'],
|
|
|
+ 'date' => $params['date'],
|
|
|
+ 'staffs' => [],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $processMap[$groupKey]['staffs'][] = [
|
|
|
+ 'staff_no' => $row['staff_no'],
|
|
|
+ 'staff_name' => $row['staff_name'],
|
|
|
+ 'standard_hour' => $row['standard_hour'],
|
|
|
+ 'standard_score' => $row['standard_score'],
|
|
|
+ 'coefficient' => $row['coefficient'],
|
|
|
+ 'number' => $row['number'],
|
|
|
+ 'production_hour' => $row['production_hour'],
|
|
|
+ 'production_score' => $row['production_score'],
|
|
|
+ 'sys_id' => $row['sys_id'],
|
|
|
+ 'sys_rq' => $row['sys_rq'],
|
|
|
+ ];
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //获取当前日期和时间
|
|
|
- public function getTime()
|
|
|
- {
|
|
|
- $data = [
|
|
|
- 'date' => date('Y-m-d',time()),
|
|
|
- 'hours' => date('Y-m-d H:i:s',time())
|
|
|
- ];
|
|
|
- $this->success('成功',$data);
|
|
|
+ $data = array_values($processMap);
|
|
|
+ $this->success('成功', $data);
|
|
|
}
|
|
|
}
|