Commit 90b9b9a8 authored by 赵啸非's avatar 赵啸非

Merge remote-tracking branch 'origin/master'

parents 65a9ec14 87e4507d
......@@ -19,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
......@@ -48,12 +47,14 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
for (ListItem list : personHikData.getList()) {
//根据id获取本地数据
StaffEntity staffEntity1 = staffDao.queryHik(list.getPersonId());
List<StaffEntity> staffEntities = staffDao.queryAllList();
DeptEntity deptEntity = deptDao.queryDept(list.getOrgIndexCode());
//判断本地数据是否为空
if (Objects.isNull(staffEntity1)) {
//如果为空则将数据存入数据库
StaffEntity staffEntity = new StaffEntity();
System.out.println(list.getPersonName());
if (Objects.nonNull(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId());
}
staffEntity.setName(list.getPersonName());
staffEntity.setRemarkId(list.getPersonId());
staffEntity.setPhotoPath(list.getPersonPhoto().getPicUri());
......@@ -74,83 +75,71 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
}
//本地数据不为空
else {
//本地数据遍历数据
for (StaffEntity staffEntity : staffEntities) {
//如果本地的id等于海康的id
if (staffEntity.getRemarkId().equals(list.getPersonId())) {
//执行修改
StaffEntity staffEntity2 = new StaffEntity();
System.out.println(list.getPersonName());
staffEntity2.setName(list.getPersonName());
staffEntity2.setRemarkId(list.getPersonId());
staffEntity2.setPhotoPath(list.getPersonPhoto().getPicUri());
staffEntity2.setDeptName(list.getOrgName());
staffEntity2.setSource(1);
staffEntity2.setStatus(1);
staffEntity2.setGender(list.getGender());
staffEntity2.setWorkNum(list.getJobNo());
staffEntity2.setCreateUserId(Long.valueOf(1));
staffEntity2.setCreateTime(new Date());
if (list.getBirthday() != null) {
staffEntity2.setBirthday((Date) list.getBirthday());
}
if (list.getPhoneNo() != null) {
staffEntity2.setPhoneNumber(String.valueOf(list.getPhoneNo()));
}
staffDao.update(staffEntity2);
}
for (ListItem item : personHikData.getList()) {
//如果本地id不等于海康id并且海康id不等于本地id
if (!item.getPersonId().equals(staffEntity.getRemarkId())) {
//否则执行删除
staffDao.delete(staffEntity.getId());
}
}
//执行修改
if (Objects.nonNull(deptEntity)) {
staffEntity1.setDeptId(deptEntity.getId());
}
staffEntity1.setName(list.getPersonName());
staffEntity1.setRemarkId(list.getPersonId());
staffEntity1.setPhotoPath(list.getPersonPhoto().getPicUri());
staffEntity1.setDeptName(list.getOrgName());
staffEntity1.setSource(1);
staffEntity1.setStatus(1);
staffEntity1.setGender(list.getGender());
staffEntity1.setWorkNum(list.getJobNo());
staffEntity1.setCreateUserId(Long.valueOf(1));
staffEntity1.setCreateTime(new Date());
if (list.getBirthday() != null) {
staffEntity1.setBirthday((Date) list.getBirthday());
}
if (list.getPhoneNo() != null) {
staffEntity1.setPhoneNumber(String.valueOf(list.getPhoneNo()));
}
staffDao.update(staffEntity1);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
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());
List<DeptEntity> deptEntities = deptDao.queryAllList();
DeptEntity deptEntityParent = deptDao.queryDeptParient(listDept.getParentOrgIndexCode());
DeptEntity deptEntity1 = new DeptEntity();
if (Objects.isNull(deptEntity)) {
DeptEntity deptEntity1 = new 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.setPersonNum(0);
deptEntity1.setRemark(listDept.getParentOrgIndexCode());
deptEntity1.setCreateTime(new Date());
deptEntity1.setCreateUserId(Long.valueOf(1));
System.out.println(deptEntity1);
deptDao.insert(deptEntity1);
} else {
for (DeptEntity deptEntity2 : deptEntities) {
if (!deptEntity2.getDeptCode().equals(listDept.getOrgIndexCode())) {
deptEntity2.setDeptName(listDept.getOrgName());
deptEntity2.setDeptCode(listDept.getOrgIndexCode());
deptEntity2.setAncestors(listDept.getOrgPath());
deptEntity2.setCreateTime(new Date());
deptEntity2.setCreateUserId(Long.valueOf(1));
deptDao.update(deptEntity2);
}
for (ListDept dept : deptHikData.getList()) {
if (!dept.getOrgIndexCode().equals(deptEntity2.getDeptCode())) {
deptDao.delete(deptEntity2.getId());
}
}
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);
}
}
}
......@@ -159,6 +148,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
e.printStackTrace();
}
}
......
......@@ -39,10 +39,11 @@ public class AttendanceVacationRecordController extends BaseCRUDJsonBodyMappingC
super.init(model, context);
}
@Override
protected void saveBefore(AttendanceVacationRecordEntity entity, Map<String, Object> model, Context context) throws AppException {
protected int saveAfter(AttendanceVacationRecordEntity entity, Map<String, Object> model, Context context) throws AppException {
AttendanceVacationBalanceEntity attendanceVacationBalanceEntity=attendanceVacationBalanceService.get(entity.getStaffId());
model.put("allHoliday",attendanceVacationBalanceEntity);
super.saveBefore(entity, model, context);
return super.saveAfter(entity, model, context);
}
}
\ No newline at end of file
......@@ -27,9 +27,17 @@ public interface DeptDao extends ICRUDDao<DeptEntity,Long>{
List<DeptEntity> queryAllList();
/**
* 统计部门人数
* 查询部门信息
* */
DeptEntity queryDept(String deptCode);
/**
* 查询是否作为上级本门
* */
DeptEntity queryDeptParient(String parentCode);
/**
*
* */
int queryDeptParentId(Long deptId);
}
......@@ -32,5 +32,15 @@ public class DeptDaoImpl extends BaseCRUDDaoMybatis<DeptEntity,Long> implements
return getSqlSession().selectOne(getSqlId("queryDept"),deptCode);
}
@Override
public DeptEntity queryDeptParient(String parentCode) {
return getSqlSession().selectOne(getSqlId("queryDeptParient"),parentCode);
}
@Override
public int queryDeptParentId(Long deptId) {
return getSqlSession().selectOne(getSqlId("queryDeptParentId"),deptId);
}
}
package com.mortals.xhx.module.dept.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptTreeSelect;
import java.util.List;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
/**
* DeptService
*
......@@ -48,4 +48,15 @@ public interface DeptService extends ICRUDService<DeptEntity,Long>{
* @return
*/
List<DeptTreeSelect> getListByParentId(Long parentId,Context context);
/**
* 查询部门人数
* */
DeptEntity queryDept(String deptCode);
DeptEntity queryParent(String parentCode);
int queryParentId(Long deptId);
}
\ No newline at end of file
......@@ -191,4 +191,19 @@ 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) {
return dao.queryDeptParentId(deptId);
}
}
\ No newline at end of file
......@@ -59,7 +59,7 @@ public interface StaffDao extends ICRUDDao<StaffEntity,Long>{
/**
*
* 查询部门信息
* */
StaffEntity queryHik(String remarkId);
}
......@@ -18,4 +18,6 @@ public interface StaffService extends ICRUDCacheService<StaffEntity,Long> {
int queryDeptNum(Long deptId);
int queryAllPerson();
}
\ No newline at end of file
......@@ -65,4 +65,5 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
}
}
\ No newline at end of file
......@@ -104,10 +104,19 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ
@Override
protected int saveAfter(StaffEntity entity, Map<String, Object> model, Context context) throws AppException {
int personNum = service.queryDeptNum(entity.getDeptId());
//统计当前部门
DeptEntity deptEntity = deptService.get(entity.getDeptId());
deptEntity.setPersonNum(personNum);
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);
}
......
......@@ -881,4 +881,10 @@
<select id="queryDept" resultType="com.mortals.xhx.module.dept.model.DeptEntity">
select * from mortals_xhx_dept where deptCode = #{deptCode}
</select>
<select id="queryDeptParient" resultType="com.mortals.xhx.module.dept.model.DeptEntity">
select * from mortals_xhx_dept where deptCode = #{parentCode}
</select>
<select id="queryDeptParentId" resultType="integer">
select parentId from mortals_xhx_dept where deptId = #{deptId}
</select>
</mapper>
\ No newline at end of file
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