Commit c141bb79 by huangZW

111

parent b46091e8
......@@ -17,4 +17,5 @@ public interface StaffService {
TabHaobanStaff selectByUserId(String userId);
void updateByPrimaryKey(TabHaobanStaff tab);
}
......@@ -53,7 +53,7 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
@Override
public void del(StaffDepartmentRelatedDTO related) {
TabHaobanStaffDepartmentRelated tab = EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, related);
tab.setStatusFlag(1);
tab.setStatusFlag(0);
tab.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(tab);
......
......@@ -51,4 +51,9 @@ public class StaffServiceImpl implements StaffService {
return mapper.selectByUserId(userId);
}
@Override
public void updateByPrimaryKey(TabHaobanStaff tab) {
mapper.updateByPrimaryKey(tab);
}
}
package com.gic.haoban.manage.service.service.out.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
......@@ -13,13 +15,16 @@ import cn.hutool.core.collection.CollectionUtil;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.StringUtil;
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.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.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
......@@ -36,6 +41,8 @@ public class StaffApiServiceImpl implements StaffApiService {
StaffMapper staffMapper;
@Autowired
StaffDepartmentRelatedService staffDepartmentRelatedService;
@Autowired
private StaffDepartmentRelatedMapper staffDepartmentRelatedMapper;
@Override
public StaffDTO selectById(String staffId) {
......@@ -144,8 +151,52 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public void staffEdit(StaffDTO staffDTO, String departmentIds) {
// TODO Auto-generated method stub
//1、先更新staff
TabHaobanStaff tab = EntityUtil.changeEntityByJSON(TabHaobanStaff.class, staffDTO);
staffService.updateByPrimaryKey(tab);
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listStaffDepartmentByStaffId(staffDTO.getStaffId());
Map<String,TabHaobanStaffDepartmentRelated> map = com.gic.commons.util.CollectionUtil.toMap(list, "departmentId");
//2、该员工新增部门
if(StringUtils.isNotBlank(departmentIds)){
String [] addIds = departmentIds.split(",");
for(String addId : addIds){
if(!map.containsKey(addId)){
//该员工新增了部门
StaffDepartmentRelatedDTO related = new StaffDepartmentRelatedDTO();
related.setStaffDepartmentRelatedId(UuidUtil.randomUUID());
related.setStaffId(staffDTO.getStaffId());
related.setClerkCode(null);
related.setCreateTime(new Date());
related.setDepartmentId(addId);
related.setNationCode(staffDTO.getNationCode());
related.setPhoneNumber(staffDTO.getPhoneNumber());
related.setStatusFlag(1);
related.setUpdateTime(new Date());
related.setWxUserId(staffDTO.getWxUserId());
staffDepartmentRelatedService.add(related);
}else{
//该员工部门没做改变(只更新手机号即可)
TabHaobanStaffDepartmentRelated related = map.get(addId);
related.setPhoneNumber(staffDTO.getPhoneNumber());
related.setNationCode(staffDTO.getNationCode());
related.setUpdateTime(new Date());
staffDepartmentRelatedMapper.updateByPrimaryKeySelective(related);
}
}
}
//3、该员工删除部门
for(TabHaobanStaffDepartmentRelated tab1 : list){
if(departmentIds == null){
departmentIds = "";
}
//不包含,则说明员工删除了该部门
if(!departmentIds.contains(tab1.getDepartmentId())){
StaffDepartmentRelatedDTO related = EntityUtil.changeEntityByJSON(StaffDepartmentRelatedDTO.class, tab1);
staffDepartmentRelatedService.del(related);
}
}
}
}
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