|
|
@@ -157,6 +157,27 @@ public class StaffService extends BaseService<Staff> {
|
|
|
if (staffResponses != null && staffResponses.size() > 0) {
|
|
|
return ResponseResultUtil.error(ResponseCodeEnum.ERROR_STAFF_CODE_EXIST);
|
|
|
}
|
|
|
+ //可以绑定微信的员工人数 人数上限
|
|
|
+ if (staffVO.getFlgCanLogin()) {
|
|
|
+ ResponseResultVO<?> resultMaxnum = companyFeign.getCompanyMaxStaffNum(cpId);
|
|
|
+ if (resultMaxnum.getCode() != ResponseCodeEnum.SUCCESS.getCode()) {
|
|
|
+ // 无用户
|
|
|
+ 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 = 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 获取编码和主键UuId
|
|
|
Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.STAFF.getName(), false);
|
|
|
@@ -208,6 +229,7 @@ public class StaffService extends BaseService<Staff> {
|
|
|
Constant.docNameConstant.STAFF.getName(), staff.getCpId(), true);
|
|
|
staff.setStaffId(codeMap.get("outId").toString());
|
|
|
staff.setStaffCode(codeMap.get("outNote").toString());
|
|
|
+ staff.setFlgCanLogin(true);
|
|
|
super.insert(staff);
|
|
|
return ResponseResultUtil.success(staff);
|
|
|
}
|
|
|
@@ -228,11 +250,11 @@ public class StaffService extends BaseService<Staff> {
|
|
|
List<Map<String, Object>> listRoles = map.get("roles");
|
|
|
List<Role> listR = new ArrayList<>();
|
|
|
String roleid = "";
|
|
|
- Integer cpId = Integer.parseInt(listCom.get(0).get("cpId").toString()) ;
|
|
|
+ Integer cpId = Integer.parseInt(listCom.get(0).get("cpId").toString());
|
|
|
String staffId = listCom.get(0).get("staffId").toString();
|
|
|
|
|
|
// 插入常用功能 标准版 插入 销售出库 库存查询 商品档案
|
|
|
- if(Constant.STD.equals(gradeCode)){
|
|
|
+ if (Constant.STD.equals(gradeCode)) {
|
|
|
List<String> objectCodeList = new ArrayList<>();
|
|
|
// 销售出库
|
|
|
objectCodeList.add("order-out");
|
|
|
@@ -249,7 +271,7 @@ public class StaffService extends BaseService<Staff> {
|
|
|
List<SettingValue> settingValueList = new ArrayList<>();
|
|
|
// 自动办理
|
|
|
settingValueList.add(new SettingValue().setCpId(cpId).setSettingCode(Constant.SystemConstant.IVT_001.getValue())
|
|
|
- .setSettingValue("true"));
|
|
|
+ .setSettingValue("true"));
|
|
|
// 欠货销售
|
|
|
settingValueList.add(new SettingValue().setCpId(cpId).setSettingCode(Constant.SystemConstant.IVT_002.getValue())
|
|
|
.setSettingValue("true"));
|
|
|
@@ -259,7 +281,7 @@ public class StaffService extends BaseService<Staff> {
|
|
|
Map<String, Object> m = listRoles.get(i);
|
|
|
Role role = new Role();
|
|
|
//设置编码
|
|
|
- Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.ROLE.getName(),cpId, false);
|
|
|
+ Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.ROLE.getName(), cpId, false);
|
|
|
if (Constant.ROLE_DATA.equals(m.get("roleCode").toString())) {
|
|
|
roleid = uniqueNoteCode.get("outId").toString();
|
|
|
}
|
|
|
@@ -350,19 +372,19 @@ public class StaffService extends BaseService<Staff> {
|
|
|
for (int i = 0; i < listGoodsCategorys.size(); i++) {
|
|
|
Map<String, Object> m = listGoodsCategorys.get(i);
|
|
|
GoodsCategory goodsCategory = new GoodsCategory();
|
|
|
- goodsCategory.setCatCode(m.get("catCode")+ "");
|
|
|
- goodsCategory.setCatName(m.get("catName")+ "");
|
|
|
- if (m.get("parentId")!=null){
|
|
|
- goodsCategory.setParentId(m.get("parentId")+ "");
|
|
|
+ goodsCategory.setCatCode(m.get("catCode") + "");
|
|
|
+ goodsCategory.setCatName(m.get("catName") + "");
|
|
|
+ if (m.get("parentId") != null) {
|
|
|
+ goodsCategory.setParentId(m.get("parentId") + "");
|
|
|
}
|
|
|
- if (m.get("topId")!=null){
|
|
|
- goodsCategory.setTopId(m.get("topId")+ "");
|
|
|
+ if (m.get("topId") != null) {
|
|
|
+ goodsCategory.setTopId(m.get("topId") + "");
|
|
|
}
|
|
|
- if (m.get("levelUpper")!=null){
|
|
|
- goodsCategory.setLevelUpper(m.get("levelUpper")+ "");
|
|
|
+ if (m.get("levelUpper") != null) {
|
|
|
+ goodsCategory.setLevelUpper(m.get("levelUpper") + "");
|
|
|
}
|
|
|
- if (m.get("levelLower")!=null){
|
|
|
- goodsCategory.setLevelLower(m.get("levelLower")+ "");
|
|
|
+ if (m.get("levelLower") != null) {
|
|
|
+ goodsCategory.setLevelLower(m.get("levelLower") + "");
|
|
|
}
|
|
|
goodsCategory.setLevelLeaf((Boolean) m.get("levelLeaf"));
|
|
|
goodsCategory.setLevelNo((Integer) m.get("levelNo"));
|
|
|
@@ -384,7 +406,7 @@ public class StaffService extends BaseService<Staff> {
|
|
|
printLayout.setLayoutName(m.get("layoutName") + "");
|
|
|
printLayout.setLayoutData(JSONObject.parseObject(JSONObject.toJSONString(m.get("layoutData"))));
|
|
|
printLayout.setDisplayNo((Integer) m.get("displayNo"));
|
|
|
- printLayout.setDocName(m.get("docName")+ "" );
|
|
|
+ printLayout.setDocName(m.get("docName") + "");
|
|
|
printLayout.setCpId(cpId);
|
|
|
printLayout.setOpCreateUserId(m.get("opCreateUserId").toString());
|
|
|
listP.add(printLayout);
|
|
|
@@ -441,7 +463,59 @@ public class StaffService extends BaseService<Staff> {
|
|
|
public ResponseResultVO<Boolean> update(StaffVO staffVO) {
|
|
|
// 转化实体
|
|
|
Staff staff = staffConvert.convertToPo(staffVO);
|
|
|
- return super.updateByUuid(staff);
|
|
|
+ // 查询原来的getFlgCanLogin
|
|
|
+ StaffResponse staffResponseOld = staffMapper.selectById(staffVO.getStaffId());
|
|
|
+
|
|
|
+ super.updateByUuid(staff);
|
|
|
+ // 获取当前公司的cpId
|
|
|
+ Integer cpId = authUtils.getStaff().getCpId();
|
|
|
+ //可以绑定微信的员工人数 人数上限
|
|
|
+ if (staffVO.getFlgCanLogin()) {
|
|
|
+ ResponseResultVO<?> resultMaxnum = companyFeign.getCompanyMaxStaffNum(cpId);
|
|
|
+ if (resultMaxnum.getCode() != ResponseCodeEnum.SUCCESS.getCode()) {
|
|
|
+ // 无用户
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseResultUtil.success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -549,11 +623,11 @@ public class StaffService extends BaseService<Staff> {
|
|
|
StaffResponse staff = staffMapper.selectByUserId(param.get("userId").toString(), Integer.parseInt(param.get("cpId").toString()));
|
|
|
if (staff != null) {
|
|
|
// 提示不允许登录
|
|
|
- if(staff.getFlgCanLogin() == null || !staff.getFlgCanLogin()){
|
|
|
+ if (staff.getFlgCanLogin() == null || !staff.getFlgCanLogin()) {
|
|
|
return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.STAFF_CAN_NOT_LOGIN.getMessage());
|
|
|
}
|
|
|
// 离职状态不允许登录
|
|
|
- if(staff.getHrStatus() != 1){
|
|
|
+ if (staff.getHrStatus() != 1) {
|
|
|
return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.STAFF_OUT_NOT_LOGIN.getMessage());
|
|
|
}
|
|
|
// 存Redis
|
|
|
@@ -595,7 +669,7 @@ public class StaffService extends BaseService<Staff> {
|
|
|
)
|
|
|
public ResponseResultVO<Boolean> logout(Map<String, Object> param) {
|
|
|
// 更新员工登录状态
|
|
|
- this.updateByUuid(new Staff().setStaffId(param.get("staffId").toString()).setFlgCanLogin(false));
|
|
|
+// this.updateByUuid(new Staff().setStaffId(param.get("staffId").toString()).setFlgCanLogin(false));
|
|
|
return ResponseResultUtil.success(true);
|
|
|
}
|
|
|
}
|