You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
228 lines
10 KiB
Java
228 lines
10 KiB
Java
package com.glxp.api.controller.purchase;
|
|
//领用单
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
import com.glxp.api.annotation.Log;
|
|
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.constant.BusinessType;
|
|
import com.glxp.api.constant.Constant;
|
|
import com.glxp.api.controller.BaseController;
|
|
import com.glxp.api.entity.auth.AuthAdmin;
|
|
import com.glxp.api.entity.auth.InvWarehouseEntity;
|
|
import com.glxp.api.entity.inout.PurReceiveDetailEntity;
|
|
import com.glxp.api.entity.inout.PurReceiveEntity;
|
|
import com.glxp.api.req.inout.AddReceiveDetailRequest;
|
|
import com.glxp.api.req.inout.FilterReceiveDetailRequest;
|
|
import com.glxp.api.req.inout.FilterReceiveRequest;
|
|
import com.glxp.api.req.inout.UpdateReceiveDetailRequest;
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
import com.glxp.api.res.inout.ReceiveDetailResponse;
|
|
import com.glxp.api.res.inout.ReceiveResponse;
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
import com.glxp.api.service.auth.InvWarehouseService;
|
|
import com.glxp.api.service.inout.ReceiveService;
|
|
import com.glxp.api.service.inout.ReceivedetailService;
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
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 java.util.Date;
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
public class PurOrderReceiveController extends BaseController {
|
|
|
|
|
|
@Resource
|
|
ReceiveService receiveService;
|
|
@Resource
|
|
ReceivedetailService receivedetailService;
|
|
@Resource
|
|
CustomerService customerService;
|
|
@Resource
|
|
GennerOrderUtils gennerOrderUtils;
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/thrsys/order/insertWeb")
|
|
@Log(title = "单据管理", businessType = BusinessType.INSERT)
|
|
public BaseResponse addReceive(@RequestBody PurReceiveEntity purReceiveEntity, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
Long userId = customerService.getUserId();
|
|
InvWarehouseEntity curWarehouseEntity = invWarehouseService.findByInvSubByCode(purReceiveEntity.getInvCode());
|
|
InvWarehouseEntity targetWarehouseEntity = invWarehouseService.findByInvSubByCode(purReceiveEntity.getTargetInvCode());
|
|
purReceiveEntity.setCreateUser(userId + "");
|
|
purReceiveEntity.setCreateTime(new Date());
|
|
purReceiveEntity.setUpdateTime(new Date());
|
|
String orderNo = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.LIN_YONG, "yyyyMMdd"));
|
|
purReceiveEntity.setBillNo(orderNo);
|
|
purReceiveEntity.setDeptCode(curWarehouseEntity.getParentId());
|
|
purReceiveEntity.setTargetDeptCode(targetWarehouseEntity.getParentId());
|
|
receiveService.insertOrder(purReceiveEntity);
|
|
return ResultVOUtils.success("成功");
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/receive/order/update")
|
|
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
|
|
public BaseResponse updateReceive(@RequestBody PurReceiveEntity purReceiveEntity, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
|
|
Long userId = customerService.getUserId();
|
|
purReceiveEntity.setStatus(purReceiveEntity.getStatus());
|
|
purReceiveEntity.setUpdateUser(userId + "");
|
|
purReceiveEntity.setUpdateTime(new Date());
|
|
receiveService.updateOrder(purReceiveEntity);
|
|
return ResultVOUtils.success("成功");
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/udiwms/receive/order/filter")
|
|
public BaseResponse filterReceive(FilterReceiveRequest filterReceiveRequest) {
|
|
List<ReceiveResponse> data = receiveService.filterList(filterReceiveRequest);
|
|
PageInfo<ReceiveResponse> pageInfo;
|
|
pageInfo = new PageInfo<>(data);
|
|
PageSimpleResponse<ReceiveResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(data);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/udiwms/receive/order/detail")
|
|
public BaseResponse filterReceiveDetail(FilterReceiveDetailRequest filterReceiveDetailRequest) {
|
|
List<ReceiveDetailResponse> data = receivedetailService.filterList(filterReceiveDetailRequest);
|
|
PageInfo<ReceiveDetailResponse> pageInfo;
|
|
pageInfo = new PageInfo<>(data);
|
|
PageSimpleResponse<ReceiveDetailResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(data);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
}
|
|
|
|
@Resource
|
|
InvWarehouseService invWarehouseService;
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/receive/detail/add")
|
|
@Log(title = "单据管理", businessType = BusinessType.INSERT)
|
|
public BaseResponse updateReceive(@RequestBody AddReceiveDetailRequest addReceiveDetailRequest, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
AuthAdmin authAdmin = getUser();
|
|
String orderNo = addReceiveDetailRequest.getPurReceiveEntity().getBillNo();
|
|
if (addReceiveDetailRequest.getPurReceiveEntity() == null)
|
|
return ResultVOUtils.error(500, "未指定订单");
|
|
|
|
if (CollUtil.isEmpty(addReceiveDetailRequest.getDatas())) {
|
|
return ResultVOUtils.error(500, "未选择产品信息");
|
|
}
|
|
PurReceiveEntity purReceiveEntity = addReceiveDetailRequest.getPurReceiveEntity();
|
|
if (StrUtil.isEmpty(purReceiveEntity.getBillNo())) {
|
|
InvWarehouseEntity curWarehouseEntity = invWarehouseService.findByInvSubByCode(purReceiveEntity.getInvCode());
|
|
InvWarehouseEntity targetWarehouseEntity = invWarehouseService.findByInvSubByCode(purReceiveEntity.getTargetInvCode());
|
|
orderNo = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.LIN_YONG, "yyyyMMdd"));
|
|
purReceiveEntity.setBillNo(orderNo);
|
|
purReceiveEntity.setCreateUser(authAdmin.getId() + "");
|
|
purReceiveEntity.setCreateTime(new Date());
|
|
purReceiveEntity.setStatus(1);
|
|
purReceiveEntity.setDeptCode(curWarehouseEntity.getParentId());
|
|
purReceiveEntity.setTargetDeptCode(targetWarehouseEntity.getParentId());
|
|
receiveService.insertOrder(purReceiveEntity);
|
|
}
|
|
for (AddReceiveDetailRequest.DetaiData detaiData : addReceiveDetailRequest.getDatas()) {
|
|
|
|
PurReceiveDetailEntity purReceiveDetailEntity = new PurReceiveDetailEntity();
|
|
purReceiveDetailEntity.setOrderIdFk(purReceiveEntity.getBillNo());
|
|
purReceiveDetailEntity.setNameCode(detaiData.getNameCode());
|
|
purReceiveDetailEntity.setExpireDate(detaiData.getExpireDate());
|
|
purReceiveDetailEntity.setProductDate(detaiData.getProductDate());
|
|
purReceiveDetailEntity.setRelIdFk(detaiData.getRelId());
|
|
purReceiveDetailEntity.setBatchNo(detaiData.getBatchNo());
|
|
purReceiveDetailEntity.setSupId(detaiData.getSupId());
|
|
receivedetailService.insert(purReceiveDetailEntity);
|
|
}
|
|
purReceiveEntity.setUpdateTime(new Date());
|
|
receiveService.updateOrder(purReceiveEntity);
|
|
return ResultVOUtils.success(orderNo);
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/receive/detail/Update")
|
|
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
|
|
public BaseResponse updateReceiveDetail(@RequestBody UpdateReceiveDetailRequest updateReceiveDetailRequest, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
boolean falg = receivedetailService.updateReceiveDetail(updateReceiveDetailRequest);
|
|
if (falg) {
|
|
return ResultVOUtils.success();
|
|
} else {
|
|
return ResultVOUtils.error(555, "更新失败!");
|
|
}
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/udiwms/receive/order/del")
|
|
@Log(title = "领用单", businessType = BusinessType.DELETE)
|
|
public BaseResponse del(String orderIdFk) {
|
|
boolean falg = receiveService.delReceive(orderIdFk);
|
|
if (falg) {
|
|
return ResultVOUtils.success();
|
|
} else {
|
|
return ResultVOUtils.error(555, "删除失败!");
|
|
}
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@GetMapping("/udiwms/receive/detail/delReceiveDetail")
|
|
@Log(title = "领用单", businessType = BusinessType.DELETE)
|
|
public BaseResponse delReceiveDetail(Integer id) {
|
|
|
|
boolean falg = receivedetailService.delDetail(id + "");
|
|
if (falg) {
|
|
return ResultVOUtils.success();
|
|
} else {
|
|
return ResultVOUtils.error(555, "删除失败!");
|
|
}
|
|
}
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/receive/order/audit")
|
|
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
|
|
public BaseResponse audit(@RequestBody PurReceiveEntity purReceiveEntity, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
|
|
Long userId = customerService.getUserId();
|
|
purReceiveEntity.setStatus(purReceiveEntity.getStatus());
|
|
purReceiveEntity.setUpdateUser(userId + "");
|
|
purReceiveEntity.setAuditRemark(purReceiveEntity.getAuditRemark());
|
|
purReceiveEntity.setAuditTime(new Date());
|
|
purReceiveEntity.setAuditUser(userId + "");
|
|
purReceiveEntity.setUpdateTime(new Date());
|
|
receiveService.updateOrder(purReceiveEntity);
|
|
return ResultVOUtils.success("成功");
|
|
}
|
|
|
|
}
|