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.
613 lines
32 KiB
Java
613 lines
32 KiB
Java
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.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.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.*;
|
|
import com.glxp.api.entity.inout.*;
|
|
import com.glxp.api.entity.purchase.PurOrderDetailEntity;
|
|
import com.glxp.api.entity.purchase.PurOrderEntity;
|
|
import com.glxp.api.entity.purchase.SupProductEntity;
|
|
import com.glxp.api.entity.system.SystemParamConfigEntity;
|
|
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
|
|
import com.glxp.api.entity.thrsys.ThrOrderEntity;
|
|
import com.glxp.api.entity.thrsys.ThrSystemBusApiEntity;
|
|
import com.glxp.api.req.inout.*;
|
|
import com.glxp.api.req.system.DeleteRequest;
|
|
import com.glxp.api.req.thrsys.FilterThrOrderDetailRequest;
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
import com.glxp.api.res.basic.UdiRelevanceResponse;
|
|
import com.glxp.api.res.inout.IoOrderDetailBizResponse;
|
|
import com.glxp.api.res.inout.IoOrderInvoiceResponse;
|
|
import com.glxp.api.service.auth.InvWarehouseService;
|
|
import com.glxp.api.service.basic.*;
|
|
import com.glxp.api.service.inout.*;
|
|
import com.glxp.api.service.purchase.PurOrderDetailService;
|
|
import com.glxp.api.service.purchase.PurOrderService;
|
|
import com.glxp.api.service.purchase.SupCertService;
|
|
import com.glxp.api.service.purchase.SupProductService;
|
|
import com.glxp.api.service.system.SystemParamConfigService;
|
|
import com.glxp.api.service.thrsys.ThrOrderDetailService;
|
|
import com.glxp.api.service.thrsys.ThrOrderService;
|
|
import com.glxp.api.service.thrsys.ThrSystemBusApiService;
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.math.BigDecimal;
|
|
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;
|
|
@Resource
|
|
private IoCheckInoutService ioCheckInoutService;
|
|
@Resource
|
|
IoOrderDetailCodeService orderDetailCodeService;
|
|
@Resource
|
|
ThrOrderService thrOrderService;
|
|
@Resource
|
|
ReceiveService receiveService;
|
|
@Resource
|
|
ReceivedetailService receivedetailService;
|
|
@Resource
|
|
IBasicBusTypeChangeService basicBusTypeChangeService;
|
|
|
|
@Resource
|
|
IoOrderInvoiceService ioOrderInvoiceService;
|
|
|
|
|
|
//获取单据业务详情---临时接口查询
|
|
@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);
|
|
}
|
|
|
|
@Resource
|
|
SupProductService supProductService;
|
|
@Resource
|
|
SystemParamConfigService systemParamConfigService;
|
|
@Resource
|
|
SupCertService supCertService;
|
|
|
|
//录入业务单据详情
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/inout/order/addBizProduct")
|
|
@Log(title = "单据管理", businessType = BusinessType.INSERT)
|
|
public BaseResponse addBizProduct(@RequestBody AddBizProductReqeust addBizProductReqeust) {
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("vail_product_cert");
|
|
// boolean isVailCert = systemParamConfigEntity.getParamValue().equals("1") ? true : false;
|
|
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();
|
|
IoOrderEntity isExit = orderService.findByBillNo(orderEntity.getBillNo());
|
|
if (StrUtil.isEmpty(orderEntity.getBillNo()) || isExit == null) {
|
|
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());
|
|
orderEntity.setBusType(bussinessTypeEntity.getBusType());
|
|
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.selectSupGroupById(item.getRelId());
|
|
|
|
// todo 查询产品是否已经通过认证
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
|
|
if (bussinessTypeEntity.getCheckCertExpire() == 2 && udiRelevanceResponse.isNeedCert()) {
|
|
SupProductEntity supProductEntity = supProductService.findByManufactury(udiRelevanceResponse.getCpmctymc(), udiRelevanceResponse.getManufactory(), "");
|
|
if (supProductEntity != null && (supProductEntity.getAuditStatus() == ConstantStatus.AUDIT_PASS || supProductEntity.getAuditStatus() == ConstantStatus.AUDIT_CHANGE_PASS)) {
|
|
|
|
} else {
|
|
return ResultVOUtils.error(500, "产品资质证书未通过审核!");
|
|
}
|
|
}
|
|
|
|
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(addBizProductReqeust.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")
|
|
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
|
|
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, "保存失败");
|
|
}
|
|
|
|
|
|
@Resource
|
|
ThrOrderDetailService thrOrderDetailService;
|
|
@Resource
|
|
ThrSystemBusApiService thrSystemBusApiService;
|
|
@Resource
|
|
UdiRlSupService udiRlSupService;
|
|
|
|
//选入第三方单据至业务单据
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/inout/order/addThrOrder")
|
|
@Log(title = "单据管理", businessType = BusinessType.INSERT)
|
|
public BaseResponse addThrOrder(@RequestBody ThrOrderEntity thrOrderRequest) {
|
|
|
|
ThrOrderEntity thrOrderEntity = thrOrderService.findById(thrOrderRequest.getId());
|
|
if (thrOrderEntity == null) {
|
|
return ResultVOUtils.error(ResultEnum.DATA_NOT);
|
|
}
|
|
List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailService.selectByBillNo(thrOrderEntity.getBillNo());
|
|
|
|
//获取单据类型
|
|
ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiService.selectByThrBus(thrOrderEntity.getBillType(), thrOrderEntity.getThirdSysFk());
|
|
if (thrSystemBusApiEntity == null || StrUtil.isEmpty(thrSystemBusApiEntity.getCode())) {
|
|
return ResultVOUtils.error(500, "单据类型对照有误!");
|
|
}
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(thrSystemBusApiEntity.getCode());
|
|
|
|
AuthAdmin authAdmin = getUser();
|
|
//创建单据
|
|
IoOrderEntity orderEntity = new IoOrderEntity();
|
|
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.setUpdateUser(authAdmin.getId() + "");
|
|
orderEntity.setUpdateTime(new Date());
|
|
orderEntity.setCustomerId(authAdmin.getCustomerId() + "");
|
|
orderEntity.setCorpOrderId(thrOrderEntity.getBillNo());
|
|
orderEntity.setAction(bussinessTypeEntity.getAction());
|
|
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
|
|
orderEntity.setFromThrBillNo(thrOrderEntity.getBillNo());
|
|
|
|
//获取当前部门
|
|
if (StrUtil.isNotEmpty(thrOrderEntity.getInvCode())) {
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseService.selectByThrCode(thrOrderEntity.getInvCode(), thrOrderEntity.getThirdSysFk());
|
|
if (invWarehouseEntity != null) {
|
|
orderEntity.setDeptCode(invWarehouseEntity.getParentId());
|
|
orderEntity.setInvCode(invWarehouseEntity.getCode());
|
|
}
|
|
} else {
|
|
return ResultVOUtils.error(500, "第三方单据所属仓库不能为空!");
|
|
}
|
|
|
|
|
|
//获取往来信息
|
|
if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INNOR) {//内部调拨
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseService.selectByThrCode(thrOrderEntity.getCorpId(), thrOrderEntity.getThirdSysFk());
|
|
orderEntity.setFromDeptCode(invWarehouseEntity.getParentId());
|
|
orderEntity.setFromInvCode(invWarehouseEntity.getCode());
|
|
} else if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT) { //往来信息
|
|
BasicCorpEntity basicCorpEntity = basicCorpService.selectByThirdId(thrOrderEntity.getCorpId(), thrOrderEntity.getThirdSysFk());
|
|
orderEntity.setFromCorp(basicCorpEntity.getErpId());
|
|
} else {
|
|
orderEntity.setFromCorp(thrOrderEntity.getCorpId());
|
|
}
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
|
|
orderEntity.setFromType(ConstantStatus.FROM_THRORDER);
|
|
orderEntity.setOrderType(ConstantStatus.ORDER_TYPE_BIZ);
|
|
orderEntity.setBusType(bussinessTypeEntity.getBusType());
|
|
orderService.insertOrder(orderEntity);
|
|
|
|
for (ThrOrderDetailEntity thrOrderDetailEntity : thrOrderDetailEntities) {
|
|
|
|
thrOrderDetailEntity.getProductId();
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceService.selectListByThirdId(thrOrderDetailEntity.getProductId(), thrOrderEntity.getThirdSysFk());
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
UdiRelevanceResponse udiRelevanceResponse = null;
|
|
if (udiRelevanceEntities.size() == 1) {
|
|
udiRelevanceResponse = udiRelevanceEntities.get(0);
|
|
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());
|
|
} else {
|
|
ioOrderDetailBizEntity.setCoName(thrOrderDetailEntity.getCorpName());
|
|
ioOrderDetailBizEntity.setCertCode(thrOrderDetailEntity.getZczbhhzbapzbh());
|
|
ioOrderDetailBizEntity.setYlqxzcrbarmc(thrOrderDetailEntity.getYlqxzcrbarmc());
|
|
ioOrderDetailBizEntity.setManufacturer(thrOrderDetailEntity.getManufactory());
|
|
ioOrderDetailBizEntity.setSpec(thrOrderDetailEntity.getSpec());
|
|
ioOrderDetailBizEntity.setPrice(thrOrderDetailEntity.getPrice());
|
|
|
|
if (udiRelevanceEntities.size() > 1) {
|
|
String bindRlIds = "";
|
|
for (UdiRelevanceResponse temp : udiRelevanceEntities) {
|
|
bindRlIds = bindRlIds + "," + temp.getId();
|
|
}
|
|
ioOrderDetailBizEntity.setBindRlIds(bindRlIds.substring(1));
|
|
}
|
|
|
|
}
|
|
ioOrderDetailBizEntity.setOrderIdFk(orderEntity.getBillNo());
|
|
ioOrderDetailBizEntity.setProductDate(thrOrderDetailEntity.getProductDate());
|
|
ioOrderDetailBizEntity.setExpireDate(thrOrderDetailEntity.getExpireDate());
|
|
ioOrderDetailBizEntity.setBatchNo(thrOrderDetailEntity.getBatchNo());
|
|
ioOrderDetailBizEntity.setCount(thrOrderDetailEntity.getCount());
|
|
|
|
if (StrUtil.isNotEmpty(thrOrderDetailEntity.getSupId())) {
|
|
BasicCorpEntity basicCorpEntity = basicCorpService.selectByThirdId(thrOrderDetailEntity.getSupId(), thrOrderEntity.getThirdSysFk());
|
|
ioOrderDetailBizEntity.setSupId(basicCorpEntity.getErpId());
|
|
} else if (udiRelevanceResponse != null) {
|
|
List<UdiRlSupEntity> udiRlSupEntities = udiRlSupService.findByUdiRlId(udiRelevanceResponse.getId());
|
|
if (CollUtil.isNotEmpty(udiRlSupEntities) && udiRlSupEntities.size() == 1) {
|
|
ioOrderDetailBizEntity.setSupId(udiRlSupEntities.get(0).getCustomerId());
|
|
}
|
|
}
|
|
orderDetailBizService.insert(ioOrderDetailBizEntity);
|
|
}
|
|
thrOrderService.updateThrOrder(thrOrderEntity);
|
|
return ResultVOUtils.success("选入成功!");
|
|
}
|
|
|
|
@Resource
|
|
BasicCorpService basicCorpService;
|
|
|
|
|
|
//选入领用单据至业务单据
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/inout/order/addReceiveOrder")
|
|
@Log(title = "单据管理", businessType = BusinessType.INSERT)
|
|
public BaseResponse addReceiveOrder(@RequestBody PurReceiveEntity purReceiveEntity,
|
|
BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
purReceiveEntity = receiveService.selectById(purReceiveEntity.getId());
|
|
List<PurReceiveDetailEntity> purReceiveDetailEntities = receivedetailService.selectByOrderId(purReceiveEntity.getBillNo());
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(purReceiveEntity.getBillType());
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(basicBusTypeChangeEntity.getTargetAction());
|
|
|
|
AuthAdmin authAdmin = getUser();
|
|
//创建单据
|
|
IoOrderEntity orderEntity = new IoOrderEntity();
|
|
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.setUpdateUser(authAdmin.getId() + "");
|
|
orderEntity.setUpdateTime(new Date());
|
|
orderEntity.setCustomerId(authAdmin.getCustomerId() + "");
|
|
orderEntity.setCorpOrderId(purReceiveEntity.getBillNo());
|
|
orderEntity.setAction(bussinessTypeEntity.getAction());
|
|
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
|
|
orderEntity.setDeptCode(purReceiveEntity.getTargetDeptCode());
|
|
orderEntity.setInvCode(purReceiveEntity.getTargetInvCode());
|
|
orderEntity.setFromReceiveBillNo(purReceiveEntity.getBillNo());
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
|
|
orderEntity.setFromType(ConstantStatus.FROM_RECEIVE);
|
|
orderEntity.setOrderType(ConstantStatus.ORDER_TYPE_BIZ);
|
|
orderEntity.setFromDeptCode(purReceiveEntity.getDeptCode());
|
|
orderEntity.setFromInvCode(purReceiveEntity.getInvCode());
|
|
orderEntity.setBusType(bussinessTypeEntity.getBusType());
|
|
orderService.insertOrder(orderEntity);
|
|
for (PurReceiveDetailEntity purReceiveDetailEntity : purReceiveDetailEntities) {
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectGroupById(purReceiveDetailEntity.getRelIdFk());
|
|
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(purReceiveDetailEntity.getProductDate());
|
|
ioOrderDetailBizEntity.setExpireDate(purReceiveDetailEntity.getExpireDate());
|
|
ioOrderDetailBizEntity.setBatchNo(purReceiveDetailEntity.getBatchNo());
|
|
ioOrderDetailBizEntity.setSupId(purReceiveDetailEntity.getSupId());
|
|
ioOrderDetailBizEntity.setCount(purReceiveDetailEntity.getCount());
|
|
orderDetailBizService.insert(ioOrderDetailBizEntity);
|
|
}
|
|
return ResultVOUtils.success("选入成功!");
|
|
|
|
}
|
|
|
|
@Resource
|
|
PurOrderService purOrderService;
|
|
@Resource
|
|
PurOrderDetailService purOrderDetailService;
|
|
|
|
//选入领用单据至业务单据
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/inout/order/addPurOrder")
|
|
@Log(title = "单据管理", businessType = BusinessType.INSERT)
|
|
public BaseResponse addPurOrder(@RequestBody PurOrderEntity purOrderEntity,
|
|
BindingResult bindingResult) {
|
|
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
purOrderEntity = purOrderService.selectById(purOrderEntity.getId());
|
|
List<PurOrderDetailEntity> purOrderDetailEntities = purOrderDetailService.findByOrderId(purOrderEntity.getId() + "");
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction(purOrderEntity.getBillType());
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(basicBusTypeChangeEntity.getTargetAction());
|
|
|
|
AuthAdmin authAdmin = getUser();
|
|
//创建单据
|
|
IoOrderEntity orderEntity = new IoOrderEntity();
|
|
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.setUpdateUser(authAdmin.getId() + "");
|
|
orderEntity.setUpdateTime(new Date());
|
|
orderEntity.setCustomerId(authAdmin.getCustomerId() + "");
|
|
orderEntity.setCorpOrderId(purOrderEntity.getBillNo());
|
|
orderEntity.setAction(bussinessTypeEntity.getAction());
|
|
orderEntity.setMainAction(bussinessTypeEntity.getMainAction());
|
|
orderEntity.setDeptCode(purOrderEntity.getDeptCode());
|
|
orderEntity.setInvCode(purOrderEntity.getInvCode());
|
|
orderEntity.setFromReceiveBillNo(purOrderEntity.getBillNo());
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE);
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_DRAFT);
|
|
orderEntity.setFromType(ConstantStatus.FROM_RECEIVE);
|
|
orderEntity.setOrderType(ConstantStatus.ORDER_TYPE_BIZ);
|
|
orderEntity.setBusType(bussinessTypeEntity.getBusType());
|
|
orderService.insertOrder(orderEntity);
|
|
for (PurOrderDetailEntity purReceiveDetailEntity : purOrderDetailEntities) {
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectGroupById(purReceiveDetailEntity.getProductId().longValue());
|
|
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.setSupId(purReceiveDetailEntity.getSupId());
|
|
ioOrderDetailBizEntity.setCount(purReceiveDetailEntity.getCount());
|
|
orderDetailBizService.insert(ioOrderDetailBizEntity);
|
|
}
|
|
return ResultVOUtils.success("选入成功!");
|
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/inout/order/delBizProduct")
|
|
@Log(title = "单据管理", businessType = BusinessType.DELETE)
|
|
public BaseResponse delBizProduct(@RequestBody DeleteRequest deleteRequest) {
|
|
IoOrderDetailBizEntity orderDetailBizEntity = orderDetailBizService.selectById(Integer.parseInt(deleteRequest.getId()));
|
|
int result = orderDetailBizService.deleteById(Integer.parseInt(deleteRequest.getId()));
|
|
if (result > 0) {
|
|
boolean r1 = orderDetailBizService.isExit(orderDetailBizEntity.getOrderIdFk());
|
|
boolean r2 = orderDetailCodeService.isExit(orderDetailBizEntity.getOrderIdFk());
|
|
if (!r1 && !r2) {
|
|
orderService.deleteByBillNo(orderDetailBizEntity.getOrderIdFk());
|
|
}
|
|
return ResultVOUtils.success("删除成功!");
|
|
}
|
|
return ResultVOUtils.error(500, "删除失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询单据业务详情列表
|
|
*
|
|
* @param orderDetailBizRequest
|
|
* @return
|
|
*/
|
|
@GetMapping("/udiwms/inout/bizDetail/filterList")
|
|
public BaseResponse filterList(FilterOrderDetailBizRequest orderDetailBizRequest) {
|
|
List<IoOrderDetailBizResponse> list = orderDetailBizService.filterList(orderDetailBizRequest);
|
|
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(orderDetailBizRequest.getOrderIdFk());
|
|
ioCheckInoutService.bizOrderCheck2(list, orderDetailCodeEntities);
|
|
PageInfo<IoOrderDetailBizResponse> pageInfo = new PageInfo<>(list);
|
|
return ResultVOUtils.page(pageInfo);
|
|
}
|
|
|
|
@GetMapping("/udiwms/inout/bizDetail/filterListInvoice")
|
|
public BaseResponse filterListInvoice(FilterOrderDetailBizRequest orderDetailBizRequest) {
|
|
List<IoOrderInvoiceResponse> list = orderDetailBizService.filterListInv(orderDetailBizRequest);
|
|
PageInfo<IoOrderInvoiceResponse> pageInfo = new PageInfo<>(list);
|
|
return ResultVOUtils.page(pageInfo);
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/udiwms/inout/biz/updateBind")
|
|
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
|
|
public BaseResponse updateBindSup(@RequestBody BizBindUpdateRequest bizBindUpdateRequest) {
|
|
|
|
|
|
IoOrderDetailBizEntity orderDetailBizEntity = orderDetailBizService.selectById(bizBindUpdateRequest.getId());
|
|
|
|
|
|
if (bizBindUpdateRequest.getBindRlFk() != null)
|
|
orderDetailBizEntity.setBindRlFk(bizBindUpdateRequest.getBindRlFk());
|
|
if (StrUtil.isNotEmpty(bizBindUpdateRequest.getSupId())) {
|
|
orderDetailBizEntity.setSupId(bizBindUpdateRequest.getSupId());
|
|
}
|
|
orderDetailBizService.update(orderDetailBizEntity);
|
|
return ResultVOUtils.success("绑定成功");
|
|
}
|
|
|
|
|
|
/**
|
|
* 删除发票表
|
|
*
|
|
* @param id
|
|
* @return
|
|
*/
|
|
@GetMapping("/udiwms/inout/biz/deleteById")
|
|
@Log(title = "发票管理", businessType = BusinessType.DELETE)
|
|
public BaseResponse deleteById(Integer id) {
|
|
|
|
return ResultVOUtils.success(ioOrderInvoiceService.deleteByInvId(id));
|
|
|
|
}
|
|
|
|
/**
|
|
* 修改发票表
|
|
*
|
|
* @param ioOrderInvoiceRequest
|
|
* @return
|
|
*/
|
|
|
|
@PostMapping("/udiwms/inout/biz/updateById")
|
|
@Log(title = "发票管理", businessType = BusinessType.UPDATE)
|
|
public BaseResponse deleteById(@RequestBody IoOrderInvoiceRequest ioOrderInvoiceRequest) {
|
|
|
|
return ResultVOUtils.success(ioOrderInvoiceService.updateByInvId(ioOrderInvoiceRequest));
|
|
|
|
}
|
|
|
|
|
|
@PostMapping("/udiwms/inout/biz/insertInvoice")
|
|
@Log(title = "发票管理", businessType = BusinessType.INSERT)
|
|
public BaseResponse insertInvoice(@RequestBody IoOrderDetailBizEntity ioOrderDetailBizEntity) {
|
|
|
|
IoOrderInvoiceEntity ioOrderInvoiceEntity = new IoOrderInvoiceEntity();
|
|
ioOrderInvoiceEntity.setOrderIdFk(ioOrderDetailBizEntity.getOrderIdFk());
|
|
ioOrderInvoiceEntity.setBindRlFk(ioOrderDetailBizEntity.getBindRlFk() + "");
|
|
ioOrderInvoiceEntity.setBatchNo(ioOrderDetailBizEntity.getBatchNo());
|
|
ioOrderInvoiceEntity.setProductDate(ioOrderDetailBizEntity.getProductDate());
|
|
ioOrderInvoiceEntity.setExpireDate(ioOrderDetailBizEntity.getExpireDate());
|
|
ioOrderInvoiceEntity.setBizIdFk(ioOrderDetailBizEntity.getId());
|
|
ioOrderInvoiceEntity.setCreateTime(new Date());
|
|
ioOrderInvoiceEntity.setUpdateTime(new Date());
|
|
boolean b = ioOrderInvoiceService.insertInvoice(ioOrderInvoiceEntity);
|
|
|
|
return ResultVOUtils.success("成功");
|
|
|
|
}
|
|
|
|
/**
|
|
* 查询单据业务详情列表
|
|
*
|
|
* @param orderDetailBizRequest
|
|
* @return
|
|
*/
|
|
@GetMapping("/udiwms/inout/bizDetail/filterBizOrderList")
|
|
public BaseResponse filterBizOrderList(FilterOrderDetailBizRequest orderDetailBizRequest) {
|
|
List<IoOrderDetailBizResponse> list = orderDetailBizService.filterList(orderDetailBizRequest);
|
|
for (IoOrderDetailBizResponse ioOrderDetailBizResponse : list) {
|
|
String msg = "";
|
|
IoOrderInvoiceEntity ioOrderInvoiceEntity = new IoOrderInvoiceEntity();
|
|
ioOrderInvoiceEntity.setOrderIdFk(ioOrderDetailBizResponse.getOrderIdFk());
|
|
List<IoOrderInvoiceEntity> ioOrderInvoiceEntityList = ioOrderInvoiceService.selectOrderInvoice(ioOrderInvoiceEntity);
|
|
for (IoOrderInvoiceEntity obj : ioOrderInvoiceEntityList) {
|
|
if (StrUtil.isNotEmpty(obj.getInvoiceCode())) {
|
|
msg += "," + obj.getInvoiceCode();
|
|
}
|
|
}
|
|
if (msg.length() > 1) {
|
|
msg = msg.substring(1);
|
|
}
|
|
ioOrderDetailBizResponse.setInvoiceCodes(msg);
|
|
}
|
|
PageInfo<IoOrderDetailBizResponse> pageInfo = new PageInfo<>(list);
|
|
return ResultVOUtils.page(pageInfo);
|
|
}
|
|
|
|
}
|