Commit e8957d26 authored by daijunxiong's avatar daijunxiong

修改定时任务 修改人员统计 删除其他无用方法

parent 6aa5c7c8
......@@ -12,6 +12,7 @@ import com.mortals.xhx.busiz.rsp.ListItem;
import com.mortals.xhx.busiz.rsp.PersonHikData;
import com.mortals.xhx.module.dept.dao.ibatis.DeptDaoImpl;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.staff.dao.ibatis.StaffDaoImpl;
import com.mortals.xhx.module.staff.model.StaffEntity;
import lombok.extern.slf4j.Slf4j;
......@@ -35,10 +36,52 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private DeptDaoImpl deptDao;
@Autowired
private DeptService deptService;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("同步用户--部门");
try {
String resultDept = ArtemisPostTest.callPostApiGetDeptList();
JSONObject jsonObjectDept = JSON.parseObject(resultDept);
JSONObject jsonObjectDept1 = jsonObjectDept.getJSONObject("data");
DeptHikData deptHikData = JSONObject.parseObject(jsonObjectDept1.toJSONString(), DeptHikData.class);
if (Objects.nonNull(deptHikData)) {
for (ListDept listDept : deptHikData.getList()) {
//查询数据库信息
DeptEntity deptEntity = deptDao.queryDept(listDept.getOrgIndexCode());
DeptEntity deptEntityParent = deptDao.queryDeptParient(listDept.getParentOrgIndexCode());
DeptEntity deptEntity1 = new DeptEntity();
if (Objects.isNull(deptEntity)) {
if (Objects.nonNull(deptEntityParent)) {
deptEntity1.setParentId(deptEntityParent.getId());
}
deptEntity1.setDeptName(listDept.getOrgName());
deptEntity1.setDeptCode(listDept.getOrgIndexCode());
deptEntity1.setAncestors(listDept.getOrgPath());
deptEntity1.setDeptStatus(1);
deptEntity1.setOrderNum(0);
deptEntity1.setRemark(listDept.getParentOrgIndexCode());
deptEntity1.setCreateTime(new Date());
deptEntity1.setCreateUserId(Long.valueOf(1));
deptEntity1.setUpdateTime(new Date());
deptEntity1.setUpdateUserId(Long.valueOf(1));
deptService.save(deptEntity1);
} else {
if (Objects.nonNull(deptEntityParent)) {
deptEntity.setParentId(deptEntityParent.getId());
}
deptEntity.setDeptName(listDept.getOrgName());
deptEntity.setDeptCode(listDept.getOrgIndexCode());
deptEntity.setAncestors(listDept.getOrgPath());
deptEntity.setCreateTime(new Date());
deptEntity.setCreateUserId(Long.valueOf(1));
deptService.update(deptEntity);
}
}
}
//同步员工
String resultPerson = ArtemisPostTest.callPostApiGetPersonList();
JSONObject jsonObject = JSON.parseObject(resultPerson);
JSONObject jsonObject1 = jsonObject.getJSONObject("data");
......@@ -72,6 +115,22 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
staffEntity.setPhoneNumber(String.valueOf(list.getPhoneNo()));
}
staffDao.insert(staffEntity);
DeptEntity deptEntity1 = deptService.get(staffEntity1.getDeptId());
String ancestor = deptEntity1.getAncestors().split(",", 2)[1];
String[] ancestors = ancestor.split(",");
for (String newAncestor : ancestors) {
DeptEntity deptEntity2 = deptService.get(Long.valueOf(newAncestor));
if (Objects.nonNull(deptEntity2)) {
int personNumcount = staffDao.queryPersonNum(staffEntity1.getDeptId());
if (Objects.nonNull(personNumcount) && Objects.nonNull(deptEntity2)) {
deptEntity2.setPersonNum(personNumcount);
deptService.update(deptEntity2);
}
}
}
}
//本地数据不为空
else {
......@@ -96,59 +155,30 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
staffEntity1.setPhoneNumber(String.valueOf(list.getPhoneNo()));
}
staffDao.update(staffEntity1);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
DeptEntity deptEntity1 = deptService.get(staffEntity1.getDeptId());
String ancestor = deptEntity1.getAncestors().split(",", 2)[1];
String[] ancestors = ancestor.split(",");
for (String newAncestor : ancestors) {
DeptEntity deptEntity2 = deptService.get(Long.valueOf(newAncestor));
if (Objects.nonNull(deptEntity2)) {
int personNumcount = staffDao.queryPersonNum(staffEntity1.getDeptId());
if (Objects.nonNull(personNumcount) && Objects.nonNull(deptEntity2)) {
deptEntity2.setPersonNum(personNumcount);
deptService.update(deptEntity2);
}
}
try {
String resultDept = ArtemisPostTest.callPostApiGetDeptList();
JSONObject jsonObjectDept = JSON.parseObject(resultDept);
JSONObject jsonObjectDept1 = jsonObjectDept.getJSONObject("data");
DeptHikData deptHikData = JSONObject.parseObject(jsonObjectDept1.toJSONString(), DeptHikData.class);
System.out.println(resultDept);
if (Objects.nonNull(deptHikData)) {
for (ListDept listDept : deptHikData.getList()) {
//查询数据库信息
DeptEntity deptEntity = deptDao.queryDept(listDept.getOrgIndexCode());
DeptEntity deptEntityParent = deptDao.queryDeptParient(listDept.getParentOrgIndexCode());
DeptEntity deptEntity1 = new DeptEntity();
if (Objects.isNull(deptEntity)) {
if (Objects.nonNull(deptEntityParent)) {
deptEntity1.setParentId(deptEntityParent.getId());
}
deptEntity1.setDeptName(listDept.getOrgName());
deptEntity1.setDeptCode(listDept.getOrgIndexCode());
deptEntity1.setAncestors(listDept.getOrgPath());
deptEntity1.setDeptStatus(1);
deptEntity1.setOrderNum(0);
deptEntity1.setRemark(listDept.getParentOrgIndexCode());
deptEntity1.setCreateTime(new Date());
deptEntity1.setCreateUserId(Long.valueOf(1));
System.out.println(deptEntity1);
deptDao.insert(deptEntity1);
} else {
if (Objects.nonNull(deptEntityParent)) {
deptEntity.setParentId(deptEntityParent.getId());
}
deptEntity.setDeptName(listDept.getOrgName());
deptEntity.setDeptCode(listDept.getOrgIndexCode());
deptEntity.setAncestors(listDept.getOrgPath());
deptEntity.setCreateTime(new Date());
deptEntity.setCreateUserId(Long.valueOf(1));
deptDao.update(deptEntity);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
......
......@@ -49,13 +49,7 @@ public interface DeptService extends ICRUDService<DeptEntity,Long>{
*/
List<DeptTreeSelect> getListByParentId(Long parentId,Context context);
/**
* 查询部门人数
* */
DeptEntity queryDept(String deptCode);
DeptEntity queryParent(String parentCode);
int queryParentId(Long deptId);
......
......@@ -191,15 +191,7 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
return collect;
}
@Override
public DeptEntity queryDept(String deptCode) {
return dao.queryDept(deptCode);
}
@Override
public DeptEntity queryParent(String parentCode) {
return dao.queryDeptParient(parentCode);
}
@Override
public int queryParentId(Long deptId) {
......
......@@ -4,7 +4,6 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.job.model.JobQuery;
import com.mortals.xhx.module.job.service.JobService;
......@@ -102,23 +101,4 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ
}
@Override
protected int saveAfter(StaffEntity entity, Map<String, Object> model, Context context) throws AppException {
//统计当前部门
DeptEntity deptEntity = deptService.get(entity.getDeptId());
int personNumcount = service.queryDeptNum(entity.getDeptId());
deptEntity.setPersonNum(personNumcount);
deptService.update(deptEntity);
//统计上级部门
int personNumId = deptService.queryParentId(entity.getDeptId());
if (personNumId!=0){
DeptEntity deptEntity1 = deptService.get(entity.getDeptId());
int personParentNumcount = service.queryDeptNum(deptEntity1.getParentId());
deptEntity1.setPersonNum(personParentNumcount);
deptService.update(deptEntity1);
}
return super.saveAfter(entity, model, context);
}
}
\ No newline at end of file
......@@ -13,18 +13,18 @@ client.global.set("SmsSet_id", JSON.parse(response.body).data.id);
client.global.set("authToken", JSON.parse(response.body).data.token);
%}
###职位信息列表
###部门信息列表
POST {{baseUrl}}/dept/list
Authorization: {{authToken}}
Content-Type: application/json
{
"page":1,
"size":10
"size":30
}
###职位信息更新与保存
###部门信息更新与保存
POST {{baseUrl}}/dept/save
Authorization: {{authToken}}
Content-Type: application/json
......@@ -41,18 +41,18 @@ Content-Type: application/json
client.global.set("Dept_id", JSON.parse(response.body).data.id);
%}
###职位信息查看
###部门信息查看
GET {{baseUrl}}/dept/info?id=1
Authorization: {{authToken}}
Accept: application/json
###职位信息编辑
###部门信息编辑
GET {{baseUrl}}/dept/edit?id={{Job_id}}
Authorization: {{authToken}}
Accept: application/json
###职位信息删除
###部门信息删除
GET {{baseUrl}}/dept/delete?id={{Job_id}}
Authorization: {{authToken}}
Accept: application/json
......
......@@ -19,9 +19,6 @@ Authorization: {{authToken}}
Content-Type: application/json
{
"groupName":"7knq8z",
"jobCode":"mmnj82",
"jobName":"z8f2k5",
"page":1,
"size":10
}
......
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