Browse Source

feat(all): 添加价格导入。

dist.1.3.0
zhaoqiaobo 9 months ago
parent
commit
02d928a4d0
  1. 26
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataPriceController.java
  2. 10
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java
  3. 18
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java

26
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataPriceController.java

@ -23,6 +23,8 @@ import com.logpm.basicdata.vo.BasicdataPriceBasicUpdateVO;
import com.logpm.basicdata.vo.BasicdataPricePageVO;
import com.logpm.basicdata.vo.PriceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
@ -32,12 +34,16 @@ import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.io.InputStream;
/**
* 基础价格表 控制器
@ -90,12 +96,30 @@ public class BasicdataPriceController extends BladeController {
* 基础价格表 修改
*/
@PutMapping
@ApiOperationSupport(order = 3)
@ApiOperationSupport(order = 5)
@ApiOperation(value = "修改", notes = "传入basicdataPrice")
public R<Boolean> update(@Valid @RequestBody PriceVO vo) {
Boolean res = basicdataPriceService.updatePrice(vo);
return R.status(res);
}
/**
* 基础价格表 导入
*/
@PostMapping("upload")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "导入", notes = "导入")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "文件", dataType = "MultipartFile")
})
public R<String> upload(@RequestPart("file") MultipartFile file) {
try (InputStream inputStream = file.getInputStream()) {
String res = basicdataPriceService.upload(inputStream);
return R.data(res);
} catch (Exception e) {
e.printStackTrace();
}
return R.data("上传失败");
}
}

10
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java

@ -26,7 +26,9 @@ import com.logpm.basicdata.vo.BasicdataPricePageVO;
import com.logpm.basicdata.vo.PriceClientVO;
import com.logpm.basicdata.vo.PriceVO;
import org.springblade.core.mp.base.BaseService;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.util.List;
/**
@ -68,4 +70,12 @@ public interface IBasicdataPriceService extends BaseService<BasicdataPriceEntity
* @return
*/
PriceClientVO price(BasicdatPriceApiVO param);
/**
* 导入价格
*
* @param file 需要上传的文件类型为MultipartFile
* @return 返回上传结果一般为上传成功或失败的信息
*/
String upload(InputStream file);
}

18
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java

@ -23,6 +23,8 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -76,7 +78,9 @@ import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@ -373,6 +377,20 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
return priceClientVO;
}
@Override
public String upload(InputStream file) {
StringBuilder message = new StringBuilder();
ExcelReader build = null;
try {
build = EasyExcel.read(file).build();
// 从build中获取5个sheet的数据
}catch (Exception e){
}
return null;
}
private void buildDetailMap(BasicdataPriceEntity priceEntity, Map<Integer, List<BasicdataPriceFullVehicleEntity>> fullMap, Map<Integer, List<BasicdataPriceCategoryBasicEntity>> basicMap, Map<Integer, List<BasicdataPriceCategoryWarehouseEntity>> warehouseMap, Map<Integer, List<BasicdataPriceCategoryDispatchEntity>> dispatchMap, Map<Integer, List<BasicdataPriceGeneralEntity>> generalMap) {
// 获取整车数据
List<BasicdataPriceFullVehicleEntity> list = fullVehicleService.list(Wrappers.<BasicdataPriceFullVehicleEntity>lambdaQuery()

Loading…
Cancel
Save