|
|
@@ -1,5 +1,6 @@
|
|
|
package com.dk.mdm.service.mst;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dk.common.exception.BaseBusinessException;
|
|
|
import com.dk.common.infrastructure.annotaiton.Pagination;
|
|
|
@@ -12,6 +13,7 @@ import com.dk.common.model.vo.core.StaffEntity;
|
|
|
import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
|
+import com.dk.common.util.AESUtil;
|
|
|
import com.dk.mdm.feign.CompanyFeign;
|
|
|
import com.dk.mdm.feign.UserFeign;
|
|
|
import com.dk.mdm.infrastructure.convert.mst.StaffConvert;
|
|
|
@@ -35,7 +37,9 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author : 姜永辉
|
|
|
@@ -126,6 +130,16 @@ public class StaffService extends BaseService<Staff> {
|
|
|
Integer cpId = authUtils.getStaff().getCpId();
|
|
|
staffQuery.setCpId(cpId);
|
|
|
}
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
+// map.put("grade_code","STD");
|
|
|
+// map.put("end_date","2099-09-01");
|
|
|
+// map.put("web_max_num",1);
|
|
|
+// map.put("wx_max_num",1);
|
|
|
+// String s1 = JSON.toJSONString(map);
|
|
|
+// // 加密
|
|
|
+// String s = AESUtil.aesEncrypt(s1);
|
|
|
+// // 解密
|
|
|
+// Map<String,Object> ss = JSON.parseObject(AESUtil.desEncrypt(s),Map.class) ;
|
|
|
return super.mergeListWithCount(staffQuery, staffMapper.selectByCond(staffQuery),
|
|
|
staffMapper.countByCond(staffQuery));
|
|
|
}
|
|
|
@@ -168,15 +182,27 @@ public class StaffService extends BaseService<Staff> {
|
|
|
ErrorCodeEnum.USER_REGISTER_ERROR.getMessage());
|
|
|
} else {
|
|
|
Map<String, Object> mp = (Map<String, Object>) resultMaxnum.getData();
|
|
|
- int intMaxnum = Integer.parseInt(mp.get("maxStaffNum") + "");
|
|
|
+ int intWebMaxnum = Integer.parseInt(mp.get("web_max_num") + "");
|
|
|
+ int intWxMaxnum = Integer.parseInt(mp.get("wx_max_num") + "");
|
|
|
staffQuery = new StaffQuery();
|
|
|
staffQuery.setFlgCanLogin(true);
|
|
|
staffQuery.setCpId(cpId);
|
|
|
List<StaffResponse> staffResponsesFlgCanLogin = staffMapper.selectByCond(staffQuery);
|
|
|
- if (staffResponsesFlgCanLogin != null && staffResponsesFlgCanLogin.size() > 0 && intMaxnum < staffResponsesFlgCanLogin.size() + 1) {
|
|
|
- // 无用户
|
|
|
- throw new BaseBusinessException(ErrorCodeEnum.USER_MAX_STAFF_ERROR.getCode(),
|
|
|
- ErrorCodeEnum.USER_MAX_STAFF_ERROR.getMessage());
|
|
|
+ if (staffResponsesFlgCanLogin != null && staffResponsesFlgCanLogin.size() > 0 ) {
|
|
|
+ List<StaffResponse> collectPc = staffResponsesFlgCanLogin.stream().filter(it -> it.getLoginType() == 1 || it.getLoginType() == 3).collect(Collectors.toList());
|
|
|
+ List<StaffResponse> collectWx = staffResponsesFlgCanLogin.stream().filter(it -> it.getLoginType() == 2 || it.getLoginType() == 3).collect(Collectors.toList());
|
|
|
+ if ((staffVO.getLoginType() == 1 || staffVO.getLoginType() == 3 ) &&
|
|
|
+ collectPc != null && collectPc.size() > 0 && intWebMaxnum < collectPc.size() + 1) {
|
|
|
+ // 无用户
|
|
|
+ throw new BaseBusinessException(ErrorCodeEnum.USER_MAX_PC_STAFF_ERROR.getCode(),
|
|
|
+ ErrorCodeEnum.USER_MAX_PC_STAFF_ERROR.getMessage());
|
|
|
+ }
|
|
|
+ if ((staffVO.getLoginType() == 2 || staffVO.getLoginType() == 3 ) &&
|
|
|
+ collectWx != null && collectWx.size() > 0 && intWxMaxnum < collectWx.size() + 1) {
|
|
|
+ // 无用户
|
|
|
+ throw new BaseBusinessException(ErrorCodeEnum.USER_MAX_WX_STAFF_ERROR.getCode(),
|
|
|
+ ErrorCodeEnum.USER_MAX_WX_STAFF_ERROR.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -372,8 +398,11 @@ public class StaffService extends BaseService<Staff> {
|
|
|
moneyAccount.setMacCode(m.get("macCode").toString());
|
|
|
moneyAccount.setMacName(m.get("macName").toString());
|
|
|
moneyAccount.setMacType(m.get("macType").toString());
|
|
|
- moneyAccount.setBalance((BigDecimal) m.get("balance"));
|
|
|
+ moneyAccount.setAccDate(LocalDate.parse(m.get("accDate").toString()) );
|
|
|
+// moneyAccount.setBalance((BigDecimal) m.get("balance"));
|
|
|
+ moneyAccount.setBalance(new BigDecimal(m.get("balance").toString()) );
|
|
|
moneyAccount.setFlgDefault((Boolean) m.get("flgDefault"));
|
|
|
+ moneyAccount.setFlgNegative((Boolean) m.get("flgNegative"));
|
|
|
moneyAccount.setDisplayNo((Integer) m.get("displayNo"));
|
|
|
moneyAccount.setCpId(cpId);
|
|
|
listMa.add(moneyAccount);
|
|
|
@@ -511,43 +540,64 @@ public class StaffService extends BaseService<Staff> {
|
|
|
throw new BaseBusinessException(ErrorCodeEnum.USER_REGISTER_ERROR.getCode(),
|
|
|
ErrorCodeEnum.USER_REGISTER_ERROR.getMessage());
|
|
|
} else {
|
|
|
- Map<String, Object> mp = (Map<String, Object>) resultMaxnum.getData();
|
|
|
- int intMaxnum = Integer.parseInt(mp.get("maxStaffNum") + "");
|
|
|
- StaffQuery staffQuery = new StaffQuery();
|
|
|
- staffQuery.setFlgCanLogin(true);
|
|
|
- staffQuery.setCpId(cpId);
|
|
|
- List<StaffResponse> staffResponsesFlgCanLogin = staffMapper.selectByCond(staffQuery);
|
|
|
- if (staffResponsesFlgCanLogin != null && staffResponsesFlgCanLogin.size() > 0 && intMaxnum < staffResponsesFlgCanLogin.size()) {
|
|
|
- // 无用户
|
|
|
- throw new BaseBusinessException(ErrorCodeEnum.USER_MAX_STAFF_ERROR.getCode(),
|
|
|
- ErrorCodeEnum.USER_MAX_STAFF_ERROR.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- if (staffResponseOld.getFlgCanLogin() != staffVO.getFlgCanLogin()) {
|
|
|
- // 增加一个可以cur_staff_num
|
|
|
- Map<String, Object> m = new HashMap<>();
|
|
|
- m.put("curStaffNum", 1);
|
|
|
- m.put("cpId", cpId);
|
|
|
- ResponseResultVO<Boolean> booleanResponseResultVO = companyFeign.updateCompanyCurStaffNum(m);
|
|
|
- if (booleanResponseResultVO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) {
|
|
|
- // 无用户
|
|
|
- throw new BaseBusinessException(ErrorCodeEnum.USER_REGISTER_ERROR.getCode(),
|
|
|
- ErrorCodeEnum.USER_REGISTER_ERROR.getMessage());
|
|
|
+ if (staffResponseOld.getFlgCanLogin() != staffVO.getFlgCanLogin()) {
|
|
|
+ Map<String, Object> mp = (Map<String, Object>) resultMaxnum.getData();
|
|
|
+ int intWebMaxnum = Integer.parseInt(mp.get("web_max_num") + "");
|
|
|
+ int intWxMaxnum = Integer.parseInt(mp.get("wx_max_num") + "");
|
|
|
+ StaffQuery staffQuery = new StaffQuery();
|
|
|
+ staffQuery.setFlgCanLogin(true);
|
|
|
+ staffQuery.setCpId(cpId);
|
|
|
+ List<StaffResponse> staffResponsesFlgCanLogin = staffMapper.selectByCond(staffQuery);
|
|
|
+ if (staffResponsesFlgCanLogin != null && staffResponsesFlgCanLogin.size() > 0 ) {
|
|
|
+ List<StaffResponse> collectPc = staffResponsesFlgCanLogin.stream().filter(it -> it.getLoginType() == 1 || it.getLoginType() == 3).collect(Collectors.toList());
|
|
|
+ List<StaffResponse> collectWx = staffResponsesFlgCanLogin.stream().filter(it -> it.getLoginType() == 2 || it.getLoginType() == 3).collect(Collectors.toList());
|
|
|
+ if (collectPc != null && collectPc.size() > 0 && intWebMaxnum < collectPc.size()) {
|
|
|
+ // 无用户
|
|
|
+ throw new BaseBusinessException(ErrorCodeEnum.USER_MAX_PC_STAFF_ERROR.getCode(),
|
|
|
+ ErrorCodeEnum.USER_MAX_PC_STAFF_ERROR.getMessage());
|
|
|
+ }
|
|
|
+ if (collectWx != null && collectWx.size() > 0 && intWxMaxnum < collectWx.size()) {
|
|
|
+ // 无用户
|
|
|
+ throw new BaseBusinessException(ErrorCodeEnum.USER_MAX_WX_STAFF_ERROR.getCode(),
|
|
|
+ ErrorCodeEnum.USER_MAX_WX_STAFF_ERROR.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+// if (staffResponsesFlgCanLogin != null && staffResponsesFlgCanLogin.size() > 0 && intMaxnum < staffResponsesFlgCanLogin.size()) {
|
|
|
+// // 无用户
|
|
|
+// throw new BaseBusinessException(ErrorCodeEnum.USER_MAX_STAFF_ERROR.getCode(),
|
|
|
+// ErrorCodeEnum.USER_MAX_STAFF_ERROR.getMessage());
|
|
|
+// }
|
|
|
+
|
|
|
}
|
|
|
+// if (staffResponseOld.getFlgCanLogin() != staffVO.getFlgCanLogin()) {
|
|
|
+// // 增加一个可以cur_staff_num
|
|
|
+// Map<String, Object> m = new HashMap<>();
|
|
|
+// m.put("curStaffNum", 1);
|
|
|
+// m.put("cpId", cpId);
|
|
|
+// ResponseResultVO<Boolean> booleanResponseResultVO = companyFeign.updateCompanyCurStaffNum(m);
|
|
|
+// if (booleanResponseResultVO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) {
|
|
|
+// // 无用户
|
|
|
+// throw new BaseBusinessException(ErrorCodeEnum.USER_REGISTER_ERROR.getCode(),
|
|
|
+// ErrorCodeEnum.USER_REGISTER_ERROR.getMessage());
|
|
|
+// }
|
|
|
+// }
|
|
|
} else {
|
|
|
- if (staffResponseOld.getFlgCanLogin() != staffVO.getFlgCanLogin()) {
|
|
|
- // 减少一个可以cur_staff_num
|
|
|
- Map<String, Object> m = new HashMap<>();
|
|
|
- m.put("curStaffNum", -1);
|
|
|
- m.put("cpId", cpId);
|
|
|
- ResponseResultVO<Boolean> booleanResponseResultVO = companyFeign.updateCompanyCurStaffNum(m);
|
|
|
- if (booleanResponseResultVO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) {
|
|
|
- // 无用户
|
|
|
- throw new BaseBusinessException(ErrorCodeEnum.USER_REGISTER_ERROR.getCode(),
|
|
|
- ErrorCodeEnum.USER_REGISTER_ERROR.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
+// 2024-05-20 edit
|
|
|
+// if (staffResponseOld.getFlgCanLogin() != staffVO.getFlgCanLogin()) {
|
|
|
+// // 减少一个可以cur_staff_num
|
|
|
+// Map<String, Object> m = new HashMap<>();
|
|
|
+// m.put("curStaffNum", -1);
|
|
|
+// m.put("cpId", cpId);
|
|
|
+// ResponseResultVO<Boolean> booleanResponseResultVO = companyFeign.updateCompanyCurStaffNum(m);
|
|
|
+// if (booleanResponseResultVO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) {
|
|
|
+// // 无用户
|
|
|
+// throw new BaseBusinessException(ErrorCodeEnum.USER_REGISTER_ERROR.getCode(),
|
|
|
+// ErrorCodeEnum.USER_REGISTER_ERROR.getMessage());
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
return ResponseResultUtil.success();
|
|
|
}
|