Commit 470071d2 by qwmqiuwenmin

fix

parent bb11f8ce
...@@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkListDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.GicTreeDTO; import com.gic.enterprise.api.dto.GicTreeDTO;
import com.gic.enterprise.api.dto.StoreDTO; import com.gic.enterprise.api.dto.StoreDTO;
...@@ -31,8 +33,11 @@ import com.gic.haoban.manage.web.auth.AuthRequestUtil; ...@@ -31,8 +33,11 @@ import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.common.utils.EntityUtil; import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse; import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO; 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.service.DepartmentApiService; 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.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.DepartmentAddQO; import com.gic.haoban.manage.web.qo.DepartmentAddQO;
import com.gic.haoban.manage.web.qo.DepartmentEditQO; import com.gic.haoban.manage.web.qo.DepartmentEditQO;
...@@ -58,6 +63,11 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -58,6 +63,11 @@ public class DepartmentContoller extends WebBaseController{
@Autowired @Autowired
private EnterpriseService enterpriseService; private EnterpriseService enterpriseService;
@Autowired
private ClerkService clerkService;
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@RequestMapping("department-list") @RequestMapping("department-list")
public HaobanResponse departmentList(String parentId,BasePageInfo pageInfo,String keyWord) { public HaobanResponse departmentList(String parentId,BasePageInfo pageInfo,String keyWord) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser(); LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
...@@ -270,6 +280,9 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -270,6 +280,9 @@ public class DepartmentContoller extends WebBaseController{
String sonDepartment = departmentAddQO.getChildren(); String sonDepartment = departmentAddQO.getChildren();
handler(sonDepartment,departmentId); handler(sonDepartment,departmentId);
if(isStore == 1){
handerStoreClerk(departmentId, departmentAddQO.getRelatedId());
}
} }
} }
logger.info("【部门修改】editDepartment={}",editDepartment); logger.info("【部门修改】editDepartment={}",editDepartment);
...@@ -459,6 +472,10 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -459,6 +472,10 @@ public class DepartmentContoller extends WebBaseController{
continue; continue;
} }
DepartmentDTO departmentAdd = (DepartmentDTO) hr.getResult(); DepartmentDTO departmentAdd = (DepartmentDTO) hr.getResult();
if(isStore == 1){
String storeId = departmentAdd.getRelatedId();
handerStoreClerk(departmentAdd.getDepartmentId(),storeId);
}
sonParentId = departmentAdd.getDepartmentId(); sonParentId = departmentAdd.getDepartmentId();
//别的部门调整过来的 //别的部门调整过来的
}else { }else {
...@@ -487,5 +504,54 @@ public class DepartmentContoller extends WebBaseController{ ...@@ -487,5 +504,54 @@ public class DepartmentContoller extends WebBaseController{
} }
} }
private void handerStoreClerk(String departmentId, String storeId) {
StoreDTO store = storeService.getStore(storeId);
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
if(departmentDTO == null){
return;
}
String wxEnterpriseId = departmentDTO.getWxEnterpriseId();
if(store != null){
List<ClerkListDTO> list = clerkService.getClerkByStoreId(store.getEnterpriseId(), storeId);
for (ClerkListDTO clerkListDTO : list) {
String nationcode = clerkListDTO.getNationcode();
String phoneNumber = clerkListDTO.getPhoneNumber();
String clerkCode = clerkListDTO.getClerkCode();
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
if(staff == null){
staff = new StaffDTO();
staff.setNationCode(nationcode);
staff.setActiveFlag(1);
staff.setDepartmentIds(departmentId);
staff.setBindFlag(1);
staff.setClerkCode(clerkCode);
staff.setNickName(clerkListDTO.getClerkName());
staff.setStaffName(clerkListDTO.getClerkName());
staff.setPostion(clerkListDTO.getPositionName());
staff.setSyncPostionFlag(1);
staffApiService.add(staff, departmentId);
}else{
String staffId = staff.getStaffId();
List<StaffDepartmentRelatedDTO> relatedList = staffApiService.listStaffDepartmentByStaffId(staffId);
String departmentIds = departmentId;
for (StaffDepartmentRelatedDTO staffDepartmentRelatedDTO : relatedList) {
departmentIds += "," + staffDepartmentRelatedDTO.getDepartmentId();
}
Map<String,StaffDepartmentRelatedDTO> map = com.gic.commons.util.CollectionUtil.toMap(relatedList, "departmentId");
if(map.get(departmentId) == null){
staffApiService.staffEdit(staff, departmentIds);
}
StaffDepartmentRelatedDTO staffRelated = staffApiService.getDepartmentIdAndStaffId(departmentId, staffId);
//如果这个人是未绑定的 则绑定clerk
if(StringUtils.isBlank(staffRelated.getClerkCode())){
staffRelated.setClerkCode(clerkCode);
staffDepartmentRelatedApiService.updateById(staffRelated);
}
}
}
}
}
} }
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