|
|
@@ -31,15 +31,16 @@ class PowerManagement extends Api
|
|
|
|
|
|
// 获取月份数据
|
|
|
$months = db('设备_产量计酬')
|
|
|
- ->where('sczl_rq', '>', $newMonth . '-01 00:00:00')
|
|
|
+ ->where('开工时间', '>', $newMonth . '-01 00:00:00')
|
|
|
->group('mouth')
|
|
|
->order('mouth desc')
|
|
|
- ->column('DATE_FORMAT(sczl_rq, "%Y%m") AS mouth');
|
|
|
+ ->column('DATE_FORMAT(开工时间, "%Y%m") AS mouth');
|
|
|
|
|
|
// 获取所有车间名称
|
|
|
$workShops = db('设备_基本资料')
|
|
|
->whereNotNull('sys_sbID')
|
|
|
->where('sys_sbID', '<>', '')
|
|
|
+ ->where('使用部门','<>','检验车间')
|
|
|
->distinct('使用部门')
|
|
|
->column('使用部门');
|
|
|
|
|
|
@@ -58,62 +59,6 @@ class PowerManagement extends Api
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
-// public function MachineList()
|
|
|
-// {
|
|
|
-// // 判断请求方式是否为GET
|
|
|
-// if (!$this->request->isGet()) {
|
|
|
-// return $this->error('请求错误');
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 获取请求参数
|
|
|
-// $params = $this->request->param();
|
|
|
-//
|
|
|
-// // 检查必需参数
|
|
|
-// if (empty($params) || !isset($params['mouth'])) {
|
|
|
-// return $this->error('参数错误');
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 转换为标准日期格式
|
|
|
-// $month = substr($params['mouth'], 0, 4) . '-' . substr($params['mouth'], 4, 2);
|
|
|
-//
|
|
|
-// // 构建查询条件
|
|
|
-// $conditions = [];
|
|
|
-// if (!empty($params['workShop'])) {
|
|
|
-// $conditions['使用部门'] = $params['workShop'];
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 获取机台列表
|
|
|
-// $machineList = db('设备_基本资料')
|
|
|
-// ->where($conditions)
|
|
|
-// ->whereNotNull('sys_sbID')
|
|
|
-// ->where('sys_sbID', '<>', '')
|
|
|
-// ->order('设备编组, 设备编号')
|
|
|
-// ->column('rtrim(设备名称)', '设备编号');
|
|
|
-//
|
|
|
-// // 准备数据容器
|
|
|
-// $data = [];
|
|
|
-//
|
|
|
-// // 查询电表数据
|
|
|
-// foreach ($machineList as $machineId => $machineName) {
|
|
|
-// $lastData = $this->getMeterData($machineId, date('Y-m', strtotime($month . ' -1 month')));
|
|
|
-// $newData = $this->getMeterData($machineId, $month);
|
|
|
-//
|
|
|
-// if (!empty($lastData) || !empty($newData)) {
|
|
|
-// $res = [
|
|
|
-// 'MachineCode' => $machineId,
|
|
|
-// 'MachineName' => $machineName,
|
|
|
-// 'lastMain' => $lastData['主电表'] ?? 0,
|
|
|
-// 'lastAuxiliary' => $lastData['辅电表'] ?? 0,
|
|
|
-// 'newMain' => $newData['主电表'] ?? 0,
|
|
|
-// 'newAuxiliary' => $newData['辅电表'] ?? 0
|
|
|
-// ];
|
|
|
-// $res['mainNumber'] = $res['newMain'] - $res['lastMain'];
|
|
|
-// $res['auxiliaryNumber'] = $res['newAuxiliary'] - $res['lastAuxiliary'];
|
|
|
-// $data[] = $res;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// $this->success('成功',$data);
|
|
|
-// }
|
|
|
public function MachineList()
|
|
|
{
|
|
|
// 判断请求方式是否为GET
|
|
|
@@ -138,6 +83,7 @@ class PowerManagement extends Api
|
|
|
// 获取机台列表
|
|
|
$machineList = db('设备_基本资料')
|
|
|
->where($conditions)
|
|
|
+ ->whereNotLike('设备编号', 'YQZ%')
|
|
|
->whereNotNull('sys_sbID')
|
|
|
->where('sys_sbID', '<>', '')
|
|
|
->order('设备编组, 设备编号')
|
|
|
@@ -183,8 +129,8 @@ class PowerManagement extends Api
|
|
|
foreach ($months as $month) {
|
|
|
$data = db('设备_产量计酬') // 替换为真实的电表数据表
|
|
|
->whereIn('sczl_jtbh', $machineIds)
|
|
|
- ->where('sczl_rq', '>=', $month . '-01')
|
|
|
- ->where('sczl_rq', '<=', $month . '-' . date('t', strtotime($month)))
|
|
|
+ ->where('开工时间', '>=', $month . '-01')
|
|
|
+ ->where('开工时间', '<=', $month . '-' . date('t', strtotime($month)))
|
|
|
->select();
|
|
|
|
|
|
// 按设备编号和月份分组存储
|
|
|
@@ -211,7 +157,7 @@ class PowerManagement extends Api
|
|
|
{
|
|
|
return db('设备_产量计酬')
|
|
|
->field('主电表, 辅电表')
|
|
|
- ->where('sczl_rq', 'like', "$date%")
|
|
|
+ ->where('开工时间', 'like', "$date%")
|
|
|
->where('主电表', '<>', 0)
|
|
|
->where('辅电表', '<>', 0)
|
|
|
->where('sczl_jtbh', $machineId)
|
|
|
@@ -239,7 +185,7 @@ class PowerManagement extends Api
|
|
|
// 转换为标准日期格式
|
|
|
$month = substr($param['mouth'], 0, 4) . '-' . substr($param['mouth'], 4, 2);
|
|
|
$where = [
|
|
|
- 'sczl_rq' => ['like',$month.'%'],
|
|
|
+ '开工时间' => ['like',$month.'%'],
|
|
|
'sczl_jtbh' => $param['machine'],
|
|
|
'主电表' => ['<>',0]
|
|
|
];
|
|
|
@@ -249,7 +195,7 @@ class PowerManagement extends Api
|
|
|
->order('开工时间 desc')
|
|
|
->select();
|
|
|
if (empty($list)){
|
|
|
- $this->error('为找打数据');
|
|
|
+ $this->error('未找到数据');
|
|
|
}else{
|
|
|
$this->success('成功',$list);
|
|
|
}
|