工单重构,导入品牌与校区

This commit is contained in:
DB 2023-11-30 08:59:07 +08:00
parent 32dbd17038
commit 6e5d889954
5 changed files with 123 additions and 40 deletions

View File

@ -0,0 +1,102 @@
package com.cpop.oam.web;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author DB
* @createTime 2023/11/27 17:24
* @description 导入数据
*/
@SpringBootTest
@Slf4j
public class CpopImportTests {
/**
* @descriptions 导入品牌
* @author DB
* @date 2023/11/27 17:26
* @return: void
*/
@Test
public void importBrandJson() throws IOException {
String brandFileUrl = "";
List<String> filterList = new ArrayList<>();
filterList.add("b00064a760d0c4f121b0835d09b909ca");
filterList.add("ac1268b164d1d20700080aae1703ecf8");
filterList.add("0122a5876468513f0d42569d389e8264");
List<JsonBrand> jsonBrands = JSONArray.parseArray(readJson(brandFileUrl), JsonBrand.class);
//过滤已存在的品牌
List<JsonBrand> filterBrand = jsonBrands.stream().filter(item -> !filterList.contains(item.getBrandCloudId())).collect(Collectors.toList());
//打印
filterBrand.forEach(item -> {
log.info("品牌信息:{}", item.toString());
});
}
/**
* @descriptions 导入校区
* @author DB
* @date 2023/11/27 17:26
* @return: void
*/
@Test
public void importStoreJson() {
}
/**
* json格式品牌
*/
@Data
private class JsonBrand implements Serializable{
/**
* 品牌名
*/
@JSONField(name = "")
private String brandName;
/**
* 云品牌id
*/
@JSONField(name = "")
private String brandCloudId;
}
/**
* 读取json文件数据
*
* @param jsonPath json文件路径
* @return 字符串
*/
public String readJson(String jsonPath) throws IOException {
File jsonFile = new File(jsonPath);
FileReader fileReader = new FileReader(jsonFile);
BufferedReader reader = new BufferedReader(fileReader);
StringBuilder sb = new StringBuilder();
while (true) {
int ch = reader.read();
if (ch != -1) {
sb.append((char) ch);
} else {
break;
}
}
fileReader.close();
reader.close();
return sb.toString();
}
}

View File

@ -1,40 +0,0 @@
package com.cpop.oam.business.bo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* @author: DB
* @Date: 2023/07/10/14:14
* @Description:
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "TaskWorkOrder对象", description = "任务-工单表")
public class TaskWorkOrderPageBo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 校区id
*/
@ApiModelProperty("校区id")
private String campusName;
/**
* 任务名
*/
@ApiModelProperty("任务名")
private String taskName;
/**
* 任务状态
*/
@ApiModelProperty("任务状态")
private List<Integer> taskStatus;
}

View File

@ -0,0 +1,7 @@
package com.cpop.oam.business.dto;/**
* @author DB
* @createTime 2023/11/28 15:42
* @description
*/
public class TaskWorkOrderReceiveDealPauseDto {
}

View File

@ -0,0 +1,7 @@
package com.cpop.oam.business.vo;/**
* @author DB
* @createTime 2023/11/28 12:35
* @description
*/
public class StoreListVo {
}

View File

@ -0,0 +1,7 @@
package com.cpop.oam.business.vo;/**
* @author DB
* @createTime 2023/11/28 15:08
* @description
*/
public class TaskWorkOrderReceiveDealPauseVo {
}