feat(material-result): 新增材料采集结果相关接口
This commit is contained in:
@@ -22,6 +22,7 @@ public enum HttpErrorResponseEnum implements NcHttpErrorResponseInterface {
|
|||||||
MATERIAL_ID_INVALID("材料 id 无效", 400, HttpStatus.SC_NOT_FOUND),
|
MATERIAL_ID_INVALID("材料 id 无效", 400, HttpStatus.SC_NOT_FOUND),
|
||||||
MATERIAL_PARENT_ID_INVALID("材料 parent_id 无效", 400, HttpStatus.SC_NOT_FOUND),
|
MATERIAL_PARENT_ID_INVALID("材料 parent_id 无效", 400, HttpStatus.SC_NOT_FOUND),
|
||||||
MATERIAL_TASK_NOT_FOUND("找不到指定材料采集任务", 400, HttpStatus.SC_NOT_FOUND),
|
MATERIAL_TASK_NOT_FOUND("找不到指定材料采集任务", 400, HttpStatus.SC_NOT_FOUND),
|
||||||
|
MATERIAL_RESULT_NOT_FOUND("找不到指定材料采集结果", 400, HttpStatus.SC_NOT_FOUND),
|
||||||
;
|
;
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
|
@@ -0,0 +1,59 @@
|
|||||||
|
package mjkf.xinke.main.controller;
|
||||||
|
|
||||||
|
import com.jgy.xxs.core.http.exp.NcHttpException;
|
||||||
|
import com.jgy.xxs.core.http.resp.HttpResponse;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import mjkf.xinke.main.common.http.FuHttpResponse;
|
||||||
|
import mjkf.xinke.main.constant.HttpErrorResponseEnum;
|
||||||
|
import mjkf.xinke.main.service.MaterialResultService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 材料结果 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author han0
|
||||||
|
* @since 2023-11-09
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/material-result")
|
||||||
|
public class MaterialResultController {
|
||||||
|
@Resource
|
||||||
|
MaterialResultService materialResultService;
|
||||||
|
|
||||||
|
@ApiOperation("获取材料结果列表")
|
||||||
|
@GetMapping("/")
|
||||||
|
public HttpResponse list (
|
||||||
|
@ApiParam("关键字") @RequestParam(value="key_word", required=false) String keyWord,
|
||||||
|
@ApiParam("年份") @RequestParam("year") Integer year,
|
||||||
|
@ApiParam("月份") @RequestParam(value="month") Integer month,
|
||||||
|
@ApiParam("类型") @RequestParam("type") Integer type,
|
||||||
|
@ApiParam("材料编号") @RequestParam(value="material_id", required=false) String materialId,
|
||||||
|
@ApiParam("名称") @RequestParam(value="name", required=false) String name
|
||||||
|
) throws Exception{
|
||||||
|
var query = materialResultService.getQuery(keyWord, year, month, type, materialId, name);
|
||||||
|
query = materialResultService.filterQuery(query, type);
|
||||||
|
var result = materialResultService.listStatistics(query, type);
|
||||||
|
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取材料结果趋势")
|
||||||
|
@GetMapping("/{id}/trend")
|
||||||
|
public HttpResponse getTrend (
|
||||||
|
@PathVariable String id,
|
||||||
|
@ApiParam("类型") @RequestParam("type") Integer type,
|
||||||
|
@ApiParam("年份") @RequestParam("year") Integer year,
|
||||||
|
@ApiParam("月份") @RequestParam(value="month") Integer month
|
||||||
|
) throws Exception{
|
||||||
|
var data = materialResultService.getById(id, type);
|
||||||
|
if (data == null) {
|
||||||
|
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_RESULT_NOT_FOUND);
|
||||||
|
}
|
||||||
|
var result = materialResultService.getTrend(data, year, month, type);
|
||||||
|
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||||
|
}
|
||||||
|
}
|
@@ -71,4 +71,8 @@ public class SteelPlate extends SteelEntity<SteelPlate> {
|
|||||||
public SteelPlate(Row row) {
|
public SteelPlate(Row row) {
|
||||||
this.fromRow(row);
|
this.fromRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(SteelPlate data) {
|
||||||
|
super.update(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
package mjkf.xinke.main.model.db;
|
package mjkf.xinke.main.model.db;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -70,4 +68,8 @@ public class SteelRebar extends SteelEntity<SteelRebar> {
|
|||||||
public SteelRebar(Row row) {
|
public SteelRebar(Row row) {
|
||||||
this.fromRow(row);
|
this.fromRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(SteelRebar data) {
|
||||||
|
super.update(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -70,4 +70,8 @@ public class SteelSection extends SteelEntity<SteelSection>{
|
|||||||
public SteelSection(Row row) {
|
public SteelSection(Row row) {
|
||||||
this.fromRow(row);
|
this.fromRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(SteelSection data) {
|
||||||
|
super.update(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
78
src/main/java/mjkf/xinke/main/model/db/SteelStrand.java
Normal file
78
src/main/java/mjkf/xinke/main/model/db/SteelStrand.java
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
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-11-08
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("STEEL_STRAND")
|
||||||
|
@ApiModel(value = "SteelStrand对象", description = "钢绞线")
|
||||||
|
public class SteelStrand extends SteelEntity<SteelStrand> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "ID", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
@TableField("`NAME`")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("规格")
|
||||||
|
@TableField("SPEC")
|
||||||
|
private String spec;
|
||||||
|
|
||||||
|
@ApiModelProperty("材质")
|
||||||
|
@TableField("MATERIAL")
|
||||||
|
private String material;
|
||||||
|
|
||||||
|
@ApiModelProperty("产地")
|
||||||
|
@TableField("`SOURCE`")
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
@ApiModelProperty("价格")
|
||||||
|
@TableField("PRICE")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@ApiModelProperty("浮动")
|
||||||
|
@TableField("FLUCTUATING")
|
||||||
|
private BigDecimal fluctuating;
|
||||||
|
|
||||||
|
@ApiModelProperty("日期")
|
||||||
|
@TableField("`DATE`")
|
||||||
|
private LocalDate date;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Serializable pkVal() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SteelStrand() {}
|
||||||
|
|
||||||
|
public SteelStrand(Row row) {
|
||||||
|
this.fromRow(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(SteelStrand data) {
|
||||||
|
super.update(data);
|
||||||
|
}
|
||||||
|
}
|
@@ -2,7 +2,6 @@ package mjkf.xinke.main.service;
|
|||||||
|
|
||||||
import com.jgy.xxs.core.http.exp.NcHttpException;
|
import com.jgy.xxs.core.http.exp.NcHttpException;
|
||||||
import mjkf.xinke.main.constant.HttpErrorResponseEnum;
|
import mjkf.xinke.main.constant.HttpErrorResponseEnum;
|
||||||
import okhttp3.MediaType;
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
|
@@ -3,38 +3,73 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.AsphaltDomestic;
|
import mjkf.xinke.main.model.db.AsphaltDomestic;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AsphaltDomesticService extends ServiceImpl<BaseMapper<AsphaltDomestic>, AsphaltDomestic> {
|
public class AsphaltDomesticService extends DataService<BaseMapper<AsphaltDomestic>, AsphaltDomestic> {
|
||||||
public boolean saveOrUpdateByIndex(AsphaltDomestic data) {
|
public LambdaQueryWrapper<AsphaltDomestic> indexQuery(AsphaltDomestic data) {
|
||||||
var result = this.getOne(this.indexQuery(data));
|
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AsphaltDomestic> saveOrUpdateByIndexBatch(List<Row> rows) {
|
|
||||||
var list = rows.stream().map(item -> new AsphaltDomestic(item)).collect(Collectors.toList());
|
|
||||||
for (AsphaltDomestic item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<AsphaltDomestic> indexQuery(AsphaltDomestic data) {
|
|
||||||
LambdaQueryWrapper<AsphaltDomestic> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AsphaltDomestic> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(AsphaltDomestic::getName, data.getName());
|
query.eq(AsphaltDomestic::getName, data.getName());
|
||||||
query.eq(AsphaltDomestic::getDate, data.getDate());
|
query.eq(AsphaltDomestic::getDate, data.getDate());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<AsphaltDomestic> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (AsphaltDomestic) obj;
|
||||||
|
LambdaQueryWrapper<AsphaltDomestic> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(AsphaltDomestic::getName, data.getName());
|
||||||
|
query.between(AsphaltDomestic::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<AsphaltDomestic> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<AsphaltDomestic> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(AsphaltDomestic::getName, keyWord).or()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(AsphaltDomestic::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(AsphaltDomestic::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(AsphaltDomestic::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<AsphaltDomestic> filterQuery(LambdaQueryWrapper<AsphaltDomestic> query) {
|
||||||
|
query.in(AsphaltDomestic::getName, List.of(
|
||||||
|
"浙江省—镇海炼化(70#,90#,A级)",
|
||||||
|
"福建省—联合石化(70#,A级)",
|
||||||
|
"广东省—茂名石化(70#,90#,A级)",
|
||||||
|
"广东省—中油高富(70#,90#,A级)华南公司"
|
||||||
|
));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AsphaltDomestic getMapGroupingBy(Map item) {
|
||||||
|
var o = new AsphaltDomestic();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,38 +3,72 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.AsphaltImported;
|
import mjkf.xinke.main.model.db.AsphaltImported;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AsphaltImportedService extends ServiceImpl<BaseMapper<AsphaltImported>, AsphaltImported> {
|
public class AsphaltImportedService extends DataService<BaseMapper<AsphaltImported>, AsphaltImported> {
|
||||||
public boolean saveOrUpdateByIndex(AsphaltImported data) {
|
public LambdaQueryWrapper<AsphaltImported> indexQuery(AsphaltImported data) {
|
||||||
var result = this.getOne(this.indexQuery(data));
|
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AsphaltImported> saveOrUpdateByIndexBatch(List<Row> rows) {
|
|
||||||
var list = rows.stream().map(item -> new AsphaltImported(item)).collect(Collectors.toList());
|
|
||||||
for (AsphaltImported item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<AsphaltImported> indexQuery(AsphaltImported data) {
|
|
||||||
LambdaQueryWrapper<AsphaltImported> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AsphaltImported> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(AsphaltImported::getName, data.getName());
|
query.eq(AsphaltImported::getName, data.getName());
|
||||||
query.eq(AsphaltImported::getDate, data.getDate());
|
query.eq(AsphaltImported::getDate, data.getDate());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<AsphaltImported> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (AsphaltImported) obj;
|
||||||
|
LambdaQueryWrapper<AsphaltImported> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(AsphaltImported::getName, data.getName());
|
||||||
|
query.between(AsphaltImported::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<AsphaltImported> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<AsphaltImported> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(AsphaltImported::getName, keyWord).or()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(AsphaltImported::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(AsphaltImported::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(AsphaltImported::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<AsphaltImported> filterQuery(LambdaQueryWrapper<AsphaltImported> query) {
|
||||||
|
query.in(AsphaltImported::getName, List.of(
|
||||||
|
"新加坡—华东",
|
||||||
|
"韩国—华东",
|
||||||
|
"泰国—华东"
|
||||||
|
));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AsphaltImported getMapGroupingBy(Map item) {
|
||||||
|
var o = new AsphaltImported();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,34 +3,16 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.Cement;
|
import mjkf.xinke.main.model.db.Cement;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CementService extends ServiceImpl<BaseMapper<Cement>, Cement> {
|
public class CementService extends DataService<BaseMapper<Cement>, Cement> {
|
||||||
public boolean saveOrUpdateByIndex(Cement data) {
|
|
||||||
var result = this.getOne(this.indexQuery(data));
|
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Cement> saveOrUpdateByIndexBatch(List<Row> rows) {
|
public LambdaQueryWrapper<Cement> indexQuery(Cement data) {
|
||||||
var list = rows.stream().map(item -> new Cement(item)).collect(Collectors.toList());
|
|
||||||
for (Cement item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<Cement> indexQuery(Cement data) {
|
|
||||||
LambdaQueryWrapper<Cement> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Cement> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(Cement::getName, data.getName());
|
query.eq(Cement::getName, data.getName());
|
||||||
query.eq(Cement::getSpec, data.getSpec());
|
query.eq(Cement::getSpec, data.getSpec());
|
||||||
@@ -39,5 +21,64 @@ public class CementService extends ServiceImpl<BaseMapper<Cement>, Cement> {
|
|||||||
query.eq(Cement::getDate, data.getDate());
|
query.eq(Cement::getDate, data.getDate());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<Cement> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (Cement) obj;
|
||||||
|
LambdaQueryWrapper<Cement> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(Cement::getName, data.getName());
|
||||||
|
query.eq(Cement::getSpec, data.getSpec());
|
||||||
|
query.eq(Cement::getPack, data.getPack());
|
||||||
|
query.eq(Cement::getSource, data.getSource());
|
||||||
|
query.between(Cement::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<Cement> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<Cement> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(Cement::getName, keyWord).or()
|
||||||
|
.like(Cement::getSpec, keyWord).or()
|
||||||
|
.like(Cement::getPack, keyWord).or()
|
||||||
|
.like(Cement::getSource, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(Cement::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(Cement::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(Cement::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<Cement> filterQuery(LambdaQueryWrapper<Cement> query) {
|
||||||
|
query.in(Cement::getName, List.of("P.S.A32.5", "M32.5", "P.P32.5R", "P.O42.5"));
|
||||||
|
query.in(Cement::getPack, List.of("散装"));
|
||||||
|
// query.in(Cement::getSource, List.of("金牛","台泥","炼石牌"));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cement getMapGroupingBy(Map item) {
|
||||||
|
var o = new Cement();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
o.setSpec(item.get("spec").toString());
|
||||||
|
o.setPack(item.get("pack").toString());
|
||||||
|
o.setSource(item.get("source").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
95
src/main/java/mjkf/xinke/main/service/DataService.java
Normal file
95
src/main/java/mjkf/xinke/main/service/DataService.java
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
package mjkf.xinke.main.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public abstract class DataService<M extends BaseMapper<T>, T> extends ServiceImpl {
|
||||||
|
public boolean saveOrUpdateByIndex(T data) throws Exception {
|
||||||
|
var result = this.getOne(this.indexQuery(data));
|
||||||
|
if (result == null) {
|
||||||
|
return this.save(data);
|
||||||
|
} else {
|
||||||
|
Method update = result.getClass().getMethod("update", this.getEntityClass());
|
||||||
|
update.invoke(result, data);
|
||||||
|
return this.updateById(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract LambdaQueryWrapper<T> indexQuery(T data);
|
||||||
|
|
||||||
|
abstract LambdaQueryWrapper<T> filterQuery(LambdaQueryWrapper<T> query);
|
||||||
|
|
||||||
|
public List<T> saveOrUpdateByIndexBatch(List<Row> rows) throws Exception {
|
||||||
|
var list = rows.stream().map(item -> {
|
||||||
|
try {
|
||||||
|
return (T) this.getEntityClass().getConstructor(Row.class).newInstance(item);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
for (T item : list) {
|
||||||
|
this.saveOrUpdateByIndex(item);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<T> getEntityClass() {
|
||||||
|
ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
|
||||||
|
Class<T> clazz = (Class<T>) pt.getActualTypeArguments()[1];
|
||||||
|
return clazz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> listMaps(Wrapper queryWrapper) {
|
||||||
|
List<Map<String, Object>> result = super.listMaps(queryWrapper);
|
||||||
|
var newResult = new ArrayList<Map<String, Object>>();
|
||||||
|
for (Map<String, Object> map: result){
|
||||||
|
var item = new HashMap<String, Object>();
|
||||||
|
for(String key: map.keySet()) {
|
||||||
|
item.put(key.toLowerCase(), map.get(key));
|
||||||
|
}
|
||||||
|
newResult.add(item);
|
||||||
|
}
|
||||||
|
return newResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map statisticItemFromGroup(List<Map<String, Object>> list) {
|
||||||
|
BigDecimal newPrice = (BigDecimal) list.stream().max(Comparator.comparing(item -> (Date) item.get("date"))).get().get("price");
|
||||||
|
Double avgPrice = list.stream().mapToInt(item->((BigDecimal) item.get("price")).intValue()).average().getAsDouble();
|
||||||
|
Date newDate = (Date) list.stream().max(Comparator.comparing(item -> (Date) item.get("date"))).get().get("date");
|
||||||
|
|
||||||
|
var result = list.get(0);
|
||||||
|
result.put("new_price", newPrice.intValue());
|
||||||
|
result.put("avg_price", avgPrice.intValue());
|
||||||
|
result.put("new_date", newDate);
|
||||||
|
result.remove("price");
|
||||||
|
result.remove("date");
|
||||||
|
result.remove("fluctuating");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public T getMapGroupingBy(Map item);
|
||||||
|
|
||||||
|
public List<Map> listStatistics(LambdaQueryWrapper<T> query) {
|
||||||
|
var data = (List<Map<String, Object>>) this.listMaps(query);
|
||||||
|
var groupMap = data.stream().collect(Collectors.groupingBy(item->this.getMapGroupingBy(item), Collectors.toList()));
|
||||||
|
|
||||||
|
var result = new ArrayList();
|
||||||
|
for (T groupKey: groupMap.keySet()) {
|
||||||
|
List group = groupMap.get(groupKey);
|
||||||
|
result.add(this.statisticItemFromGroup(group));
|
||||||
|
}
|
||||||
|
// todo 排序
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
abstract public LambdaQueryWrapper<T> trendQuery(Object data, Integer year, Integer month);
|
||||||
|
}
|
@@ -3,39 +3,69 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.FujianSurvey;
|
import mjkf.xinke.main.model.db.FujianSurvey;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.time.LocalDate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FujianSurveyService extends ServiceImpl<BaseMapper<FujianSurvey>, FujianSurvey> {
|
public class FujianSurveyService extends DataService<BaseMapper<FujianSurvey>, FujianSurvey> {
|
||||||
public boolean saveOrUpdateByIndex(FujianSurvey data) {
|
public LambdaQueryWrapper<FujianSurvey> indexQuery(FujianSurvey data) {
|
||||||
var result = this.getOne(this.indexQuery(data));
|
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FujianSurvey> saveOrUpdateByIndexBatch(List<Row> rows) {
|
|
||||||
var list = rows.stream().map(item -> new FujianSurvey(item)).collect(Collectors.toList());
|
|
||||||
for (FujianSurvey item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<FujianSurvey> indexQuery(FujianSurvey data) {
|
|
||||||
LambdaQueryWrapper<FujianSurvey> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<FujianSurvey> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(FujianSurvey::getName, data.getName());
|
query.eq(FujianSurvey::getName, data.getName());
|
||||||
query.eq(FujianSurvey::getSpec, data.getSpec());
|
query.eq(FujianSurvey::getSpec, data.getSpec());
|
||||||
query.eq(FujianSurvey::getDate, data.getDate());
|
query.eq(FujianSurvey::getDate, data.getDate());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<FujianSurvey> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (FujianSurvey) obj;
|
||||||
|
LambdaQueryWrapper<FujianSurvey> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(FujianSurvey::getName, data.getName());
|
||||||
|
query.eq(FujianSurvey::getSpec, data.getSpec());
|
||||||
|
query.between(FujianSurvey::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<FujianSurvey> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<FujianSurvey> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(FujianSurvey::getName, keyWord).or()
|
||||||
|
.like(FujianSurvey::getSpec, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(FujianSurvey::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(FujianSurvey::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(FujianSurvey::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<FujianSurvey> filterQuery(LambdaQueryWrapper<FujianSurvey> query) {
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FujianSurvey getMapGroupingBy(Map item) {
|
||||||
|
var o = new FujianSurvey();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
o.setSpec(item.get("spec").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,39 +3,70 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.FuzhouHighwayBureau;
|
import mjkf.xinke.main.model.db.FuzhouHighwayBureau;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.time.LocalDate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FuzhouHighwayBureauService extends ServiceImpl<BaseMapper<FuzhouHighwayBureau>, FuzhouHighwayBureau> {
|
public class FuzhouHighwayBureauService extends DataService<BaseMapper<FuzhouHighwayBureau>, FuzhouHighwayBureau> {
|
||||||
public boolean saveOrUpdateByIndex(FuzhouHighwayBureau data) {
|
|
||||||
var result = this.getOne(this.indexQuery(data));
|
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FuzhouHighwayBureau> saveOrUpdateByIndexBatch(List<Row> rows) {
|
public LambdaQueryWrapper<FuzhouHighwayBureau> indexQuery(FuzhouHighwayBureau data) {
|
||||||
var list = rows.stream().map(item -> new FuzhouHighwayBureau(item)).collect(Collectors.toList());
|
|
||||||
for (FuzhouHighwayBureau item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<FuzhouHighwayBureau> indexQuery(FuzhouHighwayBureau data) {
|
|
||||||
LambdaQueryWrapper<FuzhouHighwayBureau> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<FuzhouHighwayBureau> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(FuzhouHighwayBureau::getName, data.getName());
|
query.eq(FuzhouHighwayBureau::getName, data.getName());
|
||||||
query.eq(FuzhouHighwayBureau::getSpec, data.getSpec());
|
query.eq(FuzhouHighwayBureau::getSpec, data.getSpec());
|
||||||
query.eq(FuzhouHighwayBureau::getDate, data.getDate());
|
query.eq(FuzhouHighwayBureau::getDate, data.getDate());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<FuzhouHighwayBureau> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (FuzhouHighwayBureau) obj;
|
||||||
|
LambdaQueryWrapper<FuzhouHighwayBureau> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(FuzhouHighwayBureau::getName, data.getName());
|
||||||
|
query.eq(FuzhouHighwayBureau::getSpec, data.getSpec());
|
||||||
|
query.between(FuzhouHighwayBureau::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<FuzhouHighwayBureau> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<FuzhouHighwayBureau> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(FuzhouHighwayBureau::getName, keyWord).or()
|
||||||
|
.like(FuzhouHighwayBureau::getSpec, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(FuzhouHighwayBureau::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(FuzhouHighwayBureau::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(FuzhouHighwayBureau::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<FuzhouHighwayBureau> filterQuery(LambdaQueryWrapper<FuzhouHighwayBureau> query) {
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FuzhouHighwayBureau getMapGroupingBy(Map item) {
|
||||||
|
var o = new FuzhouHighwayBureau();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
o.setSpec(item.get("spec").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,34 +3,16 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.FuzhouTransportationBureau;
|
import mjkf.xinke.main.model.db.FuzhouTransportationBureau;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.time.LocalDate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FuzhouTransportationBureauService extends ServiceImpl<BaseMapper<FuzhouTransportationBureau>, FuzhouTransportationBureau> {
|
public class FuzhouTransportationBureauService extends DataService<BaseMapper<FuzhouTransportationBureau>, FuzhouTransportationBureau> {
|
||||||
public boolean saveOrUpdateByIndex(FuzhouTransportationBureau data) {
|
|
||||||
var result = this.getOne(this.indexQuery(data));
|
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FuzhouTransportationBureau> saveOrUpdateByIndexBatch(List<Row> rows) {
|
public LambdaQueryWrapper<FuzhouTransportationBureau> indexQuery(FuzhouTransportationBureau data) {
|
||||||
var list = rows.stream().map(item -> new FuzhouTransportationBureau(item)).collect(Collectors.toList());
|
|
||||||
for (FuzhouTransportationBureau item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<FuzhouTransportationBureau> indexQuery(FuzhouTransportationBureau data) {
|
|
||||||
LambdaQueryWrapper<FuzhouTransportationBureau> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<FuzhouTransportationBureau> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(FuzhouTransportationBureau::getName, data.getName());
|
query.eq(FuzhouTransportationBureau::getName, data.getName());
|
||||||
query.eq(FuzhouTransportationBureau::getSpec, data.getSpec());
|
query.eq(FuzhouTransportationBureau::getSpec, data.getSpec());
|
||||||
@@ -38,5 +20,55 @@ public class FuzhouTransportationBureauService extends ServiceImpl<BaseMapper<Fu
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<FuzhouTransportationBureau> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (FuzhouTransportationBureau) obj;
|
||||||
|
LambdaQueryWrapper<FuzhouTransportationBureau> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(FuzhouTransportationBureau::getName, data.getName());
|
||||||
|
query.eq(FuzhouTransportationBureau::getSpec, data.getSpec());
|
||||||
|
query.between(FuzhouTransportationBureau::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<FuzhouTransportationBureau> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<FuzhouTransportationBureau> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(FuzhouTransportationBureau::getName, keyWord).or()
|
||||||
|
.like(FuzhouTransportationBureau::getSpec, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(FuzhouTransportationBureau::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(FuzhouTransportationBureau::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(FuzhouTransportationBureau::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<FuzhouTransportationBureau> filterQuery(LambdaQueryWrapper<FuzhouTransportationBureau> query) {
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FuzhouTransportationBureau getMapGroupingBy(Map item) {
|
||||||
|
var o = new FuzhouTransportationBureau();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
o.setSpec(item.get("spec").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
174
src/main/java/mjkf/xinke/main/service/MaterialResultService.java
Normal file
174
src/main/java/mjkf/xinke/main/service/MaterialResultService.java
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
package mjkf.xinke.main.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import mjkf.xinke.main.constant.MaterialTaskType;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MaterialResultService {
|
||||||
|
@Resource
|
||||||
|
SteelRebarService steelRebarService;
|
||||||
|
@Resource
|
||||||
|
SteelSectionService steelSectionService;
|
||||||
|
@Resource
|
||||||
|
SteelStrandService steelStrandService;
|
||||||
|
@Resource
|
||||||
|
SteelPlateService steelPlateService;
|
||||||
|
@Resource
|
||||||
|
AsphaltDomesticService asphaltDomesticService;
|
||||||
|
@Resource
|
||||||
|
AsphaltImportedService asphaltImportedService;
|
||||||
|
@Resource
|
||||||
|
CementService cementService;
|
||||||
|
@Resource
|
||||||
|
SanmingSteelService sanmingSteelService;
|
||||||
|
@Resource
|
||||||
|
FuzhouTransportationBureauService fuzhouTransportationBureauService;
|
||||||
|
@Resource
|
||||||
|
FuzhouHighwayBureauService fuzhouHighwayBureauService;
|
||||||
|
@Resource
|
||||||
|
FujianSurveyService fujianSurveyService;
|
||||||
|
@Resource
|
||||||
|
OilService oilService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础查询
|
||||||
|
* @param keyWord
|
||||||
|
* @param year
|
||||||
|
* @param month
|
||||||
|
* @param type
|
||||||
|
* @param materialId
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public LambdaQueryWrapper getQuery(
|
||||||
|
String keyWord, Integer year, Integer month, Integer type, String materialId, String name
|
||||||
|
) throws Exception {
|
||||||
|
LambdaQueryWrapper query;
|
||||||
|
var service = this.getService(type);
|
||||||
|
Method getQuery = service.getClass().getMethod(
|
||||||
|
"getQuery",
|
||||||
|
String.class, Integer.class, Integer.class, String.class, String.class
|
||||||
|
);
|
||||||
|
query = (LambdaQueryWrapper) getQuery.invoke(service, keyWord, year, month, materialId, name);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果过滤
|
||||||
|
* @param query
|
||||||
|
* @param type
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public <T> LambdaQueryWrapper<T> filterQuery(LambdaQueryWrapper<T> query, Integer type) throws Exception {
|
||||||
|
var service = this.getService(type);
|
||||||
|
Method getQuery = service.getClass().getMethod("filterQuery", LambdaQueryWrapper.class);
|
||||||
|
query = (LambdaQueryWrapper<T>) getQuery.invoke(service, query);
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格统计
|
||||||
|
* @param query
|
||||||
|
* @param type
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public <T> List<Map> listStatistics(LambdaQueryWrapper<T> query, Integer type) throws Exception {
|
||||||
|
var service = this.getService(type);
|
||||||
|
Method statisticsQuery = service.getClass().getMethod("listStatistics", LambdaQueryWrapper.class);
|
||||||
|
var result = (List<Map>) statisticsQuery.invoke(service, query);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param query
|
||||||
|
* @param type
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public <T> List<T> list(LambdaQueryWrapper<T> query, Integer type) {
|
||||||
|
var service = this.getService(type);
|
||||||
|
var result = service.list(query);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object getById(String id, Integer type) {
|
||||||
|
var service = this.getService(type);
|
||||||
|
var result = service.getById(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对应 service
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IService getService(Integer type) {
|
||||||
|
IService service = null;
|
||||||
|
if (type.equals(MaterialTaskType.MY_STEEL_REBAR)) {
|
||||||
|
service = steelRebarService;
|
||||||
|
} else if (type.equals(MaterialTaskType.MY_STEEL_SECTION)) {
|
||||||
|
service = steelSectionService;
|
||||||
|
} else if (type.equals(MaterialTaskType.MY_STEEL_STRAND)) {
|
||||||
|
service = steelStrandService;
|
||||||
|
} else if (type.equals(MaterialTaskType.MY_STEEL_PLATE)) {
|
||||||
|
service = steelPlateService;
|
||||||
|
} else if (type.equals(MaterialTaskType.BAIINFO_ASPHALT_DOMESTIC)) {
|
||||||
|
service = asphaltDomesticService;
|
||||||
|
} else if (type.equals(MaterialTaskType.BAIINFO_ASPHALT_IMPORTED)) {
|
||||||
|
service = asphaltImportedService;
|
||||||
|
} else if (type.equals(MaterialTaskType.BAIINFO_CEMENT)) {
|
||||||
|
service = cementService;
|
||||||
|
} else if (type.equals(MaterialTaskType.SANMING_STEEL)) {
|
||||||
|
service = sanmingSteelService;
|
||||||
|
} else if (type.equals(MaterialTaskType.FUZHOU_TRANSPORTATION_BUREAU)) {
|
||||||
|
service = fuzhouTransportationBureauService;
|
||||||
|
} else if (type.equals(MaterialTaskType.FUZHOU_HIGHWAY_BUREAU)) {
|
||||||
|
service = fuzhouHighwayBureauService;
|
||||||
|
} else if (type.equals(MaterialTaskType.FUJIAN_SURVEY)) {
|
||||||
|
service = fujianSurveyService;
|
||||||
|
} else if (type.equals(MaterialTaskType.OTHER_ZHEJIANG)) {
|
||||||
|
// service = otherZhejiangService;
|
||||||
|
} else if (type.equals(MaterialTaskType.OTHER_GIANLZHOU)) {
|
||||||
|
// service = otherGianlzhouService;
|
||||||
|
} else if (type.equals(MaterialTaskType.OTHER_YUNNAN)) {
|
||||||
|
// service = otherYunnanService;
|
||||||
|
} else if (type.equals(MaterialTaskType.FUJIAN_DEPARTMENT)) {
|
||||||
|
// service = fujianDepartmentService;
|
||||||
|
} else if (type.equals(MaterialTaskType.OIL)) {
|
||||||
|
service = oilService;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public <T> List<T> getTrend(Object data, Integer year, Integer month, Integer type) throws Exception{
|
||||||
|
var service = this.getService(type);
|
||||||
|
Method trendQuery = service.getClass().getMethod("trendQuery", Object.class, Integer.class, Integer.class);
|
||||||
|
LambdaQueryWrapper query = (LambdaQueryWrapper) trendQuery.invoke(service, data, year, month);
|
||||||
|
var result = service.list(query);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
73
src/main/java/mjkf/xinke/main/service/OilService.java
Normal file
73
src/main/java/mjkf/xinke/main/service/OilService.java
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package mjkf.xinke.main.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import mjkf.xinke.main.model.db.Oil;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class OilService extends DataService<BaseMapper<Oil>, Oil> {
|
||||||
|
public LambdaQueryWrapper<Oil> indexQuery(Oil data) {
|
||||||
|
LambdaQueryWrapper<Oil> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(Oil::getName, data.getName());
|
||||||
|
query.eq(Oil::getDate, data.getDate());
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<Oil> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (Oil) obj;
|
||||||
|
LambdaQueryWrapper<Oil> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(Oil::getName, data.getName());
|
||||||
|
query.between(Oil::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<Oil> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<Oil> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(Oil::getName, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(Oil::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(Oil::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(Oil::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<Oil> filterQuery(LambdaQueryWrapper<Oil> query) {
|
||||||
|
query.in(Oil::getName, List.of(
|
||||||
|
"车用89号汽油(ⅥB)",
|
||||||
|
"车用92号汽油(ⅥB)",
|
||||||
|
"车用0号柴油(Ⅵ)"
|
||||||
|
));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Oil getMapGroupingBy(Map item) {
|
||||||
|
var o = new Oil();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -3,34 +3,14 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.SanmingSteel;
|
import mjkf.xinke.main.model.db.SanmingSteel;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.time.LocalDate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SanmingSteelService extends ServiceImpl<BaseMapper<SanmingSteel>, SanmingSteel> {
|
public class SanmingSteelService extends DataService<BaseMapper<SanmingSteel>, SanmingSteel> {
|
||||||
public boolean saveOrUpdateByIndex(SanmingSteel data) {
|
public LambdaQueryWrapper<SanmingSteel> indexQuery(SanmingSteel data) {
|
||||||
var result = this.getOne(this.indexQuery(data));
|
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SanmingSteel> saveOrUpdateByIndexBatch(List<Row> rows) {
|
|
||||||
var list = rows.stream().map(item -> new SanmingSteel(item)).collect(Collectors.toList());
|
|
||||||
for (SanmingSteel item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<SanmingSteel> indexQuery(SanmingSteel data) {
|
|
||||||
LambdaQueryWrapper<SanmingSteel> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SanmingSteel> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(SanmingSteel::getName, data.getName());
|
query.eq(SanmingSteel::getName, data.getName());
|
||||||
query.eq(SanmingSteel::getSpec, data.getSpec());
|
query.eq(SanmingSteel::getSpec, data.getSpec());
|
||||||
@@ -39,5 +19,58 @@ public class SanmingSteelService extends ServiceImpl<BaseMapper<SanmingSteel>, S
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SanmingSteel> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (SanmingSteel) obj;
|
||||||
|
LambdaQueryWrapper<SanmingSteel> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(SanmingSteel::getName, data.getName());
|
||||||
|
query.eq(SanmingSteel::getSpec, data.getSpec());
|
||||||
|
query.eq(SanmingSteel::getMaterial, data.getMaterial());
|
||||||
|
query.between(SanmingSteel::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SanmingSteel> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<SanmingSteel> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(SanmingSteel::getName, keyWord).or()
|
||||||
|
.like(SanmingSteel::getSpec, keyWord).or()
|
||||||
|
.like(SanmingSteel::getMaterial, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(SanmingSteel::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(SanmingSteel::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(SanmingSteel::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SanmingSteel> filterQuery(LambdaQueryWrapper<SanmingSteel> query) {
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SanmingSteel getMapGroupingBy(Map item) {
|
||||||
|
var o = new SanmingSteel();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
o.setSpec(item.get("spec").toString());
|
||||||
|
o.setMaterial(item.get("material").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,30 +7,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SteelPlateService extends ServiceImpl<BaseMapper<SteelPlate>, SteelPlate> {
|
public class SteelPlateService extends DataService<BaseMapper<SteelPlate>, SteelPlate> {
|
||||||
public boolean saveOrUpdateByIndex(SteelPlate data) {
|
@Override
|
||||||
var result = this.getOne(this.indexQuery(data));
|
public LambdaQueryWrapper<SteelPlate> indexQuery(SteelPlate data) {
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SteelPlate> saveOrUpdateByIndexBatch(List<Row> rows) {
|
|
||||||
var list = rows.stream().map(item -> new SteelPlate(item)).collect(Collectors.toList());
|
|
||||||
for (SteelPlate item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<SteelPlate> indexQuery(SteelPlate data) {
|
|
||||||
LambdaQueryWrapper<SteelPlate> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SteelPlate> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(SteelPlate::getName, data.getName());
|
query.eq(SteelPlate::getName, data.getName());
|
||||||
query.eq(SteelPlate::getSpec, data.getSpec());
|
query.eq(SteelPlate::getSpec, data.getSpec());
|
||||||
@@ -40,5 +25,66 @@ public class SteelPlateService extends ServiceImpl<BaseMapper<SteelPlate>, Steel
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelPlate> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (SteelPlate) obj;
|
||||||
|
LambdaQueryWrapper<SteelPlate> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(SteelPlate::getName, data.getName());
|
||||||
|
query.eq(SteelPlate::getSpec, data.getSpec());
|
||||||
|
query.eq(SteelPlate::getMaterial, data.getMaterial());
|
||||||
|
query.eq(SteelPlate::getSource, data.getSource());
|
||||||
|
query.between(SteelPlate::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelPlate> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<SteelPlate> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(SteelPlate::getName, keyWord).or()
|
||||||
|
.like(SteelPlate::getSpec, keyWord).or()
|
||||||
|
.like(SteelPlate::getMaterial, keyWord).or()
|
||||||
|
.like(SteelPlate::getSource, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(SteelPlate::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(SteelPlate::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(SteelPlate::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelPlate> filterQuery(LambdaQueryWrapper<SteelPlate> query) {
|
||||||
|
query.eq(SteelPlate::getName, "普中板");
|
||||||
|
query.in(SteelPlate::getSpec, List.of("12", "16-20", "22-28"));
|
||||||
|
query.in(SteelPlate::getMaterial, List.of("Q235B"));
|
||||||
|
query.in(SteelPlate::getSource, List.of("三钢闽光"));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SteelPlate getMapGroupingBy(Map item) {
|
||||||
|
var o = new SteelPlate();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
o.setSpec(item.get("spec").toString());
|
||||||
|
o.setMaterial(item.get("material").toString());
|
||||||
|
o.setSource(item.get("source").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,35 +3,16 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.SteelRebar;
|
import mjkf.xinke.main.model.db.SteelRebar;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.time.LocalDate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SteelRebarService extends ServiceImpl<BaseMapper<SteelRebar>, SteelRebar> {
|
public class SteelRebarService extends DataService<BaseMapper<SteelRebar>, SteelRebar> {
|
||||||
|
@Override
|
||||||
public boolean saveOrUpdateByIndex(SteelRebar data) {
|
public LambdaQueryWrapper<SteelRebar> indexQuery(SteelRebar data) {
|
||||||
var result = this.getOne(this.indexQuery(data));
|
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SteelRebar> saveOrUpdateByIndexBatch(List<Row> rows) {
|
|
||||||
var list = rows.stream().map(item -> new SteelRebar(item)).collect(Collectors.toList());
|
|
||||||
for (SteelRebar item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<SteelRebar> indexQuery(SteelRebar data) {
|
|
||||||
LambdaQueryWrapper<SteelRebar> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SteelRebar> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(SteelRebar::getName, data.getName());
|
query.eq(SteelRebar::getName, data.getName());
|
||||||
query.eq(SteelRebar::getSpec, data.getSpec());
|
query.eq(SteelRebar::getSpec, data.getSpec());
|
||||||
@@ -41,5 +22,64 @@ public class SteelRebarService extends ServiceImpl<BaseMapper<SteelRebar>, Steel
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelRebar> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (SteelRebar) obj;
|
||||||
|
LambdaQueryWrapper<SteelRebar> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(SteelRebar::getName, data.getName());
|
||||||
|
query.eq(SteelRebar::getSpec, data.getSpec());
|
||||||
|
query.eq(SteelRebar::getMaterial, data.getMaterial());
|
||||||
|
query.eq(SteelRebar::getSource, data.getSource());
|
||||||
|
query.between(SteelRebar::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelRebar> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<SteelRebar> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(SteelRebar::getName, keyWord).or()
|
||||||
|
.like(SteelRebar::getSpec, keyWord).or()
|
||||||
|
.like(SteelRebar::getMaterial, keyWord).or()
|
||||||
|
.like(SteelRebar::getSource, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(SteelRebar::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(SteelRebar::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(SteelRebar::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelRebar::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelRebar> filterQuery(LambdaQueryWrapper<SteelRebar> query) {
|
||||||
|
query.in(SteelRebar::getName, List.of("高线", "螺纹钢"));
|
||||||
|
query.in(SteelRebar::getSpec, List.of("Φ6", "Φ8-10", "Φ12", "Φ14", "Φ18-22", "Φ28-32"));
|
||||||
|
query.in(SteelRebar::getMaterial, List.of("HPB300", "HRB400E"));
|
||||||
|
query.in(SteelRebar::getSource, List.of("三钢闽光"));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SteelRebar getMapGroupingBy(Map item) {
|
||||||
|
var o = new SteelRebar();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
o.setSpec(item.get("spec").toString());
|
||||||
|
o.setMaterial(item.get("material").toString());
|
||||||
|
o.setSource(item.get("source").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,34 +3,17 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.SteelSection;
|
import mjkf.xinke.main.model.db.SteelSection;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SteelSectionService extends ServiceImpl<BaseMapper<SteelSection>, SteelSection> {
|
public class SteelSectionService extends DataService<BaseMapper<SteelSection>, SteelSection> {
|
||||||
public boolean saveOrUpdateByIndex(SteelSection data) {
|
@Override
|
||||||
var result = this.getOne(this.indexQuery(data));
|
public LambdaQueryWrapper<SteelSection> indexQuery(SteelSection data) {
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SteelSection> saveOrUpdateByIndexBatch(List<Row> rows) {
|
|
||||||
var list = rows.stream().map(item -> new SteelSection(item)).collect(Collectors.toList());
|
|
||||||
for (SteelSection item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<SteelSection> indexQuery(SteelSection data) {
|
|
||||||
LambdaQueryWrapper<SteelSection> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SteelSection> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(SteelSection::getName, data.getName());
|
query.eq(SteelSection::getName, data.getName());
|
||||||
query.eq(SteelSection::getSpec, data.getSpec());
|
query.eq(SteelSection::getSpec, data.getSpec());
|
||||||
@@ -39,5 +22,65 @@ public class SteelSectionService extends ServiceImpl<BaseMapper<SteelSection>, S
|
|||||||
query.eq(SteelSection::getDate, data.getDate());
|
query.eq(SteelSection::getDate, data.getDate());
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelSection> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (SteelSection) obj;
|
||||||
|
LambdaQueryWrapper<SteelSection> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(SteelSection::getName, data.getName());
|
||||||
|
query.eq(SteelSection::getSpec, data.getSpec());
|
||||||
|
query.eq(SteelSection::getMaterial, data.getMaterial());
|
||||||
|
query.eq(SteelSection::getSource, data.getSource());
|
||||||
|
query.between(SteelSection::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelSection> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<SteelSection> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(SteelSection::getName, keyWord).or()
|
||||||
|
.like(SteelSection::getSpec, keyWord).or()
|
||||||
|
.like(SteelSection::getMaterial, keyWord).or()
|
||||||
|
.like(SteelSection::getSource, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(SteelSection::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(SteelSection::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(SteelSection::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelSection> filterQuery(LambdaQueryWrapper<SteelSection> query) {
|
||||||
|
query.in(SteelSection::getName, List.of("角钢", "工字钢"));
|
||||||
|
query.in(SteelSection::getSpec, List.of("140*140*12", "25#"));
|
||||||
|
query.in(SteelSection::getMaterial, List.of("Q235B"));
|
||||||
|
query.in(SteelSection::getSource, List.of("唐山正丰", "唐山弘泰"));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SteelSection getMapGroupingBy(Map item) {
|
||||||
|
var o = new SteelSection();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
o.setSpec(item.get("spec").toString());
|
||||||
|
o.setMaterial(item.get("material").toString());
|
||||||
|
o.setSource(item.get("source").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,34 +3,17 @@ package mjkf.xinke.main.service;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import mjkf.xinke.main.model.db.SteelStrand;
|
import mjkf.xinke.main.model.db.SteelStrand;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SteelStrandService extends ServiceImpl<BaseMapper<SteelStrand>, SteelStrand> {
|
public class SteelStrandService extends DataService<BaseMapper<SteelStrand>, SteelStrand> {
|
||||||
public boolean saveOrUpdateByIndex(SteelStrand data) {
|
|
||||||
var result = this.getOne(this.indexQuery(data));
|
|
||||||
if (result == null) {
|
|
||||||
return this.save(data);
|
|
||||||
} else {
|
|
||||||
result.update(data);
|
|
||||||
return this.updateById(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SteelStrand> saveOrUpdateByIndexBatch(List<Row> rows) {
|
@Override
|
||||||
var list = rows.stream().map(item -> new SteelStrand(item)).collect(Collectors.toList());
|
public LambdaQueryWrapper<SteelStrand> indexQuery(SteelStrand data) {
|
||||||
for (SteelStrand item : list) {
|
|
||||||
this.saveOrUpdateByIndex(item);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<SteelStrand> indexQuery(SteelStrand data) {
|
|
||||||
LambdaQueryWrapper<SteelStrand> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SteelStrand> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(SteelStrand::getName, data.getName());
|
query.eq(SteelStrand::getName, data.getName());
|
||||||
query.eq(SteelStrand::getSpec, data.getSpec());
|
query.eq(SteelStrand::getSpec, data.getSpec());
|
||||||
@@ -40,5 +23,63 @@ public class SteelStrandService extends ServiceImpl<BaseMapper<SteelStrand>, Ste
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelStrand> trendQuery(Object obj, Integer year, Integer month) {
|
||||||
|
var data = (SteelStrand) obj;
|
||||||
|
LambdaQueryWrapper<SteelStrand> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(SteelStrand::getName, data.getName());
|
||||||
|
query.eq(SteelStrand::getSpec, data.getSpec());
|
||||||
|
query.eq(SteelStrand::getMaterial, data.getMaterial());
|
||||||
|
query.eq(SteelStrand::getSource, data.getSource());
|
||||||
|
query.between(SteelStrand::getDate, LocalDate.of(year, month, 1), LocalDate.of(year, month + 1, 1));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelStrand> getQuery(String keyWord, Integer year, Integer month, String materialId, String name) {
|
||||||
|
LambdaQueryWrapper<SteelStrand> query = new LambdaQueryWrapper<>();
|
||||||
|
if (keyWord != null) {
|
||||||
|
query.and(e -> e
|
||||||
|
.like(SteelStrand::getName, keyWord).or()
|
||||||
|
.like(SteelStrand::getSpec, keyWord).or()
|
||||||
|
.like(SteelStrand::getMaterial, keyWord).or()
|
||||||
|
.like(SteelStrand::getSource, keyWord)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (year != null) {
|
||||||
|
query.between(SteelStrand::getDate,
|
||||||
|
LocalDate.of(year, 1, 1),
|
||||||
|
LocalDate.of(year + 1, 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (month != null) {
|
||||||
|
query.between(SteelStrand::getDate,
|
||||||
|
LocalDate.of(year, month, 1),
|
||||||
|
LocalDate.of(year, month + 1, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
query.like(SteelStrand::getName, name);
|
||||||
|
}
|
||||||
|
if (materialId != null) {
|
||||||
|
// todo
|
||||||
|
// query.eq(SteelSection::getMaterialId, materialId);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LambdaQueryWrapper<SteelStrand> filterQuery(LambdaQueryWrapper<SteelStrand> query) {
|
||||||
|
query.in(SteelStrand::getName, List.of("弹簧钢"));
|
||||||
|
query.in(SteelStrand::getSpec, List.of("φ6.5-9"));
|
||||||
|
query.in(SteelStrand::getMaterial, List.of("SWRH82B"));
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SteelStrand getMapGroupingBy(Map item) {
|
||||||
|
var o = new SteelStrand();
|
||||||
|
o.setName(item.get("name").toString());
|
||||||
|
o.setSpec(item.get("spec").toString());
|
||||||
|
o.setMaterial(item.get("material").toString());
|
||||||
|
o.setSource(item.get("source").toString());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,8 +30,6 @@ mybatis-plus:
|
|||||||
configuration:
|
configuration:
|
||||||
jdbc-type-for-null: 'null'
|
jdbc-type-for-null: 'null'
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
|
|
||||||
global-config:
|
global-config:
|
||||||
banner: false
|
banner: false
|
||||||
db-config:
|
db-config:
|
||||||
|
Reference in New Issue
Block a user