Commit 96ea0b5c by xugaojun

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

parents a0f5ba72 074dc1c6
...@@ -22,7 +22,6 @@ import com.gic.haoban.common.utils.StringUtil; ...@@ -22,7 +22,6 @@ import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.common.utils.UuidUtil; import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.*; import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.SecretTypeEnum; import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper; import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper; import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
...@@ -62,17 +61,12 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -62,17 +61,12 @@ public class StaffApiServiceImpl implements StaffApiService {
private StaffDepartmentRelatedService staffDepartmentRelatedService; private StaffDepartmentRelatedService staffDepartmentRelatedService;
@Autowired @Autowired
private StaffDepartmentRelatedMapper staffDepartmentRelatedMapper; private StaffDepartmentRelatedMapper staffDepartmentRelatedMapper;
@Autowired @Autowired
private QywxUserApiService qywxUserApiService; private QywxUserApiService qywxUserApiService;
@Autowired @Autowired
private WxEnterpriseService wxEnterpriseService; private WxEnterpriseService wxEnterpriseService;
@Autowired @Autowired
private DepartmentService departmentService; private DepartmentService departmentService;
@Autowired
private DepartmentApiService departmentApiService;
@Autowired @Autowired
private ClerkService clerkService; private ClerkService clerkService;
@Autowired @Autowired
...@@ -588,14 +582,16 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -588,14 +582,16 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
private void staffEditDeal(StaffDTO staffDTO, String departmentIds) { private void staffEditDeal(StaffDTO staffDTO, String departmentIds) {
TabHaobanStaff oldStaff = staffMapper.selectByPrimaryKey(staffDTO.getStaffId()); String staffId = staffDTO.getStaffId();
TabHaobanStaff oldStaff = staffService.selectById(staffId);
logger.info("【员工修改】oldStaff={}", JSON.toJSONString(oldStaff)); logger.info("【员工修改】oldStaff={}", JSON.toJSONString(oldStaff));
//1、先更新staff //1、先更新staff
logger.info("【员工修改】staffDTO={}", JSON.toJSONString(staffDTO)); logger.info("【员工修改】staffDTO={}", JSON.toJSONString(staffDTO));
TabHaobanStaff tab = EntityUtil.changeEntityByJSON(TabHaobanStaff.class, staffDTO); staffService.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaff.class, staffDTO));
staffService.updateByPrimaryKey(tab); //再去查一下
String staffName = tab.getStaffName(); TabHaobanStaff staff = staffService.selectById(staffId);
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listStaffDepartmentByStaffId(staffDTO.getStaffId()); String staffName = staff.getStaffName();
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listStaffDepartmentByStaffId(staffId);
Map<String, TabHaobanStaffDepartmentRelated> map = com.gic.commons.util.CollectionUtil.toMap(list, "departmentId"); Map<String, TabHaobanStaffDepartmentRelated> map = com.gic.commons.util.CollectionUtil.toMap(list, "departmentId");
//2、该员工新增部门 //2、该员工新增部门
if (StringUtils.isNotBlank(departmentIds)) { if (StringUtils.isNotBlank(departmentIds)) {
...@@ -605,80 +601,42 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -605,80 +601,42 @@ public class StaffApiServiceImpl implements StaffApiService {
//该员工新增了部门 //该员工新增了部门
StaffDepartmentRelatedDTO related = new StaffDepartmentRelatedDTO(); StaffDepartmentRelatedDTO related = new StaffDepartmentRelatedDTO();
related.setStaffDepartmentRelatedId(UuidUtil.randomUUID()); related.setStaffDepartmentRelatedId(UuidUtil.randomUUID());
related.setStaffId(staffDTO.getStaffId()); related.setStaffId(staffId);
related.setClerkCode(null); related.setClerkCode(null);
related.setCreateTime(new Date());
related.setDepartmentId(addId); related.setDepartmentId(addId);
related.setNationCode(staffDTO.getNationCode()); related.setNationCode(staff.getNationCode());
related.setPhoneNumber(staffDTO.getPhoneNumber()); related.setPhoneNumber(staff.getPhoneNumber());
related.setStatusFlag(1); related.setStatusFlag(1);
related.setUpdateTime(new Date()); related.setWxUserId(staff.getWxUserId());
related.setWxUserId(oldStaff.getWxUserId()); related.setWxEnterpriseId(staff.getWxEnterpriseId());
related.setWxEnterpriseId(staffDTO.getWxEnterpriseId());
related.setStaffName(staffName); related.setStaffName(staffName);
staffDepartmentRelatedService.add(related); staffDepartmentRelatedService.add(related);
} else { } else {
//该员工部门没做改变(只更新手机号即可) //该员工部门没做改变(只更新手机号即可)
TabHaobanStaffDepartmentRelated related = map.get(addId); TabHaobanStaffDepartmentRelated related = map.get(addId);
if (!staffDTO.getPhoneNumber().equals(related.getPhoneNumber())) { if (!staff.getPhoneNumber().equals(related.getPhoneNumber())) {
related.setPhoneNumber(staffDTO.getPhoneNumber()); related.setPhoneNumber(staff.getPhoneNumber());
related.setNationCode(staffDTO.getNationCode()); related.setNationCode(staff.getNationCode());
related.setUpdateTime(new Date()); related.setUpdateTime(new Date());
related.setStaffName(staffName); related.setStaffName(staffName);
related.setWxEnterpriseId(staff.getWxEnterpriseId());
staffDepartmentRelatedMapper.updateByPrimaryKeySelective(related); staffDepartmentRelatedMapper.updateByPrimaryKeySelective(related);
} }
} }
} }
} }
//3、该员工删除部门 //3、该员工删除部门
for (TabHaobanStaffDepartmentRelated tab1 : list) { for (TabHaobanStaffDepartmentRelated staffDepartmentRelated : list) {
if (departmentIds == null) { if (departmentIds == null) {
departmentIds = ""; departmentIds = "";
} }
//不包含,则说明员工删除了该部门 //不包含,则说明员工删除了该部门
if (!departmentIds.contains(tab1.getDepartmentId())) { if (!departmentIds.contains(staffDepartmentRelated.getDepartmentId())) {
logger.info("【员工修改删除】tab1.getDepartmentId()={}", tab1.getDepartmentId()); logger.info("【员工修改删除】tab1.getDepartmentId()={}", staffDepartmentRelated.getDepartmentId());
StaffDepartmentRelatedDTO related = EntityUtil.changeEntityByJSON(StaffDepartmentRelatedDTO.class, tab1); StaffDepartmentRelatedDTO related = EntityUtil.changeEntityByJSON(StaffDepartmentRelatedDTO.class, staffDepartmentRelated);
staffDepartmentRelatedService.del(related); staffDepartmentRelatedService.del(related);
} }
} }
Boolean weixinPush = staffDTO.getWeixinPush();
if (weixinPush == null || !weixinPush) {
//不需要推送到企微
//updateWxMessage(oldStaff, staffDTO, departmentIds);
}
}
private void updateWxMessage(TabHaobanStaff oldStaff, StaffDTO staffDTO, String departmentIds) {
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(oldStaff.getWxEnterpriseId());
if (enterpriseDTO != null) {
UserDTO userDTO = new UserDTO();
userDTO.setCorpid(enterpriseDTO.getCorpid());
userDTO.setAlias(staffDTO.getNickName());
String[] departmentIdArr = departmentIds.split(",");
Integer[] wxDepartmentIdArrIntegers = new Integer[departmentIdArr.length];
int index = 0;
for (String string : departmentIdArr) {
TabHaobanDepartment tabs = departmentService.selectById(string);
wxDepartmentIdArrIntegers[index] = Integer.parseInt(tabs.getWxDepartmentId());
index++;
}
userDTO.setDepartment(wxDepartmentIdArrIntegers);
userDTO.setGender(staffDTO.getSex() == null ? "" : staffDTO.getSex().toString());
userDTO.setMobile(staffDTO.getPhoneNumber());
userDTO.setName(staffDTO.getStaffName());
userDTO.setUserid(oldStaff.getWxUserId());
userDTO.setPosition(staffDTO.getPostion());
userDTO.setExternal_position(staffDTO.getExtendPostion());
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.CONTACT_SECRET.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
throw new RuntimeException("没有设置通讯录secret");
}
JSONResponse jp = qywxUserApiService.updateSelfWorkWxUser(userDTO, enterpriseDTO.getCorpid(), secretSetting.getSecretVal());
if (jp.getErrorCode() != 0) {
throw new RuntimeException("微信新增失败");
}
}
} }
@Override @Override
......
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