Commit fbafa87d authored by daijunxiong's avatar daijunxiong

修改定时任务人员储存为空

parent e8957d26
...@@ -15,6 +15,7 @@ import com.mortals.xhx.module.dept.model.DeptEntity; ...@@ -15,6 +15,7 @@ import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.staff.dao.ibatis.StaffDaoImpl; import com.mortals.xhx.module.staff.dao.ibatis.StaffDaoImpl;
import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -39,6 +40,9 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -39,6 +40,9 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private DeptService deptService; private DeptService deptService;
@Autowired
private StaffService service;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("同步用户--部门"); log.info("同步用户--部门");
...@@ -52,22 +56,22 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -52,22 +56,22 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
//查询数据库信息 //查询数据库信息
DeptEntity deptEntity = deptDao.queryDept(listDept.getOrgIndexCode()); DeptEntity deptEntity = deptDao.queryDept(listDept.getOrgIndexCode());
DeptEntity deptEntityParent = deptDao.queryDeptParient(listDept.getParentOrgIndexCode()); DeptEntity deptEntityParent = deptDao.queryDeptParient(listDept.getParentOrgIndexCode());
DeptEntity deptEntity1 = new DeptEntity();
if (Objects.isNull(deptEntity)) { if (Objects.isNull(deptEntity)) {
if (Objects.nonNull(deptEntityParent)) { if (Objects.nonNull(deptEntityParent)) {
deptEntity1.setParentId(deptEntityParent.getId()); deptEntity.setParentId(deptEntityParent.getId());
} }
deptEntity1.setDeptName(listDept.getOrgName()); deptEntity.setDeptName(listDept.getOrgName());
deptEntity1.setDeptCode(listDept.getOrgIndexCode()); deptEntity.setDeptCode(listDept.getOrgIndexCode());
deptEntity1.setAncestors(listDept.getOrgPath()); deptEntity.setAncestors(listDept.getOrgPath());
deptEntity1.setDeptStatus(1); deptEntity.setDeptStatus(1);
deptEntity1.setOrderNum(0); deptEntity.setOrderNum(0);
deptEntity1.setRemark(listDept.getParentOrgIndexCode()); deptEntity.setRemark(listDept.getParentOrgIndexCode());
deptEntity1.setCreateTime(new Date()); deptEntity.setCreateTime(new Date());
deptEntity1.setCreateUserId(Long.valueOf(1)); deptEntity.setCreateUserId(Long.valueOf(1));
deptEntity1.setUpdateTime(new Date()); deptEntity.setUpdateTime(new Date());
deptEntity1.setUpdateUserId(Long.valueOf(1)); deptEntity.setUpdateUserId(Long.valueOf(1));
deptService.save(deptEntity1); deptService.save(deptEntity);
} else { } else {
if (Objects.nonNull(deptEntityParent)) { if (Objects.nonNull(deptEntityParent)) {
deptEntity.setParentId(deptEntityParent.getId()); deptEntity.setParentId(deptEntityParent.getId());
...@@ -94,27 +98,27 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -94,27 +98,27 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
//判断本地数据是否为空 //判断本地数据是否为空
if (Objects.isNull(staffEntity1)) { if (Objects.isNull(staffEntity1)) {
//如果为空则将数据存入数据库 //如果为空则将数据存入数据库
StaffEntity staffEntity = new StaffEntity(); staffEntity1.initAttrValue();
if (Objects.nonNull(deptEntity)) { if (Objects.nonNull(staffEntity1)) {
staffEntity.setDeptId(deptEntity.getId()); staffEntity1.setDeptId(deptEntity.getId());
} }
staffEntity.setName(list.getPersonName()); staffEntity1.setName(list.getPersonName());
staffEntity.setRemarkId(list.getPersonId()); staffEntity1.setRemarkId(list.getPersonId());
staffEntity.setPhotoPath(list.getPersonPhoto().getPicUri()); staffEntity1.setPhotoPath(list.getPersonPhoto().getPicUri());
staffEntity.setDeptName(list.getOrgName()); staffEntity1.setDeptName(list.getOrgName());
staffEntity.setSource(1); staffEntity1.setSource(1);
staffEntity.setStatus(1); staffEntity1.setStatus(1);
staffEntity.setGender(list.getGender()); staffEntity1.setGender(list.getGender());
staffEntity.setWorkNum(list.getJobNo()); staffEntity1.setWorkNum(list.getJobNo());
staffEntity.setCreateUserId(Long.valueOf(1)); staffEntity1.setCreateUserId(Long.valueOf(1));
staffEntity.setCreateTime(new Date()); staffEntity1.setCreateTime(new Date());
if (list.getBirthday() != null) { if (list.getBirthday() != null) {
staffEntity.setBirthday((Date) list.getBirthday()); staffEntity1.setBirthday((Date) list.getBirthday());
} }
if (list.getPhoneNo() != null) { if (list.getPhoneNo() != null) {
staffEntity.setPhoneNumber(String.valueOf(list.getPhoneNo())); staffEntity1.setPhoneNumber(String.valueOf(list.getPhoneNo()));
} }
staffDao.insert(staffEntity); service.save(staffEntity1);
DeptEntity deptEntity1 = deptService.get(staffEntity1.getDeptId()); DeptEntity deptEntity1 = deptService.get(staffEntity1.getDeptId());
String ancestor = deptEntity1.getAncestors().split(",", 2)[1]; String ancestor = deptEntity1.getAncestors().split(",", 2)[1];
String[] ancestors = ancestor.split(","); String[] ancestors = ancestor.split(",");
...@@ -135,6 +139,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -135,6 +139,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
//本地数据不为空 //本地数据不为空
else { else {
//执行修改 //执行修改
staffEntity1.initAttrValue();
if (Objects.nonNull(deptEntity)) { if (Objects.nonNull(deptEntity)) {
staffEntity1.setDeptId(deptEntity.getId()); staffEntity1.setDeptId(deptEntity.getId());
} }
...@@ -142,8 +147,6 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -142,8 +147,6 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
staffEntity1.setRemarkId(list.getPersonId()); staffEntity1.setRemarkId(list.getPersonId());
staffEntity1.setPhotoPath(list.getPersonPhoto().getPicUri()); staffEntity1.setPhotoPath(list.getPersonPhoto().getPicUri());
staffEntity1.setDeptName(list.getOrgName()); staffEntity1.setDeptName(list.getOrgName());
staffEntity1.setSource(1);
staffEntity1.setStatus(1);
staffEntity1.setGender(list.getGender()); staffEntity1.setGender(list.getGender());
staffEntity1.setWorkNum(list.getJobNo()); staffEntity1.setWorkNum(list.getJobNo());
staffEntity1.setCreateUserId(Long.valueOf(1)); staffEntity1.setCreateUserId(Long.valueOf(1));
...@@ -154,7 +157,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService { ...@@ -154,7 +157,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
if (list.getPhoneNo() != null) { if (list.getPhoneNo() != null) {
staffEntity1.setPhoneNumber(String.valueOf(list.getPhoneNo())); staffEntity1.setPhoneNumber(String.valueOf(list.getPhoneNo()));
} }
staffDao.update(staffEntity1); service.update(staffEntity1);
DeptEntity deptEntity1 = deptService.get(staffEntity1.getDeptId()); DeptEntity deptEntity1 = deptService.get(staffEntity1.getDeptId());
String ancestor = deptEntity1.getAncestors().split(",", 2)[1]; String ancestor = deptEntity1.getAncestors().split(",", 2)[1];
String[] ancestors = ancestor.split(","); String[] ancestors = ancestor.split(",");
......
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