feat: 新增数据展示相关接口
This commit is contained in:
@@ -2,7 +2,6 @@ package mjkf.xinke.main.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MaterialTaskType {
|
||||
// 钢筋网
|
||||
@@ -72,14 +71,17 @@ public class MaterialTaskType {
|
||||
// 辅材
|
||||
public static final Integer ASPHALT_MODIFIER = 1001; // 改性剂
|
||||
// 新地材
|
||||
public static final Integer LOCAL_FUZHOU = 1101; // 福州
|
||||
public static final Integer LOCAL_LONGYAN = 1102; // 龙岩
|
||||
public static final Integer LOCAL_NANPING = 1103; // 南平
|
||||
public static final Integer LOCAL_NINGDE = 1104; // 宁德
|
||||
public static final Integer LOCAL_PUTIAN = 1105; // 莆田
|
||||
public static final Integer LOCAL_QUANZHOU = 1106; // 泉州
|
||||
public static final Integer LOCAL_SANMING = 1107; // 三明
|
||||
public static final Integer LOCAL_ZHANGZHOU = 1108; // 漳州
|
||||
public static final Integer LOCAL_FUZHOU = 1101; // 福州地材
|
||||
public static final Integer LOCAL_LONGYAN = 1102; // 龙岩地材
|
||||
public static final Integer LOCAL_NANPING = 1103; // 南平地材
|
||||
public static final Integer LOCAL_NINGDE = 1104; // 宁德地材
|
||||
@Deprecated public static final Integer LOCAL_PINTAN = 1105; // 平潭地材
|
||||
public static final Integer LOCAL_PUTIAN = 1106; // 莆田地材
|
||||
public static final Integer LOCAL_QUANZHOU = 1107; // 泉州地材
|
||||
public static final Integer LOCAL_SANMING = 1108; // 三明地材
|
||||
@Deprecated public static final Integer LOCAL_XIAMEN = 1109; // 厦门地材
|
||||
public static final Integer LOCAL_ZHANGZHOU = 1110; // 漳州地材
|
||||
@Deprecated public static final Integer LOCAL_ZHANGZHOUKFQ = 1111; // 漳州开发区地材
|
||||
// 网络价格
|
||||
public static final Integer FUZHOU_NETWORK = 1201; // 福州网络价格
|
||||
public static final Integer LONGYAN_NETWORK = 1202; // 龙岩网络价格
|
||||
@@ -155,10 +157,13 @@ public class MaterialTaskType {
|
||||
LOCAL_LONGYAN,
|
||||
LOCAL_NANPING,
|
||||
LOCAL_NINGDE,
|
||||
LOCAL_PINTAN,
|
||||
LOCAL_PUTIAN,
|
||||
LOCAL_QUANZHOU,
|
||||
LOCAL_SANMING,
|
||||
LOCAL_ZHANGZHOU
|
||||
LOCAL_XIAMEN,
|
||||
LOCAL_ZHANGZHOU,
|
||||
LOCAL_ZHANGZHOUKFQ
|
||||
);
|
||||
|
||||
public static String getRegion (Integer type) {
|
||||
@@ -203,10 +208,13 @@ public class MaterialTaskType {
|
||||
LOCAL_LONGYAN,
|
||||
LOCAL_NANPING,
|
||||
LOCAL_NINGDE,
|
||||
LOCAL_PINTAN,
|
||||
LOCAL_PUTIAN,
|
||||
LOCAL_QUANZHOU,
|
||||
LOCAL_SANMING,
|
||||
LOCAL_ZHANGZHOU
|
||||
LOCAL_XIAMEN,
|
||||
LOCAL_ZHANGZHOU,
|
||||
LOCAL_ZHANGZHOUKFQ
|
||||
);
|
||||
return dataFromSpiderTypes.contains(type);
|
||||
}
|
||||
|
@@ -0,0 +1,93 @@
|
||||
package mjkf.xinke.main.controller;
|
||||
|
||||
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.model.db.LocalMaterial;
|
||||
import mjkf.xinke.main.service.LocalMaterialService;
|
||||
import mjkf.xinke.main.service.PriceResultService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data-showing")
|
||||
public class DataShowingController {
|
||||
|
||||
@Resource
|
||||
PriceResultService priceResultService;
|
||||
|
||||
@Resource
|
||||
LocalMaterialService localMaterialService;
|
||||
|
||||
@ApiOperation("钢材")
|
||||
@GetMapping("/steel")
|
||||
public HttpResponse steel (
|
||||
@ApiParam(value = "名称") @RequestParam(value="name", required = false) String name
|
||||
) throws Exception {
|
||||
var query = priceResultService.getQueryByName(name);
|
||||
query = priceResultService.queryLastYear(query);
|
||||
var result = priceResultService.list(query);
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
}
|
||||
|
||||
@ApiOperation("沥青")
|
||||
@GetMapping("/asphalt")
|
||||
public HttpResponse asphalt (
|
||||
@ApiParam(value = "名称") @RequestParam(value="name", required = false) String name
|
||||
) throws Exception {
|
||||
var query = priceResultService.getQueryByName(name);
|
||||
query = priceResultService.queryLastYear(query);
|
||||
var result = priceResultService.list(query);
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
}
|
||||
|
||||
@ApiOperation("水泥")
|
||||
@GetMapping("/cement")
|
||||
public HttpResponse cement (
|
||||
@ApiParam(value = "名称") @RequestParam(value="name", required = false) String name
|
||||
) throws Exception {
|
||||
var query = priceResultService.getQueryByName(name);
|
||||
query = priceResultService.queryLastYear(query);
|
||||
var result = priceResultService.list(query);
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
}
|
||||
|
||||
@ApiOperation("汽油")
|
||||
@GetMapping("/gasoline")
|
||||
public HttpResponse gasoline (
|
||||
@ApiParam(value = "名称") @RequestParam(value="name", required = false) String name
|
||||
) throws Exception {
|
||||
var query = priceResultService.getQueryByName(name);
|
||||
query = priceResultService.queryLastYear(query);
|
||||
var result = priceResultService.list(query);
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
}
|
||||
|
||||
@ApiOperation("地材")
|
||||
@GetMapping("/local-material")
|
||||
public HttpResponse localMaterial (
|
||||
@ApiParam(value = "名称") @RequestParam(value="name", required = false) String name
|
||||
) throws Exception {
|
||||
// 中(粗)砂、碎石、机制砂
|
||||
var query = localMaterialService.getQueryByName(name);
|
||||
query = localMaterialService.queryLastYear(query);
|
||||
var result = localMaterialService.list(query);
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
}
|
||||
|
||||
@ApiOperation("商混")
|
||||
@GetMapping("/commercial-concrete")
|
||||
public HttpResponse commercialConcrete (
|
||||
@ApiParam(value = "名称") @RequestParam(value="name", required = false) String name
|
||||
) throws Exception {
|
||||
// 商品混凝土
|
||||
var query = localMaterialService.getQueryByName(name);
|
||||
query.like(LocalMaterial::getSpec,"C40");
|
||||
query = localMaterialService.queryLastYear(query);
|
||||
var result = localMaterialService.list(query);
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
}
|
||||
}
|
@@ -97,8 +97,7 @@ public class PriceResultController {
|
||||
throw new NcHttpException(HttpErrorResponseEnum.PRICE_RESULT_NOT_FOUND);
|
||||
}
|
||||
var query = priceResultService.getQueryByName(data.getName());
|
||||
query.orderByAsc(PriceResult::getYear, PriceResult::getMonth);
|
||||
|
||||
query = priceResultService.queryLastYear(query);
|
||||
var result = priceResultService.list(query);
|
||||
|
||||
return FuHttpResponse.Builder().dataResponse(result).build();
|
||||
|
@@ -87,8 +87,8 @@ public class DataNetwork extends Model<DataNetwork> {
|
||||
var policy = Row.MissingCellPolicy.CREATE_NULL_AS_BLANK;
|
||||
row.getCell(0, policy).setCellType(CellType.STRING);
|
||||
this.setMaterialId(row.getCell(0, policy).getStringCellValue());
|
||||
this.setName(row.getCell(1, policy).getStringCellValue());
|
||||
this.setSpec(row.getCell(2, policy).getStringCellValue());
|
||||
this.setName(row.getCell(1, policy).getStringCellValue().replace(" ", ""));
|
||||
this.setSpec(row.getCell(2, policy).getStringCellValue().replace(" ", ""));
|
||||
this.setUnit(row.getCell(3, policy).getStringCellValue());
|
||||
this.setBrand(row.getCell(4, policy).getStringCellValue());
|
||||
this.setPrice(BigDecimal.valueOf(row.getCell(5, policy).getNumericCellValue()));
|
||||
|
@@ -100,5 +100,21 @@ public class LocalMaterialService extends DataService<BaseMapper<LocalMaterial>,
|
||||
o.setName(item.get("name").toString());
|
||||
return o;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapper<LocalMaterial> getQueryByName(String name) {
|
||||
LambdaQueryWrapper<LocalMaterial> query = new LambdaQueryWrapper<>();
|
||||
query.eq(LocalMaterial::getName, name);
|
||||
return query;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapper<LocalMaterial> queryLastYear (LambdaQueryWrapper<LocalMaterial> query) {
|
||||
var endDate = LocalDate.now();
|
||||
var startDate = endDate.minusYears(1);
|
||||
query.between(LocalMaterial::getDate, startDate, endDate); // 过去一年
|
||||
query.orderByAsc(LocalMaterial::getDate);
|
||||
query.orderByAsc(LocalMaterial::getCity);
|
||||
query.orderByAsc(LocalMaterial::getCounty);
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
||||
@Service
|
||||
public class PriceResultService extends ServiceImpl<BaseMapper<PriceResult>, PriceResult> {
|
||||
@@ -29,5 +31,19 @@ public class PriceResultService extends ServiceImpl<BaseMapper<PriceResult>, Pri
|
||||
public LambdaQueryWrapper<PriceResult> getQueryByName(String name) {
|
||||
return this.getQuery(null, null, null, name);
|
||||
}
|
||||
|
||||
public LambdaQueryWrapper<PriceResult> queryLastYear (LambdaQueryWrapper<PriceResult> query) {
|
||||
var endDate = LocalDate.now();
|
||||
var startDate = endDate.minusYears(1);
|
||||
// 过去一年
|
||||
query.and(e -> e
|
||||
.eq(PriceResult::getYear, startDate.getYear())
|
||||
.between(PriceResult::getMonth, startDate.getMonth(), 12).or()
|
||||
.eq(PriceResult::getYear, endDate.getYear())
|
||||
.between(PriceResult::getMonth, 1, endDate.getMonth())
|
||||
);
|
||||
query.orderByAsc(PriceResult::getYear, PriceResult::getMonth);
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user