package com.gkhy.safePlatform.equipment.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
|
import com.gkhy.safePlatform.commons.enums.ResultCodes;
|
import com.gkhy.safePlatform.commons.query.PageQuery;
|
import com.gkhy.safePlatform.commons.vo.ResultVO;
|
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
|
import com.gkhy.safePlatform.equipment.model.dto.req.*;
|
import com.gkhy.safePlatform.equipment.model.dto.resp.SafeMaterialDetailDto;
|
import com.gkhy.safePlatform.equipment.service.SafeMaterialDetailService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.security.core.Authentication;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.List;
|
|
@RestController
|
@RequestMapping(value = "/equipment/smDetail")
|
public class SafeMaterialDetailController {
|
@Autowired
|
private SafeMaterialDetailService safeMaterialDetailService;
|
/**
|
* 新增入库
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/save")
|
public ResultVO save(Authentication authentication,@Validated @RequestBody SafeMaterialDetailAddReq req){
|
return safeMaterialDetailService.save(req);
|
}
|
/**
|
* 批量入库
|
*/
|
@PostMapping(value = "/saveBatch")
|
public ResultVO saveBatch(Authentication authentication,@Validated @RequestBody SafeMaterialDetailAddReq req){
|
return safeMaterialDetailService.saveBatch(req);
|
}
|
/**
|
* 编辑
|
*/
|
@PostMapping(value = "/update")
|
public ResultVO update(Authentication authentication,@Validated @RequestBody SafeMaterialDetailReq req){
|
return safeMaterialDetailService.update(req);
|
}
|
|
|
/**
|
* 单独出库
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/single/delivery")
|
public ResultVO singleDelivery(Authentication authentication, @Validated @RequestBody SafeMaterialDetailReq req){
|
ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
|
safeMaterialDetailService.singleDelivery(currentUser,req);
|
return new ResultVO(ResultCodes.OK);
|
}
|
|
/**
|
* 单独入库
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/single/receipt")
|
public ResultVO singleReceipt(Authentication authentication,@RequestBody JSONObject jsonObject){
|
ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
|
Long id = jsonObject.getLong("id");
|
safeMaterialDetailService.singleReceipt(id,currentUser);
|
return new ResultVO(ResultCodes.OK);
|
}
|
/**
|
* 批量出库 - 根据ids
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/batch/delivery/ids")
|
public ResultVO deliveryBatchByIds(Authentication authentication, @Validated @RequestBody MterialDeliveryReq req){
|
ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
|
safeMaterialDetailService.deliveryBatchByIds(req,currentUser);
|
return new ResultVO(ResultCodes.OK);
|
}
|
/**
|
* 批量出库
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/batch/delivery/random")
|
public ResultVO deliveryBatchRandom(Authentication authentication,@Validated @RequestBody MterialRandomDeliveryReq req){
|
ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
|
safeMaterialDetailService.deliveryBatchBySmId(req,currentUser);
|
return new ResultVO(ResultCodes.OK);
|
}
|
|
/**
|
* 批量重新入库
|
*/
|
@PostMapping(value = "/batch/receipt")
|
public ResultVO receiptBatch(Authentication authentication ,@Validated @RequestBody ParamForm paramForm){
|
ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
|
return safeMaterialDetailService.receiptBatch(paramForm);
|
}
|
/**
|
* 删除-单条
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/delete")
|
public ResultVO delete(Authentication authentication, @RequestBody JSONObject jsonObject){
|
Long id = jsonObject.getLong("id");
|
return safeMaterialDetailService.delete(id);
|
}
|
|
/**
|
* 批量删除
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/deleteBatch")
|
public ResultVO deleteBatch(Authentication authentication,@Validated @RequestBody ParamForm paramForm){
|
ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
|
return safeMaterialDetailService.deleteBatch(currentUser,paramForm);
|
}
|
|
|
/**
|
* 分页查询
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/page/list")
|
public SearchResultVO<List<SafeMaterialDetailDto>> listByPage(Authentication authentication, @RequestBody PageQuery<SafeMatetrialDetailQuery> pageQuery){
|
ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
|
return safeMaterialDetailService.listByPage(currentUser,pageQuery);
|
}
|
|
/**
|
* 查询单条数据
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/queryById")
|
public ResultVO queryById(Authentication authentication,@RequestBody JSONObject jsonObject){
|
Long id = jsonObject.getLong("id");
|
return safeMaterialDetailService.queryById(id);
|
}
|
/**
|
* 特殊作业批量出库接口
|
* @param authentication
|
* @return
|
*/
|
@PostMapping(value = "/deliveryBatchSpw")
|
public ResultVO deliveryBatchSpw(Authentication authentication, @Validated @RequestBody MaterialSpwReq req){
|
safeMaterialDetailService.deliveryBatchSpw(req);
|
return new ResultVO<>(ResultCodes.OK);
|
}
|
/**
|
* 根据rfid获去数据
|
* @param authentication
|
* @return
|
*//*
|
@PostMapping(value = "/rfid/list")
|
public ResultVO getListByRfid(Authentication authentication, @RequestBody String[] rfids){
|
return new ResultVO(ResultCodes.OK,safeMaterialDetailService.getListByRfids(rfids));
|
}*/
|
}
|