|
|
|
package com.glxp.api.controller.thrsys;
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrInvOrder;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrInvOrderDetail;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrOrderEntity;
|
|
|
|
import com.glxp.api.req.system.DeleteRequest;
|
|
|
|
import com.glxp.api.req.thrsys.*;
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
import com.glxp.api.service.thrsys.ThrInvOrderDetailService;
|
|
|
|
import com.glxp.api.service.thrsys.ThrInvOrderService;
|
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.validation.Valid;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
public class ThrInvOrderController {
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
ThrInvOrderService thrInvOrderService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
ThrInvOrderDetailService thrInvOrderDetailService;
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@GetMapping("/udiwms/thrsys/getThrInvOrders")
|
|
|
|
public BaseResponse getOrders(FilterThrInvOrderRequest filterThrInvOrderRequest,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
List<ThrInvOrder> thrInvOrders
|
|
|
|
= thrInvOrderService.filterThrInvOrder(filterThrInvOrderRequest);
|
|
|
|
PageInfo<ThrInvOrder> pageInfo;
|
|
|
|
pageInfo = new PageInfo<>(thrInvOrders);
|
|
|
|
PageSimpleResponse<ThrInvOrder> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
|
pageSimpleResponse.setList(thrInvOrders);
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@GetMapping("/udiwms/thrsys/getThrInvOrderDetails")
|
|
|
|
public BaseResponse getThrInvOrderDetails(FilterThrInvOrderDetailRequest filterThrInvOrderDetailRequest,
|
|
|
|
BindingResult bindingResult) {
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
List<ThrInvOrderDetail> thrInvOrderDetails
|
|
|
|
= thrInvOrderDetailService.filterThrInvOrderDetails(filterThrInvOrderDetailRequest);
|
|
|
|
PageInfo<ThrInvOrderDetail> pageInfo;
|
|
|
|
pageInfo = new PageInfo<>(thrInvOrderDetails);
|
|
|
|
PageSimpleResponse<ThrInvOrderDetail> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
|
pageSimpleResponse.setList(thrInvOrderDetails);
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("/udiwms/thrsys/delThrInvOrderDetail")
|
|
|
|
public BaseResponse delThrInvOrderDetail(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
String id = deleteRequest.getId();
|
|
|
|
int b = thrInvOrderDetailService.delThrInvOrderDetail(Integer.parseInt(id));
|
|
|
|
if (b > 0) return ResultVOUtils.success("删除成功");
|
|
|
|
else return ResultVOUtils.error(500, "无法删除!");
|
|
|
|
}
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("/udiwms/thrsys/delThrInvOrder")
|
|
|
|
public BaseResponse delThrInvOrder(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
String billNo = deleteRequest.getBillNo();
|
|
|
|
int b = thrInvOrderService.delThrInvOrderByBillNo(billNo);
|
|
|
|
if (b > 0) {
|
|
|
|
thrInvOrderDetailService.delThrInvOrderDetailByBillNo(billNo);
|
|
|
|
return ResultVOUtils.success("删除成功");
|
|
|
|
} else return ResultVOUtils.error(500, "无法删除!");
|
|
|
|
}
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("/udiwms/thrsys/generateOrder")
|
|
|
|
public BaseResponse generateOrder(@RequestBody @Valid GenerateOrderRequest generateOrderRequest, BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
if (thrInvOrderService.generateOrder(generateOrderRequest)) {
|
|
|
|
return ResultVOUtils.success("生成成功");
|
|
|
|
}
|
|
|
|
return ResultVOUtils.error(500, "生成失败!");
|
|
|
|
}
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("/udiwms/thrsys/generateGhOrder")
|
|
|
|
public BaseResponse generateGhOrder(@RequestBody @Valid GenerateOrderRequest generateOrderRequest, BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
if (thrInvOrderService.generateGhOrder(generateOrderRequest)) {
|
|
|
|
return ResultVOUtils.success("生成成功");
|
|
|
|
}
|
|
|
|
return ResultVOUtils.error(500, "生成失败!");
|
|
|
|
}
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("/udiwms/thrsys/refreshOrder")
|
|
|
|
public BaseResponse refreshOrder(@RequestBody @Valid RefreshOrderRequest refreshOrderRequest, BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
if (thrInvOrderService.refreshOrder(refreshOrderRequest)) {
|
|
|
|
return ResultVOUtils.success("刷新成功");
|
|
|
|
}
|
|
|
|
return ResultVOUtils.error(500, "刷新失败!");
|
|
|
|
}
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("/udiwms/thrsys/refreshGhOrder")
|
|
|
|
public BaseResponse refreshGhOrder(@RequestBody @Valid RefreshOrderRequest refreshOrderRequest, BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
}
|
|
|
|
if (thrInvOrderService.refreshGhOrder(refreshOrderRequest)) {
|
|
|
|
return ResultVOUtils.success("刷新成功");
|
|
|
|
}
|
|
|
|
return ResultVOUtils.error(500, "刷新失败!");
|
|
|
|
}
|
|
|
|
}
|