diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityOrderController.java index 49c71e12..671b19df 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityOrderController.java @@ -302,6 +302,61 @@ public class QualityOrderController extends BaseController return toAjax(orderReportService.updateMakeInOrderReport(qualityOrderReport)); } + /** + * 委外加工品质单开始品质 + */ + @GetMapping("/makeOutStartingQuality/{qualityOrderId}") + public String makeOStartingQuality(@PathVariable("qualityOrderId") Long qualityOrderId, ModelMap mmap) + { + QualityOrder qualityOrder = qualityOrderService.selectQualityOrderById(qualityOrderId); + mmap.put("qualityOrder", qualityOrder); + return prefix + "/makeOutStartingQuality"; + } + /** + * 修改保存委外加工品质单开始品质 + */ + @RequiresPermissions("quality:qualityOrder:makeInStartingQuality") + @Log(title = "品质管理品质单", businessType = BusinessType.UPDATE) + @PostMapping("/makeOutStartingQuality") + @ResponseBody + public AjaxResult makeOutStartingQualitySave(@RequestBody QualityOrder qualityOrder) + { + return toAjax(qualityOrderService.updateMakeOutStartingQuality(qualityOrder)); + } + /** + * 委外加工品质单开始品质列表详情接口 + */ + @GetMapping("/makeOutStartingQualityDetail/{qualityOrderId}") + public String makeOutStartingQualityDetail(@PathVariable("qualityOrderId") Long qualityOrderId, ModelMap mmap) + { + QualityOrder qualityOrder = qualityOrderService.selectQualityOrderById(qualityOrderId); + mmap.put("qualityOrder", qualityOrder); + return prefix + "/makeOutStartingQualityDetail"; + } + /** + * 修改委外加工入库单品质报告按钮 + */ + @GetMapping("/makeOutOrderReport") + public String makeOutOrderReport( @RequestParam("materialNo") String materialNo, + @RequestParam("qualityOrderCode") String qualityOrderCode, + ModelMap mmap) + { + QualityOrderReport qualityOrderReport = orderReportService.selectMakeInOrderReportByNoAndCode(materialNo,qualityOrderCode); + mmap.put("qualityOrderReport", qualityOrderReport); + mmap.put("qualityOrderCode",qualityOrderCode); + return prefix + "/makeOutOrderReport"; + } + + /** + * 修改保存委外加工入库单品质报告按钮 + */ + @Log(title = "品质管理品质单", businessType = BusinessType.UPDATE) + @PostMapping("/makeOutOrderReport") + @ResponseBody + public AjaxResult makeOutOrderReportSave(@RequestBody QualityOrderReport qualityOrderReport) + { + return toAjax(orderReportService.updateMakeInOrderReport(qualityOrderReport)); + } /*1111111111*/ /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityOrderService.java index dfa0fa4f..31040279 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityOrderService.java @@ -6,6 +6,7 @@ import com.ruoyi.quality.domain.QualityOrderDetail; import com.ruoyi.quality.domain.QualityOrderReport; import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; +import org.springframework.transaction.annotation.Transactional; /** * 品质管理品质单Service接口 @@ -82,11 +83,21 @@ public interface IQualityOrderService * */ void insertQualityOrderByWarehouseStorageOrder(WarehouseStorageOrder warehouseStorageOrder, List warehouseStorageOrderDetailList); + /* + * 委外入库仓库入库后生成品质单 + * */ + void insertQualityOrderByOutsourceStorageOrder(WarehouseStorageOrder warehouseStorageOrder, List storageOrderDetailList); + /* * 修改保存委内加工品质单开始品质 * */ int updateMakeInStartingQuality(QualityOrder qualityOrder); + /* + * 修改保存委外加工品质单开始品质 + * */ + int updateMakeOutStartingQuality(QualityOrder qualityOrder); + /** * 查询委内加工品质单开始品质 物料相关信息 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java index c712d14b..5f46bac4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderServiceImpl.java @@ -1,6 +1,5 @@ package com.ruoyi.quality.service.impl; -import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -16,7 +15,6 @@ import com.ruoyi.quality.mapper.*; import com.ruoyi.quality.service.IQualityOrderReportService; import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; -import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper; import com.ruoyi.warehouse.mapper.WarehouseStorageOrderMapper; import com.ruoyi.warehouse.service.IWarehouseStorageOrderService; @@ -255,6 +253,9 @@ public class QualityOrderServiceImpl implements IQualityOrderService // 根据品质单生成退换货单 @Transactional(rollbackFor = Exception.class) public int generateBeforeRefundsExchanges(QualityOrder qualityOrder){ + if(qualityOrder.getQualityUnqualifiedNum() == 0){ + return 0; + } QualityRefundsExchanges refundsExchanges = new QualityRefundsExchanges(); refundsExchanges.setRefundsExchangesCode(redisCache.generateBillNo("THH")); refundsExchanges.setRelatedOrderCode(qualityOrder.getQualityOrderCode()); @@ -526,6 +527,45 @@ public class QualityOrderServiceImpl implements IQualityOrderService } + /* + * 委外入库仓库暂收生成品质单 + * */ + @Override + public void insertQualityOrderByOutsourceStorageOrder(WarehouseStorageOrder warehouseStorageOrder, List storageOrderDetailList) { + QualityOrder qualityOrder = new QualityOrder(); + qualityOrder.setCreateTime(DateUtils.getNowDate()); + qualityOrder.setCreateBy(warehouseStorageOrder.getCreateBy()); + //使用redis自动生成品质单号 + String qualityOrderCode = redisCache.generateBillNo("PZ"); + + qualityOrder.setQualityOrderCode(qualityOrderCode); + qualityOrder.setInStorageCode(warehouseStorageOrder.getWarehouseStorageCode()); + qualityOrder.setRelatedOrderCode(warehouseStorageOrder.getRelatedOrderCode()); + qualityOrder.setQualityStatus("0"); + qualityOrder.setQualityOrderType("2"); + qualityOrder.setQualityStorageStatus("2"); + // 计算本次到货数合计 + int totalReceivedQuantity = storageOrderDetailList.stream() + .mapToInt(WarehouseStorageOrderDetail::getActualArriveNum) + .sum(); + qualityOrder.setThisArrivedNum(totalReceivedQuantity); + + qualityOrder.setWarehouseCode(warehouseStorageOrder.getWarehouseCode()); + qualityOrder.setWarehouseName(warehouseStorageOrder.getWarehouseName()); + qualityOrder.setDeliveryInspectionTime(warehouseStorageOrder.getDeliveryInspectionTime()); + qualityOrder.setCreateBy(ShiroUtils.getLoginName()); + qualityOrder.setCreateTime(DateUtils.getNowDate()); + qualityOrderMapper.insertQualityOrder(qualityOrder); + + //新增三个子表的数据 + for (WarehouseStorageOrderDetail detail : storageOrderDetailList) { + // 构建QualityOrderDetail,假设其他属性与QualityOrder相同,故不重复设置 + insertQualityOrderDetailByWarehouseStorageOrder(warehouseStorageOrder, detail, qualityOrderCode); + insertQualityOrderReportByWarehouseStorageOrder(detail,qualityOrderCode); + insertQualityOrderUnqualifiedByWarehouseStorageOrder(detail); + // ... + } + } /* * 修改保存委内加工品质单开始品质 * */ @@ -647,6 +687,120 @@ public class QualityOrderServiceImpl implements IQualityOrderService } + + /* + * 修改保存委外加工品质单开始品质 + * */ + @Transactional(rollbackFor = Exception.class) + @Override + public int updateMakeOutStartingQuality(QualityOrder qualityOrder) { + String loginName = ShiroUtils.getLoginName(); + qualityOrder.setUpdateBy(loginName); + qualityOrder.setUpdateTime(DateUtils.getNowDate()); + qualityOrder.setQualityEmployee(loginName); + List qualityOrderDetailList = qualityOrder.getQualityOrderDetailList(); + if (CollectionUtils.isEmpty(qualityOrderDetailList)){ + throw new BusinessException("品质单详情数据为空"); + } + + for (QualityOrderDetail qualityOrderDetail : qualityOrderDetailList) { + qualityOrderDetail.setUpdateBy(loginName); + qualityOrderDetail.setUpdateTime(DateUtils.getNowDate()); + Long qualityOrderDetailId = qualityOrderDetail.getQualityOrderDetailId(); + QualityOrderDetail tempQualityOrderDetail = orderDetailMapper.selectQualityOrderDetailById(qualityOrderDetailId); + Integer qualifiedNum = tempQualityOrderDetail.getQualityQualifiedNum(); + Integer unqualifiedNum = tempQualityOrderDetail.getQualityUnqualifiedNum(); + if (qualifiedNum == null || unqualifiedNum == null){ + throw new BusinessException("请先进行品质报告操作"); + } + qualityOrderDetail.setInStorageCode(qualityOrder.getInStorageCode()); + //更新品质单详情数据 + int updateQualityOrderDetailResult = orderDetailMapper.updateQualityOrderDetail(qualityOrderDetail); + if (updateQualityOrderDetailResult <= 0){ + throw new BusinessException("更新品质单详情数据失败"); + } + } + //根据品质单号从数据库查询 用于更新入库单 + QualityOrder tempQualityOrder = qualityOrderMapper.selectQualityOrderByCode(qualityOrder.getQualityOrderCode()); + String qualityStatus = tempQualityOrder.getQualityStatus(); + String qualityStorageStatus = tempQualityOrder.getQualityStorageStatus(); + + Integer thisArrivedNumSum = 0; + Integer qualityQualifiedNumSum = 0; + Integer qualityUnqualifiedNumSum = 0; + +// 检查thisArrivedNum是否含有null值 + boolean hasThisArrivedNumNull = qualityOrderDetailList.stream() + .anyMatch(item -> item.getThisArrivedNum() == null); + +// 检查qualityQualifiedNum是否含有null值 + boolean hasQualityQualifiedNumNull = qualityOrderDetailList.stream() + .anyMatch(item -> item.getQualityQualifiedNum() == null); + +// 检查qualityUnqualifiedNum是否含有null值 + boolean hasQualityUnqualifiedNumNull = qualityOrderDetailList.stream() + .anyMatch(item -> item.getQualityUnqualifiedNum() == null); + + if (hasThisArrivedNumNull) { + throw new BusinessException("存在本次到货数为空,请检查!"); + } + if (hasQualityQualifiedNumNull) { + throw new BusinessException("存在品质已合格数为空,请检查!"); + } + if (hasQualityUnqualifiedNumNull) { + throw new BusinessException("存在品质不合格数为空,请检查!"); + } +// 计算各个字段的总和 + thisArrivedNumSum = qualityOrderDetailList.stream() + .mapToInt(QualityOrderDetail::getThisArrivedNum) + .sum(); + + qualityQualifiedNumSum = qualityOrderDetailList.stream() + .mapToInt(QualityOrderDetail::getQualityQualifiedNum) + .sum(); + + qualityUnqualifiedNumSum = qualityOrderDetailList.stream() + .mapToInt(QualityOrderDetail::getQualityUnqualifiedNum) + .sum(); + //插入主表中本次到货数 + qualityOrder.setThisArrivedNum(thisArrivedNumSum); + //插入主表中品质合格数 + qualityOrder.setQualityQualifiedNum(qualityQualifiedNumSum); + //插入主表中品质不合格数 + qualityOrder.setQualityUnqualifiedNum(qualityUnqualifiedNumSum); + +// if (thisArrivedNum == qualityQualifiedNum){ + //全部品质 + qualityOrder.setQualityStatus("2"); + tempQualityOrder.setQualityStatus("2"); +// }else { +// //部分品质 +// qualityOrder.setQualityStatus("1"); +// tempQualityOrder.setQualityStatus("1"); +// } + + + //如果品质时修改交检时间 + tempQualityOrder.setDeliveryInspectionTime(qualityOrder.getDeliveryInspectionTime()); + tempQualityOrder.setQualityQualifiedNum(qualityQualifiedNumSum); + tempQualityOrder.setQualityUnqualifiedNum(qualityUnqualifiedNumSum); + tempQualityOrder.setThisArrivedNum(thisArrivedNumSum); + + + //数据生成到入库单中,后续进行入库操作 + int updateStorageOrderResult = warehouseStorageOrderService.updateWarehouseStorageOrderByOutQualityOrder(tempQualityOrder, qualityOrderDetailList); + if (updateStorageOrderResult <= 0){ + throw new BusinessException("更新入库单数据失败"); + } + + int updateResult = qualityOrderMapper.updateQualityOrder(qualityOrder); + if (updateResult <= 0){ + log.warn("更新品质单失败,未影响任何行"); + } + return updateResult; + + } + /** * 查询委内加工品质单开始品质 物料相关信息 */ @@ -686,7 +840,7 @@ public class QualityOrderServiceImpl implements IQualityOrderService String loginName = ShiroUtils.getLoginName(); qualityOrder.setUpdateBy(loginName); - qualityOrder.setUpdateTime(new Date()); + qualityOrder.setUpdateTime(DateUtils.getNowDate()); qualityOrder.setQualityEmployee(loginName); //生成入库单号 String warehouseStorageCode = redisCache.generateBillNo("RK"); @@ -868,8 +1022,5 @@ public class QualityOrderServiceImpl implements IQualityOrderService if (insertResult <= 0){ throw new BusinessException("插入品质单详情失败"); } - - } - } diff --git a/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/makeOutOrderReport.html b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/makeOutOrderReport.html new file mode 100644 index 00000000..f8b47f23 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/makeOutOrderReport.html @@ -0,0 +1,298 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+

合格数

+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ +
+
+
+ 不合格数 + + 添加 + +
+
+
+
+
+
+
+
+ +
+ + +
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/makeOutStartingQuality.html b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/makeOutStartingQuality.html new file mode 100644 index 00000000..976e1c50 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/makeOutStartingQuality.html @@ -0,0 +1,256 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/makeOutStartingQualityDetail.html b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/makeOutStartingQualityDetail.html new file mode 100644 index 00000000..c900e877 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/makeOutStartingQualityDetail.html @@ -0,0 +1,180 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/qualityOrder.html b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/qualityOrder.html index 466f2c22..d4aa8399 100644 --- a/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/qualityOrder.html +++ b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/qualityOrder.html @@ -188,6 +188,14 @@ if (row.qualityStorageStatus == 4 ){ actions.push('详情 '); } + //委外入库品质 + if (row.qualityStatus != 2 && row.qualityStorageStatus == 2 ){ + actions.push('品质 '); + } + //委外入库品质详情 + if (row.qualityStorageStatus == 2 ){ + actions.push('详情 '); + } return actions.join(''); } }] @@ -220,6 +228,18 @@ $.modal.open("进行品质详情",url) } + //委内加工单品质 + function makeOutStartingQuality(qualityOrderId){ + var url = ctx +'quality/qualityOrder/makeOutStartingQuality/' + qualityOrderId; + $.modal.open("进行品质",url) + } + + //委内加工单品质详情 + function makeOutStartingQualityDetail(qualityOrderId){ + var url = ctx +'quality/qualityOrder/makeOutStartingQualityDetail/' + qualityOrderId; + $.modal.open("品质详情",url) + } + //生产入库品质 function makeStartingQuality(qualityOrderId){ var url = ctx +'quality/qualityOrder/makeStartingQuality/' + qualityOrderId;