Commit 069422a1 by CnChunfeng

修改逻辑手动触发

parent 43dba2c4
......@@ -71,16 +71,19 @@ class CreateNotice extends Command
->where('bid',$value['system_id'])
->select('username','userId')->get();
$allUpdate = $systemUpdateModel->getWhereObj($where)->where('system_id',$value['system_id'])->get()->toArray();
$this->createNoticeSaveData($allUpdate,$date,$value['system_name'],json_encode($sendUser));
}
}
private function createNoticeSaveData($allUpdate,$date,$systemName,$sendUser)
public function createNoticeSaveData($allUpdate,$date,$systemName,$sendUser)
{
$todayTime = strtotime($date);
$saveData['title'] = $date.'系统不停机维护公告';
$saveData['is_send'] = '未发送';
$saveData['create_time'] = time();
$saveData['create_time'] = $todayTime;
$saveData['send_user'] = $sendUser;
$saveData['system_name'] = $systemName;
......@@ -121,6 +124,11 @@ class CreateNotice extends Command
</tbody>
</table>
';
(new SystemBulletinModel())->insertGetId($saveData);
$systemBulletinModel = new SystemBulletinModel();
if($smbnId = $systemBulletinModel->where('create_time',$todayTime)->where('system_name',$systemName)->value('smbn_id')){
$systemBulletinModel->where('smbn_id',$smbnId)->update($saveData);
}else{
$systemBulletinModel->insertGetId($saveData);
}
}
}
......@@ -48,6 +48,20 @@ class MessageApiController extends Controller
}
}
//获取系统更新信息列表
private function createNotice($request)
{
$data = $request->all();
try{
$returnData = (new SystemNoticeLogic())->createNotice($data);
echo json_encode(['code'=>0,'count'=>[],'data'=>[],'msg'=>'获取成功']);
exit();
}catch(\Exception $e){
echo json_encode(['code'=>400,'msg'=>$e->getMessage()]);
exit();
}
}
//获取系统宣讲列表
private function systemPreachList($request)
{
......
......@@ -9,6 +9,7 @@
namespace App\Logic;
//系统通知逻辑层
use App\Console\Commands\CreateNotice;
use App\Model\SystemBulletinModel;
use App\Model\SystemPreachModel;
use App\Model\SystemUpdateModel;
......@@ -336,4 +337,43 @@ class SystemNoticeLogic
return $data;
}
public function createNotice($requestData)
{
//查找出今日的所有更新
$date = $requestData['date'];
$where['begin_time'] = $date;
$where['end_time'] = date('Y-m-d H:i:s',strtotime($date)+86400);
$systemUpdateModel = new SystemUpdateModel();
$createNotice = new CreateNotice();
//韦伯系统是所有的,通知所有人
$allUpdate = $systemUpdateModel->getWhereObj($where)->get()->toArray();
if (!empty($allUpdate)){
// 查找所有通知用户邮箱和ID
$sendUser = DB::table('t_user_perm')->where('begDate','<=',$date)
->where('endDate','>=',$date)
->select('username','userId')->get();
$createNotice->createNoticeSaveData($allUpdate,$date,'韦伯系统',json_encode($sendUser));
}
//查找所有需要更新的子系统,通知对应系统的人
$allGroup = $systemUpdateModel->getWhereObj($where)->groupBy('system_id')->get()->toArray();
foreach ($allGroup as $value){
// 查找所有通知ID
$sendUser = DB::table('t_user_perm')->where('begDate','<=',$date)
->where('endDate','>=',$date)
->where('bid',$value['system_id'])
->select('username','userId')->get();
$allUpdate = $systemUpdateModel->getWhereObj($where)->where('system_id',$value['system_id'])->get()->toArray();
$createNotice->createNoticeSaveData($allUpdate,$date,$value['system_name'],json_encode($sendUser));
}
}
}
\ No newline at end of file
......@@ -4,6 +4,12 @@ layui.use(['jquery','element', 'layer', 'form','table','laypage','laydate','laye
var form = layui.form;
var table = layui.table;
var layedit = layui.layedit;
var laydate = layui.laydate;
//执行一个laydate实例
laydate.render({
elem: '#notice_date' //指定元素
});
form.render();
......@@ -174,6 +180,39 @@ layui.use(['jquery','element', 'layer', 'form','table','laypage','laydate','laye
});
$("#createNotice").click(function () {
var date = $("#notice_date").val();
if (date == ''){
layer.msg('必须选择时间');
return false;
}
layer.confirm('确定生成公告吗?', {icon: 3, title:'提示'}, function(index){
$.ajax({
url: "/msgapi/createNotice",
dataType: 'json',
data: {
date: date
},
success: function (resp) {
if(resp.code==0){
layer.msg('生成成功');
location.reload();
}else{
layer.msg(resp.msg);
return false;
}
},
error:function(jqXHR, textStatus, errorThrown){
Prompt("网络异常,请重试",5);
}
});
layer.close(index);
});
});
......
......@@ -12,6 +12,21 @@
@if($have_perm)
<div class="layui-form-item">
<div class="layui-inline ">
<label class="layui-form-label"></label>
<div class="layui-input-inline">
<input type="text" class="layui-input" id="notice_date" name="notice_date" >
</div>
</div>
<div class="layui-inline ">
<label class="layui-form-label"></label>
<div class="layui-input-inline">
<button class="layui-btn-sm layui-btn-warm" id="createNotice">生成公告</button>
</div>
</div>
</div>
<form class="layui-form layui-box" method="post">
<div class="layui-form-item">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment