feat(material-task): 新增地材表格上传接口

This commit is contained in:
han0
2023-12-14 09:45:39 +08:00
parent cb9091f517
commit 7e2a4f3ac5
8 changed files with 237 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ public class DataDbMpGenerator {
private static String password = "Xxs123456"; private static String password = "Xxs123456";
private static String schema = "material_manage"; private static String schema = "material_manage";
private static String[] tableList = { private static String[] tableList = {
"SANMING_STEEL", "LOCAL_MATERIAL",
}; };

View File

@@ -27,6 +27,14 @@ public class MaterialTaskType {
public static final Integer FUJIAN_DEPARTMENT = 701; public static final Integer FUJIAN_DEPARTMENT = 701;
// 发改委 // 发改委
public static final Integer OIL = 801; // 汽柴油 public static final Integer OIL = 801; // 汽柴油
// 地材
public static final Integer LOCAL_MEDIUM_COARSE_SAND = 901; // 中粗砂
public static final Integer LOCAL_MECHANISM_SAND = 902; // 机制砂
public static final Integer LOCAL_GRAVEL = 903; // 碎石
public static final Integer LOCAL_MAOTIAO_STONE = 904; // 毛条石
public static final Integer LOCAL_FINE_AGGREGATE = 905; // 细料石
public static final Integer LOCAL_COARSE_AGGREGATE = 906; // 粗料石
public static final Integer LOCAL_CLAY = 907; // 粘土
public static final List<Integer> list = List.of( public static final List<Integer> list = List.of(
MY_STEEL_REBAR, MY_STEEL_REBAR,
@@ -44,7 +52,14 @@ public class MaterialTaskType {
OTHER_GIANLZHOU, OTHER_GIANLZHOU,
OTHER_YUNNAN, OTHER_YUNNAN,
FUJIAN_DEPARTMENT, FUJIAN_DEPARTMENT,
OIL OIL,
LOCAL_MEDIUM_COARSE_SAND,
LOCAL_MECHANISM_SAND,
LOCAL_GRAVEL,
LOCAL_MAOTIAO_STONE,
LOCAL_FINE_AGGREGATE,
LOCAL_COARSE_AGGREGATE,
LOCAL_CLAY
); );
public static boolean isFromSpider(Integer type) { public static boolean isFromSpider(Integer type) {
@@ -57,5 +72,18 @@ public class MaterialTaskType {
); );
return dataFromSpiderTypes.contains(type); return dataFromSpiderTypes.contains(type);
} }
public static boolean isLocalMaterial(Integer type) {
var dataFromSpiderTypes = List.of(
LOCAL_MEDIUM_COARSE_SAND,
LOCAL_MECHANISM_SAND,
LOCAL_GRAVEL,
LOCAL_MAOTIAO_STONE,
LOCAL_FINE_AGGREGATE,
LOCAL_COARSE_AGGREGATE,
LOCAL_CLAY
);
return dataFromSpiderTypes.contains(type);
}
} }

View File

@@ -0,0 +1,18 @@
package mjkf.xinke.main.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 地材 前端控制器
* </p>
*
* @author han0
* @since 2023-12-14
*/
@RestController
@RequestMapping("/local-material")
public class LocalMaterialController {
}

View File

@@ -0,0 +1,16 @@
package mjkf.xinke.main.dao;
import mjkf.xinke.main.model.db.LocalMaterial;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 地材 Mapper 接口
* </p>
*
* @author han0
* @since 2023-12-14
*/
public interface LocalMaterialMapper extends BaseMapper<LocalMaterial> {
}

View File

@@ -0,0 +1,87 @@
package mjkf.xinke.main.model.db;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.apache.poi.ss.usermodel.Row;
/**
* <p>
* 地材
* </p>
*
* @author han0
* @since 2023-12-14
*/
@Getter
@Setter
@TableName("LOCAL_MATERIAL")
@ApiModel(value = "LocalMaterial对象", description = "地材")
public class LocalMaterial extends Model<LocalMaterial> {
private static final long serialVersionUID = 1L;
@TableId(value = "ID", type = IdType.AUTO)
private Integer id;
@ApiModelProperty("名称")
@TableField("`NAME`")
private String name;
@ApiModelProperty("材料id")
@TableField("MATERIAL_ID")
private String materialId;
@ApiModelProperty("规格")
@TableField("SPEC")
private String spec;
@ApiModelProperty("地市")
@TableField("CITY")
private String city;
@ApiModelProperty("区县")
@TableField("COUNTY")
private String county;
@ApiModelProperty("价格")
@TableField("PRICE")
private BigDecimal price;
@ApiModelProperty("日期")
@TableField("`DATE`")
private LocalDate date;
@Override
public Serializable pkVal() {
return this.id;
}
public LocalMaterial() {}
public LocalMaterial (Row row) {
this.setName(row.getCell(0).getStringCellValue());
this.setCity(row.getCell(1).getStringCellValue());
this.setCounty(row.getCell(2).getStringCellValue());
this.setPrice(BigDecimal.valueOf(row.getCell(3).getNumericCellValue()));
this.setDate(row.getCell(4).getLocalDateTimeCellValue().toLocalDate());
}
public LocalMaterial update(LocalMaterial item) {
this.setName(item.getName());
this.setCity(item.getCity());
this.setCounty(item.getCounty());
this.setPrice(item.getPrice());
this.setDate(item.getDate());
return this;
}
}

View File

@@ -0,0 +1,66 @@
package mjkf.xinke.main.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import mjkf.xinke.main.model.db.LocalMaterial;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.Map;
@Service
public class LocalMaterialService extends DataService<BaseMapper<LocalMaterial>, LocalMaterial> {
public LambdaQueryWrapper<LocalMaterial> indexQuery(LocalMaterial data) {
LambdaQueryWrapper<LocalMaterial> query = new LambdaQueryWrapper<>();
query.eq(LocalMaterial::getName, data.getName());
query.eq(LocalMaterial::getCity, data.getCity());
query.eq(LocalMaterial::getCounty, data.getCounty());
query.eq(LocalMaterial::getSpec, data.getSpec());
query.eq(LocalMaterial::getDate, data.getDate());
return query;
}
public LambdaQueryWrapper<LocalMaterial> trendQuery(Object obj, Integer year, Integer month) {
var data = (LocalMaterial) obj;
LambdaQueryWrapper<LocalMaterial> query = new LambdaQueryWrapper<>();
query.eq(LocalMaterial::getName, data.getName());
var date = LocalDate.of(year, month, 1);
query.between(LocalMaterial::getDate, date, date.minusMonths(1));
return query;
}
public LambdaQueryWrapper<LocalMaterial> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
LambdaQueryWrapper<LocalMaterial> query = new LambdaQueryWrapper<>();
if (keyWord != null) {
query.and(e -> e
.like(LocalMaterial::getName, keyWord)
);
}
if (year != null) {
var date = LocalDate.of(year, month, 1);
query.between(LocalMaterial::getDate, date, date.plusYears(1));
}
if (month != null) {
var date = LocalDate.of(year, month, 1);
query.between(LocalMaterial::getDate, date, date.plusMonths(1));
}
if (name != null) {
query.like(LocalMaterial::getName, name);
}
if (materialId != null) {
query.eq(LocalMaterial::getMaterialId, materialId);
}
return query;
}
public LambdaQueryWrapper<LocalMaterial> filterQuery(LambdaQueryWrapper<LocalMaterial> query) {
return query;
}
public LocalMaterial getMapGroupingBy(Map item) {
var o = new LocalMaterial();
o.setName(item.get("name").toString());
return o;
}
}

View File

@@ -36,6 +36,8 @@ public class MaterialResultService {
FujianSurveyService fujianSurveyService; FujianSurveyService fujianSurveyService;
@Resource @Resource
OilService oilService; OilService oilService;
@Resource
LocalMaterialService localMaterialService;
/** /**
* 基础查询 * 基础查询
@@ -156,6 +158,20 @@ public class MaterialResultService {
// service = fujianDepartmentService; // service = fujianDepartmentService;
} else if (type.equals(MaterialTaskType.OIL)) { } else if (type.equals(MaterialTaskType.OIL)) {
service = oilService; service = oilService;
} else if (type.equals(MaterialTaskType.LOCAL_MEDIUM_COARSE_SAND)) {
service = localMaterialService;
} else if (type.equals(MaterialTaskType.LOCAL_MECHANISM_SAND)) {
service = localMaterialService;
} else if (type.equals(MaterialTaskType.LOCAL_GRAVEL)) {
service = localMaterialService;
} else if (type.equals(MaterialTaskType.LOCAL_MAOTIAO_STONE)) {
service = localMaterialService;
} else if (type.equals(MaterialTaskType.LOCAL_FINE_AGGREGATE)) {
service = localMaterialService;
} else if (type.equals(MaterialTaskType.LOCAL_COARSE_AGGREGATE)) {
service = localMaterialService;
} else if (type.equals(MaterialTaskType.LOCAL_CLAY)) {
service = localMaterialService;
} else { } else {
} }

View File

@@ -48,6 +48,8 @@ public class MaterialTaskService extends ServiceImpl<BaseMapper<MaterialTask>, M
FuzhouHighwayBureauService fuzhouHighwayBureauService; FuzhouHighwayBureauService fuzhouHighwayBureauService;
@Resource @Resource
FujianSurveyService fujianSurveyService; FujianSurveyService fujianSurveyService;
@Resource
LocalMaterialService localMaterialService;
@Override @Override
public boolean save(MaterialTask data) { public boolean save(MaterialTask data) {
@@ -104,6 +106,8 @@ public class MaterialTaskService extends ServiceImpl<BaseMapper<MaterialTask>, M
list = fuzhouHighwayBureauService.saveOrUpdateByIndexBatch(rows); list = fuzhouHighwayBureauService.saveOrUpdateByIndexBatch(rows);
} else if (data.getType().equals(MaterialTaskType.FUJIAN_SURVEY)) { } else if (data.getType().equals(MaterialTaskType.FUJIAN_SURVEY)) {
list = fujianSurveyService.saveOrUpdateByIndexBatch(rows); list = fujianSurveyService.saveOrUpdateByIndexBatch(rows);
} else if (MaterialTaskType.isLocalMaterial(data.getType())) {
list = localMaterialService.saveOrUpdateByIndexBatch(rows);
} else { } else {
// todo 异常处理:未识别的类型 // todo 异常处理:未识别的类型
return false; return false;