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