Merge remote-tracking branch 'origin/dev' into dev

pull/4/head
chenxinying 2024-01-11 17:04:36 +08:00
commit d230d3e62a
7 changed files with 1976 additions and 109 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
package com.zcloud.controller.system; package com.zcloud.controller.system;
import com.zcloud.controller.base.BaseController; import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.EmployeeData;
import com.zcloud.entity.Page; import com.zcloud.entity.Page;
import com.zcloud.entity.PageData; import com.zcloud.entity.PageData;
import com.zcloud.entity.system.Dictionaries; import com.zcloud.entity.system.Dictionaries;
@ -20,9 +21,7 @@ import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@ -656,88 +655,20 @@ public class UsersController extends BaseController {
@RequestMapping(value="/saveUser") @RequestMapping(value="/saveUser")
@RequiresPermissions("user:add") @RequiresPermissions("user:add")
@ResponseBody @ResponseBody
@Transactional
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "保存用户") @LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "用户管理",instructionsType = "保存用户")
public Object saveUser() throws Exception{ public Object saveUser() throws Exception{
Map<String,Object> map = new HashMap<String,Object>(); Map<String, Object> map = new HashMap<>();
String errInfo = "success"; String errInfo = "success";
PageData pd = new PageData(); PageData pd = this.getPageData();
pd = this.getPageData();
// 默认周期初始值为1
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
// pd.put("DURATION", "1"); //工作状态持续时间
pd.put("WORKSTATUS", "1"); //工作状态
pd.put("WORKPERIOD", "1"); //当前工作周期数
pd.put("RIGHTS", "788664966448");
if(pd.get("USERAVATARURL")!=null && !pd.getString("USERAVATARURL").equals("")){
// System.out.println("USERAVATARURL原长度"+pd.getString("USERAVATARURL").length());
String USERAVATARURL64 = ImageAnd64Binary.zipBase64(pd.getString("USERAVATARURL"));
// System.out.println("USERAVATARURL压缩长度"+USERAVATARURL64.length());
try { try {
FaceUtil.compareFace(pd.getString("USERAVATARURL"),pd.getString("USERAVATARURL")); usersService.saveUserNew(pd);
} catch (Exception e) { } catch (Exception e) {
map.put("result", "fail"); errInfo = "error";
map.put("msg", "人脸图像不符合要求 请重新上传!"); map.put("msg", e.getMessage());
return map;
} }
} map.put("result", errInfo);
if ("input".equals(pd.getString("LEARNERCATEGORYSTATUS"))) { map.put("USER_ID", pd.getString("USER_ID"));
pd.put("DICTTYPE","APPLICABLE_PERSONNEL");
PageData lc = dictionariesCorpService.saveSelf(pd);
pd.put("LEARNERCATEGORY", lc.getString("DICTIONARIES_ID"));
}
pd.put("USER_ID", this.get32UUID()); //ID 主键
pd.put("LAST_LOGIN", ""); //最后登录时间
pd.put("IP", ""); //IP
pd.put("STATUS", "0"); //状态
pd.put("ISMAIN", "0"); //状态
pd.put("SKIN", "pcoded-navbar navbar-image-3,navbar pcoded-header navbar-expand-lg navbar-light header-dark,"); //用户默认皮肤
pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString()); //密码加密
if(null == usersService.findByUsername(pd)){ //判断用户名是否存在
usersService.saveUser(pd); //执行保存
if("true".equals(pd.getString("ISSTUDENT"))) {
if ("select".equals(pd.getString("letDutiesType"))) {
pd.put("DUTIES", pd.getString("DUTIES"));
} else {
PageData dicPd = new PageData();
dicPd.put("PARENT_ID", "09e36ac01e9540f8bc84eab1c1a78754");
dicPd.put("BIANMA", "zhiwu");
dicPd.put("NAME", pd.getString("DUTIESValue"));
dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
pd.put("DUTIES", dicPd.getString("DICTIONARIES_ID"));
}
if ("select".equals(pd.getString("letTitleType"))) {
pd.put("TITLE", pd.getString("TITLE"));
} else {
PageData dicPd = new PageData();
dicPd.put("PARENT_ID", "945a6b10e59946078b500f0fbafa8679");
dicPd.put("BIANMA", "zhicheng");
dicPd.put("NAME", pd.getString("letTitleValue"));
dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
pd.put("TITLE", dicPd.getString("DICTIONARIES_ID"));
}
if ("select".equals(pd.getString("letTypeOfWorkType"))) {
pd.put("TYPE_OF_WORK", pd.getString("TYPE_OF_WORK"));
} else {
PageData dicPd = new PageData();
dicPd.put("PARENT_ID", "55484e491a5e442d839c4595380713ec");
dicPd.put("BIANMA", "gongzhong");
dicPd.put("NAME", pd.getString("letTypeOfWorkValue"));
dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
pd.put("TYPE_OF_WORK", dicPd.getString("DICTIONARIES_ID"));
}
userInfoService.save(pd);
}
}else{
map.put("result","failed");
}
FHLOG.save(Jurisdiction.getUsername(), "新增用户:"+pd.getString("USERNAME"));//记录日志
map.put("result", errInfo); //返回结果
map.put("USER_ID", pd.getString("USER_ID")); //返回结果
return map; return map;
} }

View File

@ -0,0 +1,23 @@
package com.zcloud.entity;
import lombok.Data;
@Data
public class EmployeeData {
private String remark; // 备注
private String name; // 姓名
private String avatar; // 头像地址
private String cardNo; // 卡号
private String empNo; // 员工编号
private String sex; // 性别
private String certType; // 证件类型
private String certNo; // 证件号码
private Integer office; // 办公室/科室编号
private String staffType; // 员工类型
private String phone; // 手机号码
private String deptId; // 部门ID
private String empId; // 员工ID
private String abo; // 血型
private Integer age; // 年龄
private String addr; // 地址
}

View File

@ -4,6 +4,7 @@ import com.zcloud.entity.Page;
import com.zcloud.entity.PageData; import com.zcloud.entity.PageData;
import com.zcloud.entity.system.User; import com.zcloud.entity.system.User;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
@ -262,4 +263,7 @@ public interface UsersService {
List<PageData> listAll(PageData pd)throws Exception; List<PageData> listAll(PageData pd)throws Exception;
void editUserState(PageData pageData)throws Exception; void editUserState(PageData pageData)throws Exception;
void saveUserNew(PageData pd) throws Exception;
} }

View File

@ -5,13 +5,14 @@ import com.zcloud.entity.Page;
import com.zcloud.entity.PageData; import com.zcloud.entity.PageData;
import com.zcloud.entity.system.User; import com.zcloud.entity.system.User;
import com.zcloud.mapper.datasource.system.UsersMapper; import com.zcloud.mapper.datasource.system.UsersMapper;
import com.zcloud.service.system.DepartmentService; import com.zcloud.service.system.*;
import com.zcloud.service.system.UsersService; import com.zcloud.util.*;
import com.zcloud.util.HttpClientUtil; import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -28,6 +29,12 @@ public class UsersServiceImpl implements UsersService {
private UsersMapper usersMapper; private UsersMapper usersMapper;
@Autowired @Autowired
private DepartmentService departmentService; private DepartmentService departmentService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private DictionariesCorpService dictionariesCorpService;
@Autowired
private FHlogService FHLOG;
/** /**
* @param pd * @param pd
@ -176,6 +183,86 @@ public class UsersServiceImpl implements UsersService {
public void editUserState(PageData pd)throws Exception{ public void editUserState(PageData pd)throws Exception{
usersMapper.editUserState(pd); usersMapper.editUserState(pd);
} }
@Override
public void saveUserNew(PageData pd) throws Exception {
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
pd.put("WORKSTATUS", "1");
pd.put("WORKPERIOD", "1");
pd.put("RIGHTS", "788664966448");
if (pd.get("USERAVATARURL") != null && !pd.getString("USERAVATARURL").equals("")) {
String USERAVATARURL64 = ImageAnd64Binary.zipBase64(pd.getString("USERAVATARURL"));
try {
FaceUtil.compareFace(pd.getString("USERAVATARURL"), pd.getString("USERAVATARURL"));
} catch (Exception e) {
throw new Exception("人脸图像不符合要求,请重新上传");
}
}
if ("input".equals(pd.getString("LEARNERCATEGORYSTATUS"))) {
pd.put("DICTTYPE", "APPLICABLE_PERSONNEL");
PageData lc = dictionariesCorpService.saveSelf(pd);
pd.put("LEARNERCATEGORY", lc.getString("DICTIONARIES_ID"));
}
pd.put("USER_ID", Warden.get32UUID());
pd.put("LAST_LOGIN", "");
pd.put("IP", "");
pd.put("STATUS", "0");
pd.put("ISMAIN", "0");
pd.put("SKIN", "pcoded-navbar navbar-image-3, navbar pcoded-header navbar-expand-lg navbar-light header-dark");
pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString());
if (usersMapper.findByUsername(pd) == null) {
if ("true".equals(pd.getString("ISSTUDENT"))) {
if ("select".equals(pd.getString("letDutiesType"))) {
pd.put("DUTIES", pd.getString("DUTIES"));
} else {
PageData dicPd = new PageData();
dicPd.put("PARENT_ID", "09e36ac01e9540f8bc84eab1c1a78754");
dicPd.put("BIANMA", "zhiwu");
dicPd.put("NAME", pd.getString("DUTIESValue"));
dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
pd.put("DUTIES", dicPd.getString("DICTIONARIES_ID"));
}
if ("select".equals(pd.getString("letTitleType"))) {
pd.put("TITLE", pd.getString("TITLE"));
} else {
PageData dicPd = new PageData();
dicPd.put("PARENT_ID", "945a6b10e59946078b500f0fbafa8679");
dicPd.put("BIANMA", "zhicheng");
dicPd.put("NAME", pd.getString("letTitleValue"));
dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
pd.put("TITLE", dicPd.getString("DICTIONARIES_ID"));
}
if ("select".equals(pd.getString("letTypeOfWorkType"))) {
pd.put("TYPE_OF_WORK", pd.getString("TYPE_OF_WORK"));
} else {
PageData dicPd = new PageData();
dicPd.put("PARENT_ID", "55484e491a5e442d839c4595380713ec");
dicPd.put("BIANMA", "gongzhong");
dicPd.put("NAME", pd.getString("letTypeOfWorkValue"));
dicPd = dictionariesCorpService.saveByZidongxinzeng(dicPd);
pd.put("TYPE_OF_WORK", dicPd.getString("DICTIONARIES_ID"));
}
userInfoService.save(pd);
}
usersMapper.saveUser(pd);
FHLOG.save(Jurisdiction.getUsername(), "新增用户:" + pd.getString("USERNAME"));
if (PLSUtil.getToken(pd)) {
PLSUtil.saveUser(pd);
} else {
throw new Exception("无法获取有效的Token");
}
} else {
throw new Exception("用户名已存在");
}
}
public void editPassword(PageData pd)throws Exception{ public void editPassword(PageData pd)throws Exception{
usersMapper.editPassword(pd); usersMapper.editPassword(pd);
} }

View File

@ -0,0 +1,104 @@
package com.zcloud.util;
import com.alibaba.fastjson.JSONObject;
import com.zcloud.controller.corp.CorpInfoController;
import com.zcloud.entity.EmployeeData;
import com.zcloud.entity.PageData;
import com.zcloud.service.corp.CorpInfoService;
import com.zcloud.service.corp.CorpPlsInfoService;
import com.zcloud.service.system.UsersService;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
public class PLSUtil {
@Autowired
public static CorpPlsInfoService corpplsinfoService;
@Autowired
public static UsersService usersService;
// 修改 getToken 方法以返回布尔值
public static boolean getToken(PageData pd) throws Exception {
boolean tokenUpdated = false;
pd = corpplsinfoService.findById(pd);
String token = pd.getString("TOKEN");
String expireTime = pd.getString("EXPIRE_TIME");
String userName = pd.getString("ACCOUNT");
String passWord = pd.getString("PASSWORD");
String loginUrl = pd.getString("POST_URL") + "/auth/login";
if (token == null || expireTime == null || expireTime.trim().isEmpty() || DateUtil.compareDate(DateUtil.getTime(), expireTime)) {
JSONObject loginPayload = new JSONObject();
loginPayload.put("username", userName);
loginPayload.put("password", passWord);
loginPayload.put("isPresentationMode", "2");
OkHttpClient client = new OkHttpClient();
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON, loginPayload.toJSONString());
Request request = new Request.Builder()
.url(loginUrl)
.post(body)
.build();
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
String responseBody = response.body().string();
JSONObject responseJSON = new JSONObject(responseBody.isEmpty());
JSONObject data = responseJSON.getJSONObject("data");
token = data.getString("access_token");
String newExpireTime = DateUtil.getAfterDayDate("1");
pd.put("TOKEN", token);
pd.put("EXPIRE_TIME", newExpireTime);
corpplsinfoService.edit(pd);
tokenUpdated = true;
} else {
System.out.println("登录失败" + response.code());
}
} else {
tokenUpdated = true;
}
return tokenUpdated;
}
public static void saveUser(PageData pd) throws Exception {
if (getToken(pd)) {
PageData user = usersService.findByUsername(pd);
EmployeeData employeeData = new EmployeeData();
if (user == null) {
employeeData.setName(user.getString("NAME"));
employeeData.setAvatar(user.getString("USERAVATARPREFIX") + user.getString("USERAVATARURL"));
employeeData.setCardNo(user.getString("CARDNO"));
employeeData.setSex(user.getString("SEX"));
employeeData.setPhone(user.getString("PHONE"));
}
pd = corpplsinfoService.findById(pd);
String token = pd.getString("TOKEN");
String url = pd.getString("POST_URL") + "/deploy/psnmgmt/insertPsnInfo";
OkHttpClient client = new OkHttpClient();
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON, employeeData.toString());
Request request = new Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", "Bearer " + token)
.build();
Response response = client.newCall(request).execute();
if (!response.isSuccessful()) {
throw new IOException(String.valueOf(response));
}
} else {
throw new Exception("无法获取有效的Token");
}
}
}

View File

@ -20,7 +20,10 @@
f.MARK_NAME, f.MARK_NAME,
f.MESSAGE, f.MESSAGE,
f.CREATE_TIME, f.CREATE_TIME,
f.MESSAGE_LOG_ID f.MESSAGE_LOG_ID,
f.TYPE,
f.DIGESTION_FLAG,
f.PLAN_TIME
</sql> </sql>
<!-- 字段用于新增 --> <!-- 字段用于新增 -->
@ -31,7 +34,10 @@
MARK_NAME, MARK_NAME,
MESSAGE, MESSAGE,
CREATE_TIME, CREATE_TIME,
MESSAGE_LOG_ID MESSAGE_LOG_ID,
TYPE,
DIGESTION_FLAG,
PLAN_TIME
</sql> </sql>
<!-- 字段值 --> <!-- 字段值 -->
@ -42,7 +48,10 @@
#{MARK_NAME}, #{MARK_NAME},
#{MESSAGE}, #{MESSAGE},
#{CREATE_TIME}, #{CREATE_TIME},
#{MESSAGE_LOG_ID} #{MESSAGE_LOG_ID},
#{TYPE},
#{DIGESTION_FLAG},
#{PLAN_TIME}
</sql> </sql>
<!-- 新增--> <!-- 新增-->
@ -75,6 +84,9 @@
MARK_NAME = #{MARK_NAME}, MARK_NAME = #{MARK_NAME},
MESSAGE = #{MESSAGE}, MESSAGE = #{MESSAGE},
CREATE_TIME = #{CREATE_TIME}, CREATE_TIME = #{CREATE_TIME},
TYPE = #{TYPE},
DIGESTION_FLAG = #{DIGESTION_FLAG},
PLAN_TIME = #{PLAN_TIME},
MESSAGE_LOG_ID = MESSAGE_LOG_ID MESSAGE_LOG_ID = MESSAGE_LOG_ID
where where
MESSAGE_LOG_ID = #{MESSAGE_LOG_ID} MESSAGE_LOG_ID = #{MESSAGE_LOG_ID}