Oam值班,数据导入,事务,员工,任务,定时器,校区插件相关代码调整
This commit is contained in:
parent
6f607d2771
commit
28ac4e95ad
@ -46,9 +46,10 @@ public class StorePlugServiceImpl extends ServiceImpl<StorePlugMapper, StorePlug
|
||||
try {
|
||||
DataSourceKey.use("jambox");
|
||||
rows = Db.selectListByQuery("t_application_info", QueryWrapper.create()
|
||||
.select("application", "char_tag as plugTag", "pic", "tag", "status","creation_time as listingTime")
|
||||
.select("application", "char_tag as plugTag", "pic", "tag", "status", "creation_time as listingTime")
|
||||
.from("t_application_info")
|
||||
.where("char_tag IS NOT NULL"));
|
||||
.where("deleted = 1")
|
||||
.and("char_tag IS NOT NULL"));
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package com.cpop.mall.business.controller.mini;
|
||||
|
||||
import com.cpop.core.base.R;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
import com.cpop.jambox.business.entity.BrandExtend;
|
||||
import com.cpop.jambox.business.service.BrandExtendService;
|
||||
import com.cpop.mall.business.vo.OrderPageVo;
|
||||
import com.cpop.system.business.service.BrandService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.cpop.mall.business.service.StaffService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND;
|
||||
import static com.cpop.mall.business.entity.table.RoleBrandTableDef.ROLE_BRAND;
|
||||
import static com.cpop.mall.business.entity.table.StaffTableDef.STAFF;
|
||||
|
||||
/**
|
||||
* @author DB
|
||||
@ -38,7 +40,13 @@ public class MiniBrandController {
|
||||
@GetMapping("/jamboxBrandIsInMall/{cloudBrandId}")
|
||||
@ApiOperation("小程序-果酱品牌是否在商城内")
|
||||
public R<Boolean> jamboxBrandIsInMall(@PathVariable String cloudBrandId) {
|
||||
long count = brandExtendService.queryChain().where(BRAND_EXTEND.BRAND_CLOUD_ID.eq(cloudBrandId)).count();
|
||||
BrandExtend brandExtend = brandExtendService.queryChain().where(BRAND_EXTEND.BRAND_CLOUD_ID.eq(cloudBrandId)).one();
|
||||
if (brandExtend == null) {
|
||||
return R.ok(false);
|
||||
}
|
||||
long count = SpringUtils.getBean(StaffService.class).queryChain()
|
||||
.leftJoin(ROLE_BRAND).on(ROLE_BRAND.ID.eq(STAFF.ROLE_BRAND_ID))
|
||||
.where(ROLE_BRAND.BRAND_ID.eq(brandExtend.getBrandId())).count();
|
||||
return R.ok(count > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,10 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.cpop.common.utils.StringUtils;
|
||||
import com.cpop.common.utils.bean.BeanUtils;
|
||||
import com.cpop.core.base.entity.BaseEntity;
|
||||
import com.cpop.core.base.enums.InitRoleEnum;
|
||||
import com.cpop.core.base.enums.SourceType;
|
||||
import com.cpop.core.utils.RsaUtils;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
import com.cpop.jambox.business.entity.BrandExtend;
|
||||
import com.cpop.jambox.business.entity.EasyLearnOrder;
|
||||
@ -15,10 +18,10 @@ import com.cpop.jambox.business.service.BrandExtendService;
|
||||
import com.cpop.jambox.business.service.EasyLearnOrderService;
|
||||
import com.cpop.jambox.business.service.StoreExtendService;
|
||||
import com.cpop.jambox.business.service.StorePlugService;
|
||||
import com.cpop.oam.business.entity.BrandManager;
|
||||
import com.cpop.oam.business.entity.BrandManagerStore;
|
||||
import com.cpop.oam.business.service.BrandManagerService;
|
||||
import com.cpop.oam.business.service.BrandManagerStoreService;
|
||||
import com.cpop.oam.business.bo.StaffBo;
|
||||
import com.cpop.oam.business.entity.*;
|
||||
import com.cpop.oam.business.service.*;
|
||||
import com.cpop.oam.business.vo.StaffInfoVo;
|
||||
import com.cpop.system.business.entity.Store;
|
||||
import com.cpop.system.business.entity.StoreLicense;
|
||||
import com.cpop.system.business.entity.StoreRenew;
|
||||
@ -40,14 +43,17 @@ import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import java.io.*;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER;
|
||||
import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND;
|
||||
import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND;
|
||||
import static com.cpop.oam.business.entity.table.StaffTableDef.STAFF;
|
||||
import static com.cpop.system.business.entity.table.BrandTableDef.BRAND;
|
||||
import static com.cpop.system.business.entity.table.StoreTableDef.STORE;
|
||||
|
||||
@ -58,7 +64,7 @@ import static com.cpop.system.business.entity.table.StoreTableDef.STORE;
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
//@ActiveProfiles(profiles = {"prod", "core"})
|
||||
@ActiveProfiles(profiles = {"prod", "core"})
|
||||
public class CpopImportTests {
|
||||
|
||||
/**
|
||||
@ -691,4 +697,524 @@ public class CpopImportTests {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入旧员工数据
|
||||
* @author DB
|
||||
* @since 2024/01/02
|
||||
*/
|
||||
@Test
|
||||
public void importOldStaffData(){
|
||||
//获取已有的员工数据
|
||||
List<Row> rows = Db.selectListByQuery(QueryWrapper.create()
|
||||
.select(STAFF.ID)
|
||||
.select(SYS_USER.PHONE_NUMBER)
|
||||
.from(STAFF)
|
||||
.leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID)));
|
||||
System.out.println(rows);
|
||||
List<Row> rowList;
|
||||
try {
|
||||
DataSourceKey.use("jambox");
|
||||
rowList = DbChain.table("OAM_staff")
|
||||
.select("qy_id as wxCpUserId", "name", "phone as phoneNumber", "type", "avatar_url as avatar", "plaintext as password")
|
||||
.from("OAM_staff")
|
||||
.where("deleted = 1")
|
||||
.notIn("phone", rows.stream().map(item -> item.getString("phoneNumber")).collect(Collectors.toList()))
|
||||
.list();
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
StaffService staffService = SpringUtils.getBean(StaffService.class);
|
||||
RsaUtils rsaUtils = SpringUtils.getBean(RsaUtils.class);
|
||||
rowList.forEach(item->{
|
||||
String encrypt = rsaUtils.encrypt(item.getString("password"));
|
||||
// 创建员工
|
||||
StaffBo staffBo = new StaffBo();
|
||||
// 读取用户通用信息
|
||||
staffBo.setUserName(item.getString("phoneNumber"))
|
||||
.setName(item.getString("name"))
|
||||
.setPhoneNumber(item.getString("phoneNumber"))
|
||||
.setSex(true)
|
||||
.setStatus(true)
|
||||
.setStaffType(1)
|
||||
.setWxCpUserId(item.getString("wxCpUserId"))
|
||||
.setPassword(encrypt)
|
||||
// 设置部门
|
||||
.setDeptId("82682906627141632")
|
||||
// 区分技术员工和运营员工
|
||||
.setRoleId(InitRoleEnum.WX_CP_INIT_OPERATION_ROLE.getId());
|
||||
// 保存员工
|
||||
staffService.insertStaff(staffBo);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入旧值班数据
|
||||
* @author DB
|
||||
* @since 2024/01/02
|
||||
*/
|
||||
@Test
|
||||
public void importOldDutyData() {
|
||||
List<Row> rowList;
|
||||
//获取旧员工数据
|
||||
Map<String, String> oldStaffPhone;
|
||||
try {
|
||||
DataSourceKey.use("jambox");
|
||||
rowList = DbChain.table("OAM_staff")
|
||||
.select("after_sales", "iteration", "duty_time")
|
||||
.from("OAM_duty")
|
||||
.where("deleted = 1")
|
||||
.list();
|
||||
//获取旧员工数据
|
||||
oldStaffPhone = DbChain.table("OAM_staff")
|
||||
.select("staff_id", "phone")
|
||||
.from("OAM_staff")
|
||||
.where("deleted = 1")
|
||||
.list().stream().collect(Collectors.toMap(item -> item.getString("staffId"), item -> item.getString("phone")));
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
//获取现有所有员工
|
||||
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));
|
||||
rowList.forEach(item -> {
|
||||
StaffInfoVo afterSales = staffMap.get(oldStaffPhone.get(item.getString("afterSales")));
|
||||
StaffInfoVo iteration = staffMap.get(oldStaffPhone.get(item.getString("iteration")));
|
||||
if (afterSales != null && iteration != null){
|
||||
item.put("serviceStaffId",afterSales.getId());
|
||||
item.put("technologyStaffId",iteration.getId());
|
||||
}
|
||||
//时间戳转日期
|
||||
item.put("dutyDate", item.getLocalDateTime("dutyTime").toLocalDate());
|
||||
});
|
||||
List<Duty> entityList = RowUtil.toEntityList(rowList, Duty.class);
|
||||
SpringUtils.getBean(DutyService.class).saveBatch(entityList.stream().filter(item->item.getServiceStaffId()!=null).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入旧数据记录
|
||||
* @author DB
|
||||
* @since 2024/01/02
|
||||
*/
|
||||
@Test
|
||||
public void importOldDataImport(){
|
||||
List<Row> rowList;
|
||||
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")
|
||||
.from("OAM_upload").as("ou")
|
||||
.where("ou.deleted = 1")
|
||||
.leftJoin("t_mechanism_info").as("tmi").on("tmi.mechanism_id = ou.mechanism_id")
|
||||
.list();
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
//查询校区
|
||||
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));
|
||||
rowList.forEach(item -> {
|
||||
String storeId = cloudToStore.get(item.getString("storeCloudId"));
|
||||
if (StringUtils.isNotBlank(storeId)) {
|
||||
item.put("storeId", storeId);
|
||||
item.put("brandId", storeMap.get(storeId).getBrandId());
|
||||
item.put("sourceType", SourceType.JAMBOX.toString());
|
||||
}
|
||||
});
|
||||
List<Row> filterList = rowList.stream().filter(item -> StringUtils.isNotBlank(item.getString("storeId"))).collect(Collectors.toList());
|
||||
List<DataImport> entityList = RowUtil.toEntityList(filterList, DataImport.class);
|
||||
SpringUtils.getBean(DataImportService.class).saveBatch(entityList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 财务报销旧数据导入
|
||||
* @author DB
|
||||
* @since 2024/01/03
|
||||
*/
|
||||
@Test
|
||||
public void financeReimburseOldDataImport(){
|
||||
//报销类型
|
||||
//List<Row> typeRowList;
|
||||
List<Row> recordRowList;
|
||||
List<Row> stageRowList;
|
||||
try {
|
||||
DataSourceKey.use("jambox");
|
||||
/*
|
||||
typeRowList = DbChain.table("OAM_finance_reimbursement_type")
|
||||
.select("report_id as createUserId", "report_name as typeName")
|
||||
.from("OAM_finance_reimbursement_type")
|
||||
.where("deleted = 1")
|
||||
.list();*/
|
||||
//报销记录
|
||||
/*recordRowList = DbChain.table("OAM_finance_reimbursement")
|
||||
.select("ofr.id as createUserId", "os.phone", "ofr.status", "ofr.type_id", "ofr.report_date", "ofr.remarks", "ofr.price", "ofr.annex as attachmentUrl")
|
||||
.from("OAM_finance_reimbursement").as("ofr")
|
||||
.leftJoin("OAM_staff").as("os").on("os.staff_id = ofr.staff_id")
|
||||
.where("ofr.deleted = 1")
|
||||
.list();*/
|
||||
//报销阶段
|
||||
stageRowList = DbChain.table("OAM_finance_reimbursement_stage")
|
||||
.select("finance_reimbursement_id", "stage_amount", "payment_time")
|
||||
.from("OAM_finance_reimbursement_stage")
|
||||
.where("deleted = 1")
|
||||
.list();
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
//List<FinanceReimburseType> financeReimburseTypes = RowUtil.toEntityList(typeRowList, FinanceReimburseType.class);
|
||||
//SpringUtils.getBean(FinanceReimburseTypeService.class).saveBatch(financeReimburseTypes);
|
||||
//System.out.println(JSONArray.toJSONString(typeRowList));
|
||||
//Map<String, FinanceReimburseType> oldTypeIdMap = SpringUtils.getBean(FinanceReimburseTypeService.class).list().stream().collect(Collectors.toMap(BaseEntity::getCreateUserId, item -> item));
|
||||
//获取所有员工
|
||||
//获取现有所有员工
|
||||
/*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, FinanceReimburse> oldReimburseIdMap = SpringUtils.getBean(FinanceReimburseService.class).list().stream().collect(Collectors.toMap(BaseEntity::getCreateUserId, item -> item));
|
||||
stageRowList.forEach(item -> {
|
||||
if (oldReimburseIdMap.get(item.getString("financeReimbursementId")) != null){
|
||||
item.set("financeReimburseId", oldReimburseIdMap.get(item.getString("financeReimbursementId")).getId());
|
||||
}
|
||||
});
|
||||
List<FinanceReimburseStage> financeReimburseStages = RowUtil.toEntityList(stageRowList, FinanceReimburseStage.class);
|
||||
SpringUtils.getBean(FinanceReimburseStageService.class).saveBatch(financeReimburseStages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 迭代旧数据
|
||||
* @author DB
|
||||
* @since 2024/01/03
|
||||
*/
|
||||
@Test
|
||||
public void iterationOldDataImport(){
|
||||
List<Row> rowList;
|
||||
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")
|
||||
.list();
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
//获取现有所有员工
|
||||
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));
|
||||
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("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));
|
||||
}
|
||||
//获取任务状态
|
||||
getTaskStatus(item.getInt("status"),item);
|
||||
if (StringUtils.isNotBlank(item.getString("taskRating"))){
|
||||
//获取任务权重
|
||||
getTaskWeight(item);
|
||||
}
|
||||
});
|
||||
List<Task> entityList = RowUtil.toEntityList(rowList, Task.class);
|
||||
SpringUtils.getBean(TaskService.class).saveBatch(entityList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绩点
|
||||
* @author DB
|
||||
* @since 2024/01/03
|
||||
*/
|
||||
@Test
|
||||
public void taskStaffOldDataImport() {
|
||||
List<Row> rowList;
|
||||
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")
|
||||
.list();
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
//获取所有任务
|
||||
Map<String, String> taskMap = SpringUtils.getBean(TaskService.class).list().stream().collect(Collectors.toMap(BaseEntity::getCreateUserId, Task::getId));
|
||||
//获取现有所有员工
|
||||
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));
|
||||
rowList.forEach(item -> {
|
||||
if (staffMap.get(item.getString("phone")) != null) {
|
||||
item.put("staffId", staffMap.get(item.getString("phone")).getId());
|
||||
}
|
||||
item.put("taskId",taskMap.get(item.getString("iterationId")));
|
||||
});
|
||||
List<TaskStaffGroup> entityList = RowUtil.toEntityList(rowList, TaskStaffGroup.class);
|
||||
SpringUtils.getBean(TaskStaffGroupService.class).saveBatch(entityList);
|
||||
}
|
||||
|
||||
private Row getTaskStatus(Integer status,Row row) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
row.put("taskStatus",1);
|
||||
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");
|
||||
break;
|
||||
case 3:
|
||||
row.put("taskStatus",8);
|
||||
row.put("taskItem",2);
|
||||
row.put("taskProgress","0,1,2,3,4");
|
||||
break;
|
||||
default:
|
||||
row.put("taskStatus",9);
|
||||
row.put("taskItem",3);
|
||||
row.put("taskProgress","0,1,2,3,4");
|
||||
break;
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
private Integer getTaskWeight(Row row){
|
||||
switch (row.getString("taskRating")){
|
||||
case "A":
|
||||
row.put("taskWeight",200);
|
||||
return 200;
|
||||
case "B":
|
||||
row.put("taskWeight",100);
|
||||
return 100;
|
||||
case "C":
|
||||
row.put("taskWeight",80);
|
||||
return 80;
|
||||
case "D":
|
||||
row.put("taskWeight",40);
|
||||
return 40;
|
||||
case "E":
|
||||
row.put("taskWeight",20);
|
||||
return 20;
|
||||
default:
|
||||
row.put("taskWeight",10);
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void demandOldDataImport(){
|
||||
List<Row> rowList;
|
||||
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",
|
||||
"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")
|
||||
.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();
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
//查询校区
|
||||
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));
|
||||
//是否有任务
|
||||
List<Row> notHaveTask = rowList.stream().filter(item -> StringUtils.isBlank(item.getString("iteration_id"))).collect(Collectors.toList());
|
||||
//更新
|
||||
notHaveTask.forEach(item -> {
|
||||
//是否有评级
|
||||
Task task = new Task();
|
||||
if (StringUtils.isBlank(item.getString("taskRating"))) {
|
||||
// 默认待审核
|
||||
task.setTaskStatus(0).setTaskItem(0).setTaskType(1).setRecordStaffId("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.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item));
|
||||
} else {
|
||||
//未完成
|
||||
task.setTaskStatus(1).setTaskItem(0).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
|
||||
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item));
|
||||
}
|
||||
taskService.save(task);
|
||||
item.set("taskId", task.getId());
|
||||
if (storeMap.get(cloudToStore.get(item.getString("storeCloudId"))) != null){
|
||||
item.set("storeId", storeMap.get(cloudToStore.get(item.getString("storeCloudId"))).getId());
|
||||
item.set("brandId", storeMap.get(cloudToStore.get(item.getString("storeCloudId"))).getBrandId());
|
||||
}
|
||||
});
|
||||
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();
|
||||
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"));
|
||||
} else if (item.getBoolean("status")) {
|
||||
//已完成
|
||||
task.setId(taskMap.get(item.getString("iterationId")).getId()).setTaskStatus(9).setTaskItem(3).setTaskType(1).setRecordStaffId("1")
|
||||
.setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
|
||||
task.setTaskRating(item.getString("taskRating")).setTaskWeight(getTaskWeight(item));
|
||||
} 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));
|
||||
}
|
||||
updateTasks.add(task);
|
||||
} else {
|
||||
//是否有评级
|
||||
if (StringUtils.isBlank(item.getString("taskRating"))) {
|
||||
// 默认待审核
|
||||
task.setTaskStatus(0).setTaskItem(0).setTaskType(1).setRecordStaffId("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"));
|
||||
} else {
|
||||
//未完成
|
||||
task.setTaskStatus(1).setTaskItem(0).setTaskType(1).setRecordStaffId("1").setSubject("果酱盒子").setTaskContent(item.getString("taskContent"));
|
||||
}
|
||||
taskService.save(task);
|
||||
} item.set("taskId", task.getId());
|
||||
if (storeMap.get(cloudToStore.get(item.getString("storeCloudId"))) != null){
|
||||
item.set("storeId", storeMap.get(cloudToStore.get(item.getString("storeCloudId"))).getId());
|
||||
item.set("brandId", storeMap.get(cloudToStore.get(item.getString("storeCloudId"))).getBrandId());
|
||||
}
|
||||
});
|
||||
taskService.updateBatch(updateTasks);
|
||||
SpringUtils.getBean(TaskDemandService.class).saveBatch(RowUtil.toEntityList(rowList, TaskDemand.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 工单旧数据导入
|
||||
* @author DB
|
||||
* @since 2024/01/03
|
||||
*/
|
||||
@Test
|
||||
public void workOrderOldDataImport(){
|
||||
List<Row> rowList;
|
||||
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",
|
||||
"ow.last_modification_date as finishTime")
|
||||
.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();
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
//查询校区
|
||||
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));
|
||||
//获取现有所有员工
|
||||
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));
|
||||
TaskService taskService = SpringUtils.getBean(TaskService.class);
|
||||
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());
|
||||
}
|
||||
task.setTaskItem(3).setTaskStatus(9).setTaskReceiptTime(item.getLocalDateTime("receiveTime"))
|
||||
.setTaskType(2).setTaskRating("N").setTaskContent(item.getString("taskContent")).setCreateUserId("1");
|
||||
taskService.save(task);
|
||||
TaskWorkOrder workOrder = new TaskWorkOrder();
|
||||
String storeId = cloudToStore.get(item.getString("storeCloudId"));
|
||||
if (StringUtils.isNotBlank(storeId)) {
|
||||
workOrder.setStoreId(storeId).setBrandId(storeMap.get(storeId).getBrandId());
|
||||
}
|
||||
workOrder.setTaskId(task.getId()).setPhoneNumber(item.getString("phoneNumber")).setReceivingTime(item.getInt("receivingTime"))
|
||||
.setFinishTime(item.getLocalDateTime("finishTime"));
|
||||
workOrder.setCreateUserId(item.getString("workId"));
|
||||
taskWorkOrders.add(workOrder);
|
||||
});
|
||||
SpringUtils.getBean(TaskWorkOrderService.class).saveBatch(taskWorkOrders);
|
||||
}
|
||||
|
||||
/**
|
||||
* 工单旧数据导入
|
||||
*/
|
||||
@Test
|
||||
public void workOrderRecordOldDataImport() {
|
||||
List<Row> rowList;
|
||||
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")
|
||||
.list();
|
||||
} finally {
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
//获取现有所有员工
|
||||
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> workOrderMap = SpringUtils.getBean(TaskWorkOrderService.class).list().stream().filter(item->StringUtils.isNotBlank(item.getCreateUserId())).collect(Collectors.toMap(BaseEntity::getCreateUserId, 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("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));
|
||||
}
|
||||
item.set("taskWordOrderId",workOrderMap.get(item.getString("workId")));
|
||||
});
|
||||
SpringUtils.getBean(TaskWorkOrderRecordService.class).saveBatch(RowUtil.toEntityList(rowList,TaskWorkOrderRecord.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.cpop.oam.business.service.DutyService;
|
||||
import com.cpop.oam.business.service.StaffService;
|
||||
import com.cpop.oam.business.vo.DutyListVo;
|
||||
import com.cpop.oam.business.vo.StaffVo;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -16,6 +17,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER;
|
||||
import static com.cpop.oam.business.entity.table.StaffTableDef.STAFF;
|
||||
|
||||
/**
|
||||
* 值班表 控制层。
|
||||
*
|
||||
@ -100,7 +104,14 @@ public class DutyController {
|
||||
@ApiOperation("查询技术员工列表")
|
||||
@GetMapping("/getTechnologyStaffList")
|
||||
public R<List<StaffVo>> getTechnologyStaffList() {
|
||||
List<StaffVo> list = staffService.getTechnologyStaffList();
|
||||
List<StaffVo> list = staffService.listAs(QueryWrapper.create()
|
||||
.select(STAFF.ID, STAFF.NAME, STAFF.USER_ID, STAFF.STAFF_TYPE)
|
||||
.from(STAFF)
|
||||
.leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID))
|
||||
.where(STAFF.STAFF_TYPE.eq(0))
|
||||
//不查询停用的员工
|
||||
.and(SYS_USER.STATUS.eq(true)),
|
||||
StaffVo.class);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
@ -4,8 +4,6 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 数据导入Dto
|
||||
* @author DB
|
||||
@ -60,16 +58,14 @@ public class DataImportDto {
|
||||
/**
|
||||
* 办卡日期
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy/MM/dd")
|
||||
@ExcelProperty("办卡日期")
|
||||
private LocalDate createCardDate;
|
||||
private String createCardDate;
|
||||
|
||||
/**
|
||||
* 有效期至
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy/MM/dd")
|
||||
@ExcelProperty("有效期至")
|
||||
private LocalDate expiryDate;
|
||||
private String expiryDate;
|
||||
|
||||
/**
|
||||
* 课程顾问
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
package com.cpop.oam.business.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.cpop.core.base.entity.BaseEntity;
|
||||
import com.cpop.core.base.entity.BaseInsertListener;
|
||||
import com.cpop.core.base.entity.BaseUpdateListener;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 值班表 实体类。
|
||||
@ -45,7 +45,7 @@ public class Duty extends BaseEntity implements Serializable {
|
||||
/**
|
||||
* 值班日期
|
||||
*/
|
||||
private Date dutyDate;
|
||||
private LocalDate dutyDate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
|
||||
@ -48,11 +48,6 @@ public class TaskWorkOrder extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private String storeId;
|
||||
|
||||
/**
|
||||
* 产品id
|
||||
*/
|
||||
private String productId;
|
||||
|
||||
/**
|
||||
* 问题手机号
|
||||
*/
|
||||
|
||||
@ -51,6 +51,7 @@ import static com.cpop.oam.business.entity.table.StaffTableDef.STAFF;
|
||||
import static com.cpop.system.business.entity.table.BrandTableDef.BRAND;
|
||||
import static com.cpop.system.business.entity.table.StoreLicenseTableDef.STORE_LICENSE;
|
||||
import static com.cpop.system.business.entity.table.StoreTableDef.STORE;
|
||||
import static com.mybatisflex.core.query.QueryMethods.distinct;
|
||||
import static com.mybatisflex.core.query.QueryMethods.select;
|
||||
|
||||
/**
|
||||
@ -187,7 +188,8 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
||||
throw new ServiceException("导入的excel存在空文件,请检查后重新操作");
|
||||
}
|
||||
List<Store> storeList = SpringUtils.getBean(StoreService.class).queryChain()
|
||||
.where(STORE.ID.in(businessDistributeDataList.stream().map(BusinessDistributeDto::getStoreId).collect(Collectors.toSet()))).list();
|
||||
.where(STORE.ID.in(businessDistributeDataList.stream().map(BusinessDistributeDto::getStoreId).collect(Collectors.toSet())))
|
||||
.list();
|
||||
if (storeList.size() != businessDistributeDataList.size()) {
|
||||
throw new ServiceException("校区查询匹配失败,请核实数据后重新提交");
|
||||
}
|
||||
@ -244,10 +246,11 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
||||
//查询自己处理中的校区的记录
|
||||
queryWrapper.and(BUSINESS_STAFF.STAFF_ID.eq(loginUserInfo.getString("id"))
|
||||
//获取所有无人处理的校区
|
||||
.or(STORE.ID.notIn(select(BUSINESS_DETAIL.STORE_ID)
|
||||
.or(STORE.ID.notIn(select(distinct(BUSINESS_DETAIL.STORE_ID))
|
||||
.from(BUSINESS_DETAIL)
|
||||
.leftJoin(BUSINESS_STAFF).on(BUSINESS_STAFF.BUSINESS_ID.eq(BUSINESS_DETAIL.BUSINESS_ID))
|
||||
.where(BUSINESS_STAFF.STAFF_ID.ne(loginUserInfo.getString("id")))
|
||||
.where(BUSINESS_STAFF.STAFF_ID.ne(loginUserInfo.getString("id"))
|
||||
.and(BUSINESS_DETAIL.STORE_ID.isNotNull()))
|
||||
)));
|
||||
} else {
|
||||
queryWrapper.and(BUSINESS_STAFF.STAFF_ID.in(bo.getStaffIds()));
|
||||
|
||||
@ -115,7 +115,7 @@ public class DutyServiceImpl extends ServiceImpl<DutyMapper, Duty> implements Du
|
||||
List<Duty> entityList = new ArrayList<Duty>();
|
||||
dateList.forEach(item->{
|
||||
Duty entity = new Duty();
|
||||
entity.setDutyDate(new Date(DateUtils.parseDate(item).getTime()))
|
||||
entity.setDutyDate(LocalDate.parse(item))
|
||||
.setServiceStaffId(bo.getServiceStaffId())
|
||||
.setTechnologyStaffId(bo.getTechnologyStaffId());
|
||||
entityList.add(entity);
|
||||
|
||||
@ -405,7 +405,13 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||
jsonBody.put("_type", "oamDel");
|
||||
jsonBody.put("phone", sysUser.getPhoneNumber());
|
||||
}
|
||||
SpringUtils.getBean(RestTemplate.class).postForObject(JamboxCloudUrl.COMMON_CARD_URL, jsonBody, JSONObject.class);
|
||||
JSONObject jsonObject = SpringUtils.getBean(RestTemplate.class).postForObject(JamboxCloudUrl.COMMON_CARD_URL, jsonBody, JSONObject.class);
|
||||
assert jsonObject != null;
|
||||
if (!jsonObject.getBoolean("success")) {
|
||||
throw new ServiceException(jsonObject.getString("error"));
|
||||
} else {
|
||||
this.updateChain().set(STAFF.IS_OPERATION, bo.getIsOperation()).where(STAFF.ID.eq(bo.getId())).update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -770,7 +770,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
||||
.where(TASK.TASK_STATUS.in(2, 3, 4, 5, 6, 7, 8, 9))
|
||||
.and(TASK_STAFF_GROUP.STAFF_ID.eq(loginUserInfo.getString("id")))
|
||||
//获取当月绩点
|
||||
//.and(dateFormat(TASK.TASK_RECEIPT_TIME, "%Y-%m-%d").between(firstDay, lastDay))
|
||||
.and(dateFormat(TASK.TASK_RECEIPT_TIME, "%Y-%m-%d").between(firstDay, lastDay))
|
||||
, TaskIndividualGpaDetailVo.class);
|
||||
TaskIndividualGpaVo vo = new TaskIndividualGpaVo();
|
||||
if (individualGpas.isEmpty()) {
|
||||
|
||||
@ -70,7 +70,7 @@ public class OamScheduledTasks {
|
||||
* @author DB
|
||||
* @since 2023/12/11
|
||||
*/
|
||||
@Profile(value = {"prod", "test", "dev"})
|
||||
@Profile(value = {"prod", "test"})
|
||||
@Scheduled(cron = "0 10 0 * * *")
|
||||
public void checkTaskWhetherFinish() {
|
||||
log.info("==============开始检查进行中任务===========");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user