|
@@ -24,7 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.lang.reflect.Method;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.regex.Matcher;
|
|
@@ -124,64 +126,50 @@ public class OwnCompanyManageController extends BaseController
|
|
|
private String status = "0";
|
|
|
|
|
|
/**
|
|
|
- * 查询核心企业列表
|
|
|
- * @param sysCompany 企业实体
|
|
|
+ * 企业列表
|
|
|
+ * @param sysCompany 企业实体类
|
|
|
+ * @param nickName 联系人
|
|
|
+ * @param userName 联系电话
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@PreAuthorize(hasPermi = "service:company:list")
|
|
|
@GetMapping("/list")
|
|
|
- public R list(SysCompany sysCompany, QueryRequest request)
|
|
|
+ public R list(SysCompany sysCompany, String nickName, String userName,QueryRequest request)
|
|
|
{
|
|
|
//获取当前操作员
|
|
|
LoginUser user = tokenService.getLoginUser();
|
|
|
String companyId = user.getSysUser().getCompanyId();
|
|
|
|
|
|
- LambdaQueryWrapper<SysCompany> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
Map map = new HashMap();
|
|
|
- map.put("companyId",companyId);
|
|
|
+ //企业Id
|
|
|
+ if(!SalaryConstants.OPEX.equals(companyId)) {
|
|
|
+ map.put("companyId", companyId);
|
|
|
+ }
|
|
|
//企业名称
|
|
|
if(CommonUtil.isNotEmpty(sysCompany.getScyName())) {
|
|
|
- queryWrapper.like(SysCompany::getScyName, sysCompany.getScyName());
|
|
|
map.put("scyName",sysCompany.getScyName());
|
|
|
}
|
|
|
//企业统一信用代码
|
|
|
if(CommonUtil.isNotEmpty(sysCompany.getScySocialCode())) {
|
|
|
- queryWrapper.like(SysCompany::getScySocialCode, sysCompany.getScySocialCode());
|
|
|
map.put("scySocialCode",sysCompany.getScySocialCode());
|
|
|
}
|
|
|
- //企业联系人(法人)
|
|
|
- if(CommonUtil.isNotEmpty(sysCompany.getScyLegal())) {
|
|
|
- queryWrapper.like(SysCompany::getScyLegal, sysCompany.getScyLegal());
|
|
|
- map.put("scyLegal",sysCompany.getScyLegal());
|
|
|
+ //企业联系人
|
|
|
+ if(CommonUtil.isNotEmpty(nickName)) {
|
|
|
+ map.put("nickName",nickName);
|
|
|
}
|
|
|
//企业联系电话
|
|
|
- if(CommonUtil.isNotEmpty(sysCompany.getScyPhone())) {
|
|
|
- queryWrapper.like(SysCompany::getScyPhone, sysCompany.getScyPhone());
|
|
|
- map.put("scyPhone",sysCompany.getScyPhone());
|
|
|
- }
|
|
|
- //企业状态不为空
|
|
|
- if(CommonUtil.isNotEmpty(sysCompany.getScyStatus())) {
|
|
|
- if(TREE_STATE.equals(sysCompany.getScyStatus())) {
|
|
|
- queryWrapper.and(i -> i.eq(SysCompany::getScyStatus, TREE_STATE).or().eq(SysCompany::getScyStatus, "03")
|
|
|
- .or().eq(SysCompany::getScyStatus, "04"));
|
|
|
- map.put("scyStatus",sysCompany.getScyStatus());
|
|
|
- }
|
|
|
- if(!TREE_STATE.equals(sysCompany.getScyStatus())){
|
|
|
- queryWrapper.eq(SysCompany::getScyStatus, sysCompany.getScyStatus());
|
|
|
- map.put("scyStatus",sysCompany.getScyStatus());
|
|
|
- }
|
|
|
+ if(CommonUtil.isNotEmpty(userName)) {
|
|
|
+ map.put("userName",userName);
|
|
|
}
|
|
|
- //企业状态如果为空,则查询正常或停用状态
|
|
|
- if(CommonUtil.isEmpty(sysCompany.getScyStatus())){
|
|
|
- queryWrapper.ne(SysCompany::getScyStatus, DELETE_STATE);
|
|
|
+ if(CommonUtil.isNotEmpty(sysCompany.getScyStatus())){
|
|
|
+ map.put("scyStatus",sysCompany.getScyStatus());
|
|
|
}
|
|
|
//企业类型
|
|
|
if(CommonUtil.isNotEmpty(sysCompany.getScyType()) && SalaryConstants.OPEX.equals(companyId)) {
|
|
|
- queryWrapper.eq(SysCompany::getScyType, sysCompany.getScyType());
|
|
|
+ map.put("scyType",sysCompany.getScyType());
|
|
|
//创建时间倒序排列
|
|
|
- queryWrapper.orderByDesc(SysCompany::getCreateTime);
|
|
|
- IPage<SysCompany> list = iSysCompanyService.findSysCompanys(request,queryWrapper);
|
|
|
+ IPage<Map> list = iOwnCompanyManageService.selectCompanyList(request,map);
|
|
|
return R.ok(list);
|
|
|
}
|
|
|
if(CommonUtil.isNotEmpty(sysCompany.getScyType()) && "01".equals(sysCompany.getScyType()) && !SalaryConstants.OPEX.equals(companyId)){
|
|
@@ -248,6 +236,22 @@ public class OwnCompanyManageController extends BaseController
|
|
|
throw new Exception("手机格式不正确");
|
|
|
}
|
|
|
}
|
|
|
+ //如果企业名称重复,不让其添加
|
|
|
+ LambdaQueryWrapper<SysCompany> sysCompanyLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ sysCompanyLambdaQueryWrapper.ne(SysCompany::getScyStatus,"99");
|
|
|
+ sysCompanyLambdaQueryWrapper.eq(SysCompany::getScyName,scyName);
|
|
|
+ List<SysCompany> sysCompanyList = iSysCompanyService.findSysCompanys(sysCompanyLambdaQueryWrapper);
|
|
|
+ if(sysCompanyList.size() > 0){
|
|
|
+ throw new Exception("当前企业名称已存在,请重新输入");
|
|
|
+ }
|
|
|
+ //如果社会统一信用代码重复,不让其添加
|
|
|
+ LambdaQueryWrapper<SysCompany> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SysCompany::getScySocialCode,scySocialCode);
|
|
|
+ queryWrapper.ne(SysCompany::getScyStatus,"99");
|
|
|
+ List<SysCompany> list = iSysCompanyService.findSysCompanys(queryWrapper);
|
|
|
+ if(list.size() > 0){
|
|
|
+ throw new Exception("当前社会统一信用代码已存在,请重新输入");
|
|
|
+ }
|
|
|
//执行新增
|
|
|
SysCompany sysCompany = new SysCompany();
|
|
|
//主键
|
|
@@ -256,8 +260,6 @@ public class OwnCompanyManageController extends BaseController
|
|
|
sysCompany.setScyName(scyName);
|
|
|
//社会统一代码
|
|
|
sysCompany.setScySocialCode(scySocialCode);
|
|
|
- //法人
|
|
|
- sysCompany.setScyLegal(scyLegal);
|
|
|
//类型(核心企业)
|
|
|
sysCompany.setScyType(CONFIRM_STATE);
|
|
|
//企业状态:待四要素状态
|
|
@@ -288,6 +290,9 @@ public class OwnCompanyManageController extends BaseController
|
|
|
} else {
|
|
|
createUser = users.get(0);
|
|
|
}
|
|
|
+ Long useId = createUser.getUserId();
|
|
|
+ sysCompany.setScyContractId(useId);
|
|
|
+ iSysCompanyService.updateById(sysCompany);
|
|
|
|
|
|
// 创建部门
|
|
|
String alternateNumber = IdUtils.fastSimpleUUID();
|
|
@@ -339,22 +344,22 @@ public class OwnCompanyManageController extends BaseController
|
|
|
|
|
|
|
|
|
// flowable数据
|
|
|
- Map<String, Object> flowableRes = flowableService.addFlowableGroup(scyId, sysCompany.getScyName());
|
|
|
- if (!"200".equals(flowableRes.get("code"))) {
|
|
|
- throw new Exception("审批数据新增失败!");
|
|
|
- }
|
|
|
- flowableRes = flowableService.addFlowableGroup(alternateNumber, dept.getDeptName());
|
|
|
- if (!"200".equals(flowableRes.get("code"))) {
|
|
|
- throw new Exception("审批数据新增失败!");
|
|
|
- }
|
|
|
- flowableRes = flowableService.addFlowableUser(String.valueOf(createUser.getUserId()), createUser.getNickName(), scyId);
|
|
|
- if (!"200".equals(flowableRes.get("code"))) {
|
|
|
- throw new Exception("审批数据新增失败!");
|
|
|
- }
|
|
|
- flowableRes = flowableService.addFlowableUser(String.valueOf(createUser.getUserId()), createUser.getNickName(), alternateNumber);
|
|
|
- if (!"200".equals(flowableRes.get("code"))) {
|
|
|
- throw new Exception("审批数据新增失败!");
|
|
|
- }
|
|
|
+// Map<String, Object> flowableRes = flowableService.addFlowableGroup(scyId, sysCompany.getScyName());
|
|
|
+// if (!"200".equals(flowableRes.get("code"))) {
|
|
|
+// throw new Exception("审批数据新增失败!");
|
|
|
+// }
|
|
|
+// flowableRes = flowableService.addFlowableGroup(alternateNumber, dept.getDeptName());
|
|
|
+// if (!"200".equals(flowableRes.get("code"))) {
|
|
|
+// throw new Exception("审批数据新增失败!");
|
|
|
+// }
|
|
|
+// flowableRes = flowableService.addFlowableUser(String.valueOf(createUser.getUserId()), createUser.getNickName(), scyId);
|
|
|
+// if (!"200".equals(flowableRes.get("code"))) {
|
|
|
+// throw new Exception("审批数据新增失败!");
|
|
|
+// }
|
|
|
+// flowableRes = flowableService.addFlowableUser(String.valueOf(createUser.getUserId()), createUser.getNickName(), alternateNumber);
|
|
|
+// if (!"200".equals(flowableRes.get("code"))) {
|
|
|
+// throw new Exception("审批数据新增失败!");
|
|
|
+// }
|
|
|
|
|
|
return R.ok();
|
|
|
}
|
|
@@ -369,7 +374,26 @@ public class OwnCompanyManageController extends BaseController
|
|
|
LambdaQueryWrapper<SysCompany> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(SysCompany::getScyId,scyId);
|
|
|
List<SysCompany> list = iSysCompanyService.findSysCompanys(queryWrapper);
|
|
|
+ //转为MapList
|
|
|
+ List<Map<String, Object>> result = EntityConvertMap(list);
|
|
|
if(list.size() > 0) {
|
|
|
+ for(Map r : result) {
|
|
|
+ //联系人
|
|
|
+ Long userId = list.get(0).getScyContractId();
|
|
|
+ //查询联系人信息
|
|
|
+ LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
|
|
|
+ userQuery.eq(SysUser::getUserId, userId);
|
|
|
+ List<SysUser> useList = iSysUserService.findSysUsers(userQuery);
|
|
|
+ if(useList.size() > 0) {
|
|
|
+ //联系电话
|
|
|
+ String userName = useList.get(0).getUserName();
|
|
|
+ //联系人
|
|
|
+ String nickName = useList.get(0).getNickName();
|
|
|
+ //新增值
|
|
|
+ r.put("userName", userName);
|
|
|
+ r.put("nickName", nickName);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (NORMAL_STATE.equals(list.get(0).getScyStatus())) {
|
|
|
//经办人信息
|
|
|
LambdaQueryWrapper<SysUserCompanyRel> sysUserCompanyRel = new LambdaQueryWrapper<>();
|
|
@@ -399,7 +423,7 @@ public class OwnCompanyManageController extends BaseController
|
|
|
/*返回结果*/
|
|
|
Map map = new HashMap();
|
|
|
//基本信息
|
|
|
- map.put("basicList",list);
|
|
|
+ map.put("basicList",result);
|
|
|
//经办人信息
|
|
|
if(contactsList.size() > 0) {
|
|
|
Long sucrUserId = contactsList.get(0).getSucrUserId();
|
|
@@ -432,9 +456,9 @@ public class OwnCompanyManageController extends BaseController
|
|
|
map.put("appendixList",appendixList);
|
|
|
return R.ok(map);
|
|
|
}if (NORMAL_STATE.equals(list.get(0).getScyAuthStatus())) {
|
|
|
- return R.ok(list);
|
|
|
+ return R.ok(result);
|
|
|
}else if(!NORMAL_STATE.equals(list.get(0).getScyStatus())){
|
|
|
- return R.ok(list);
|
|
|
+ return R.ok(result);
|
|
|
}
|
|
|
}else {
|
|
|
throw new Exception("企业不存在");
|
|
@@ -599,6 +623,14 @@ public class OwnCompanyManageController extends BaseController
|
|
|
if(CommonUtil.isEmpty(scyName)){
|
|
|
throw new Exception("企业名称不能为空");
|
|
|
}
|
|
|
+ //企业名称正则校验
|
|
|
+ String checkScyName = "^[^\\\\/\\\\:\\\\*\\\\?\\\"<>]+$";
|
|
|
+ Pattern regeScyName = Pattern.compile(checkScyName);
|
|
|
+ Matcher matcherScyName = regeScyName.matcher(scyName);
|
|
|
+ boolean isMatScyName = matcherScyName.matches();
|
|
|
+ if(!isMatScyName){
|
|
|
+ throw new Exception("企业名称格式错误,不能含有特殊字符");
|
|
|
+ }
|
|
|
//企业统一信用代码
|
|
|
String scySocialCode = CommonUtil.objToString(map.get("scySocialCode"));
|
|
|
if(CommonUtil.isEmpty(scySocialCode)){
|
|
@@ -613,30 +645,38 @@ public class OwnCompanyManageController extends BaseController
|
|
|
throw new Exception("统一信用代码格式错误");
|
|
|
}
|
|
|
//联系人
|
|
|
- String scyLegal = CommonUtil.objToString(map.get("scyLegal"));
|
|
|
- if(CommonUtil.isEmpty(scyLegal)){
|
|
|
+ String nickName = CommonUtil.objToString(map.get("nickName"));
|
|
|
+ if(CommonUtil.isEmpty(nickName)){
|
|
|
throw new Exception("联系人不能为空");
|
|
|
}
|
|
|
- if(scyLegal.length() > 30){
|
|
|
+ if(nickName.length() > 30){
|
|
|
throw new Exception("联系人长度不能超过30字;请检查是否正确");
|
|
|
}
|
|
|
+ //联系人正则校验
|
|
|
+ String checkNickName = "^[^\\\\/\\\\:\\\\*\\\\?\\\"<>]+$";
|
|
|
+ Pattern regeNickName = Pattern.compile(checkNickName);
|
|
|
+ Matcher matcherNickName = regeNickName.matcher(nickName);
|
|
|
+ boolean isMatNickName = matcherNickName.matches();
|
|
|
+ if(!isMatNickName){
|
|
|
+ throw new Exception("联系人格式错误,不能含有特殊字符");
|
|
|
+ }
|
|
|
//联系电话
|
|
|
-// String scyPhone = CommonUtil.objToString(map.get("scyPhone"));
|
|
|
-// if(CommonUtil.isEmpty(scyPhone)){
|
|
|
-// throw new Exception("联系电话不能为空");
|
|
|
-// }
|
|
|
-// if(CommonUtil.isNotEmpty(scyPhone)) {
|
|
|
-// if(scyPhone.length() > 11){
|
|
|
-// throw new Exception("手机号不能超过11位");
|
|
|
-// }
|
|
|
-// String checkPhone = "^1[3|4|5|6|7|8|9][0-9]\\d{8}$";
|
|
|
-// Pattern regePhone = Pattern.compile(checkPhone);
|
|
|
-// Matcher matcherPhone = regePhone.matcher(scyPhone);
|
|
|
-// boolean isMatPhone = matcherPhone.matches();
|
|
|
-// if (!isMatPhone) {
|
|
|
-// throw new Exception("手机格式不正确");
|
|
|
-// }
|
|
|
-// }
|
|
|
+ String userName = CommonUtil.objToString(map.get("userName"));
|
|
|
+ if(CommonUtil.isEmpty(nickName)){
|
|
|
+ throw new Exception("联系人手机号不能为空");
|
|
|
+ }
|
|
|
+ if(CommonUtil.isNotEmpty(userName)) {
|
|
|
+ if(userName.length() > 11){
|
|
|
+ throw new Exception("手机号不能超过11位");
|
|
|
+ }
|
|
|
+ String checkPhone = "^1[3|4|5|6|7|8|9][0-9]\\d{8}$";
|
|
|
+ Pattern regePhone = Pattern.compile(checkPhone);
|
|
|
+ Matcher matcherPhone = regePhone.matcher(userName);
|
|
|
+ boolean isMatPhone = matcherPhone.matches();
|
|
|
+ if (!isMatPhone) {
|
|
|
+ throw new Exception("手机格式不正确");
|
|
|
+ }
|
|
|
+ }
|
|
|
//查询当前企业id的状态
|
|
|
SysCompany sysCompanyQuery = iSysCompanyService.getById(scyId);
|
|
|
//执行修改
|
|
@@ -647,10 +687,6 @@ public class OwnCompanyManageController extends BaseController
|
|
|
sysCompany.setScyName(scyName);
|
|
|
//社会统一代码
|
|
|
sysCompany.setScySocialCode(scySocialCode);
|
|
|
- //法人
|
|
|
- sysCompany.setScyLegal(scyLegal);
|
|
|
- //联系电话
|
|
|
-// sysCompany.setScyPhone(scyPhone);
|
|
|
//类型(核心企业)
|
|
|
sysCompany.setScyType(sysCompanyQuery.getScyType());
|
|
|
//企业状态
|
|
@@ -663,6 +699,16 @@ public class OwnCompanyManageController extends BaseController
|
|
|
sysCompany.setCreateTime(DateUtils.getNowDate());
|
|
|
//修改
|
|
|
iSysCompanyService.updateById(sysCompany);
|
|
|
+ //获取企业实体
|
|
|
+ SysCompany company = iSysCompanyService.getById(scyId);
|
|
|
+ Long useId = company.getScyContractId();
|
|
|
+ if(CommonUtil.isNotEmpty(String.valueOf(useId))) {
|
|
|
+ //修改联系人
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
+ sysUser.setUserId(useId);
|
|
|
+ sysUser.setNickName(nickName);
|
|
|
+ iSysUserService.updateById(sysUser);
|
|
|
+ }
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
@@ -786,4 +832,31 @@ public class OwnCompanyManageController extends BaseController
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<Map<String,Object>> EntityConvertMap(List<SysCompany> list){
|
|
|
+ List<Map<String,Object>> l = new LinkedList<>();
|
|
|
+ try {
|
|
|
+ for(SysCompany t : list){
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ Method[] methods = t.getClass().getMethods();
|
|
|
+ for (Method method : methods) {
|
|
|
+ if (method.getName().startsWith("get")) {
|
|
|
+ String name = method.getName().substring(3);
|
|
|
+ name = name.substring(0, 1).toLowerCase() + name.substring(1);
|
|
|
+ Object value = method.invoke(t);
|
|
|
+ map.put(name,value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ l.add(map);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return l;
|
|
|
+ }
|
|
|
+
|
|
|
}
|