库存列表 导入导出
库存记录 更新供应商 最后一次进货时间
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
package cn.ysk.cashier.controller.product;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.dto.product.OutAndOnDto;
|
||||
import cn.ysk.cashier.dto.product.StockQueryDto;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.service.TbProductStockOperateService;
|
||||
import cn.ysk.cashier.service.product.StockService;
|
||||
import cn.ysk.cashier.vo.StockVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "库存管理")
|
||||
@RequestMapping("/api/stock")
|
||||
@Slf4j
|
||||
public class StockController {
|
||||
|
||||
private final StockService stockService;
|
||||
private final TbProductStockOperateService stockOperateService;
|
||||
|
||||
@ApiOperation("库存导出")
|
||||
@PostMapping(value = "download")
|
||||
public void exportTbOrderInfo(HttpServletResponse response, @RequestBody StockQueryDto criteria) throws IOException {
|
||||
stockService.download(criteria,response);
|
||||
}
|
||||
|
||||
@Log("库存导入")
|
||||
@PostMapping("/doImport")
|
||||
@ApiOperation("文件导入库存")
|
||||
public ResponseEntity<Object> importExcel(@RequestParam String shopId,@RequestParam("file") MultipartFile file) {
|
||||
String fileName = file.getOriginalFilename();
|
||||
if (file.isEmpty()) {
|
||||
throw new BadRequestException("文件不能为空");
|
||||
}
|
||||
if (!fileName.contains("xls") && !fileName.contains("xlsx")) {
|
||||
throw new BadRequestException("文件格式不正确");
|
||||
}
|
||||
try {
|
||||
//根据路径获取这个操作excel的实例
|
||||
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(file.getInputStream());
|
||||
//根据页面index 获取sheet页
|
||||
XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
|
||||
XSSFRow row = null;
|
||||
List<StockVo> list=new ArrayList<>();
|
||||
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
|
||||
row = sheet.getRow(i);
|
||||
if(row!=null){
|
||||
if(row.getCell(0)!=null){
|
||||
list.add(new StockVo(
|
||||
Integer.valueOf(row.getCell(0).getRawValue()),
|
||||
row.getCell(1).toString(),
|
||||
row.getCell(4).toString(),
|
||||
row.getCell(3).toString(),
|
||||
row.getCell(5).toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("库存导入.importExcel.data:"+list);
|
||||
OutAndOnDto outAndOnDto=new OutAndOnDto();
|
||||
outAndOnDto.setShopId(shopId);
|
||||
outAndOnDto.setList(new ArrayList<>(list));
|
||||
outAndOnDto.setType("purchase");
|
||||
outAndOnDto.setRemark("一次性导入库存");
|
||||
outAndOnDto.setIsImport("true");
|
||||
outAndOnDto.setTime(System.currentTimeMillis());
|
||||
outAndOnDto.setTotalAmount(BigDecimal.ZERO);
|
||||
outAndOnDto.setPaidAmount(BigDecimal.ZERO);
|
||||
stockOperateService.createOutAndONOperate(outAndOnDto);
|
||||
stockService.inHouse(shopId,list);
|
||||
} catch (Exception e) {
|
||||
log.error("文件导入库存异常:",e);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询库存")
|
||||
public ResponseEntity<Object> queryTbProduct(StockQueryDto criteria,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10") Integer size){
|
||||
return new ResponseEntity<>(stockService.queryAll(criteria,page,size), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/isStock")
|
||||
public ResponseEntity<Object> updateIsHot(
|
||||
@RequestParam String shopId,
|
||||
@RequestParam Integer proId,
|
||||
@RequestParam Integer isStock){
|
||||
stockService.updateIsStock(proId,shopId,isStock);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/product管理")
|
||||
@Api(tags = "商品管理")
|
||||
@RequestMapping("/api/tbProduct")
|
||||
public class TbProductController {
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "product/spec管理")
|
||||
@Api(tags = "商品规格管理")
|
||||
@RequestMapping("/api/tbProductSpec")
|
||||
public class TbProductSpecController {
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/shop/purveyorTransact管理")
|
||||
@Api(tags = "帐目往来管理")
|
||||
@RequestMapping("/api/tbShopPurveyorTransact")
|
||||
public class TbShopPurveyorTransactController {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class TbShopPurveyorTransactController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@ApiOperation("查询/shop/purveyorTransact")
|
||||
@ApiOperation("查询帐目往来")
|
||||
public ResponseEntity<Object> queryTbShopPurveyorTransactSum(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbShopPurveyorTransactService.queryTransactDate(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
@@ -84,20 +84,20 @@ public class TbShopPurveyorTransactController {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("新增/shop/purveyorTransact")
|
||||
@ApiOperation("新增帐目往来")
|
||||
public ResponseEntity<Object> createTbShopPurveyorTransact(@Validated @RequestBody TbShopPurveyorTransact resources){
|
||||
return new ResponseEntity<>(tbShopPurveyorTransactService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("修改/shop/purveyorTransact")
|
||||
@ApiOperation("修改帐目往来")
|
||||
public ResponseEntity<Object> updateTbShopPurveyorTransact(@Validated @RequestBody TbShopPurveyorTransact resources){
|
||||
tbShopPurveyorTransactService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation("删除/shop/purveyorTransact")
|
||||
@ApiOperation("删除帐目往来")
|
||||
public ResponseEntity<Object> deleteTbShopPurveyorTransact(@RequestBody Integer[] ids) {
|
||||
tbShopPurveyorTransactService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
Reference in New Issue
Block a user