Merge pull request 'update build modul' (#83) from zhangwei into dev
Reviewed-on: #83
This commit is contained in:
commit
67a0965715
@ -20,6 +20,12 @@ use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\build\BuildPlanLists;
|
||||
use app\adminapi\logic\build\BuildPlanLogic;
|
||||
use app\adminapi\validate\build\BuildPlanValidate;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\build\BuildPlan;
|
||||
use app\common\model\build\BuildReport;
|
||||
use app\common\model\build\BuildReportDetail;
|
||||
use app\common\model\project\ProjectPersonnel;
|
||||
use think\app\command\Build;
|
||||
|
||||
|
||||
/**
|
||||
@ -103,6 +109,78 @@ class BuildPlanController extends BaseAdminController
|
||||
$result = BuildPlanLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//某个计划下的施工汇报列表
|
||||
public function reports(): \think\response\Json
|
||||
{
|
||||
$params = $this->request->get(['plan_id','page_no','page_size']);
|
||||
if(empty($params['plan_id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
|
||||
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
|
||||
$planInfo = BuildPlan::field('price')->where('id',$params['plan_id'])->findOrEmpty();
|
||||
if($planInfo->isEmpty()){
|
||||
return $this->fail('施工计划数据不存在');
|
||||
}
|
||||
$data = BuildReport::field('report_code,add_user,create_time,scene_file,report_workload,report_amount,remark')
|
||||
->where('plan_id',$params['plan_id'])
|
||||
->page($pageNo,$pageSize)
|
||||
->order('id desc')
|
||||
->select()->each(function($item)use($planInfo){
|
||||
$admin = Admin::field('name')->where('id',$item['add_user'])->findOrEmpty();
|
||||
$item['price'] = $planInfo['price'];
|
||||
$item['add_user_name'] = $admin['name'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
$count = BuildReport::field('id')->where('plan_id',$params['plan_id'])->count();
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize,
|
||||
'lists' => $data
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
//某个计划下的人工明细列表
|
||||
public function persons(): \think\response\Json
|
||||
{
|
||||
$params = $this->request->get(['plan_id','page_no','page_size']);
|
||||
if(empty($params['plan_id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
|
||||
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
|
||||
$planInfo = BuildPlan::field('price,unit')->where('id',$params['plan_id'])->findOrEmpty();
|
||||
if($planInfo->isEmpty()){
|
||||
return $this->fail('施工计划数据不存在');
|
||||
}
|
||||
$report_ids = BuildReport::where('plan_id',$params['plan_id'])->column('id');
|
||||
$data = BuildReportDetail::field('report_id,person_id,work_num')->where('report_id','in',$report_ids)
|
||||
->page($pageNo,$pageSize)->order('id desc')
|
||||
->select()->each(function($item)use($planInfo){
|
||||
$report = BuildReport::field('report_code,create_time')->where('id',$item['report_id'])->findOrEmpty();
|
||||
$person = ProjectPersonnel::field('name,idcard,work_type')->where('id',$item['person_id'])->findOrEmpty();
|
||||
$item['report_code'] = $report['report_code'];
|
||||
$item['report_date'] = $report['create_time'];
|
||||
$item['person_name'] = $person['name'];
|
||||
$item['person_idcard'] = $person['idcard'];
|
||||
$item['person_work_type_text'] = $person->work_type_text;
|
||||
$item['price'] = $planInfo['price'];
|
||||
$item['unit'] = $planInfo['unit'];
|
||||
$item['amount'] = $item['price']*$item['work_num'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
$count = BuildReportDetail::field('id')->where('report_id','in',$report_ids)->count();
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize,
|
||||
'lists' => $data
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
}
|
@ -20,6 +20,10 @@ use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\build\BuildReportLists;
|
||||
use app\adminapi\logic\build\BuildReportLogic;
|
||||
use app\adminapi\validate\build\BuildReportValidate;
|
||||
use app\common\model\build\BuildPlan;
|
||||
use app\common\model\build\BuildReport;
|
||||
use app\common\model\build\BuildReportDetail;
|
||||
use app\common\model\project\ProjectPersonnel;
|
||||
|
||||
|
||||
/**
|
||||
@ -71,6 +75,40 @@ class BuildReportController extends BaseAdminController
|
||||
$result = BuildReportLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function personDetails(): \think\response\Json
|
||||
{
|
||||
$params = $this->request->get(['report_id','page_no','page_size']);
|
||||
if(empty($params['report_id'])){
|
||||
return $this->fail('缺少必要参数');
|
||||
}
|
||||
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
|
||||
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
|
||||
$reportInfo = BuildReport::field('plan_id')->where('id',$params['report_id'])->findOrEmpty();
|
||||
if($reportInfo->isEmpty()){
|
||||
return $this->fail('施工汇报数据不存在');
|
||||
}
|
||||
$planInfo = BuildPlan::field('price,unit')->where('id',$reportInfo['plan_id'])->findOrEmpty();
|
||||
$data = BuildReportDetail::field('person_id,work_num')->where('report_id',$params['report_id'])
|
||||
->page($pageNo,$pageSize)->order('id desc')
|
||||
->select()->each(function($item)use($planInfo){
|
||||
$person = ProjectPersonnel::field('name,idcard,work_type')->where('id',$item['person_id'])->findOrEmpty();
|
||||
$item['person_name'] = $person['name'];
|
||||
$item['person_idcard'] = $person['idcard'];
|
||||
$item['person_work_type_text'] = $person->work_type_text;
|
||||
$item['price'] = $planInfo['price'];
|
||||
$item['unit'] = $planInfo['unit'];
|
||||
$item['amount'] = $item['price']*$item['work_num'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
$count = BuildReportDetail::field('id')->where('report_id',$params['report_id'])->count();
|
||||
$result = [
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize,
|
||||
'lists' => $data
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ use app\common\model\build\BuildDivision;
|
||||
use app\common\model\build\BuildPlan;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\build\BuildProcessSettings;
|
||||
use app\common\model\build\BuildReport;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectMember;
|
||||
|
||||
@ -78,6 +79,9 @@ class BuildPlanLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$item['quality_control_points'] = $process['quality_control_points'];
|
||||
$item['file'] = $process['file'];
|
||||
$item['project_member_name'] = $admin['name'];
|
||||
$item['done_workload'] = BuildReport::where('plan_id',$item['id'])->sum('report_workload');
|
||||
$item['residue_workload'] = ($item['workload'] - $item['done_workload']) <=0 ? 0 : $item['workload'] - $item['done_workload'];
|
||||
$item['completion_degree'] = round($item['done_workload'] / $item['workload'],3).'%';
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
|
@ -62,7 +62,7 @@ class BuildReportLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
public function lists(): array
|
||||
{
|
||||
return BuildReport::where($this->searchWhere)
|
||||
->field(['id', 'plan_id', 'file', 'remark', 'add_user'])
|
||||
->field(['id', 'plan_id', 'scene_file', 'report_workload', 'report_amount', 'remark', 'add_user'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
@ -87,9 +87,8 @@ class BuildReportLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
$data['unit'] = $plan['unit'];
|
||||
$data['workload'] = $plan['workload'];
|
||||
$data['price'] = $plan['price'];
|
||||
$data['amount'] = $plan['amount'];
|
||||
$data['today_workload'] = BuildReportDetail::where('report_id',$data['id'])->sum('work_num');
|
||||
$data['residue_workload'] = $data['workload'] - $data['today_workload'];
|
||||
$data['residue_workload'] = ($data['workload'] - $data['report_workload']) <=0 ? 0 : $data['workload'] - $data['report_workload'];
|
||||
$data['completion_degree'] = round($data['report_workload'] / $data['workload'],3).'%';
|
||||
$data['add_user_name'] = $admin[$data['add_user']];
|
||||
})
|
||||
->toArray();
|
||||
|
@ -18,6 +18,7 @@ namespace app\adminapi\logic\build;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\build\BuildDivision;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\build\BuildProcessSettings;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -114,6 +115,7 @@ class BuildDivisionLogic extends BaseLogic
|
||||
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
|
||||
$data['add_user_name'] = $admin[$data['add_user']];
|
||||
$data['update_user_name'] = $admin[$data['update_user']];
|
||||
$data['build_process'] = BuildProcessSettings::field('process_step_no,process_step,quality_control_points,file')->where('division_id',$data['id'])->select();
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ use app\common\model\build\BuildDivision;
|
||||
use app\common\model\build\BuildPlan;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\build\BuildProcessSettings;
|
||||
use app\common\model\build\BuildReport;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectMember;
|
||||
use think\facade\Db;
|
||||
@ -49,7 +50,7 @@ class BuildPlanLogic extends BaseLogic
|
||||
'project_id' => $params['project_id'],
|
||||
'process_id' => $params['process_id'],
|
||||
'project_member_id' => $params['project_member_id'],
|
||||
'zy_code' => zy_code(),
|
||||
'zy_code' => data_unique_code('ZY'),
|
||||
'plan_start_date' => strtotime($params['plan_start_date']),
|
||||
'plan_end_date' => strtotime($params['plan_end_date']),
|
||||
'work_user' => $params['work_user'],
|
||||
@ -125,7 +126,8 @@ class BuildPlanLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = BuildPlan::findOrEmpty($params['id'])->toArray();
|
||||
$field = 'id,zy_code,project_id,process_id,project_member_id,plan_start_date,plan_end_date,work_user,work_content,workload,unit,price,amount';
|
||||
$data = BuildPlan::field($field)->findOrEmpty($params['id']);
|
||||
if(empty($data)) return [];
|
||||
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$process = BuildProcessSettings::field('division_id,process_step_no,process_step,quality_control_points,file')->where('id',$data['process_id'])->findOrEmpty();
|
||||
@ -141,6 +143,9 @@ class BuildPlanLogic extends BaseLogic
|
||||
$data['quality_control_points'] = $process['quality_control_points'];
|
||||
$data['file'] = $process['file'];
|
||||
$data['project_member_name'] = $admin['name'];
|
||||
return $data;
|
||||
$data['done_workload'] = BuildReport::where('plan_id',$data['id'])->sum('report_workload');
|
||||
$data['residue_workload'] = ($data['workload'] - $data['done_workload']) <=0 ? 0 : $data['workload'] - $data['done_workload'];
|
||||
$data['completion_degree'] = round($data['done_workload'] / $data['workload'],3).'%';
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -49,8 +49,11 @@ class BuildReportLogic extends BaseLogic
|
||||
try {
|
||||
$detail = json_decode($params['person_detail'],true);
|
||||
$reportRes = BuildReport::create([
|
||||
'report_code' => data_unique_code('施工汇报'),
|
||||
'plan_id' => $params['plan_id'],
|
||||
'file' => $params['file'],
|
||||
'scene_file' => !empty($params['scene_file']) ? $params['scene_file'] : null,
|
||||
'report_workload' => $params['report_workload'],
|
||||
'report_amount' => $params['report_amount'],
|
||||
'remark' => $params['remark'],
|
||||
'add_user' => $admin_id,
|
||||
]);
|
||||
@ -103,10 +106,9 @@ class BuildReportLogic extends BaseLogic
|
||||
$data['unit'] = $plan['unit'];
|
||||
$data['workload'] = $plan['workload'];
|
||||
$data['price'] = $plan['price'];
|
||||
$data['amount'] = $plan['amount'];
|
||||
$data['today_workload'] = BuildReportDetail::where('report_id',$data['id'])->sum('work_num');
|
||||
$data['residue_workload'] = $data['workload'] - $data['today_workload'];
|
||||
$data['add_user_name'] = $admin[$data['add_user']];
|
||||
$data['residue_workload'] = ($data['workload'] - $data['report_workload']) <=0 ? 0 : $data['workload'] - $data['report_workload'];
|
||||
$data['completion_degree'] = round($data['report_workload'] / $data['workload'],3).'%';
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ class ProjectAttendanceRecordLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$attendance_detail = json_decode($params['attendance_detail'],true);
|
||||
$attendance_code = process_code('项目考勤记录');
|
||||
$attendance_code = data_unique_code('项目考勤记录');
|
||||
$ProjectAttendanceRecordRes = ProjectAttendanceRecord::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'attendance_code' => $attendance_code,
|
||||
|
@ -45,7 +45,7 @@ class ProjectDocumentLogic extends BaseLogic
|
||||
ProjectDocument::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'classify_id' => $params['classify_id'],
|
||||
'code' =>document_code(),
|
||||
'code' =>data_unique_code('D'),
|
||||
'name' => $params['name'],
|
||||
'describe' => $params['describe'],
|
||||
'version' => $params['version'],
|
||||
|
@ -46,7 +46,7 @@ class ProjectLogic extends BaseLogic
|
||||
'custom_id' => $params['custom_id'],
|
||||
'name' => $params['name'],
|
||||
'project_type' => $params['project_type'],
|
||||
'project_code' => project_code(),
|
||||
'project_code' => data_unique_code('P'),
|
||||
'project_content' => $params['project_content'],
|
||||
'project_estimation' => $params['project_estimation'],
|
||||
'project_address' => $params['project_address'],
|
||||
|
@ -39,7 +39,7 @@ class BuildPlanValidate extends BaseValidate
|
||||
'process_id' => 'require|checkProcess',
|
||||
'project_member_id' => 'require|checkMember',
|
||||
'plan_start_date' => 'require|dateFormat:Y-m-d',
|
||||
'plan_end_date' => 'require|dateFormat:Y-m-d',
|
||||
'plan_end_date' => 'require|dateFormat:Y-m-d|checkPlanEndDate',
|
||||
'workload' => 'require|integer|egt:0',
|
||||
'unit' => 'require',
|
||||
'price' => 'require|float|egt:0',
|
||||
@ -67,26 +67,6 @@ class BuildPlanValidate extends BaseValidate
|
||||
'amount.egt' => '金额值必须大于等于0',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'project_id' => '项目id',
|
||||
'process_id' => '工序id',
|
||||
'project_member_id' => '项目成员id',
|
||||
'zy_code' => '作业编码',
|
||||
'plan_start_date' => '计划开始日期',
|
||||
'plan_end_date' => '计划结束日期',
|
||||
'workload' => '作业量',
|
||||
'unit' => '单位',
|
||||
'price' => '单价',
|
||||
'amount' => '金额',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return BuildPlanValidate
|
||||
@ -161,5 +141,13 @@ class BuildPlanValidate extends BaseValidate
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkPlanEndDate($value,$rule,$data): bool|string
|
||||
{
|
||||
if(strtotime($value) - strtotime($data['plan_start_date']) <= 0){
|
||||
return '计划结束日期必须大于计划开始日期';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -34,7 +34,7 @@ class BuildProcessSettingsValidate extends BaseValidate
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'division_id' => 'require|checkDivision',
|
||||
'process_step_no' => 'require',
|
||||
'process_step_no' => 'require|integer|gt:0',
|
||||
'process_step' => 'require',
|
||||
'quality_control_points' => 'require',
|
||||
'file' => 'checkFile'
|
||||
@ -44,6 +44,8 @@ class BuildProcessSettingsValidate extends BaseValidate
|
||||
'id.require' => '缺少必要参数',
|
||||
'division_id.require' => '请选择分部工程',
|
||||
'process_step_no.require' => '请填写工序步骤号',
|
||||
'process_step_no.integer' => '序步骤号值必须是整数',
|
||||
'process_step_no.gt' => '序步骤号值必须大于0',
|
||||
'process_step.require' => '请填写工序步骤',
|
||||
'quality_control_points.require' => '请填写质量控制点',
|
||||
];
|
||||
|
@ -16,6 +16,7 @@ namespace app\adminapi\validate\build;
|
||||
|
||||
|
||||
use app\common\model\build\BuildPlan;
|
||||
use app\common\model\project\ProjectPersonnel;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
@ -35,14 +36,22 @@ class BuildReportValidate extends BaseValidate
|
||||
'id' => 'require',
|
||||
'plan_id' => 'require|checkPlan',
|
||||
'person_detail' => 'require|checkDetail',
|
||||
'file' => 'require|checkFile',
|
||||
'scene_file' => 'require|checkFile',
|
||||
'report_workload' => 'require|float|egt:0',
|
||||
'report_amount' => 'require|float|egt:0'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少必要参数',
|
||||
'plan_id.require' => '请选择施工计划',
|
||||
'person_detail.require' => '请填写人工明细',
|
||||
'file.require' => '请上传现场照片',
|
||||
'scene_file.require' => '请上传现场照片',
|
||||
'report_workload.require' => '请填写完工量',
|
||||
'report_workload.float' => '完工量值必须是数字',
|
||||
'report_workload.egt' => '完工量值必须大于等于0',
|
||||
'report_amount.require' => '请填写金额',
|
||||
'report_amount.float' => '金额值必须是数字',
|
||||
'report_amount.egt' => '金额值必须大于等于0',
|
||||
];
|
||||
|
||||
|
||||
@ -109,15 +118,31 @@ class BuildReportValidate extends BaseValidate
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDetail($value): bool|string
|
||||
public function checkDetail($value,$rule,$data): bool|string
|
||||
{
|
||||
$person_detail = json_decode($value,true);
|
||||
if(empty($person_detail) || !is_array($person_detail)){
|
||||
return '人工明细数据格式错误';
|
||||
}
|
||||
foreach($person_detail as $v) {
|
||||
if(empty($v['person_id']) || empty($v['work_num'])){
|
||||
if(empty($v['person_id'])){
|
||||
return '人工明细缺少必要参数';
|
||||
}else{
|
||||
$person = ProjectPersonnel::where('id',$v['person_id'])->findOrEmpty();
|
||||
if($person->isEmpty()){
|
||||
return '项目人员不存在';
|
||||
}
|
||||
$plan = BuildPlan::field('project_id')->where('id',$data['plan_id'])->findOrEmpty();
|
||||
if($plan['project_id'] != $person['project_id']){
|
||||
return '项目人员无效';
|
||||
}
|
||||
}
|
||||
if(empty($v['work_num'])){
|
||||
return '请填写项目人员完工量';
|
||||
}else{
|
||||
if(!is_numeric($v['work_num']) || $v['work_num'] < 0){
|
||||
return '项目人员完工量值必须是大于等于0的数字';
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -298,12 +298,6 @@ function format_amount($float)
|
||||
return $float;
|
||||
}
|
||||
|
||||
//生成项目编码
|
||||
function project_code(): string
|
||||
{
|
||||
return 'P'.date('Ymd',time()).'-'.mt_rand(100000, 999999);
|
||||
}
|
||||
|
||||
function group_by($array, $key): array
|
||||
{
|
||||
$result = [];
|
||||
@ -328,18 +322,9 @@ function buildTree($items, $parentField, $parentId = 0): array
|
||||
return $tree;
|
||||
}
|
||||
|
||||
function process_code($str): string
|
||||
//数据唯一编码
|
||||
function data_unique_code($str): string
|
||||
{
|
||||
//质量检查单-20231215-0001
|
||||
return $str.'-'.date('Ymd',time()).'-'.mt_rand(100000, 999999);
|
||||
}
|
||||
|
||||
function document_code(): string
|
||||
{
|
||||
return 'D'.date('Ymd',time()).'-'.mt_rand(100000, 999999);
|
||||
}
|
||||
|
||||
function zy_code(): string
|
||||
{
|
||||
return 'ZY'.date('Ymd',time()).'-'.mt_rand(100000, 999999);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ namespace app\common\model\build;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\project\Project;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ class BuildReport extends BaseModel
|
||||
protected $name = 'build_report';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getFileAttr($value)
|
||||
public function getSceneFileAttr($value)
|
||||
{
|
||||
return json_decode($value,true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user