feat: 上传地材历史数据
This commit is contained in:
@@ -91,24 +91,23 @@ public class LocalMaterial extends Model<LocalMaterial> {
|
||||
|
||||
public LocalMaterial() {}
|
||||
|
||||
public LocalMaterial (Row row, MaterialTask data) {
|
||||
public LocalMaterial (Row row, MaterialTask task) {
|
||||
var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK;
|
||||
this.setDate(row.getCell(0, policy).getLocalDateTimeCellValue().toLocalDate());
|
||||
this.setCity(row.getCell(1, policy).getStringCellValue());
|
||||
this.setCounty(row.getCell(2, policy).getStringCellValue());
|
||||
this.setName(row.getCell(3, policy).getStringCellValue());
|
||||
this.setSpec(row.getCell(4, policy).getStringCellValue());
|
||||
this.setUnit(row.getCell(5, policy).getStringCellValue());
|
||||
this.setPrice(BigDecimal.valueOf(row.getCell(6, policy).getNumericCellValue()));
|
||||
this.setPriceWithoutTax(BigDecimal.valueOf(row.getCell(7, policy).getNumericCellValue()));
|
||||
this.setPosition(row.getCell(8, policy).getStringCellValue());
|
||||
this.setRemark(row.getCell(9, policy).getStringCellValue());
|
||||
|
||||
if (ObjectUtil.isNotEmpty(this.name)) {
|
||||
this.name = this.name.replace(" ", "");
|
||||
this.setCity(row.getCell(0, policy).getStringCellValue());
|
||||
this.setCounty(row.getCell(1, policy).getStringCellValue());
|
||||
this.setName(row.getCell(2, policy).getStringCellValue().replace(" ", ""));
|
||||
this.setSpec(row.getCell(3, policy).getStringCellValue().replace(" ", ""));
|
||||
this.setUnit(row.getCell(4, policy).getStringCellValue());
|
||||
this.setPrice(BigDecimal.valueOf(row.getCell(5, policy).getNumericCellValue()));
|
||||
this.setPriceWithoutTax(BigDecimal.valueOf(row.getCell(6, policy).getNumericCellValue()));
|
||||
this.setPosition(row.getCell(7, policy).getStringCellValue());
|
||||
this.setRemark(row.getCell(8, policy).getStringCellValue());
|
||||
this.setDate(LocalDate.of(task.getYear(), task.getMonth(), 1)); // 从任务获取日期
|
||||
if (this.getName().isEmpty()) {
|
||||
throw new IllegalArgumentException("名称为空");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(this.spec)) {
|
||||
this.spec = this.spec.replace(" ", "");
|
||||
if (ObjectUtil.isEmpty(this.getPrice())) {
|
||||
throw new IllegalArgumentException("缺少价格");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,7 @@ public class UploadFileTest {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
var filePath = "C:\\Users\\Administrator\\Desktop\\材料管理系统模版\\主材\\交通局.xlsx";
|
||||
var filePath = "C:\\Users\\Administrator\\Desktop\\材料管理系统模版\\历史数据\\地材-202405.xlsx";
|
||||
var file = new File(filePath);
|
||||
var multipartFile = this.mockMultipartFile(file, "网络价格.xlsx", "application/x-zip-compressed");
|
||||
var fileId = devFileService.uploadReturnId(DevFileEngineTypeEnum.LOCAL.getValue(), multipartFile);
|
||||
@@ -34,6 +34,8 @@ public class UploadFileTest {
|
||||
* 1810481654990442497 调查表.xlsx 501
|
||||
* 1810481965629005826 公路局.xlsx 40201
|
||||
* 1810482216079302658 交通局.xlsx 40101
|
||||
* 1810497092512178177 地材.xlsx 1101
|
||||
* 1810506191866003457 地材-202405.xlsx 1101
|
||||
*/
|
||||
|
||||
private MultipartFile mockMultipartFile(File file, String fileName, String contentType) {
|
||||
|
Reference in New Issue
Block a user