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.
udi-spms-java/src/main/java/com/glxp/api/controller/inout/IoOrderDetailBizController....

795 lines
42 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.glxp.api.controller.inout;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
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.annotation.RepeatSubmit;
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.SupCertEntity;
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.inv.FilterInvoiceRequest;
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.IoOrderDetailCodeResponse;
import com.glxp.api.res.inout.IoOrderDetailResultResponse;
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.inout.impl.IoOrderInvoiceService;
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.IntUtil;
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.*;
import java.util.stream.Collectors;
/**
* 单据业务详情
*/
@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(), addBizProductReqeust.getSupId());
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
//是否校验产品采购类型 1校验2.无需校验
if (IntUtil.value(bussinessTypeEntity.getVailProductAttributes()) == 1) {
Integer purType = IntUtil.value(udiRelevanceResponse.getPurType()); //1普通入账产品2.预验收产品。3寄售产品
int actionType = IntUtil.value(bussinessTypeEntity.getActionType()); //1带票正常2.预验收。3寄售
if (purType != actionType) {
//包装友好提示
String msg = "";
switch (actionType) {
case 1:
msg = "普通入账产品";
break;
case 2:
msg = "预验收产品";
break;
case 3:
msg = "寄售产品";
break;
}
String msg2 = "";
switch (purType) {
case 1:
msg2 = "普通入账产品";
break;
case 2:
msg2 = "预验收产品";
break;
case 3:
msg2 = "寄售产品";
break;
}
return ResultVOUtils.error(500, "单据只允许录入" + msg + ",当前录入产品为" + msg2 + ",请检查后重试!");
}
}
// if(udiRelevanceResponse.getRequireScanCode() == 1) {
//是否校验耗材材质 1高值耗材2.普通耗材
if (IntUtil.value(bussinessTypeEntity.getVailHcType() == 1)) {
if (IntUtil.value(udiRelevanceResponse.getHcType()) != 1) {
return ResultVOUtils.error(500, "单据只允许录入高值耗材" + ",请检查后重试!");
}
} else if (IntUtil.value(bussinessTypeEntity.getVailHcType() == 2)) {
if (IntUtil.value(udiRelevanceResponse.getHcType()) != 2) {
return ResultVOUtils.error(500, "单据只允许录入普通耗材" + ",请检查后重试!");
}
}
// }
if (IntUtil.value(bussinessTypeEntity.getCheckCertExpire()) == 2 && udiRelevanceResponse.isNeedCert()) {
SupProductEntity supProductEntity = supProductService.findExitByManufactury(udiRelevanceResponse.getCpmctymc(), udiRelevanceResponse.getManufactory(), authAdmin.getCustomerId());
if (supProductEntity != null && (supProductEntity.getAuditStatus() == ConstantStatus.AUDIT_PASS || supProductEntity.getAuditStatus() == ConstantStatus.AUDIT_CHANGE_PASS)) {
// List<SupCertEntity> supCertEntities = supCertService.findByProductId(supProductEntity.getProductId());
addBizProductReqeust.setProductId(supProductEntity.getProductId());
List<SupCertEntity> supCertEntities = supCertService.findByzczbhhzbapzbh(addBizProductReqeust);
if (CollUtil.isNotEmpty(supCertEntities)) {
Date curDate = new Date();
for (SupCertEntity supCertEntity : supCertEntities) {
if (supCertEntity.getExpireDate() != null && supCertEntity.getExpireDate().compareTo(curDate) < 0) {
return ResultVOUtils.error(500, "该注册备案号所属产品资质证书已过期!");
}
}
}
} else {
return ResultVOUtils.error(500, "产品资质证书未通过审核!");
}
}
if (bussinessTypeEntity.isVailDispatch()) {
if (!udiRelevanceResponse.isDispatch()) {
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());
if (basicBusTypeChangeEntity == null) {
return ResultVOUtils.error(500, "采购订单未配置转换单据类型!");
}
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(Long.parseLong(deleteRequest.getId()));
int result = orderDetailBizService.deleteById(Long.parseLong(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);
String value = systemParamConfigService.selectValueByParamKey("order_detail_visible");
if (IntUtil.value(value) == 1) {
list = list.stream()
.sorted(Comparator.comparing(IoOrderDetailBizResponse::getNameCode))
.collect(Collectors.toList());
}
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/filterListInv")
// public BaseResponse filterListInv(FilterOrderDetailBizRequest orderDetailBizRequest) {
// List<IoOrderDetailBizResponse> list = orderDetailBizService.getfilterList(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
* @return
*/
@PostMapping("/udiwms/inout/biz/deleteById")
@Log(title = "发票管理", businessType = BusinessType.DELETE)
public BaseResponse deleteById(@RequestBody IoOrderInvoiceEntity ioOrderInvoiceEntity) {
IoOrderInvoiceResponse ioOrderInvoiceResponse = orderDetailBizService.selectByinvoiceId(ioOrderInvoiceEntity.getId());
//更改 登记状态
IoOrderDetailCodeEntity ioOrderDetailBizEntity = new IoOrderDetailCodeEntity();
FilterOrderDetailBizRequest filterOrderDetailBizRequest = new FilterOrderDetailBizRequest();
FilterOrderDetailBizRequest filterOrderDetailBizRequest1 = new FilterOrderDetailBizRequest();
filterOrderDetailBizRequest1.setOrderIdFk(ioOrderInvoiceEntity.getOrderIdFk());
filterOrderDetailBizRequest1.setBatchNo(ioOrderInvoiceEntity.getBatchNo());
filterOrderDetailBizRequest.setOrderIdFk(ioOrderInvoiceEntity.getOrderIdFk());
filterOrderDetailBizRequest.setBatchNo(ioOrderInvoiceEntity.getBatchNo());
filterOrderDetailBizRequest.setRelId(ioOrderInvoiceEntity.getBizIdFk());
ioOrderDetailBizEntity.setOrderIdFk(ioOrderInvoiceEntity.getOrderIdFk());
ioOrderDetailBizEntity.setBatchNo(ioOrderInvoiceEntity.getBatchNo());
ioOrderDetailBizEntity.setBindRlFk(ioOrderInvoiceEntity.getBizIdFk());
ioOrderDetailBizEntity.setId(ioOrderInvoiceResponse.getBizIdFk().longValue());
ioOrderInvoiceService.deleteByInvId(ioOrderInvoiceEntity.getId() + "");
List<IoOrderInvoiceResponse> list = orderDetailBizService.filterListInv(filterOrderDetailBizRequest);
List<IoOrderInvoiceResponse> ioOrderInvoiceResponses = orderDetailBizService.filterListInv(filterOrderDetailBizRequest1);
if (list.size() == 0) {
ioOrderDetailBizEntity.setRegStatus(false);
} else {
ioOrderDetailBizEntity.setRegStatus(true);
}
orderDetailCodeService.updateOrderDetailBiz(ioOrderDetailBizEntity);
return ResultVOUtils.success(ioOrderInvoiceResponses);
}
/**
* 修改发票表
*
* @param ioOrderInvoiceRequest
* @return
*/
@PostMapping("/udiwms/inout/biz/updateById")
@Log(title = "发票管理", businessType = BusinessType.UPDATE)
public BaseResponse updateById(@RequestBody IoOrderInvoiceRequest ioOrderInvoiceRequest) {
IoOrderEntity orderEntity = orderService.findByBillNo(ioOrderInvoiceRequest.getOrderIdFk());
if (orderEntity != null) {
orderEntity.setUpdateTime(new Date());
orderService.update(orderEntity);
}
return ResultVOUtils.success(ioOrderInvoiceService.updateByInvId(ioOrderInvoiceRequest));
}
@PostMapping("/udiwms/inout/bizDetail/updateById")
@Log(title = "发票管理", businessType = BusinessType.UPDATE)
public BaseResponse updateBizById(@RequestBody IoOrderDetailBizEntity ioOrderDetailBizEntity) {
IoOrderEntity orderEntity = orderService.findByBillNo(ioOrderDetailBizEntity.getOrderIdFk());
if (orderEntity != null) {
orderEntity.setUpdateTime(new Date());
orderService.update(orderEntity);
}
ioOrderDetailBizEntity.setCheckFileName(ioOrderDetailBizEntity.getCheckFileName());
ioOrderDetailBizEntity.setCheckColdFileName(ioOrderDetailBizEntity.getCheckColdFileName());
boolean b = orderDetailBizService.updateOrderDetailBiz(ioOrderDetailBizEntity);
return ResultVOUtils.success("修改成功!");
}
@RepeatSubmit
@PostMapping("/udiwms/inout/biz/insertInvoice")
@Log(title = "发票管理", businessType = BusinessType.INSERT)
public BaseResponse insertInvoice(@RequestBody IoOrderInvoiceEntity ioOrderInvoice) {
String billNo = null;
for (IoOrderDetailBizEntity ioOrderDetailBizEntity : ioOrderInvoice.getList()) {
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());
ioOrderInvoiceEntity.setId(IdUtil.getSnowflakeNextId());
ioOrderInvoiceEntity.setMachineNo(ioOrderInvoice.getMachineNo());
ioOrderInvoiceEntity.setInvoiceCode(ioOrderInvoice.getInvoiceCode());
ioOrderInvoiceEntity.setInvoiceEncode(ioOrderInvoice.getInvoiceEncode());
ioOrderInvoiceEntity.setInvoiceDate(ioOrderInvoice.getInvoiceDate());
ioOrderInvoiceEntity.setPrice(ioOrderInvoice.getPrice());
ioOrderInvoiceEntity.setRemark(ioOrderInvoice.getRemark());
ioOrderInvoiceEntity.setLicenseUrl(ioOrderInvoice.getLicenseUrl());
boolean b = ioOrderInvoiceService.insertInvoice(ioOrderInvoiceEntity);
billNo = ioOrderDetailBizEntity.getOrderIdFk();
}
IoOrderEntity orderEntity = orderService.findByBillNo(billNo);
orderEntity.setUpdateTime(new Date());
orderService.update(orderEntity);
return ResultVOUtils.success("成功");
}
@GetMapping("/udiwms/inout/biz/parseInvoice")
public BaseResponse parseInvoice(String code) {
List<String> list = Arrays.asList(code.split(","));
FilterInvoiceRequest filterInvoiceRequest = new FilterInvoiceRequest();
filterInvoiceRequest.setType(list.get(1));
filterInvoiceRequest.setInvoiceCode(list.get(2));
filterInvoiceRequest.setInvoiceEncode(list.get(3));
filterInvoiceRequest.setPrice(new BigDecimal(list.get(4)));
filterInvoiceRequest.setInvoiceDate(DateUtil.formatDateTime(DateUtil.parse(list.get(5), "yyyyMMdd")));
return ResultVOUtils.success(filterInvoiceRequest);
}
@PostMapping("/udiwms/inout/biz/updateorderBiz")
public BaseResponse updateorderBiz(@RequestBody InvoiceRequest invoiceRequest) {
String billNo = null;
for (IoOrderDetailCodeEntity ioOrderDetailBizEntity : invoiceRequest.getList()) {
ioOrderInvoiceService.updateRegStatus(ioOrderDetailBizEntity);
billNo = ioOrderDetailBizEntity.getOrderIdFk();
}
IoOrderEntity orderEntity = orderService.findByBillNo(billNo);
orderEntity.setUpdateTime(new Date());
orderService.update(orderEntity);
return ResultVOUtils.success("成功");
}
/**
* 查询单据业务详情列表
*
* @param orderDetailBizRequest
* @return
*/
@GetMapping("/udiwms/inout/bizDetail/filterBizOrderList")
public BaseResponse filterBizOrderList(FilterOrderDetailCodeRequest orderDetailBizRequest) {
List<IoOrderDetailResultResponse> ioOrderDetailCodeResponses = orderDetailBizService.getfilterOrderList(orderDetailBizRequest);
List<IoOrderInvoiceEntity> orderInvoiceEntities = ioOrderInvoiceService.findByBillNo(orderDetailBizRequest.getOrderIdFk());
for (IoOrderDetailResultResponse orderDetailCodeEntity : ioOrderDetailCodeResponses) {
if (orderDetailCodeEntity.getReCount() != 0 && orderDetailCodeEntity.getPrice() != null) {
orderDetailCodeEntity.setAmount(new BigDecimal(orderDetailCodeEntity.getReCount()).multiply(orderDetailCodeEntity.getPrice()));
}
String msg = "";
for (IoOrderInvoiceEntity orderInvoiceEntity : orderInvoiceEntities) {
if (StrUtil.trimToEmpty(orderInvoiceEntity.getBatchNo()).equals(StrUtil.trimToEmpty(orderDetailCodeEntity.getBatchNo()))
&& StrUtil.trimToEmpty(orderInvoiceEntity.getBindRlFk()).equals(StrUtil.trimToEmpty(orderDetailCodeEntity.getBindRlFk() + ""))) {
orderDetailCodeEntity.setRegStatus(true);
if (StrUtil.isNotEmpty(orderInvoiceEntity.getInvoiceEncode())) {
msg += "," + orderInvoiceEntity.getInvoiceEncode();
}
}
}
if (msg.length() > 1) {
msg = msg.substring(1);
}
orderDetailCodeEntity.setInvoiceCodes(msg);
}
PageInfo<IoOrderDetailResultResponse> pageInfo = new PageInfo<>(ioOrderDetailCodeResponses);
return ResultVOUtils.page(pageInfo);
}
}