diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityRefundsExchangesController.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityRefundsExchangesController.java index c60a4c30..024530ee 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityRefundsExchangesController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityRefundsExchangesController.java @@ -407,7 +407,7 @@ public class QualityRefundsExchangesController extends BaseController public AjaxResult beforeHasConfirmSupplierSave(@RequestBody QualityRefundsExchanges qualityRefundsExchanges) { qualityRefundsExchanges.setQualityPurchaseStatus("1"); - return toAjax(qualityRefundsExchangesService.updateQualityRefundsExchanges(qualityRefundsExchanges)); + return toAjax(qualityRefundsExchangesService.updateBeforeConfirmSupplier(qualityRefundsExchanges)); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityRefundsExchanges.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityRefundsExchanges.java index 74804b68..9d962e73 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityRefundsExchanges.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityRefundsExchanges.java @@ -50,6 +50,8 @@ public class QualityRefundsExchanges extends BaseEntity @Excel(name = "入库单号") private String inStorageCode; + private String outStorageCode; + /** 入库类型 */ @Excel(name = "入库类型") private String warehouseStorageType; @@ -213,6 +215,14 @@ public class QualityRefundsExchanges extends BaseEntity this.refundsExchangesDetails = refundsExchangesDetails; } + public String getOutStorageCode() { + return outStorageCode; + } + + public void setOutStorageCode(String outStorageCode) { + this.outStorageCode = outStorageCode; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityRefundsExchangesDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityRefundsExchangesDetail.java index a7340459..7235afda 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityRefundsExchangesDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityRefundsExchangesDetail.java @@ -56,11 +56,11 @@ public class QualityRefundsExchangesDetail extends BaseEntity /** 物料数合计 */ @Excel(name = "物料数合计") - private Long materialTotal; + private int materialTotal; /** 数量合计 */ @Excel(name = "数量合计") - private Long numTotal; + private int numTotal; /** 供应商Id */ @@ -223,21 +223,21 @@ public class QualityRefundsExchangesDetail extends BaseEntity { return qualityReturnNode; } - public void setMaterialTotal(Long materialTotal) + public void setMaterialTotal(int materialTotal) { this.materialTotal = materialTotal; } - public Long getMaterialTotal() + public int getMaterialTotal() { return materialTotal; } - public void setNumTotal(Long numTotal) + public void setNumTotal(int numTotal) { this.numTotal = numTotal; } - public Long getNumTotal() + public int getNumTotal() { return numTotal; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityRefundsExchangesService.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityRefundsExchangesService.java index 03605596..f6d2437d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityRefundsExchangesService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityRefundsExchangesService.java @@ -81,6 +81,8 @@ public interface IQualityRefundsExchangesService int returnBeforeStorageDetail(QualityRefundsExchanges qualityRefundsExchanges); + int updateBeforeConfirmSupplier(QualityRefundsExchanges qualityRefundsExchanges); + /** * 保存入库后退货-选择供应商-无供应商 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityRefundsExchangesServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityRefundsExchangesServiceImpl.java index 4ed7aed8..8d819f9b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityRefundsExchangesServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityRefundsExchangesServiceImpl.java @@ -1,9 +1,7 @@ package com.ruoyi.quality.service.impl; import java.text.DecimalFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.List; import com.ruoyi.common.core.redis.RedisCache; @@ -16,9 +14,12 @@ import com.ruoyi.quality.domain.QualityRefundsExchangesUnqualified; import com.ruoyi.quality.domain.VO.QualityRefundsExchangesExportVO; import com.ruoyi.quality.mapper.QualityRefundsExchangesDetailMapper; import com.ruoyi.quality.mapper.QualityRefundsExchangesUnqualifiedMapper; -import com.ruoyi.storehouse.domain.WarehousingInInfo; +import com.ruoyi.warehouse.domain.WarehouseOutOrder; +import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail; import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; +import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; +import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper; import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper; import com.ruoyi.warehouse.mapper.WarehouseStorageOrderMapper; import lombok.extern.slf4j.Slf4j; @@ -29,6 +30,7 @@ import com.ruoyi.quality.domain.QualityRefundsExchanges; import com.ruoyi.quality.service.IQualityRefundsExchangesService; import com.ruoyi.common.core.text.Convert; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; /** * 品质管理退换货单Service业务层处理 @@ -56,7 +58,10 @@ public class QualityRefundsExchangesServiceImpl implements IQualityRefundsExchan private WarehouseStorageOrderDetailMapper warehouseStorageOrderDetailMapper; @Autowired - private WarehouseStorageOrderDetailMapper storageOrderDetailMapper; + private WarehouseOutOrderMapper warehouseOutOrderMapper; + + @Autowired + private WarehouseOutOrderDetailMapper warehouseOutOrderDetailMapper; @Autowired private RedisCache redisCache; @@ -91,6 +96,7 @@ public class QualityRefundsExchangesServiceImpl implements IQualityRefundsExchan * @param qualityRefundsExchanges 品质管理退换货单 * @return 结果 */ + @Transactional(rollbackFor = Exception.class) @Override public int insertQualityRefundsExchanges(QualityRefundsExchanges qualityRefundsExchanges) { @@ -143,7 +149,7 @@ public class QualityRefundsExchangesServiceImpl implements IQualityRefundsExchan List warehouseStorageOrderDetails = createWarehouseStorageDetail(qualityRefundsExchanges,warehouseStorageOrder.getWarehouseStorageCode()); warehouseStorageOrderMapper.batchWarehouseStorageOrderDetail(warehouseStorageOrderDetails); - qualityRefundsExchanges.setQualityWarehouseStatus("0"); + qualityRefundsExchanges.setQualityWarehouseStatus("1"); qualityRefundsExchanges.setInStorageCode(warehouseStorageOrder.getWarehouseStorageCode()); qualityRefundsExchangesMapper.insertQualityRefundsExchanges(qualityRefundsExchanges); return 1; @@ -281,10 +287,38 @@ public class QualityRefundsExchangesServiceImpl implements IQualityRefundsExchan return 1; } + /** + * 保存入库前退货-确认供应商-有供应商 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int updateBeforeConfirmSupplier(QualityRefundsExchanges qualityRefundsExchanges) + { + QualityRefundsExchanges refundsExchanges = qualityRefundsExchangesMapper.selectQualityRefundsExchangesById(qualityRefundsExchanges.getRefundsExchangesId()); + List details = refundsExchangesDetailMapper.selectRefundsExchangesDetailListByCode(refundsExchanges.getRefundsExchangesCode()); + if(CollectionUtils.isEmpty(details)){ + throw new BusinessException("退换货详情为空!"); + } + refundsExchanges.setRefundsExchangesDetails(details); + WarehouseOutOrder warehouseOutOrder = generateWarehouseOutOrder(refundsExchanges); + int insertOutResult = warehouseOutOrderMapper.insertWarehouseOutOrder(warehouseOutOrder); + if(insertOutResult<=0){ + throw new BusinessException("新增退换货出库单失败!"); + } + + qualityRefundsExchanges.setQualityWarehouseStatus("2"); + String loginName = ShiroUtils.getLoginName(); + qualityRefundsExchanges.setUpdateBy(loginName); + qualityRefundsExchanges.setUpdateTime(DateUtils.getNowDate()); + int updateResult = qualityRefundsExchangesMapper.updateQualityRefundsExchanges(qualityRefundsExchanges); + + return updateResult; + } + /** * 保存入库后退货-选择供应商-无供应商 */ - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public int updateAfterNoConfirmSupplier(QualityRefundsExchanges qualityRefundsExchanges) { String loginName = ShiroUtils.getLoginName(); @@ -317,13 +351,85 @@ public class QualityRefundsExchangesServiceImpl implements IQualityRefundsExchan //更新数据库记录 updateRows += refundsExchangesDetailMapper.updateQualityRefundsExchangesDetail(refundsExchangesDetail); } + + + WarehouseOutOrder warehouseOutOrder = generateWarehouseOutOrder(qualityRefundsExchanges); + int insertOutResult = warehouseOutOrderMapper.insertWarehouseOutOrder(warehouseOutOrder); + if(insertOutResult<=0){ + throw new BusinessException("新增退换货出库单失败!"); + } + qualityRefundsExchanges.setQualityPurchaseStatus("1"); qualityRefundsExchanges.setUpdateBy(loginName); qualityRefundsExchanges.setUpdateTime(DateUtils.getNowDate()); - qualityRefundsExchangesMapper.updateQualityRefundsExchanges(qualityRefundsExchanges); + qualityRefundsExchanges.setOutStorageCode(warehouseOutOrder.getOutOrderCode()); + + int updateResult = qualityRefundsExchangesMapper.updateQualityRefundsExchanges(qualityRefundsExchanges); + if(updateResult<=0){ + throw new BusinessException("更新退换货订单失败!"); + } return updateRows; } - +// 根据退换货订单生成出库单 + public WarehouseOutOrder generateWarehouseOutOrder(QualityRefundsExchanges refundsExchanges){ + WarehouseOutOrder warehouseOutOrder = new WarehouseOutOrder(); + String outOrderCode = redisCache.generateBillNo("CK"); + warehouseOutOrder.setOutOrderCode(outOrderCode); + warehouseOutOrder.setWarehouseOutStatus("4");//出库状态:待出库 + warehouseOutOrder.setWarehouseOrderType("4");//出库订单类型:退换货订单 + warehouseOutOrder.setWarehouseOutType("4");//出库类型:公司退货 + warehouseOutOrder.setRelatedOrderCode(refundsExchanges.getRefundsExchangesCode()); + warehouseOutOrder.setBusinessName(ShiroUtils.getLoginName()); + warehouseOutOrder.setMaterialSum(refundsExchanges.getMaterialTotal()); + warehouseOutOrder.setEnterpriseSum(refundsExchanges.getNumTotal()); + warehouseOutOrder.setApplyName(ShiroUtils.getLoginName()); + warehouseOutOrder.setCreateBy(ShiroUtils.getLoginName()); + warehouseOutOrder.setCreateTime(DateUtils.getNowDate()); + + int insertResult = 0; + List refundsExchangesDetails = refundsExchanges.getRefundsExchangesDetails(); + if(CollectionUtils.isEmpty(refundsExchangesDetails)){ + throw new BusinessException("新增出库单详情失败!退换货详情数据为空!"); + } + for (QualityRefundsExchangesDetail detail:refundsExchangesDetails) { + insertResult += generateWarehouseOutOrderDetail(detail,outOrderCode); + } + if(insertResult!=refundsExchangesDetails.size()){ + throw new BusinessException("新增出库单详情失败!"); + } + return warehouseOutOrder; + } +// 根据退换货单详情生成出库单详情 + public int generateWarehouseOutOrderDetail(QualityRefundsExchangesDetail exchangeDetail,String outOrderCode){ + WarehouseOutOrderDetail outOrderDetail = new WarehouseOutOrderDetail(); + outOrderDetail.setOutOrderCode(outOrderCode); + outOrderDetail.setRelatedOrderCode(exchangeDetail.getRefundsExchangesCode()); + outOrderDetail.setWarehouseOutStatus("4");//出库状态:待出库 + outOrderDetail.setWarehouseOrderType("4");//出库订单类型:退换货订单 + outOrderDetail.setWarehouseOutType("4");//出库类型:公司退货 + outOrderDetail.setBusinessName(ShiroUtils.getLoginName()); + outOrderDetail.setMaterialNo(exchangeDetail.getMaterialNo()); + outOrderDetail.setMaterialName(exchangeDetail.getMaterialName()); + outOrderDetail.setMaterialType(exchangeDetail.getMaterialType()); + outOrderDetail.setMaterialPhotourl(exchangeDetail.getMaterialPhotourl()); + outOrderDetail.setMaterialBrand(exchangeDetail.getMaterialBrand()); + outOrderDetail.setMaterialUnit(exchangeDetail.getMaterialUnit()); + outOrderDetail.setMaterialDescribe(exchangeDetail.getMaterialDescribe()); + outOrderDetail.setMaterialProcessMethod(exchangeDetail.getMaterialProcessMethod()); + outOrderDetail.setMaterialSum(exchangeDetail.getMaterialTotal()); + outOrderDetail.setEnterpriseSum(exchangeDetail.getNumTotal()); + outOrderDetail.setApplyOutOrderSum(exchangeDetail.getRefundsExchangesNum()); + outOrderDetail.setSupplierCode(exchangeDetail.getSupplierCode()); + outOrderDetail.setSupplierName(exchangeDetail.getSupplierName()); + outOrderDetail.setDeliveryName(exchangeDetail.getCustomerContact()); + outOrderDetail.setDeliveryNumber(exchangeDetail.getContactNumber()); + outOrderDetail.setDeliveryAddress(exchangeDetail.getSupplierAddress()); + outOrderDetail.setApplyName(ShiroUtils.getLoginName()); + outOrderDetail.setCreateBy(ShiroUtils.getLoginName()); + outOrderDetail.setCreateTime(DateUtils.getNowDate()); + int insertResult = warehouseOutOrderDetailMapper.insertWarehouseOutOrderDetail(outOrderDetail); + return insertResult; + } /** * 保存入库前退货-确认收货 */ diff --git a/ruoyi-admin/src/main/resources/mapper/quality/QualityRefundsExchangesMapper.xml b/ruoyi-admin/src/main/resources/mapper/quality/QualityRefundsExchangesMapper.xml index 8707c69f..acfa07ea 100644 --- a/ruoyi-admin/src/main/resources/mapper/quality/QualityRefundsExchangesMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/quality/QualityRefundsExchangesMapper.xml @@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -27,20 +28,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select refunds_exchanges_id, refunds_exchanges_code, refunds_exchanges_status, quality_warehouse_status, quality_purchase_status, quality_delivery_status ,related_order_code, in_storage_code, warehouse_storage_type ,quality_return_node, material_total, num_total, delivery_inspection_time, quality_remark, remark, create_by, create_time, update_by, update_time from quality_refunds_exchanges + select refunds_exchanges_id, refunds_exchanges_code, refunds_exchanges_status, quality_warehouse_status, quality_purchase_status, quality_delivery_status ,related_order_code, in_storage_code, out_storage_code, warehouse_storage_type ,quality_return_node, material_total, num_total, delivery_inspection_time, quality_remark, remark, create_by, create_time, update_by, update_time from quality_refunds_exchanges @@ -59,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" quality_delivery_status, related_order_code, in_storage_code, + out_storage_code, warehouse_storage_type, quality_return_node, material_total, @@ -79,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{qualityDeliveryStatus}, #{relatedOrderCode}, #{inStorageCode}, + #{outStorageCode}, #{warehouseStorageType}, #{qualityReturnNode}, #{materialTotal}, @@ -103,6 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" quality_delivery_status = #{qualityDeliveryStatus}, related_order_code = #{relatedOrderCode}, in_storage_code = #{inStorageCode}, + out_storage_code = #{outStorageCode}, warehouse_storage_type = #{warehouseStorageType}, quality_return_node = #{qualityReturnNode}, material_total = #{materialTotal}, diff --git a/ruoyi-admin/src/main/resources/templates/quality/refundsExchanges/refundsExchanges.html b/ruoyi-admin/src/main/resources/templates/quality/refundsExchanges/refundsExchanges.html index 9aa2996d..90221ed0 100644 --- a/ruoyi-admin/src/main/resources/templates/quality/refundsExchanges/refundsExchanges.html +++ b/ruoyi-admin/src/main/resources/templates/quality/refundsExchanges/refundsExchanges.html @@ -52,7 +52,9 @@
  • - + + - +
  •  搜索 @@ -103,6 +105,7 @@ updateUrl: prefix + "/edit/{id}", exportUrl: prefix + "/export", modalName: "品质管理退换货单", + showFooter: true, columns: [{ checkbox: true }, @@ -150,10 +153,24 @@ { title: '物料合计', field: 'materialTotal', + footerFormatter: function (value) { + var sum = 0; + for (var i in value) { + sum += parseFloat(value[i].materialTotal)|| 0; + } + return "总物料: " + sum; + } }, { title: '数量合计', field: 'numTotal', + footerFormatter: function (value) { + var sum = 0; + for (var i in value) { + sum += parseFloat(value[i].numTotal)|| 0; + } + return "总数量: " + sum; + } }, { title: '交付质检时间', @@ -182,7 +199,7 @@ formatter: function(value, row, index) { var actions = []; // actions.push('编辑 '); - if (row.refundsExchangesStatus == 0 && row.qualityPurchaseStatus == 4){ + if (row.refundsExchangesStatus == 0 && row.qualityPurchaseStatus >= 3){ actions.push('结案 '); } /*入库前退货详情*/ @@ -194,17 +211,21 @@ actions.push('详情 '); } /*入库前退换货-确认供应商-已有供应商*/ - if (row.qualityReturnNode == 0){ + if (row.qualityReturnNode == 0 && row.qualityPurchaseStatus == 0 && row.qualityWarehouseStatus == 1){ actions.push('确认供应商 '); + } + /*入库前退换货-确认收货-已有供应商*/ + if (row.qualityReturnNode == 0 && row.qualityPurchaseStatus != 0 && row.qualityWarehouseStatus > 2 ){ actions.push('确认收货 '); - } /*入库后退货-确认供应商-没有供应商*/ - if (row.qualityReturnNode == 1){ + if (row.qualityReturnNode == 1 && row.qualityPurchaseStatus == 0 && row.qualityWarehouseStatus == 1){ actions.push('确认供应商 '); + } + /*入库前退换货-确认收货-已有供应商*/ + if (row.qualityReturnNode == 1 && row.qualityPurchaseStatus != 0 && row.qualityWarehouseStatus > 2 ){ actions.push('确认收货 '); - } diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/refundsExchangesOutWarehouse.html b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/refundsExchangesOutWarehouse.html index 9ff1c7fc..be668a1d 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/refundsExchangesOutWarehouse.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/warehouseOutOrder/refundsExchangesOutWarehouse.html @@ -59,6 +59,8 @@