| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.Sale; |
| | | import com.yuanchu.mom.pojo.dto.ConsignmentDto; |
| | | import com.yuanchu.mom.service.SaleService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.yuanchu.mom.service.ConsignmentService; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Wrapper; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(name = "orderNumber", value = "订单编号", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @GetMapping("/selSale") |
| | | public Result selSale(String orderNumber ) { |
| | | public Result selSale(String orderNumber) { |
| | | //只有销售单审核通过之后才能发货 |
| | | Sale sale = saleService.getOne(Wrappers.<Sale>query().eq("order_number", orderNumber)); |
| | | if (ObjectUtils.isEmpty(sale.getType()) || sale.getType() != 1 ) { |
| | | return Result.fail("只有销售单审核通过之后才能发货!"); |
| | | } |
| | | return Result.success(saleService.selSale(orderNumber)); |
| | | } |
| | | |
| | | @ApiOperation(value = "新增成品发货") |
| | | @PostMapping("/addCon") |
| | | public Result addCon(@RequestHeader("token") String token, @RequestBody ConsignmentDto consignmentDto) throws Exception { |
| | | public Result addCon(@RequestHeader("token") String token, @Validated @RequestBody ConsignmentDto consignmentDto) throws Exception { |
| | | Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); |
| | | return Result.success(consignmentService.addCon(data.get("name").replaceAll("\"", ""), consignmentDto)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "查询发货记录列表") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "name", value = "产品名称", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "specifications", value = "产品型号", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "time", value = "发货日期", dataTypeClass = String.class) |
| | | }) |
| | | @GetMapping("/selectAllCon") |
| | | public Result selectAllCon(int pageSize, int countSize, String name, String specifications, String time) { |
| | | IPage<Map<String, Object>> consignmentPage = consignmentService.selectAllCon(new Page<Object>(pageSize, countSize), name, specifications, time); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("total", consignmentPage.getTotal()); |
| | | map.put("row", consignmentPage.getRecords()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation(value = "根据发货id删除") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "发货id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/delCon") |
| | | public Result delCon(Integer id) { |
| | | consignmentService.delCon(id); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "批量删除") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "ids", value = "ids", dataTypeClass = Integer.class, dataType = "List", required = true) |
| | | }) |
| | | @PostMapping("/delAllCon") |
| | | public Result delAllCon(@RequestParam("ids") List<Integer> ids) { |
| | | consignmentService.delAllCon(ids); |
| | | return Result.success(); |
| | | } |
| | | |
| | | } |
| | | |