Commit 2489727d by qwmqiuwenmin

fix

parent 10f47373
......@@ -13,21 +13,31 @@ import org.springframework.stereotype.Service;
import cn.hutool.core.collection.CollectionUtil;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
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.StaffMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxApplicationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.pagehelper.PageHelper;
@Service
......@@ -42,6 +52,15 @@ public class StaffApiServiceImpl implements StaffApiService {
@Autowired
private StaffDepartmentRelatedMapper staffDepartmentRelatedMapper;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private WxApplicationService wxApplicationService;
@Autowired
private DepartmentService departmentService;
@Override
public StaffDTO selectById(String staffId) {
TabHaobanStaff staff = staffService.selectById(staffId);
......@@ -63,6 +82,38 @@ public class StaffApiServiceImpl implements StaffApiService {
String staffId = staffService.add(tab);
//调接口获取
String wxUserId = "";
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(staff.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(staff.getWxEnterpriseId(),1);
if(enterpriseDTO != null) {
if(application != null) {
UserDTO userDTO = new UserDTO();
userDTO.setCorpid(enterpriseDTO.getCorpid());
List<Integer> wxDepartmentIdArrIntegers = new ArrayList<Integer>();
String[] departmentIdArr = departmentIds.split(",");
for (String string : departmentIdArr) {
TabHaobanDepartment tabs = departmentService.selectById(string);
wxDepartmentIdArrIntegers.add(Integer.parseInt(tabs.getWxDepartmentId()));
}
userDTO.setDepartment((Integer[]) wxDepartmentIdArrIntegers.toArray());
userDTO.setGender("女");
userDTO.setMobile(staff.getPhoneNumber());
userDTO.setName(staff.getStaffName());
userDTO.setUserid(staffId);
if(activeFlag == 1) {
userDTO.setTo_invite(true);
}
JSONResponse jp = qywxUserApiService.createWorkWxUser(userDTO, enterpriseDTO.getCorpid(), application.getSiteId());
if(jp.getErrorCode() != 1) {
hr.setErrorCode(0);
hr.setDetailError("微信新增失败");
return hr;
}
wxUserId = jp.getResult().toString();
}
}
if(StringUtils.isNotBlank(wxUserId)){
String[] departmentIdArr = departmentIds.split(",");
for (String string : departmentIdArr) {
......
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