调整数据导入

This commit is contained in:
DB 2024-01-04 21:42:11 +08:00
parent 28ac4e95ad
commit d0e5811442
5 changed files with 307 additions and 67 deletions

View File

@ -3,8 +3,6 @@ package com.cpop.core.base.entity;
import com.cpop.core.utils.SecurityUtils;
import com.mybatisflex.annotation.InsertListener;
import java.time.LocalDateTime;
/**
* @author: DB
* @Date: 2023/08/04/15:12
@ -17,9 +15,9 @@ public class BaseInsertListener implements InsertListener {
BaseEntity baseEntity = (BaseEntity) entity;
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
//设置 account 被新增时的一些默认数据
baseEntity.setCreateTime(LocalDateTime.now());
baseEntity.setCreateUserId(null == loginUser ? "1" : loginUser.getUserId());
baseEntity.setUpdateTime(LocalDateTime.now());
baseEntity.setUpdateUserId(null == loginUser ? "1" : loginUser.getUserId());
//baseEntity.setCreateTime(LocalDateTime.now());
//baseEntity.setCreateUserId(null == loginUser ? "1" : loginUser.getUserId());
//baseEntity.setUpdateTime(LocalDateTime.now());
//baseEntity.setUpdateUserId(null == loginUser ? "1" : loginUser.getUserId());
}
}

View File

@ -188,8 +188,7 @@ public class CpopWxPayTests {
@Test
public void getPayScoreUserSignPlans() throws WxPayException {
wxPayService.getConfig().setServiceId("00003053000000169450961228104460");
String v3 = wxPayService.getV3("https://api.mch.weixin.qq.com/v3/payscore/sign-plan/partner/user-sign-plans/merchant-sign-plan-no/1735294783081091132?sub_mchid=1618925571");
System.out.println(v3);
wxPayService.getV3("https://api.mch.weixin.qq.com/v3/payscore/sign-plan/partner/user-sign-plans/merchant-sign-plan-no/1735294783081091132?sub_mchid=1618925571");
}
}

View File

@ -805,7 +805,7 @@ public class CpopImportTests {
try {
DataSourceKey.use("jambox");
rowList = DbChain.table("OAM_upload")
.select("ou.file_url", "ou.empty_tag as isClear", "ou.status as importStatus", "ou.remarks", "tmi.store_id as storeCloudId")
.select("ou.file_url", "ou.empty_tag as isClear", "ou.status as importStatus", "ou.remarks", "tmi.store_id as storeCloudId","ou.creation_time as createTime")
.from("OAM_upload").as("ou")
.where("ou.deleted = 1")
.leftJoin("t_mechanism_info").as("tmi").on("tmi.mechanism_id = ou.mechanism_id")
@ -894,19 +894,26 @@ public class CpopImportTests {
@Test
public void iterationOldDataImport(){
List<Row> rowList;
List<Row> staffRowList;
try {
DataSourceKey.use("jambox");
//报销阶段
rowList = DbChain.table("OAM_iteration")
.select("oi.iteration_id as createUserId","oi.system_name as subject", "oi.type", "os.phone", "oi.enclosure as attachmentUrl", "oi.content as taskContent",
"DATE_FORMAT(oi.estimate_time,'%Y-%m-%d') as expectedCompletionDate", "oi.status", "oi.grade as taskRating", "oi.remarks as remark")
.from("OAM_iteration").as("oi")
.leftJoin("OAM_staff").as("os").on("os.staff_id = oi.staff_id")
.where("oi.deleted = 1")
.select("iteration_id as updateUserId", "system_name as subject", "staff_id", "enclosure as attachmentUrl", "content as taskContent",
"DATE_FORMAT(estimate_time,'%Y-%m-%d') as expectedCompletionDate", "status", "grade as taskRating", "remarks as remark")
.select("creation_time as createTime", "last_modification_date as updateTime", "creation_by")
.from("OAM_iteration")
.where("deleted = 1")
.list();
staffRowList = DbChain.table("OAM_staff")
.select("staff_id", "phone")
.from("OAM_staff")
.where("deleted = 1")
.list();
} finally {
DataSourceKey.clear();
}
//获取旧员工id
Map<String, String> oldStaffMap = staffRowList.stream().collect(Collectors.toMap(item -> item.getString("staffId"), item -> item.getString("phone")));
//获取现有所有员工
Map<String, StaffInfoVo> staffMap = SpringUtils.getBean(StaffService.class).listAs(QueryWrapper.create()
.select(STAFF.ID, STAFF.NAME)
@ -915,10 +922,28 @@ public class CpopImportTests {
.leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID)),
StaffInfoVo.class).stream().collect(Collectors.toMap(StaffInfoVo::getPhoneNumber, item -> item));
rowList.forEach(item -> {
//所有任务预设为迭代任务
item.put("taskType", 0);
if (staffMap.get(item.getString("phone")) != null) {
item.put("responsibleStaffId", staffMap.get(item.getString("phone")).getId());
//负责员工不为空
if (StringUtils.isNotBlank(item.getString("staffId")) && oldStaffMap.get(item.getString("staffId")) != null) {
if (staffMap.get(oldStaffMap.get(item.getString("staffId"))) != null) {
item.put("responsibleStaffId", staffMap.get(oldStaffMap.get(item.getString("staffId"))).getId());
}
}
//记录员工为创建人
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
item.put("recordStaffId", staffMap.get(createStaffPhone).getId());
}
}
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
item.put("createUserId", staffMap.get(createStaffPhone).getId());
}
}
//文件上传地址格式调整
if (StringUtils.isNotBlank(item.getString("attachmentUrl"))) {
Map<String, String> map = new HashMap<>();
map.put("name", "旧数据无名字");
@ -928,7 +953,8 @@ public class CpopImportTests {
item.set("attachmentUrl", JSONArray.toJSONString(maps));
}
//获取任务状态
getTaskStatus(item.getInt("status"),item);
getTaskStatus(item.getInt("status"), item);
//评级
if (StringUtils.isNotBlank(item.getString("taskRating"))){
//获取任务权重
getTaskWeight(item);
@ -946,20 +972,27 @@ public class CpopImportTests {
@Test
public void taskStaffOldDataImport() {
List<Row> rowList;
List<Row> staffRowList;
try {
DataSourceKey.use("jambox");
//报销阶段
rowList = DbChain.table("OAM_iteration_scale")
.select("ois.iteration_id","ois.scale as gradePoint", "os.phone")
.from("OAM_iteration_scale").as("ois")
.leftJoin("OAM_staff").as("os").on("os.staff_id = ois.staff_id")
.where("ois.deleted = 1")
.select("iteration_id", "scale as gradePoint", "staff_id", "remarks as remark")
.select("creation_time as createTime", "last_modification_date as updateTime", "creation_by", "last_modified")
.from("OAM_iteration_scale")
.where("deleted = 1")
.list();
staffRowList = DbChain.table("OAM_staff")
.select("staff_id", "phone")
.from("OAM_staff")
.where("deleted = 1")
.list();
} finally {
DataSourceKey.clear();
}
//获取旧员工id
Map<String, String> oldStaffMap = staffRowList.stream().collect(Collectors.toMap(item -> item.getString("staffId"), item -> item.getString("phone")));
//获取所有任务
Map<String, String> taskMap = SpringUtils.getBean(TaskService.class).list().stream().collect(Collectors.toMap(BaseEntity::getCreateUserId, Task::getId));
Map<String, String> taskMap = SpringUtils.getBean(TaskService.class).list().stream().collect(Collectors.toMap(BaseEntity::getUpdateUserId, Task::getId));
//获取现有所有员工
Map<String, StaffInfoVo> staffMap = SpringUtils.getBean(StaffService.class).listAs(QueryWrapper.create()
.select(STAFF.ID, STAFF.NAME)
@ -968,39 +1001,85 @@ public class CpopImportTests {
.leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID)),
StaffInfoVo.class).stream().collect(Collectors.toMap(StaffInfoVo::getPhoneNumber, item -> item));
rowList.forEach(item -> {
if (staffMap.get(item.getString("phone")) != null) {
item.put("staffId", staffMap.get(item.getString("phone")).getId());
//员工
if (StringUtils.isNotBlank(item.getString("staffId")) && oldStaffMap.get(item.getString("staffId")) != null) {
if (staffMap.get(oldStaffMap.get(item.getString("staffId"))) != null) {
item.set("staffId", staffMap.get(oldStaffMap.get(item.getString("staffId"))).getId());
}
}
item.put("taskId",taskMap.get(item.getString("iterationId")));
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
item.put("createUserId", staffMap.get(createStaffPhone).getId());
}
}
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
item.put("createUserId", staffMap.get(createStaffPhone).getId());
}
}
if (StringUtils.isNotBlank(item.getString("lastModified")) && oldStaffMap.get(item.getString("lastModified")) != null) {
String updateStaffPhone = oldStaffMap.get(item.getString("lastModified"));
if (staffMap.get(updateStaffPhone) != null) {
item.put("updateUserId", staffMap.get(updateStaffPhone).getId());
}
}
});
List<TaskStaffGroup> entityList = RowUtil.toEntityList(rowList, TaskStaffGroup.class);
SpringUtils.getBean(TaskStaffGroupService.class).saveBatch(entityList);
}
private Row getTaskStatus(Integer status,Row row) {
/**
* 获取任务状态
* @author DB
* @since 2024/1/4
* @param status 旧状态值
* @param row 插入
*/
private void getTaskStatus(Integer status, Row row) {
switch (status) {
//待领取
case 0:
row.put("taskStatus",1);
//有评级
if (StringUtils.isNotBlank(row.getString("taskRating"))){
row.put("taskStatus",1);
} else {
row.put("taskStatus",0);
}
row.put("taskItem",0);
break;
//进行中
case 1:
case 2:
row.put("taskStatus",2);
row.put("taskItem",1);
row.put("taskProgress","0,1,2,3,4");
row.put("taskReceiptTime",row.getLocalDateTime("createTime"));
break;
//带部署
case 3:
row.put("taskStatus",8);
row.put("taskItem",2);
row.put("taskProgress","0,1,2,3,4");
row.put("taskStatus", 8);
row.put("taskItem", 2);
row.put("taskProgress", "0,1,2,3,4");
row.put("testToFinishUrl",row.getString("attachmentUrl"));
row.put("toTestTime",row.getLocalDateTime("updateTime"));
row.put("taskReceiptTime",row.getLocalDateTime("createTime"));
row.put("completion_date",row.getLocalDateTime("updateTime").toLocalDate());
break;
//已归档
default:
row.put("taskStatus",9);
row.put("taskItem",3);
row.put("taskProgress","0,1,2,3,4");
row.put("taskStatus", 9);
row.put("taskItem", 3);
row.put("taskProgress", "0,1,2,3,4");
row.put("testToFinishUrl",row.getString("attachmentUrl"));
row.put("toDeployTime",row.getLocalDateTime("updateTime"));
row.put("toTestTime",row.getLocalDateTime("updateTime"));
row.put("taskReceiptTime",row.getLocalDateTime("createTime"));
row.put("completion_date",row.getLocalDateTime("updateTime").toLocalDate());
break;
}
return row;
}
private Integer getTaskWeight(Row row){
@ -1026,46 +1105,117 @@ public class CpopImportTests {
}
}
private LocalDate taskRatingToDate(String rating,LocalDate startDate){
switch (rating){
case "A":
return startDate.plusDays(30);
case "B":
return startDate.plusDays(21);
case "C":
return startDate.plusDays(15);
case "D":
return startDate.plusDays(7);
case "E":
return startDate.plusDays(3);
default:
return startDate.plusDays(1);
}
}
@Test
public void demandOldDataImport(){
List<Row> rowList;
List<Row> staffRowList;
try {
DataSourceKey.use("jambox");
//报销阶段
rowList = DbChain.table("OAM_demand")
.select("tmi.store_id as storeCloudId", "od.iteration_id", "od.type", "od.content as taskContent", "od.file_url", "od.status",
.select("tmi.store_id as storeCloudId", "od.iteration_id", "od.type", "od.content as taskContent", "od.file_url as attachmentUrl", "od.status",
"od.remarks", "od.grade as taskRating", "od.sign_pic", "od.sign_url as payQrCode", "od.payment as prepayment", "od.price as payable", "od.wx_order_id", "od.sign_agree")
.select("od.creation_time as createTime", "od.last_modification_date as updateTime", "od.creation_by", "od.last_modified")
.from("OAM_demand").as("od")
.leftJoin("t_mechanism_info").as("tmi").on("tmi.mechanism_id = od.mechanism_id")
.leftJoin("OAM_iteration").as("oi").on("oi.iteration_id = od.iteration_id")
.where("od.deleted = 1")
.list();
staffRowList = DbChain.table("OAM_staff")
.select("staff_id", "phone")
.from("OAM_staff")
.where("deleted = 1")
.list();
} finally {
DataSourceKey.clear();
}
//获取旧员工id
Map<String, String> oldStaffMap = staffRowList.stream().collect(Collectors.toMap(item -> item.getString("staffId"), item -> item.getString("phone")));
//获取现有所有员工
Map<String, StaffInfoVo> staffMap = SpringUtils.getBean(StaffService.class).listAs(QueryWrapper.create()
.select(STAFF.ID, STAFF.NAME)
.select(SYS_USER.PHONE_NUMBER.as(StaffInfoVo::getPhoneNumber))
.from(STAFF)
.leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID)),
StaffInfoVo.class).stream().collect(Collectors.toMap(StaffInfoVo::getPhoneNumber, item -> item));
//查询校区
Map<String, String> cloudToStore = SpringUtils.getBean(StoreExtendService.class).list().stream().collect(Collectors.toMap(StoreExtend::getStoreCloudId, StoreExtend::getStoreId));
Map<String, Store> storeMap = SpringUtils.getBean(StoreService.class).queryChain().list().stream().collect(Collectors.toMap(Store::getId, item -> item));
TaskService taskService = SpringUtils.getBean(TaskService.class);
//获取所有任务
Map<String, Task> taskMap = taskService.list().stream().collect(Collectors.toMap(BaseEntity::getCreateUserId, item->item));
Map<String, Task> taskMap = taskService.list().stream().collect(Collectors.toMap(BaseEntity::getUpdateUserId, item->item));
//是否有任务
List<Row> notHaveTask = rowList.stream().filter(item -> StringUtils.isBlank(item.getString("iteration_id"))).collect(Collectors.toList());
//更新
notHaveTask.forEach(item -> {
//是否有评级
Task task = new Task();
task.setCreateTime(item.getLocalDateTime("createTime"));
task.setUpdateTime(item.getLocalDateTime("updateTime"));
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
item.put("createUserId", staffMap.get(createStaffPhone).getId());
task.setCreateUserId(staffMap.get(createStaffPhone).getId());
task.setUpdateUserId(staffMap.get(createStaffPhone).getId());
}
}
if (StringUtils.isNotBlank(item.getString("lastModified")) && oldStaffMap.get(item.getString("lastModified")) != null) {
String updateStaffPhone = oldStaffMap.get(item.getString("lastModified"));
if (staffMap.get(updateStaffPhone) != null) {
item.put("updateUserId", staffMap.get(updateStaffPhone).getId());
}
}
//文件上传地址格式调整
if (StringUtils.isNotBlank(item.getString("attachmentUrl"))) {
Map<String, String> map = new HashMap<>();
map.put("name", "旧数据无名字");
map.put("url", item.getString("attachmentUrl"));
List<Map<String, String>> maps = new ArrayList<>();
maps.add(map);
item.set("attachmentUrl", JSONArray.toJSONString(maps));
}
//记录员工为创建人
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
task.setRecordStaffId(staffMap.get(createStaffPhone).getId());
}
}
if (StringUtils.isBlank(item.getString("taskRating"))) {
// 默认待审核
task.setTaskStatus(0).setTaskItem(0).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskStatus(0).setTaskItem(0).setTaskType(1).setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
} else if (item.getBoolean("status")) {
//已完成
task.setTaskStatus(9).setTaskItem(3).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskStatus(9).setTaskItem(3).setTaskType(1).setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item));
//通用
task.setToDeployTime(item.getLocalDateTime("updateTime")).setToTestTime(item.getLocalDateTime("updateTime"))
.setTaskReceiptTime(item.getLocalDateTime("createTime")).setCompletionDate(item.getLocalDateTime("updateTime").toLocalDate())
.setAttachmentUrl(item.getString("attachmentUrl")).setTestToFinishUrl(item.getString("attachmentUrl"))
.setExpectedCompletionDate(taskRatingToDate(item.getString("taskRating"), item.getLocalDateTime("createTime").toLocalDate()));
} else {
//未完成
task.setTaskStatus(1).setTaskItem(0).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item));
task.setTaskStatus(1).setTaskItem(0).setTaskType(1).setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item)).setTaskReceiptTime(item.getLocalDateTime("createTime"))
.setAttachmentUrl(item.getString("attachmentUrl"));
}
taskService.save(task);
item.set("taskId", task.getId());
@ -1077,35 +1227,81 @@ public class CpopImportTests {
List<Task> updateTasks = new ArrayList<>();
List<Row> haveTask = rowList.stream().filter(item -> StringUtils.isNotBlank(item.getString("iteration_id"))).collect(Collectors.toList());
haveTask.forEach(item->{
//是否能查到任务
//是否有评级
Task task = new Task();
task.setCreateTime(item.getLocalDateTime("createTime"));
task.setUpdateTime(item.getLocalDateTime("updateTime"));
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
item.put("createUserId", staffMap.get(createStaffPhone).getId());
task.setCreateUserId(staffMap.get(createStaffPhone).getId());
task.setUpdateUserId(staffMap.get(createStaffPhone).getId());
}
}
if (StringUtils.isNotBlank(item.getString("lastModified")) && oldStaffMap.get(item.getString("lastModified")) != null) {
String updateStaffPhone = oldStaffMap.get(item.getString("lastModified"));
if (staffMap.get(updateStaffPhone) != null) {
item.put("updateUserId", staffMap.get(updateStaffPhone).getId());
}
}
//文件上传地址格式调整
if (StringUtils.isNotBlank(item.getString("attachmentUrl"))) {
Map<String, String> map = new HashMap<>();
map.put("name", "旧数据无名字");
map.put("url", item.getString("attachmentUrl"));
List<Map<String, String>> maps = new ArrayList<>();
maps.add(map);
item.set("attachmentUrl", JSONArray.toJSONString(maps));
}
//记录员工为创建人
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
task.setRecordStaffId(staffMap.get(createStaffPhone).getId());
}
}
if (taskMap.get(item.getString("iterationId")) != null) {
//是否有评级
if (StringUtils.isBlank(item.getString("taskRating"))) {
// 默认待审核
task.setId(taskMap.get(item.getString("iterationId")).getId()).setTaskStatus(0).setTaskItem(0).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setId(taskMap.get(item.getString("iterationId")).getId()).setTaskStatus(0).setTaskItem(0).setTaskType(1).setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
} else if (item.getBoolean("status")) {
//已完成
task.setId(taskMap.get(item.getString("iterationId")).getId()).setTaskStatus(9).setTaskItem(3).setTaskType(1).setRecordStaffId("1")
task.setId(taskMap.get(item.getString("iterationId")).getId()).setTaskStatus(9).setTaskItem(3).setTaskType(1)
.setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item));
//通用
task.setToDeployTime(item.getLocalDateTime("updateTime")).setToTestTime(item.getLocalDateTime("updateTime"))
.setTaskReceiptTime(item.getLocalDateTime("createTime")).setCompletionDate(item.getLocalDateTime("updateTime").toLocalDate())
.setAttachmentUrl(item.getString("attachmentUrl")).setTestToFinishUrl(item.getString("attachmentUrl"))
.setExpectedCompletionDate(taskRatingToDate(item.getString("taskRating"), item.getLocalDateTime("createTime").toLocalDate()));
} else {
//未完成
task.setId(taskMap.get(item.getString("iterationId")).getId()).setTaskStatus(1).setTaskItem(0).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item));
task.setId(taskMap.get(item.getString("iterationId")).getId()).setTaskStatus(1).setTaskItem(0).setTaskType(1).setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item))
.setAttachmentUrl(item.getString("attachmentUrl"));
}
updateTasks.add(task);
} else {
//是否有评级
if (StringUtils.isBlank(item.getString("taskRating"))) {
// 默认待审核
task.setTaskStatus(0).setTaskItem(0).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskStatus(0).setTaskItem(0).setTaskType(1).setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
} else if (item.getBoolean("status")) {
//已完成
task.setTaskStatus(9).setTaskItem(3).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskStatus(9).setTaskItem(3).setTaskType(1).setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item));
//通用
task.setToDeployTime(item.getLocalDateTime("updateTime")).setToTestTime(item.getLocalDateTime("updateTime"))
.setTaskReceiptTime(item.getLocalDateTime("createTime")).setCompletionDate(item.getLocalDateTime("updateTime").toLocalDate())
.setAttachmentUrl(item.getString("attachmentUrl")).setTestToFinishUrl(item.getString("attachmentUrl"))
.setExpectedCompletionDate(taskRatingToDate(item.getString("taskRating"), item.getLocalDateTime("createTime").toLocalDate()));
} else {
//未完成
task.setTaskStatus(1).setTaskItem(0).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskStatus(1).setTaskItem(0).setTaskType(1).setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item)).setTaskReceiptTime(item.getLocalDateTime("createTime"))
.setAttachmentUrl(item.getString("attachmentUrl"));
}
taskService.save(task);
} item.set("taskId", task.getId());
@ -1126,21 +1322,28 @@ public class CpopImportTests {
@Test
public void workOrderOldDataImport(){
List<Row> rowList;
List<Row> staffRowList;
try {
DataSourceKey.use("jambox");
//报销阶段
rowList = DbChain.table("OAM_work")
.select("tmi.store_id as storeCloudId","ow.work_id", "ow.suspend_time", "ow.system_name", "ow.content as taskContent", "ow.phone as phoneNumber", "ow.file_url",
"ow.status", "os.phone", "ow.receive_time", "ow.remarks as remark","TIMESTAMPDIFF(MINUTE, ow.creation_time, receive_time) as receivingTime",
.select("tmi.store_id as storeCloudId","ow.work_id as updateUserId", "ow.suspend_time", "ow.system_name", "ow.content as taskContent", "ow.phone as phoneNumber", "ow.file_url as attachmentUrl",
"ow.status", "ow.receive", "ow.receive_time", "ow.remarks as remark","TIMESTAMPDIFF(MINUTE, ow.creation_time, receive_time) as receivingTime",
"ow.last_modification_date as finishTime")
.select("ow.creation_time as createTime", "ow.last_modification_date as updateTime", "ow.creation_by", "ow.last_modified")
.from("OAM_work").as("ow")
.leftJoin("t_mechanism_info").as("tmi").on("tmi.mechanism_id = ow.mechanism_id")
.leftJoin("OAM_staff").as("os").on("os.staff_id = ow.receive")
.where("ow.deleted = 1")
.list();
staffRowList = DbChain.table("OAM_staff")
.select("staff_id", "phone")
.from("OAM_staff")
.where("deleted = 1")
.list();
} finally {
DataSourceKey.clear();
}
//获取旧员工id
Map<String, String> oldStaffMap = staffRowList.stream().collect(Collectors.toMap(item -> item.getString("staffId"), item -> item.getString("phone")));
//查询校区
Map<String, String> cloudToStore = SpringUtils.getBean(StoreExtendService.class).list().stream().collect(Collectors.toMap(StoreExtend::getStoreCloudId, StoreExtend::getStoreId));
Map<String, Store> storeMap = SpringUtils.getBean(StoreService.class).queryChain().list().stream().collect(Collectors.toMap(Store::getId, item -> item));
@ -1155,9 +1358,23 @@ public class CpopImportTests {
List<TaskWorkOrder> taskWorkOrders = new ArrayList<>();
rowList.forEach(item->{
Task task = new Task();
if (staffMap.get(item.getString("phone")) != null) {
task.setResponsibleStaffId(staffMap.get(item.getString("phone")).getId());
//负责员工不为空
if (StringUtils.isNotBlank(item.getString("receive")) && oldStaffMap.get(item.getString("receive")) != null) {
if (staffMap.get(oldStaffMap.get(item.getString("receive"))) != null) {
task.setResponsibleStaffId(staffMap.get(oldStaffMap.get(item.getString("receive"))).getId());
}
}
//记录员工为创建人
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
task.setRecordStaffId(staffMap.get(createStaffPhone).getId());
task.setCreateUserId(staffMap.get(createStaffPhone).getId());
task.setUpdateUserId(staffMap.get(createStaffPhone).getId());
}
}
task.setCreateTime(item.getLocalDateTime("createTime"));
task.setUpdateTime(item.getLocalDateTime("updateTime"));
task.setTaskItem(3).setTaskStatus(9).setTaskReceiptTime(item.getLocalDateTime("receiveTime"))
.setTaskType(2).setTaskRating("N").setTaskContent(item.getString("taskContent")).setCreateUserId("1");
taskService.save(task);
@ -1168,7 +1385,17 @@ public class CpopImportTests {
}
workOrder.setTaskId(task.getId()).setPhoneNumber(item.getString("phoneNumber")).setReceivingTime(item.getInt("receivingTime"))
.setFinishTime(item.getLocalDateTime("finishTime"));
workOrder.setCreateUserId(item.getString("workId"));
//记录员工为创建人
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
workOrder.setCreateUserId(staffMap.get(createStaffPhone).getId());
workOrder.setFinishStaffId(staffMap.get(createStaffPhone).getId());
}
}
workOrder.setCreateTime(item.getLocalDateTime("createTime"));
workOrder.setUpdateTime(item.getLocalDateTime("updateTime"));
workOrder.setUpdateUserId(item.getString("updateUserId"));
taskWorkOrders.add(workOrder);
});
SpringUtils.getBean(TaskWorkOrderService.class).saveBatch(taskWorkOrders);
@ -1180,18 +1407,25 @@ public class CpopImportTests {
@Test
public void workOrderRecordOldDataImport() {
List<Row> rowList;
List<Row> staffRowList;
try {
DataSourceKey.use("jambox");
//报销阶段
rowList = DbChain.table("OAM_work_record")
.select("owr.work_id as workId", "owr.content as recordText", "owr.file_url as attachmentUrl", "os.phone")
.from("OAM_work_record").as("owr")
.leftJoin("OAM_staff").as("os").on("os.staff_id = owr.creation_by")
.where("owr.deleted = 1")
.select("work_id", "content as recordText", "file_url as attachmentUrl")
.select("creation_time as createTime", "creation_time as updateTime", "creation_by")
.from("OAM_work_record")
.where("deleted = 1")
.list();
staffRowList = DbChain.table("OAM_staff")
.select("staff_id", "phone")
.from("OAM_staff")
.where("deleted = 1")
.list();
} finally {
DataSourceKey.clear();
}
//获取旧员工id
Map<String, String> oldStaffMap = staffRowList.stream().collect(Collectors.toMap(item -> item.getString("staffId"), item -> item.getString("phone")));
//获取现有所有员工
Map<String, StaffInfoVo> staffMap = SpringUtils.getBean(StaffService.class).listAs(QueryWrapper.create()
.select(STAFF.ID, STAFF.NAME)
@ -1200,10 +1434,17 @@ public class CpopImportTests {
.leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID)),
StaffInfoVo.class).stream().collect(Collectors.toMap(StaffInfoVo::getPhoneNumber, item -> item));
//获取所有工单
Map<String, String> workOrderMap = SpringUtils.getBean(TaskWorkOrderService.class).list().stream().filter(item->StringUtils.isNotBlank(item.getCreateUserId())).collect(Collectors.toMap(BaseEntity::getCreateUserId, TaskWorkOrder::getId));
Map<String, String> workOrderMap = SpringUtils.getBean(TaskWorkOrderService.class).list().stream().filter(item->StringUtils.isNotBlank(item.getUpdateUserId()))
.collect(Collectors.toMap(BaseEntity::getUpdateUserId, TaskWorkOrder::getId));
rowList.forEach(item->{
if (staffMap.get(item.getString("phone"))!=null){
item.set("recordStaffId",staffMap.get(item.getString("phone")).getId());
//记录员工为创建人
if (StringUtils.isNotBlank(item.getString("creationBy")) && oldStaffMap.get(item.getString("creationBy")) != null) {
String createStaffPhone = oldStaffMap.get(item.getString("creationBy"));
if (staffMap.get(createStaffPhone) != null) {
item.put("recordStaffId", staffMap.get(createStaffPhone).getId());
item.put("createUserId", staffMap.get(createStaffPhone).getId());
item.put("updateUserid", staffMap.get(createStaffPhone).getId());
}
}
if (StringUtils.isNotBlank(item.getString("attachmentUrl"))){
Map<String, String> map = new HashMap<>();
@ -1213,7 +1454,7 @@ public class CpopImportTests {
maps.add(map);
item.set("attachmentUrl", JSONArray.toJSONString(maps));
}
item.set("taskWordOrderId",workOrderMap.get(item.getString("workId")));
item.set("taskWorkOrderId",workOrderMap.get(item.getString("workId")));
});
SpringUtils.getBean(TaskWorkOrderRecordService.class).saveBatch(RowUtil.toEntityList(rowList,TaskWorkOrderRecord.class));
}

View File

@ -73,7 +73,8 @@ public class DataImportServiceImpl extends ServiceImpl<DataImportMapper, DataImp
.leftJoin(BRAND).on(BRAND.ID.eq(DATA_IMPORT.BRAND_ID))
.leftJoin(STORE).on(STORE.ID.eq(DATA_IMPORT.STORE_ID))
.where(DATA_IMPORT.IMPORT_STATUS.eq(bo.getImportStatus()))
.and(STORE.STORE_NAME.like(bo.getStoreName())),
.and(STORE.STORE_NAME.like(bo.getStoreName()))
.orderBy(DATA_IMPORT.CREATE_TIME.desc()),
DataImportPageVo.class);
}

View File

@ -86,7 +86,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
.from(TASK)
.where(TASK.TASK_TYPE.in(0, 1))
.and(TASK.TASK_STATUS.eq(bo.getIsFinish() ? 9 : 8).and(TASK.TASK_CONTENT.like(bo.getTaskContent())))
.and(TASK.SUBJECT.like(bo.getSubject())),
.and(TASK.SUBJECT.like(bo.getSubject()))
.orderBy(TASK.UPDATE_TIME.desc()),
TaskArchivingPagVo.class,
// 负责人
item -> item.field(TaskArchivingPagVo::getResponsibleStaffName)