|
|
|
package com.glxp.api.controller.inout;
|
|
|
|
|
|
|
|
|
|
|
|
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.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
import com.glxp.api.controller.BaseController;
|
|
|
|
import com.glxp.api.dao.inout.IoOrderDetailBizDao;
|
|
|
|
import com.glxp.api.entity.auth.AuthAdmin;
|
|
|
|
import com.glxp.api.entity.auth.InvWarehouseEntity;
|
|
|
|
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
|
|
|
|
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
import com.glxp.api.req.inout.AddBizProductReqeust;
|
|
|
|
import com.glxp.api.req.inout.FilterOrderDetailBizRequest;
|
|
|
|
import com.glxp.api.req.system.DeleteRequest;
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
import com.glxp.api.res.basic.UdiRelevanceResponse;
|
|
|
|
import com.glxp.api.res.inout.IoOrderDetailBizResponse;
|
|
|
|
import com.glxp.api.service.auth.InvWarehouseService;
|
|
|
|
import com.glxp.api.service.basic.IBasicBussinessTypeService;
|
|
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
|
|
import com.glxp.api.service.inout.IoOrderDetailBizService;
|
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
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.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 单据业务详情
|
|
|
|
*/
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
public class IoOrderDetailBizController extends BaseController {
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
IoOrderService orderService;
|
|
|
|
@Resource
|
|
|
|
IoOrderDetailBizService orderDetailBizService;
|
|
|
|
@Resource
|
|
|
|
UdiRelevanceService udiRelevanceService;
|
|
|
|
@Resource
|
|
|
|
GennerOrderUtils gennerOrderUtils;
|
|
|
|
@Resource
|
|
|
|
private IBasicBussinessTypeService basicBussinessTypeService;
|
|
|
|
@Resource
|
|
|
|
InvWarehouseService invWarehouseService;
|
|
|
|
|
|
|
|
//获取单据业务详情---临时接口查询
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@GetMapping("udiwms/inout/order/draft/biz")
|
|
|
|
public BaseResponse getDraftsDetailCode(String orderId) {
|
|
|
|
List<IoOrderDetailBizEntity> orderEntityList = orderDetailBizService.checkOrderList(orderId);
|
|
|
|
PageSimpleResponse<IoOrderDetailBizEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
|
pageSimpleResponse.setTotal(100l);
|
|
|
|
pageSimpleResponse.setList(orderEntityList);
|
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//录入业务单据详情
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("/udiwms/inout/order/addBizProduct")
|
|
|
|
public BaseResponse addBizProduct(@RequestBody AddBizProductReqeust addBizProductReqeust) {
|
|
|
|
|
|
|
|
AuthAdmin authAdmin = getUser();
|
|
|
|
if (addBizProductReqeust.getRelId() == null && CollUtil.isEmpty(addBizProductReqeust.getDatas()))
|
|
|
|
return ResultVOUtils.error(500, "未选择产品信息");
|
|
|
|
if (addBizProductReqeust.getOrderEntity() == null)
|
|
|
|
return ResultVOUtils.error(500, "未指定订单");
|
|
|
|
IoOrderEntity orderEntity = addBizProductReqeust.getOrderEntity();
|
|
|
|
if (StrUtil.isEmpty(orderEntity.getBillNo())) {
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByInvSubByCode(orderEntity.getInvCode());
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
orderEntity.setBillNo(orderNo);
|
|
|
|
orderEntity.setCreateUser(authAdmin.getId() + "");
|
|
|
|
orderEntity.setCreateTime(new Date());
|
|
|
|
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
|
|
|
|
if (StrUtil.isNotEmpty(orderEntity.getFromInvCode())) {
|
|
|
|
InvWarehouseEntity fromEntity = invWarehouseService.findByInvSubByCode(orderEntity.getInvCode());
|
|
|
|
orderEntity.setFromDeptCode(fromEntity.getParentId());
|
|
|
|
}
|
|
|
|
orderEntity.setFromType(ConstantStatus.FROM_WEBNEW);
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
|
|
|
|
orderEntity.setCreateUser(authAdmin.getId() + "");
|
|
|
|
orderEntity.setCreateTime(new Date());
|
|
|
|
orderEntity.setUpdateUser(authAdmin.getId() + "");
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
orderEntity.setCustomerId(authAdmin.getCustomerId() + "");
|
|
|
|
orderEntity.setDeptCode(invWarehouseEntity.getParentId());
|
|
|
|
orderEntity.setInvCode(orderEntity.getInvCode());
|
|
|
|
orderService.insertOrder(orderEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
List<AddBizProductReqeust> datas = new ArrayList<>();
|
|
|
|
if (CollUtil.isNotEmpty(addBizProductReqeust.getDatas())) {
|
|
|
|
datas.addAll(addBizProductReqeust.getDatas());
|
|
|
|
} else {
|
|
|
|
datas.add(addBizProductReqeust);
|
|
|
|
}
|
|
|
|
for (AddBizProductReqeust item : datas) {
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectGroupById(item.getRelId());
|
|
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
|
|
ioOrderDetailBizEntity.setOrderIdFk(orderEntity.getBillNo());
|
|
|
|
ioOrderDetailBizEntity.setBindRlFk(udiRelevanceResponse.getId());
|
|
|
|
ioOrderDetailBizEntity.setUuidFk(udiRelevanceResponse.getUuid());
|
|
|
|
ioOrderDetailBizEntity.setNameCode(udiRelevanceResponse.getNameCode());
|
|
|
|
ioOrderDetailBizEntity.setCoName(udiRelevanceResponse.getCpmctymc());
|
|
|
|
ioOrderDetailBizEntity.setCertCode(udiRelevanceResponse.getZczbhhzbapzbh());
|
|
|
|
ioOrderDetailBizEntity.setYlqxzcrbarmc(udiRelevanceResponse.getYlqxzcrbarmc());
|
|
|
|
ioOrderDetailBizEntity.setManufacturer(udiRelevanceResponse.getManufactory());
|
|
|
|
ioOrderDetailBizEntity.setMeasname(udiRelevanceResponse.getMeasname());
|
|
|
|
ioOrderDetailBizEntity.setSpec(udiRelevanceResponse.getGgxh());
|
|
|
|
ioOrderDetailBizEntity.setPrice(udiRelevanceResponse.getPrice());
|
|
|
|
ioOrderDetailBizEntity.setProductDate(item.getProductDate());
|
|
|
|
ioOrderDetailBizEntity.setExpireDate(item.getExpireDate());
|
|
|
|
ioOrderDetailBizEntity.setBatchNo(item.getBatchNo());
|
|
|
|
ioOrderDetailBizEntity.setSupId(item.getSupId());
|
|
|
|
orderDetailBizService.insert(ioOrderDetailBizEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
orderEntity.setUpdateUser(authAdmin.getId() + "");
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
return ResultVOUtils.success(orderEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
//修改业务单据详情
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("/udiwms/inout/order/updateBizProduct")
|
|
|
|
public BaseResponse updateBizProduct(@RequestBody IoOrderDetailBizEntity orderDetailBizEntity) {
|
|
|
|
boolean isExit = orderDetailBizService.isExit(orderDetailBizEntity.getBindRlFk(), orderDetailBizEntity.getBatchNo(), orderDetailBizEntity.getId(), orderDetailBizEntity.getOrderIdFk());
|
|
|
|
if (isExit) {
|
|
|
|
return ResultVOUtils.error(500, "存在相同产品,相同批次号,请检查后保存!");
|
|
|
|
}
|
|
|
|
return orderDetailBizService.update(orderDetailBizEntity) > 0 ? ResultVOUtils.success("保存成功!") : ResultVOUtils.error(500, "保存失败");
|
|
|
|
}
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("/udiwms/inout/order/delBizProduct")
|
|
|
|
public BaseResponse delBizProduct(@RequestBody DeleteRequest deleteRequest) {
|
|
|
|
return orderDetailBizService.deleteById(Integer.parseInt(deleteRequest.getId())) > 0 ? ResultVOUtils.success("删除成功!") : ResultVOUtils.error(500, "删除失败");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询单据业务详情列表
|
|
|
|
*
|
|
|
|
* @param orderDetailBizRequest
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@GetMapping("/udiwms/inout/bizDetail/filterList")
|
|
|
|
public BaseResponse filterList(FilterOrderDetailBizRequest orderDetailBizRequest) {
|
|
|
|
List<IoOrderDetailBizResponse> list = orderDetailBizService.filterList(orderDetailBizRequest);
|
|
|
|
PageInfo<IoOrderDetailBizResponse> pageInfo = new PageInfo<>(list);
|
|
|
|
return ResultVOUtils.page(pageInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|