Commit 802ebbb2 authored by 赵啸非's avatar 赵啸非

添加前端打包文件

parent b5b33213
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -33,12 +33,12 @@
<el-dropdown @command="handleCommand">
<span class="el-dropdown-link" style="color:white">
{{userData.currUserName}}
<i class="el-icon-arrow-down el-icon--right"></i>
<!-- <i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
</span>
<el-dropdown-menu slot="dropdown">
<!-- <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="update">修改密码</el-dropdown-item>
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown-menu>-->
</el-dropdown>
</div>
</div>
......
......@@ -5,13 +5,29 @@
</template>
<script>
import jwt_decode from "jwt-decode";
export default {
name: 'sso',
created () {
},
mounted() {
let token = this.$route.query.token
console.log("token:"+token)
if(token ) {
window.sessionStorage.setItem("token", token);
this.$router.push('/index') // 有token直接跳转首页
console.log("解析后的token:",jwt_decode(token))
//const decode = jwt_decode(data.normal_login_token).accountId; // 解析
if(token) {
//本地登录后跳转
this.form.loginName=jwt_decode(token).userInfo.account
this.form.password=jwt_decode(token).userInfo.password
/* this.form.loginName="admin"
this.form.password="scsmile"*/
this.login()
//window.sessionStorage.setItem("token", token);
// this.$router.push('/index') // 有token直接跳转首页
}else{
this.$message({
message: '没有权限,正在跳转登录页面...',
......@@ -22,6 +38,37 @@ export default {
//this.$router.push('/login')
},1000)
}
},
methods: {
login() {
this.loading = true;
this.$post("/login/login", this.form)
.then(this.loginSuccess)
.catch(this.loginFail);
},
loginSuccess({ data }) {
console.log("userData", data);
this.$store.commit("setUserData", data);
this.$router.push('/index') // 有token直接跳转首页
/* this.$router.replace({
path: this.redirect,
});*/
},
loginFail(error) {
this.loading = false;
this.$message.error(error.message);
},
},
data() {
return {
form: {
loginName: '',
password: '',
securityCode: '',
},
redirect: this.$route.query.redirect,
loading: true,
}
}
}
</script>
......
......@@ -109,6 +109,7 @@ export default {
},
loginSuccess({ data }) {
console.log("userData", data);
console.log("redirect",this.redirect)
this.$store.commit("setUserData", data);
this.$router.replace({
path: this.redirect,
......
......@@ -2,3 +2,7 @@
# yarn lockfile v1
"jwt-decode@^3.1.2":
"integrity" "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A=="
"resolved" "https://registry.npmmirror.com/jwt-decode/-/jwt-decode-3.1.2.tgz"
"version" "3.1.2"
......@@ -25,7 +25,7 @@
<profiles.server.port>17300</profiles.server.port>
<profiles.server.gatewayport>11078</profiles.server.gatewayport>
<profiles.server.path>/study</profiles.server.path>
<profiles.nacos.server-addr>192.168.0.62:8848</profiles.nacos.server-addr>
<profiles.nacos.server-addr>192.168.0.54:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov-cs</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path>
......
......@@ -9,7 +9,6 @@
package com.mortals.xhx.base.system.task.service;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.base.system.task.model.TaskEntity;
......@@ -22,7 +21,7 @@ import com.mortals.xhx.base.system.task.model.TaskEntity;
* @version 1.0.0
*/
public interface TaskService extends ICRUDCacheService<TaskEntity,Long> {
public interface TaskService extends ICRUDService<TaskEntity,Long> {
boolean doForceUpdateTaskLock(TaskEntity task);
boolean doForceUpdateTaskUnLock(TaskEntity task);
......
......@@ -4,21 +4,6 @@
package com.mortals.xhx.base.system.task.service.impl;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import cn.hutool.core.net.NetUtil;
import cn.hutool.core.thread.ThreadUtil;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.code.ExcuteStatus;
import com.mortals.framework.common.code.TaskExcuteStrategy;
......@@ -34,7 +19,12 @@ import com.mortals.xhx.base.system.task.dao.TaskDao;
import com.mortals.xhx.base.system.task.model.TaskEntity;
import com.mortals.xhx.base.system.task.model.TaskQuery;
import com.mortals.xhx.base.system.task.service.TaskService;
import org.springframework.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* <p>
......@@ -54,13 +44,11 @@ import org.springframework.util.ObjectUtils;
* @version 1.0.0
*/
@Service("taskService")
public class TaskServiceImpl extends AbstractCRUDCacheServiceImpl<TaskDao, TaskEntity, Long>
public class TaskServiceImpl extends AbstractCRUDServiceImpl<TaskDao, TaskEntity, Long>
implements TaskService, IApplicationStartedService {//
private boolean isStop = false;
/**
* 休眠时间
*/
/** 休眠时间 */
private long sleepTime = 1000;
private boolean isUnlockSuccess = true;
......@@ -68,98 +56,53 @@ public class TaskServiceImpl extends AbstractCRUDCacheServiceImpl<TaskDao, TaskE
private TaskEntity prevTask = null;
private Thread thread = null;
/**
* 日志打印时间,key:任务ID,value:最后一次打印日志时间
*/
/** 日志打印时间,key:任务ID,value:最后一次打印日志时间 */
private Map<Long, Long> printLogTime = new HashMap<>();
@Autowired(required = false)
@Autowired(required=false)
private TaskService taskService;
//加锁
public boolean doForceUpdateTaskLock(TaskEntity task) throws AppException {
int ret=0;
if (task == null) {
return false;
}
TaskEntity condition = new TaskEntity();
condition.setStatus(ExcuteStatus.WAIT_RUN.getValue());
condition.setId(task.getId());
List<TaskEntity> taskEntities = taskService.find(condition);
if(!ObjectUtils.isEmpty(taskEntities)){
for (TaskEntity data : taskEntities) {
data.setStatus(ExcuteStatus.RUNNING.getValue());
data.setLastExcuteHost(task.getLastExcuteHost());
this.update(data,null);
}
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("status", ExcuteStatus.RUNNING.getValue());
data.put("lastExcuteHost", task.getLastExcuteHost());
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("status", ExcuteStatus.WAIT_RUN.getValue());
condition.put("id", task.getId());
int ret = dao.update(data, condition);
return ret > 0 ? true : false;
}
//解锁
public boolean doForceUpdateTaskUnLock(TaskEntity task) throws AppException {
int ret = 0;
if (task.getInterimExcuteStatus() == TaskInterimExcuteStatus.IMMEDIATE_EXECUTION_BEFORE_DELETE.getValue()) {
//ret = dao.re(task.getId());
ret = this.remove(task.getId(), null);
ret = dao.delete(task.getId());
} else {
TaskEntity condition = new TaskEntity();
condition.setStatus(ExcuteStatus.RUNNING.getValue());
condition.setId(task.getId());
List<TaskEntity> taskEntities = this.find(condition);
if(!ObjectUtils.isEmpty(taskEntities)){
for (TaskEntity data : taskEntities) {
data.setStatus(ExcuteStatus.WAIT_RUN.getValue());
data.setInterimExcuteStatus(TaskInterimExcuteStatus.UNUSE.getValue());
Map<String, Object> data = new HashMap<String, Object>();
data.put("status", ExcuteStatus.WAIT_RUN.getValue());
data.put("interimExcuteStatus", TaskInterimExcuteStatus.UNUSE.getValue());
if (task.getLastExcuteTime() != null) {
data.setLastExcuteTime(task.getLastExcuteTime());
}
this.update(data);
}
data.put("lastExcuteTime", task.getLastExcuteTime());
}
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("status", ExcuteStatus.RUNNING.getValue());
condition.put("id", task.getId());
ret = this.dao.update(data, condition);
}
return ret > 0 ? true : false;
}
public boolean doForceUpdateTaskUnLock(String excuteHost) throws AppException {
int ret =0;
if (StringUtils.isEmpty(excuteHost)) {
return false;
}
TaskEntity condition = new TaskEntity();
condition.setLastExcuteHost(excuteHost);
List<TaskEntity> taskEntities = this.find(condition);
if(!ObjectUtils.isEmpty(taskEntities)){
for (TaskEntity taskEntity : taskEntities) {
taskEntity.setStatus(ExcuteStatus.WAIT_RUN.getValue());
this.update(taskEntity);
}
}
/* TaskEntity condition = new TaskEntity();
condition.setLastExcuteHost(excuteHost);
List<TaskEntity> taskEntities = this.find(condition);
for (TaskEntity taskEntity : taskEntities) {
taskEntity.setStatus(ExcuteStatus.WAIT_RUN.getValue());
}
int ret = this.update(taskEntities);*/
// TaskEntity data = new TaskEntity();
// data.setStatus(ExcuteStatus.WAIT_RUN.getValue());
//
// TaskEntity condition = new TaskEntity();
// condition.setLastExcuteHost(excuteHost);
/* Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> data = new HashMap<String, Object>();
data.put("status", ExcuteStatus.WAIT_RUN.getValue());
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("lastExcuteHost", excuteHost);
int ret = this.getDao().update(data, condition);*/
int ret = this.dao.update(data, condition);
return ret > 0 ? true : false;
}
......@@ -205,7 +148,7 @@ public class TaskServiceImpl extends AbstractCRUDCacheServiceImpl<TaskDao, TaskE
@Override
public void start() throws AppException {
final String localIp = NetUtil.getLocalhostStr();
final String localIp = SystemUtil.getLocalHostIp();
log.info("任务执行线程启动...-->" + localIp);
thread = new Thread(() -> {
// 将本机上次执行而未完成的任务状态变更
......@@ -218,7 +161,6 @@ public class TaskServiceImpl extends AbstractCRUDCacheServiceImpl<TaskDao, TaskE
ExecutorService executorService = Executors.newFixedThreadPool(threadSize);
while (!isStop) {
if (!isUnlockSuccess && prevTask != null) {
log.info("doForceUpdateTaskUnLock=====");
try {
taskService.doForceUpdateTaskUnLock(prevTask);
isUnlockSuccess = true;
......@@ -246,9 +188,7 @@ public class TaskServiceImpl extends AbstractCRUDCacheServiceImpl<TaskDao, TaskE
try {
TaskQuery params = new TaskQuery();
params.setStatus(ExcuteStatus.WAIT_RUN.getValue());
//修改为redis 缓存
List<TaskEntity> taskList = this.getCacheList().stream().filter(f -> ExcuteStatus.WAIT_RUN.getValue() == f.getStatus()).collect(Collectors.toList());
//List<TaskEntity> taskList = find(params, null);
List<TaskEntity> taskList = find(params, null);
if (taskList != null && taskList.size() > 0) {
final Date currDateTime = cal.getTime();
String currDateTimeStr = DateUtils.getDateTime(currDateTime, "yyyyMMddHHmm");
......
......@@ -118,4 +118,6 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
UserDao getUserDao();
void doHandlerUser(UserEntity entity);
}
\ No newline at end of file
......@@ -50,18 +50,14 @@ import java.util.stream.Collectors;
*/
@Service("userService")
public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity, Long> implements UserService {
@Autowired
private MenuService menuService;
@Autowired
private ResourceService resourceService;
@Autowired
private RoleService roleService;
@Autowired
private RoleUserService roleUserService;
private void doHandlerUser(UserEntity entity) throws AppException {
@Override
public void doHandlerUser(UserEntity entity) throws AppException {
if (StringUtils.isNotEmpty(entity.getLoginPwd())) {
try {
entity.setLoginPwd(SecurityUtil.md5DoubleEncoding(entity.getLoginPwd()));
......
......@@ -13,7 +13,9 @@ public class CustomerInfoPdu {
private String user_name;
private String account;
private String password;
private Integer userType;
private Integer type;
private String mobile;
}
......@@ -13,9 +13,14 @@ import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.UserType;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.common.pdu.CustomerInfoPdu;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -24,6 +29,7 @@ import java.util.*;
/**
* 用户同步
*
* @author:
* @date: 2023/3/6 13:46
*/
......@@ -35,6 +41,8 @@ public class UserSyncTaskImpl implements ITaskExcuteService {
private UserService userService;
@Autowired
private RoleUserService roleUserService;
@Autowired
private DeptService deptService;
@Override
public void excuteTask(ITask task) throws AppException {
......@@ -47,40 +55,66 @@ public class UserSyncTaskImpl implements ITaskExcuteService {
* 用户同步
*/
private void syncUser() {
String url = GlobalSysInfo.getParamValue(ParamKey.SYS_PARAM_USER_URL, "http://127.0.0.1:8076/doors/inter/user/userList");
String url = GlobalSysInfo.getParamValue(ParamKey.SYS_PARAM_USER_URL, "http://192.168.0.231:8076/doors/inter/user/userList");
Map<String, String> headers = new HashMap<>();
try {
String resp = HttpUtil.doGet(url, headers);
ApiResp<List<CustomerInfoPdu>> apiResp = JSON.parseObject(resp, new TypeReference<ApiResp<List<CustomerInfoPdu>>>() {
});
if(apiResp.getCode()==0){
apiResp.getData().stream().forEach(user->{
//查询用户是否存在
if (apiResp.getCode() == 0) {
for (CustomerInfoPdu user : apiResp.getData()) {
if("admin".equalsIgnoreCase(user.getAccount())){
//更新超级管理员
UserEntity userEntity = userService.get(1L);
userEntity.setLoginName(user.getAccount());
userEntity.setRealName(user.getUser_name());
userEntity.setMobile(user.getMobile());
userEntity.setUserType(UserType.SYSTEM.getValue());
userEntity.setLoginPwd(user.getPassword());
userEntity.setUpdateUserId(1L);
userEntity.setUpdateTime(new Date());
updateDefaultDept(userEntity);
userService.doHandlerUser(userEntity);
userService.getUserDao().update(userEntity);
// userService.update(userEntity);
continue;
}
//查询用户是否存在,登录用户名唯一
UserQuery userQuery = new UserQuery();
userQuery.id(user.getId());
//userQuery.id(user.getId());
userQuery.setLoginName(user.getAccount());
UserEntity userEntity = userService.selectOne(userQuery);
if(!ObjectUtils.isEmpty(userEntity)){
// userEntity.setCustomerId(user.getId());
if (!ObjectUtils.isEmpty(userEntity)) {
updateDefaultDept(userEntity);
userEntity.setLoginName(user.getAccount());
userEntity.setRealName(user.getUser_name());
userEntity.setMobile(user.getMobile());
userEntity.setUserType(user.getUserType());
userEntity.setUserType(user.getType());
userEntity.setLoginPwd(user.getPassword());
userEntity.setUpdateUserId(1L);
userEntity.setUpdateTime(new Date());
userService.update(userEntity);
}else {
} else {
//新增用户
userEntity = userService.createUser(null, user.getId(), "", user.getAccount(), user.getPassword(), user.getUser_name(), user.getMobile());
if(UserType.WORK.getValue()==user.getType()){
//根据用户类型添加默认访问权限
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(userEntity.getId());
roleUserQuery.setRoleIdList(Arrays.asList(new Long[]{1L}));
roleUserQuery.setRoleIdList(Arrays.asList(new Long[]{3L}));
roleUserService.doDistributionRole(roleUserQuery);
}else if (UserType.WORK_PERSON.getValue()==user.getType()){
//根据用户类型添加默认访问权限
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(userEntity.getId());
roleUserQuery.setRoleIdList(Arrays.asList(new Long[]{2L}));
roleUserService.doDistributionRole(roleUserQuery);
}
});
}
}
}
log.debug("user resp:{}", JSON.toJSONString(apiResp));
} catch (Exception e) {
......@@ -88,6 +122,17 @@ public class UserSyncTaskImpl implements ITaskExcuteService {
}
}
private void updateDefaultDept(UserEntity userEntity) {
if(ObjectUtils.isEmpty(userEntity.getDeptId())){
//没有部门 默认添加一个
DeptEntity deptEntity = deptService.selectOne(new DeptQuery());
if(!ObjectUtils.isEmpty(deptEntity)){
userEntity.setDeptId(deptEntity.getId());
userEntity.setDeptName(deptEntity.getDeptName());
}
}
}
@Override
public void stopTask(ITask task) throws AppException {
......
......@@ -8,7 +8,7 @@ spring:
application:
name: study-manager
profiles:
active: test
active: develop
servlet:
multipart:
max-file-size: 100MB
......@@ -23,9 +23,9 @@ spring:
nacos:
# Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类
discovery:
server-addr: 192.168.0.252:8848 # Nacos 服务器地址
server-addr: 192.168.0.54:8848 # Nacos 服务器地址
group: DEFAULT_GROUP
namespace: smart-gov-chuanshan
namespace: smart-gov-cs
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务器地址
group: ${spring.cloud.nacos.discovery.group}
......
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 to comment