| | |
| | | |
| | | 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; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.spring.web.json.Json; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | |
| | | @Resource |
| | | Jwt jwt; |
| | | |
| | | @Resource |
| | | RepertoryService repertoryService; |
| | | |
| | | @ApiOperation(value = "查询销售单列表") |
| | | @ApiImplicitParams(value = { |
| | |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation(value = "新增销售单-->添加产品-->查询成品库存") |
| | | @PostMapping("/seleRepe") |
| | | public Result seleRepe() { |
| | | return Result.success(repertoryService.getSale()); |
| | | } |
| | | |
| | | @ApiOperation(value = "新增销售单") |
| | | @PostMapping("/addSale") |
| | | public Result addSale(@RequestHeader("token") String token, @RequestBody SaleDto saleDto) throws Exception { |
| | | 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("新增成功!"); |
| | |
| | | |
| | | @ApiOperation(value = "根据销售单id修改详情信息") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "销售单id", dataTypeClass = Integer.class, required = true) |
| | | @ApiImplicitParam(name = "id", value = "销售单id", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "id", value = "json格式的销售单内容", dataTypeClass = Json.class, required = true) |
| | | }) |
| | | @PostMapping("/updateSaleById") |
| | | public Result updateSaleById(@RequestHeader("token") String token, Integer id, @RequestBody SaleVo saleVo) throws Exception { |
| | | public Result updateSaleById(@RequestHeader("token") String token, Integer id, String str) throws Exception { |
| | | SaleVo saleVo = JackSonUtil.unmarshal(str, SaleVo.class); |
| | | Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); |
| | | saleService.updateSaleById(data.get("name").replaceAll("\"", ""),id, saleVo); |
| | | return Result.success("修改成功!"); |
| | | return Result.success(saleService.updateSaleById(data.get("name").replaceAll("\"", ""), id, saleVo)); |
| | | } |
| | | |
| | | @ApiOperation(value = "根据销售单id删除") |
| | |
| | | |
| | | @ApiOperation(value = "批量删除") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "ids", value = "ids", dataTypeClass = Integer.class, dataType = "List",required = true) |
| | | @ApiImplicitParam(name = "ids", value = "ids", dataTypeClass = String.class,required = true) |
| | | }) |
| | | @PostMapping("/delAllSale") |
| | | public Result delAllSale( @RequestParam("ids") List<Integer> ids) { |
| | | public Result delAllSale(String ids) { |
| | | saleService.delAllSale(ids); |
| | | return Result.success(); |
| | | } |
| | |
| | | @ApiImplicitParam(name = "type", value = "状态", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/check") |
| | | public Result check(@RequestHeader("token") String token,Integer id,Integer type) throws Exception { |
| | | public Result check(@RequestHeader("token") String token, Integer id, Integer type) throws Exception { |
| | | Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); |
| | | saleService.check(data.get("name").replaceAll("\"", ""),id,type); |
| | | saleService.check(data.get("name").replaceAll("\"", ""), id, type); |
| | | return Result.success("审核成功"); |
| | | } |
| | | |
| | | @ApiOperation(value = "同步") |
| | | @PostMapping("/synchronization") |
| | | public Result synchronization(){ |
| | | return Result.success(saleService.synchronization()); |
| | | } |
| | | |
| | | @ApiOperation(value = "下载附件") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "销售单id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/download") |
| | | public Result download(Integer id){ |
| | | return Result.success(saleService.download(id)); |
| | | } |
| | | |
| | | } |