| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.dto.SaleMaterialDto; |
| | | import com.yuanchu.mom.pojo.vo.SaleVo; |
| | | import com.yuanchu.mom.service.RepertoryService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | |
| | | @Resource |
| | | Jwt jwt; |
| | | |
| | | @Resource |
| | | RepertoryService repertoryService; |
| | | |
| | | @ApiOperation(value = "查询销售单列表") |
| | | @ApiImplicitParams(value = { |
| | |
| | | @ApiOperation(value = "新增销售单") |
| | | @PostMapping("/addSale") |
| | | public Result addSale(@RequestHeader("token") String token,@Validated @RequestBody SaleDto saleDto) throws Exception { |
| | | //校验,同一个产品的规格型号不能相同 |
| | | List<SaleMaterialDto> saleMaterialList = saleDto.getSaleMaterialList(); |
| | | // 使用哈希集合来判断是否存在相同字段值组合 |
| | | Set<String> seen = new HashSet<>(); |
| | | for (SaleMaterialDto saleMaterial: saleMaterialList) { |
| | | String key = saleMaterial.getName() + "," + saleMaterial.getSpecifications(); |
| | | if (seen.contains(key)) { |
| | | return Result.fail("同一个产品的规格型号不能相同"); |
| | | } else { |
| | | seen.add(key); |
| | | } |
| | | } |
| | | Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); |
| | | saleService.addSale(data.get("name").replaceAll("\"", ""), saleDto); |
| | | return Result.success("新增成功!"); |