Browse Source

读取企业部门信息

master
zhizhi wu 5 years ago
parent
commit
f9601e2f7d
  1. 8
      health/src/main/java/com/ccsens/health/service/WeiXinService.java
  2. 4
      health/src/main/resources/mapper_dao/DepartmentDao.xml
  3. 2
      health/src/main/resources/mapper_dao/DepartmentEmployeeDao.xml

8
health/src/main/java/com/ccsens/health/service/WeiXinService.java

@ -196,7 +196,7 @@ public class WeiXinService implements IWeiXinService {
params.put("department_id", department.getId());
params.put("fetch_child", 0);
JSONObject userResult = (JSONObject) RestTemplateUtil.getForEntity(WeiXinConstant.USER_LIST, params, JSONObject.class);
if (WeiXinConstant.pageResult(userResult)) {
if (!WeiXinConstant.pageResult(userResult)) {
log.error("查询员工信息异常:{},{}", params, userResult);
return;
}
@ -218,7 +218,7 @@ public class WeiXinService implements IWeiXinService {
DepartmentEmployee de = new DepartmentEmployee();
de.setId(snowflake.nextId());
de.setEmployeeId(employee.getId());
de.setDepartmentId((Long)departmentIds.get(0));
de.setDepartmentId(departmentIds.getLong(0));
de.setSort(i);
des.add(de);
}
@ -228,12 +228,13 @@ public class WeiXinService implements IWeiXinService {
}
private void insertBatchEmployee(List<Employee> employees, List<DepartmentEmployee> des) {
TransactionStatus status = getTransactionStatus();
int empSize = employees.size();
int deSize = des.size();
int once = 100;
for (int i = 0; i < empSize; i+=once) {
int end = i+once > empSize ? empSize : i+once;
TransactionStatus status = getTransactionStatus();
try {
employeeDao.insertBatch(employees.subList(i, end));
//提交事务
@ -246,6 +247,7 @@ public class WeiXinService implements IWeiXinService {
}
for (int i = 0; i < deSize; i+=once) {
int end = i+once > deSize ? deSize : i+once;
TransactionStatus status = getTransactionStatus();
try {
departmentEmployeeDao.insertBatch(des.subList(i, end));
//提交事务

4
health/src/main/resources/mapper_dao/DepartmentDao.xml

@ -5,12 +5,12 @@
<insert id="insertBatch" parameterType="ArrayList">
insert into t_department (id, name,
name_en, parentid, order
name_en, parentid, `order`
)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=BIGINT}, #{item.name,jdbcType=VARCHAR},#{item.nameEn,jdbcType=VARCHAR},
#{item.parentid,jdbcType=VARCHAR}, #{item.order,jdbcType=INTEGER}
#{item.parentid,jdbcType=BIGINT}, #{item.order,jdbcType=INTEGER}
)
</foreach>
</insert>

2
health/src/main/resources/mapper_dao/DepartmentEmployeeDao.xml

@ -5,7 +5,7 @@
<insert id="insertBatch" parameterType="ArrayList">
insert into t_department_employee (id, department_id, employee_id,
order, sort
`order`, sort
)
values
<foreach collection="list" item="item" separator=",">

Loading…
Cancel
Save