From 0bae138ed3cbf69eef054a1b78142aea40829aef Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Wed, 15 May 2024 15:14:34 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E5=93=81=E8=B4=A8=E7=AE=A1=E7=90=86:=20?= =?UTF-8?q?=E9=80=80=E6=A3=80=E7=AE=A1=E7=90=86=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=80=80=E6=A3=80=E7=AE=A1=E7=90=86Controller=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=80=80=E6=A3=80=E7=AE=A1=E7=90=86Service=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=80=E6=A3=80=E7=AE=A1=E7=90=86ServiceIm?= =?UTF-8?q?pl=20=E6=96=B0=E5=A2=9E=E5=88=B6=E7=A8=8B=E5=B7=A5=E5=BA=8Fretu?= =?UTF-8?q?rnInspection.html=20=E5=AE=8C=E6=88=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=A1=AB=E5=85=85=EF=BC=8C=E9=A1=B5=E9=9D=A2=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=EF=BC=8C=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QualityReturnInspectionController.java | 119 ++++++ .../IQualityReturnInspectionService.java | 53 +++ .../QualityReturnInspectionServiceImpl.java | 140 +++++++ .../quality/returnInspection/edit.html | 384 ++++++++++++++++++ .../returnInspection/returnInspection.html | 135 ++++++ 5 files changed, 831 insertions(+) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityReturnInspectionController.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityReturnInspectionService.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityReturnInspectionServiceImpl.java create mode 100644 ruoyi-admin/src/main/resources/templates/quality/returnInspection/edit.html create mode 100644 ruoyi-admin/src/main/resources/templates/quality/returnInspection/returnInspection.html diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityReturnInspectionController.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityReturnInspectionController.java new file mode 100644 index 00000000..68d60143 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityReturnInspectionController.java @@ -0,0 +1,119 @@ +package com.ruoyi.quality.controller; + +import java.util.List; + +import com.ruoyi.erp.domain.ErpMaterialReturnInspection; +import com.ruoyi.erp.domain.ErpMaterialReturnInspectionExcelDto; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.quality.service.IQualityReturnInspectionService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 物料退检单Controller + * + * @author 刘晓旭 + * @date 2024-05-15 + */ +@Controller +@RequestMapping("/quality/returnInspection") +public class QualityReturnInspectionController extends BaseController +{ + private String prefix = "quality/returnInspection"; + + @Autowired + private IQualityReturnInspectionService qualityReturnInspectionService; + + @RequiresPermissions("quality:returnInspection:view") + @GetMapping() + public String returnInspection() + { + return prefix + "/returnInspection"; + } + + /** + * 查询物料退检单列表 + */ + @RequiresPermissions("quality:returnInspection:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(ErpMaterialReturnInspection erpMaterialReturnInspection) + { + startPage(); + List list = qualityReturnInspectionService.selectQualityReturnInspectionList(erpMaterialReturnInspection); + return getDataTable(list); + } + + /** + * 导出物料退检单列表 + */ + @RequiresPermissions("quality:returnInspection:export") + @Log(title = "物料退检单", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(ErpMaterialReturnInspection erpMaterialReturnInspection) + { + List list = qualityReturnInspectionService.selectExportList(erpMaterialReturnInspection); + ExcelUtil util = new ExcelUtil(ErpMaterialReturnInspectionExcelDto.class); + return util.exportExcel(list, "物料退检单数据"); + } + + /** + * 新增物料退检单 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存物料退检单 + */ + @RequiresPermissions("quality:returnInspection:add") + @Log(title = "物料退检单", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(ErpMaterialReturnInspection erpMaterialReturnInspection) + { + return toAjax(qualityReturnInspectionService.insertQualityReturnInspection(erpMaterialReturnInspection)); + } + + /** + * 修改物料退检单 + */ + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") Long id, ModelMap mmap) + { + ErpMaterialReturnInspection erpMaterialReturnInspection = qualityReturnInspectionService.selectQualityReturnInspectionById(id); + mmap.put("erpMaterialReturnInspection", erpMaterialReturnInspection); + return prefix + "/edit"; + } + + /** + * 修改保存物料退检单 + */ + @RequiresPermissions("quality:returnInspection:edit") + @Log(title = "物料退检单", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(ErpMaterialReturnInspection erpMaterialReturnInspection) + { + return toAjax(qualityReturnInspectionService.updateQualityReturnInspection(erpMaterialReturnInspection)); + } + + + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityReturnInspectionService.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityReturnInspectionService.java new file mode 100644 index 00000000..425f5790 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/IQualityReturnInspectionService.java @@ -0,0 +1,53 @@ +package com.ruoyi.quality.service; + +import java.util.List; + +import com.ruoyi.erp.domain.ErpMaterialReturnInspection; +import com.ruoyi.erp.domain.ErpMaterialReturnInspectionExcelDto; + +/** + * 物料退检单Service接口 + * + * @author 刘晓旭 + * @date 2024-05-15 + */ +public interface IQualityReturnInspectionService +{ + /** + * 查询物料退检单 + * + * @param id 物料退检单ID + * @return 物料退检单 + */ + public ErpMaterialReturnInspection selectQualityReturnInspectionById(Long id); + + /** + * 查询物料退检单列表 + * + * @param qualityReturnInspection 物料退检单 + * @return 物料退检单集合 + */ + public List selectQualityReturnInspectionList(ErpMaterialReturnInspection erpMaterialReturnInspection); + + /** + * 新增物料退检单 + * + * @param qualityReturnInspection 物料退检单 + * @return 结果 + */ + public int insertQualityReturnInspection(ErpMaterialReturnInspection erpMaterialReturnInspection); + + /** + * 修改物料退检单 + * + * @param qualityReturnInspection 物料退检单 + * @return 结果 + */ + public int updateQualityReturnInspection(ErpMaterialReturnInspection erpMaterialReturnInspection); + + + /** + * 导出列表查询 + * */ + List selectExportList(ErpMaterialReturnInspection erpMaterialReturnInspection); +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityReturnInspectionServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityReturnInspectionServiceImpl.java new file mode 100644 index 00000000..0330ccfe --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityReturnInspectionServiceImpl.java @@ -0,0 +1,140 @@ +package com.ruoyi.quality.service.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import cn.hutool.core.collection.CollectionUtil; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.erp.domain.ErpMaterialReturnInspection; +import com.ruoyi.erp.domain.ErpMaterialReturnInspectionDetail; +import com.ruoyi.erp.domain.ErpMaterialReturnInspectionExcelDto; +import com.ruoyi.erp.mapper.ErpMaterialReturnInspectionMapper; +import com.ruoyi.erp.service.IErpMaterialReturnInspectionDetailService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.quality.service.IQualityReturnInspectionService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 物料退检单Service业务层处理 + * + * @author 刘晓旭 + * @date 2024-05-15 + */ +@Service +public class QualityReturnInspectionServiceImpl implements IQualityReturnInspectionService +{ + @Autowired + private ErpMaterialReturnInspectionMapper erpMaterialReturnInspectionMapper; + + @Autowired + private RedisCache redisCache; + + @Autowired + private IErpMaterialReturnInspectionDetailService materialReturnInspectionDetailService; + + /** + * 查询物料退检单 + * + * @param id 物料退检单ID + * @return 物料退检单 + */ + @Override + public ErpMaterialReturnInspection selectQualityReturnInspectionById(Long id) + { + return erpMaterialReturnInspectionMapper.selectErpMaterialReturnInspectionById(id); + } + + /** + * 查询物料退检单列表 + * + * @param qualityReturnInspection 物料退检单 + * @return 物料退检单 + */ + @Override + public List selectQualityReturnInspectionList(ErpMaterialReturnInspection erpMaterialReturnInspection) + { + return erpMaterialReturnInspectionMapper.selectErpMaterialReturnInspectionList(erpMaterialReturnInspection); + } + + /** + * 新增物料退检单 + * + * @param qualityReturnInspection 物料退检单 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int insertQualityReturnInspection(ErpMaterialReturnInspection erpMaterialReturnInspection) + { + String loginName = ShiroUtils.getLoginName(); + erpMaterialReturnInspection.setCreateBy(loginName); + erpMaterialReturnInspection.setCreateTime(DateUtils.getNowDate()); + // 生成编号,年月日规则 + String billNo = redisCache.generateBillNo("TJ"); + erpMaterialReturnInspection.setReturnInspectionNo(billNo); + int id = erpMaterialReturnInspectionMapper.insertErpMaterialReturnInspection(erpMaterialReturnInspection); + List inspectionDetails = erpMaterialReturnInspection.getInspectionDetails(); + // 插入子表 + for (int i = 0; i < inspectionDetails.size(); i++) { + ErpMaterialReturnInspectionDetail inspectionDetail = inspectionDetails.get(i); + inspectionDetail.setReturnInspectionNo(billNo); + materialReturnInspectionDetailService.insertErpMaterialReturnInspectionDetail(inspectionDetail); + } + return id; + } + + /** + * 修改物料退检单 + * + * @param qualityReturnInspection 物料退检单 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int updateQualityReturnInspection(ErpMaterialReturnInspection erpMaterialReturnInspection) + { + String returnInspectionNo = erpMaterialReturnInspection.getReturnInspectionNo(); + ErpMaterialReturnInspectionDetail detailQueryObj = new ErpMaterialReturnInspectionDetail(); + detailQueryObj.setReturnInspectionNo(returnInspectionNo); + List oldDetails = materialReturnInspectionDetailService.selectErpMaterialReturnInspectionDetailList(detailQueryObj); + List oldDetailIds = new ArrayList<>(); + if(CollectionUtil.isNotEmpty(oldDetails)){ + oldDetailIds = oldDetails.stream().map(t->t.getId()).collect(Collectors.toList()); + }else{ + materialReturnInspectionDetailService.deleteByReturnInspectionNo(returnInspectionNo); + } + List inspectionDetails = erpMaterialReturnInspection.getInspectionDetails(); + List finalOldDetailIds = oldDetailIds; + inspectionDetails.forEach(detail->{ + Long id = detail.getId(); + if(finalOldDetailIds.contains(id)){ + materialReturnInspectionDetailService.updateErpMaterialReturnInspectionDetail(detail); + finalOldDetailIds.remove(id); + }else{ + detail.setReturnInspectionNo(returnInspectionNo); + materialReturnInspectionDetailService.insertErpMaterialReturnInspectionDetail(detail); + } + }); + if(CollectionUtil.isNotEmpty(finalOldDetailIds)){ + materialReturnInspectionDetailService.deleteErpMaterialReturnInspectionDetailByIdList(finalOldDetailIds); + } + + String loginName = ShiroUtils.getLoginName(); + erpMaterialReturnInspection.setUpdateBy(loginName); + erpMaterialReturnInspection.setUpdateTime(DateUtils.getNowDate()); + int updateFlag = erpMaterialReturnInspectionMapper.updateErpMaterialReturnInspection(erpMaterialReturnInspection); + return updateFlag; + } + + /* + * 导出列表查询 + * */ + @Override + public List selectExportList(ErpMaterialReturnInspection erpMaterialReturnInspection) { + return erpMaterialReturnInspectionMapper.selectExportList(erpMaterialReturnInspection); + } +} diff --git a/ruoyi-admin/src/main/resources/templates/quality/returnInspection/edit.html b/ruoyi-admin/src/main/resources/templates/quality/returnInspection/edit.html new file mode 100644 index 00000000..9cb0a348 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/quality/returnInspection/edit.html @@ -0,0 +1,384 @@ + + + + + + + +
+
+
+
+ +
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+
+ + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+ +
+
+ + +
+
+
+
+
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/quality/returnInspection/returnInspection.html b/ruoyi-admin/src/main/resources/templates/quality/returnInspection/returnInspection.html new file mode 100644 index 00000000..6ff6df55 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/quality/returnInspection/returnInspection.html @@ -0,0 +1,135 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + + - + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ +
+ + + + + 导出 + +
+
+
+
+
+
+ + + + \ No newline at end of file