commit
This commit is contained in:
@@ -16,10 +16,10 @@ public enum Api2FinanceFiledMap {
|
||||
RYDM("rydm", "loginname"),
|
||||
// 人员名称
|
||||
RYMC("rymc", "username"),
|
||||
// 编制会费
|
||||
HF("hf", "name"),
|
||||
// 合同制会费
|
||||
HF2("hf2", "unitType");
|
||||
// 编制会费,需与财务拉取后读取的 NutMap key 保持一致。
|
||||
HF("hf", "preparationMemberFee"),
|
||||
// 合同制会费,需与财务拉取后读取的 NutMap key 保持一致。
|
||||
HF2("hf2", "contractMemberFee");
|
||||
|
||||
public final String apiField;
|
||||
public final String dbColumn;
|
||||
|
||||
@@ -195,8 +195,6 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
||||
Sys_user u = new Sys_user();
|
||||
BeanUtils.copyProperties(source, u);
|
||||
|
||||
// 先不处理会员
|
||||
u.setMember(null);
|
||||
|
||||
if (user == null) {
|
||||
// 新增用户,初始化数据
|
||||
@@ -204,9 +202,9 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
||||
u.setSalt(salt);
|
||||
u.setPassword(PwdUtil.getPassword(PwdUtil.generate(12), salt));
|
||||
|
||||
// if (u.getMember()) {
|
||||
// addMemberUserIds.add(u.getId());
|
||||
// }
|
||||
if (u.getMember()) {
|
||||
addMemberUserIds.add(u.getId());
|
||||
}
|
||||
needInitUserList.add(u);
|
||||
} else {
|
||||
|
||||
@@ -218,13 +216,13 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
||||
u.setId(user.getId());
|
||||
|
||||
// 更新会员状态
|
||||
boolean currentIsMember = user.getMember() != null && user.getMember();
|
||||
boolean currentIsMember = source.getMember() != null && source.getMember();
|
||||
|
||||
// if (!currentIsMember) {
|
||||
// addMemberUserIds.add(user.getId());
|
||||
// } else{
|
||||
// removeMemberUserIds.add(user.getId());
|
||||
// }
|
||||
if (currentIsMember) {
|
||||
addMemberUserIds.add(user.getId());
|
||||
} else{
|
||||
removeMemberUserIds.add(user.getId());
|
||||
}
|
||||
|
||||
needDoUpdateList.add(u);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.budwk.app.sys.models.Sys_user_source;
|
||||
import com.budwk.app.sys.services.SysDataUnitPullService;
|
||||
import com.budwk.app.sys.services.SysDataUserPullService;
|
||||
import com.budwk.app.sys.services.SysDictService;
|
||||
import com.budwk.app.sys.utils.DataCenterUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.aop.interceptor.async.Async;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
@@ -396,7 +395,7 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
||||
|
||||
List<JSONObject> rawDataList = new ArrayList<>();
|
||||
String year = String.valueOf(DateUtil.thisYear());
|
||||
String month = String.valueOf(DateUtil.thisMonth() + 1);
|
||||
String month = String.valueOf(DateUtil.thisMonth());
|
||||
|
||||
int pageNum = 1;
|
||||
int pageSize = 1000;
|
||||
@@ -414,12 +413,14 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
||||
"pageSize", pageSize
|
||||
);
|
||||
httpRequest.body(JSONUtil.toJsonStr(reqBody));
|
||||
|
||||
log.info("财务接口填写数据: {}", reqBody);
|
||||
JSONObject resp = JSONUtil.parseObj(httpRequest.execute().body());
|
||||
log.info("财务接口返回结果: {}", resp);
|
||||
if (resp.getInt("code") != 0) {
|
||||
throw new BaseException("获取财务数据失败,错误码: " + resp.getInt("code") + ";错误原因:" + resp.getStr("msg"));
|
||||
}
|
||||
|
||||
// 财务接口的分页信息在 data 节点,明细数据在顶层 records 节点,解析时需要分别读取。
|
||||
JSONObject data = resp.getJSONObject("data");
|
||||
if (pageNum == 1) {
|
||||
totalCount = data.getInt("total", 0);
|
||||
@@ -427,16 +428,18 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
||||
totalPages = (int) Math.ceil((double) totalCount / pageSize);
|
||||
}
|
||||
|
||||
JSONArray records = data.getJSONArray("records");
|
||||
JSONArray records = resp.getJSONArray("records");
|
||||
log.info("财务数据转换前: {}", records);
|
||||
if (CollUtil.isNotEmpty(records)) {
|
||||
rawDataList.addAll(records.stream().map(v -> (JSONObject) v).toList());
|
||||
log.info("数据拉取进度: {}/{}", rawDataList.size(), totalCount);
|
||||
log.info("财务数据拉取进度: {}/{}", rawDataList.size(), totalCount);
|
||||
}
|
||||
log.info("财务数据转换后: {}", records.stream().map(v -> (JSONObject) v).toList());
|
||||
pageNum++; // 只加页码
|
||||
} while (pageNum <= totalPages);
|
||||
|
||||
// 接口数据输出
|
||||
log.info("数据拉取结果: {}", rawDataList);
|
||||
log.info("财务数据拉取结果: {}", rawDataList);
|
||||
|
||||
// 最后结果数据
|
||||
Map<String, NutMap> result = new HashMap<>();
|
||||
@@ -445,14 +448,25 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
||||
.collect(Collectors.toMap(e -> e.apiField, e -> e.dbColumn));
|
||||
|
||||
for (JSONObject row : rawDataList) {
|
||||
NutMap nutMap = DataCenterUtil.mapJsonToBean(row, NutMap.class, api2db);
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
// NutMap 不是普通 JavaBean,不能用反射字段赋值,这里按映射关系直接写入键值。
|
||||
api2db.forEach((apiField, dbColumn) -> {
|
||||
Object value = row.get(apiField);
|
||||
if (value != null) {
|
||||
nutMap.setv(dbColumn, value);
|
||||
}
|
||||
});
|
||||
if (StrUtil.isBlank(nutMap.getString("loginname"))) {
|
||||
log.warn("财务数据缺少工号,跳过本条记录: {}", row);
|
||||
continue;
|
||||
}
|
||||
result.put(nutMap.getString("loginname"), nutMap);
|
||||
}
|
||||
|
||||
// 输出结果
|
||||
log.info("财务数据拉取转换结果: {}", result);
|
||||
|
||||
log.info("数据拉取完成,共拉取 {} 条数据", result.size());
|
||||
log.info("财务数据拉取完成,共拉取 {} 条数据", result.size());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user