From cf547a04248786c22d9fde83202a2e97e092d3aa Mon Sep 17 00:00:00 2001 From: jiang Date: Mon, 22 Dec 2025 10:37:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/BackChangeServiceImpl.java | 34 +++++-- .../controller/EquipmentTypeController.java | 37 +++++-- .../devConfig/domain/EquipmentType.java | 1 + .../devConfig/domain/EquipmentTypeEntity.java | 92 ++++++++++++++++++ .../devConfig/mapper/EquipmentTypeMapper.java | 3 +- .../service/EquipmentTypeService.java | 7 +- .../impl/EquipmentTypeServiceImpl.java | 16 +-- .../devchange/domain/CsDeviceDetails.java | 4 +- .../devchange/mapper/DevChangeMapper.java | 4 + .../service/DevChangeServiceImpl.java | 27 ++++++ .../bonus/material/device/domain/MaDevQc.java | 6 ++ .../device/mapper/DevMergeMapper.java | 2 +- .../service/impl/DevMergeServiceImpl.java | 31 +++--- .../service/impl/RepairServiceImpl.java | 66 ++++++------- .../mapper/material/back/BackChangeMapper.xml | 4 +- .../devConfig/EquipmentTypeMapper.xml | 49 ++++++---- .../material/devchange/DevChangeMapper.xml | 97 ++++++++++++------- .../devchange/MaDevRetireWarningMapper.xml | 2 +- .../mapper/material/device/MaDevQcMapper.xml | 49 +++++++--- .../mapper/material/index/IndexMapper.xml | 4 +- .../mapper/material/repair/RepairMapper.xml | 2 +- .../material/toolLedger/ToolLedgerMapper.xml | 2 +- 22 files changed, 386 insertions(+), 153 deletions(-) create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/domain/EquipmentTypeEntity.java diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/back/service/impl/BackChangeServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/back/service/impl/BackChangeServiceImpl.java index 1632047..f5920d6 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/back/service/impl/BackChangeServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/back/service/impl/BackChangeServiceImpl.java @@ -28,6 +28,8 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.ZoneId; import java.util.*; import static com.bonus.common.biz.constant.MaterialConstants.ADMIN_ID; @@ -93,9 +95,12 @@ public class BackChangeServiceImpl implements BackChangeService { ) public AjaxResult addDevDetails(BackCsDeviceVo csDeviceVo) { try { + + if (csDeviceVo == null || csDeviceVo.getDevInfo() == null || CollectionUtils.isEmpty(csDeviceVo.getDevDetailsList())) { return AjaxResult.error("请选择需要添加的设备"); } + // 判断提交的数据csDeviceVo.getDevDetailsList()中是否存在相同编号或者数量设备typeId相同的数据 Set devCodeSet = new HashSet<>(); Set typeIdSet = new HashSet<>(); @@ -104,6 +109,18 @@ public class BackChangeServiceImpl implements BackChangeService { if (details == null) { continue; } + Date updateTime = details.getUpdateTime(); + LocalDate updateLocalDate = updateTime.toInstant() + .atZone(ZoneId.systemDefault()) // 转换为带时区的ZonedDateTime + .toLocalDate(); // 提取日期部分 + + // 步骤2:获取useTime并比较 + LocalDate useTime = details.getUseTime(); + + boolean isUseTimeGreater = !useTime.isBefore(updateLocalDate); + if (!isUseTimeGreater) { + throw new RuntimeException(details.getTypeName() + ",退库日期不能早于出库日期"); + } // 编码重复 String devCode = details.getDevCode(); if (!devCode.equals("/") && StringUtils.isNotBlank(devCode) && devCodeSet.contains(devCode)) { @@ -150,7 +167,7 @@ public class BackChangeServiceImpl implements BackChangeService { } catch (Exception e) { log.error(e.getMessage()); - throw new RuntimeException("添加失败"); + throw new RuntimeException(e.getMessage()); } return AjaxResult.success("退库申请提交成功,等待审批", csDeviceVo.getDevInfo().getId()); } @@ -411,7 +428,7 @@ public class BackChangeServiceImpl implements BackChangeService { if (CollectionUtils.isNotEmpty(devDetailsList)) { // 创建维修任务 String re = createRepairTask(devDetailsList); - if ("-1".equals(re)){ + if ("-1".equals(re)) { throw new RuntimeException("创建维修任务失败"); } @@ -479,27 +496,27 @@ public class BackChangeServiceImpl implements BackChangeService { return AjaxResult.success("审核成功"); } - private String createRepairTask(List devDetailsList){ + private String createRepairTask(List devDetailsList) { try { //在此处将需要维修的设备,生成一个维修单 List toBeRepairList = new ArrayList<>(); - for (BackCsDeviceDetails csDeviceDetails : devDetailsList){ - if ("1".equals(csDeviceDetails.getIsRepair())){ + for (BackCsDeviceDetails csDeviceDetails : devDetailsList) { + if ("1".equals(csDeviceDetails.getIsRepair())) { ToBeRepair toBeRepair = new ToBeRepair(); toBeRepair.setCode(csDeviceDetails.getDevCode()); toBeRepair.setDevType(csDeviceDetails.getDevType()); toBeRepair.setRepairNum(csDeviceDetails.getRealNum()); - toBeRepair.setTypeId(csDeviceDetails.getTypeId()+ ""); + toBeRepair.setTypeId(csDeviceDetails.getTypeId() + ""); toBeRepairList.add(toBeRepair); } } //如果有需要维修的设备 - if (toBeRepairList.size() > 0){ + if (toBeRepairList.size() > 0) { //创建维修任务 String userName = SecurityUtils.getLoginUser().getSysUser().getNickName(); Long changeId = addRepairTask(userName); //保存明细 - for (ToBeRepair toBeRepair : toBeRepairList){ + for (ToBeRepair toBeRepair : toBeRepairList) { toBeRepair.setChangeId(changeId); toBeRepair.setCreateUser(userName); repairMapper.addRepairData(toBeRepair); @@ -539,6 +556,7 @@ public class BackChangeServiceImpl implements BackChangeService { /** * 生成维修任务编号 + * * @param thisMonthMaxOrder * @return */ diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/controller/EquipmentTypeController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/controller/EquipmentTypeController.java index 43405e8..2aaf981 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/controller/EquipmentTypeController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/controller/EquipmentTypeController.java @@ -9,16 +9,21 @@ package com.bonus.material.devConfig.controller; // EquipmentTypeController.java +import com.bonus.common.core.utils.poi.ExcelUtil; +import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; -import com.bonus.material.devConfig.domain.PageResult; -import com.bonus.material.devConfig.domain.EquipmentTypeDTO; -import com.bonus.material.devConfig.domain.EquipmentType; -import com.bonus.material.devConfig.domain.EquipmentTypeQuery; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.material.devConfig.domain.*; import com.bonus.material.devConfig.service.EquipmentTypeService; +import com.bonus.material.device.domain.vo.DevInfoVo; +import com.bonus.material.toolProcess.domain.ToolApplyEntity; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; import java.util.List; /** @@ -26,7 +31,7 @@ import java.util.List; */ @RestController @RequestMapping("/equipment/type") -public class EquipmentTypeController { +public class EquipmentTypeController extends BaseController { @Autowired private EquipmentTypeService equipmentTypeService; @@ -47,11 +52,27 @@ public class EquipmentTypeController { //获取列表 @GetMapping("/list") - public AjaxResult getEquipmentTypeList(EquipmentTypeQuery query) { - PageResult result = equipmentTypeService.getEquipmentTypeList(query); - return AjaxResult.success(result); + public TableDataInfo getEquipmentTypeList(EquipmentTypeEntity query) { + try { + startPage(); + List list = equipmentTypeService.getEquipmentTypeList(query); + return getDataTable(list); + } catch (Exception e) { + logger.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); } + //获取列表 + @PostMapping("/export") + public void export(HttpServletResponse response, EquipmentTypeEntity query) { + List list = equipmentTypeService.getEquipmentTypeList(query); + ExcelUtil util = new ExcelUtil<>(EquipmentTypeEntity.class); + util.exportExcel(response, list, "装备类型数据"); + + } + + //获取详细信息 @GetMapping("/detail/{id}") public AjaxResult getEquipmentTypeDetail(@PathVariable Long id) { diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/domain/EquipmentType.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/domain/EquipmentType.java index ed02ac4..6a7581a 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/domain/EquipmentType.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/domain/EquipmentType.java @@ -82,4 +82,5 @@ public class EquipmentType { * 删除标志(0代表存在 2代表删除),默认值0 */ private String delFlag = "0"; + } \ No newline at end of file diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/domain/EquipmentTypeEntity.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/domain/EquipmentTypeEntity.java new file mode 100644 index 0000000..7a0690a --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/domain/EquipmentTypeEntity.java @@ -0,0 +1,92 @@ +package com.bonus.material.devConfig.domain; + +import com.bonus.common.core.annotation.Excel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class EquipmentTypeEntity implements Serializable { + /** + * 订单id + */ + private Integer typeId; + /** + * 专业Id + * 说明:装备所属的专业领域(如机械、电子、建筑等) + */ + private Integer majorId; + /** + * 专业 + * 说明:装备所属的专业领域(如机械、电子、建筑等) + */ + @Excel(name = "所属专业") + private String major; + /** + * 主工序id + */ + private Integer mainProcessId; + /** + * 主工序 + * 说明:装备主要参与的工序环节 + */ + @Excel(name = "施工主工序") + private String mainProcess; + /** + * 子工序id + * 说明:装备参与的具体子工序 + */ + private Integer subProcessId; + /** + * 子工序 + * 说明:装备参与的具体子工序 + */ + @Excel(name = "施工子工序") + private String subProcess; + + /** + * 装备大类目id + * 说明:装备所属的一级分类(如工程机械、仪器仪表等) + */ + private Integer mainCategoryId; + /** + * 装备大类目 + * 说明:装备所属的一级分类(如工程机械、仪器仪表等) + */ + @Excel(name = "装备大类") + private String mainCategory; + /** + * 装备小类目id + * 说明:装备所属的二级分类,主类目下的细分分类 + */ + private Integer subCategoryId; + /** + * 装备小类目 + * 说明:装备所属的二级分类,主类目下的细分分类 + */ + @Excel(name = "装备小类") + private String subCategory; + /** + * 装备分支id + * 说明:小类目下的更细分类,代表具体的装备类型分支 + */ + private Integer branchId; + /** + * 装备分支 + * 说明:小类目下的更细分类,代表具体的装备类型分支 + */ + @Excel(name = "类型分支") + private String branch; + /** + * 关键字 + */ + private String keyWord; + /** + * 级别 + */ + private String actualLevel; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentTypeMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentTypeMapper.java index 6cc0464..0d16b35 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentTypeMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/mapper/EquipmentTypeMapper.java @@ -3,6 +3,7 @@ package com.bonus.material.devConfig.mapper; // EquipmentTypeMapper.java import com.bonus.material.devConfig.domain.EquipmentType; +import com.bonus.material.devConfig.domain.EquipmentTypeEntity; import com.bonus.material.devConfig.domain.EquipmentTypeQuery; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -18,7 +19,7 @@ public interface EquipmentTypeMapper { /** * 查询装备分类列表 */ - List selectEquipmentTypeList(EquipmentTypeQuery query); + List selectEquipmentTypeList(EquipmentTypeEntity query); /** * 查询装备分类数量 diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/EquipmentTypeService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/EquipmentTypeService.java index 351430b..1fa534d 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/EquipmentTypeService.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/EquipmentTypeService.java @@ -4,10 +4,7 @@ package com.bonus.material.devConfig.service; import com.bonus.common.core.web.domain.AjaxResult; -import com.bonus.material.devConfig.domain.PageResult; -import com.bonus.material.devConfig.domain.EquipmentTypeDTO; -import com.bonus.material.devConfig.domain.EquipmentType; -import com.bonus.material.devConfig.domain.EquipmentTypeQuery; +import com.bonus.material.devConfig.domain.*; import java.util.List; @@ -20,7 +17,7 @@ public interface EquipmentTypeService { List getEquipmentCascader(); - PageResult getEquipmentTypeList(EquipmentTypeQuery query); + List getEquipmentTypeList(EquipmentTypeEntity query); EquipmentType getEquipmentTypeDetail(Long id); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentTypeServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentTypeServiceImpl.java index 8d354c0..64ffb26 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentTypeServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devConfig/service/impl/EquipmentTypeServiceImpl.java @@ -2,11 +2,8 @@ package com.bonus.material.devConfig.service.impl; import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult; -import com.bonus.material.devConfig.domain.PageResult; -import com.bonus.material.devConfig.domain.EquipmentTypeDTO; -import com.bonus.material.devConfig.domain.EquipmentType; +import com.bonus.material.devConfig.domain.*; import com.bonus.material.devConfig.mapper.EquipmentTypeMapper; -import com.bonus.material.devConfig.domain.EquipmentTypeQuery; import com.bonus.material.devConfig.service.EquipmentTypeService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -39,15 +36,8 @@ public class EquipmentTypeServiceImpl implements EquipmentTypeService { } @Override - public PageResult getEquipmentTypeList(EquipmentTypeQuery query) { - // 计算offset,修正分页参数 - if (query.getPageNum() != null && query.getPageSize() != null) { - query.setOffset((query.getPageNum() - 1) * query.getPageSize()); - } - - List list = equipmentTypeMapper.selectEquipmentTypeList(query); - Long total = equipmentTypeMapper.countEquipmentTypeList(query); - return new PageResult<>(total, list, query.getPageNum(), query.getPageSize()); + public List getEquipmentTypeList(EquipmentTypeEntity query) { + return equipmentTypeMapper.selectEquipmentTypeList(query); } @Override diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceDetails.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceDetails.java index 4ac7277..0f6db92 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceDetails.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceDetails.java @@ -93,8 +93,6 @@ public class CsDeviceDetails { @ApiModelProperty(value = "数据所属组织") private Long companyId; - - /** * 下次维保日期 */ @@ -105,4 +103,6 @@ public class CsDeviceDetails { private String remainingYears; + private String proCode; + } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/DevChangeMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/DevChangeMapper.java index 5c2799d..5366ccc 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/DevChangeMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/mapper/DevChangeMapper.java @@ -298,4 +298,8 @@ public interface DevChangeMapper { BigDecimal getToolNum(CsDeviceDetails entity); + + BigDecimal getMaNum(CsDeviceDetails entity); + + DevChangeVo getChange(CsDeviceChangeDetailsVo vo); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java index 4efcbf6..6beae1d 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java @@ -539,6 +539,17 @@ public class DevChangeServiceImpl implements DevChangeService { try { //装备 if (entity.getDevType().equals("1")) { + BigDecimal toolNum = mapper.getMaNum(entity); + if (toolNum.compareTo(entity.getOutNum()) < 0) { + // 库存不足,计算差额 + BigDecimal shortage = entity.getOutNum().subtract(toolNum); + return AjaxResult.error(String.format( + "库存不足!当前可用:%s,需要出库:%s,短缺:%s", + toolNum.stripTrailingZeros().toPlainString(), + entity.getOutNum().stripTrailingZeros().toPlainString(), + shortage.stripTrailingZeros().toPlainString() + )); + } mapper.updateZb(entity); } else { BigDecimal toolNum = mapper.getToolNum(entity); @@ -621,6 +632,20 @@ public class DevChangeServiceImpl implements DevChangeService { shortage.stripTrailingZeros().toPlainString() )); } + } else { + // 工器具需要检查库存 + BigDecimal toolNum = mapper.getMaNum(item); // 注意:参数应该是 item + BigDecimal outNum = item.getOutNum(); + if (toolNum.compareTo(outNum) < 0) { + BigDecimal shortage = outNum.subtract(toolNum); + return AjaxResult.error(String.format( + "库存不足! 装备:%s,当前可用:%s,需要出库:%s,短缺:%s", + item.getTypeName(), + toolNum.stripTrailingZeros().toPlainString(), + outNum.stripTrailingZeros().toPlainString(), + shortage.stripTrailingZeros().toPlainString() + )); + } } } @@ -1129,6 +1154,8 @@ public class DevChangeServiceImpl implements DevChangeService { @Override public List getDevDetails(CsDeviceChangeDetailsVo vo) { try { + DevChangeVo entity = mapper.getChange(vo); + vo.setType(entity.getType()); List list = mapper.getDevDetails(vo); for (DevChangeVo devChangeVo : list) { if (devChangeVo.getWorkingHours() == null) { diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/MaDevQc.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/MaDevQc.java index d3450c3..58ad1df 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/MaDevQc.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/MaDevQc.java @@ -40,6 +40,12 @@ public class MaDevQc extends BaseEntity implements Serializable { @DateTimeFormat(pattern = "yyyy-MM-dd") private Date nextCheckTime; + + @ApiModelProperty(value = "上次检验日期") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date upCheckTime; + @ApiModelProperty(value = "质检编码") private String qcCode; diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevMergeMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevMergeMapper.java index aca594d..adb8d35 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevMergeMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevMergeMapper.java @@ -81,7 +81,7 @@ public interface DevMergeMapper { List getDeviceByOrderId(MaDevInfo o); - void interFile(MaDevFile item); + Integer interFile(MaDevFile item); Integer updateDeviceByMaId(MaDevInfo maDevInfo); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevMergeServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevMergeServiceImpl.java index 1bb077a..5f6d38b 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevMergeServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevMergeServiceImpl.java @@ -449,7 +449,9 @@ public class DevMergeServiceImpl implements DevMergeService { list = list.stream().filter(item -> StringUtils.isNotBlank(item.getProfession())).collect(Collectors.toList()); // 3. 再次检查过滤后是否有有效数据 - if (list.isEmpty()) {return AjaxResult.error("表格内没有有效数据");} + if (list.isEmpty()) { + return AjaxResult.error("表格内没有有效数据"); + } if (ObjectUtil.isEmpty(orderId)) { DevMergeVo o = new DevMergeVo(); @@ -488,7 +490,10 @@ public class DevMergeServiceImpl implements DevMergeService { if (item.getProductionDate() != null && item.getPurchaseDate() != null && item.getProductionDate().after(item.getPurchaseDate())) { rowError.append("生产日期不能晚于采购日期;"); } - + Integer typeId = devMergeMapper.getTypeId(item.getProfession()); + if (ObjectUtil.isEmpty(typeId)) { + rowError.append("请选择类别"); + } // 4.5 若当前行有错误,记录并继续校验其他行 if (rowError.length() > ("第" + (i + 1) + "行:").length()) { errorMessages.add(rowError.toString()); @@ -498,7 +503,7 @@ public class DevMergeServiceImpl implements DevMergeService { // 5. 校验通过,执行导入逻辑 try { MaDevInfo maDevInfo = new MaDevInfo(); - Integer typeId = devMergeMapper.getTypeId(item.getProfession()); + maDevInfo.setTypeId(typeId); maDevInfo.setProductionDate(item.getProductionDate()); maDevInfo.setPurchaseDate(item.getPurchaseDate()); @@ -522,14 +527,14 @@ public class DevMergeServiceImpl implements DevMergeService { // 从Excel导入的9组特征项数据中提取有效数据 String[] propertyNames = { - item.getPropertyName1(), item.getPropertyName2(), item.getPropertyName3(), - item.getPropertyName4(), item.getPropertyName5(), item.getPropertyName6(), - item.getPropertyName7(), item.getPropertyName8(), item.getPropertyName9() + item.getPropertyName1(), item.getPropertyName2(), item.getPropertyName3(), + item.getPropertyName4(), item.getPropertyName5(), item.getPropertyName6(), + item.getPropertyName7(), item.getPropertyName8(), item.getPropertyName9() }; String[] propertyValues = { - item.getPropertyValue1(), item.getPropertyValue2(), item.getPropertyValue3(), - item.getPropertyValue4(), item.getPropertyValue5(), item.getPropertyValue6(), - item.getPropertyValue7(), item.getPropertyValue8(), item.getPropertyValue9() + item.getPropertyValue1(), item.getPropertyValue2(), item.getPropertyValue3(), + item.getPropertyValue4(), item.getPropertyValue5(), item.getPropertyValue6(), + item.getPropertyValue7(), item.getPropertyValue8(), item.getPropertyValue9() }; // 遍历9组特征项,只保存有效的(特征项名称和特征值都不为空) @@ -743,7 +748,7 @@ public class DevMergeServiceImpl implements DevMergeService { // 4. 核心:递归遍历所有层级,找出所有Apply-开头的目录 Set applyFolders = new HashSet<>(); findAllApplyFolders(tempUnzipDir, applyFolders); - + Integer num = 0; // 5. 遍历所有Apply-目录并处理 for (File applyFolder : applyFolders) { String applyFolderName = applyFolder.getName(); @@ -786,7 +791,7 @@ public class DevMergeServiceImpl implements DevMergeService { // 这里编写对每个 image 的处理逻辑,比如打印、处理等 item.setFileUrl(url); item.setCreator(Math.toIntExact(SecurityUtils.getLoginUser().getUserid())); - devMergeMapper.interFile(item); + num += devMergeMapper.interFile(item); } } @@ -812,6 +817,10 @@ public class DevMergeServiceImpl implements DevMergeService { if (totalRootFolder == 0) { return AjaxResult.error(400, "未找到有效的Apply-开头的目录"); } + + if (num == 0) { + return AjaxResult.error(400, "无数据导入,请检查模板"); + } result.put("code", 200); result.put("msg", "ZIP包解压完成(识别到" + totalRootFolder + "个Apply-目录)"); result.put("totalRootFolder", totalRootFolder); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/service/impl/RepairServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/service/impl/RepairServiceImpl.java index ccf869a..24b2097 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/service/impl/RepairServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/service/impl/RepairServiceImpl.java @@ -75,19 +75,19 @@ public class RepairServiceImpl implements RepairService { String username = getCurrentUsername(); Long changeId; - if (bean.getChangeId()==null){ + if (bean.getChangeId() == null) { // 1. 创建维修任务 changeId = createRepairTask(username); //将申请的设备状态都改为维修 - for (ToBeRepair detail : list){ - if ("编码管理".equals(detail.getManageMode()) && !StringHelper.isNullOrEmptyString(detail.getCode())){ + for (ToBeRepair detail : list) { + if ("编码管理".equals(detail.getManageMode()) && !StringHelper.isNullOrEmptyString(detail.getCode())) { //1、如果是编码管理,将设备状态改为维修状态 - if ("装备".equals(detail.getType())){ + if ("装备".equals(detail.getType())) { int re1 = mapper.updateDevStatus(detail); - } else if ("工具".equals(detail.getType())){ + } else if ("工具".equals(detail.getType())) { int re2 = mapper.updateToolStatus(detail); } - } else if ("数量管理".equals(detail.getManageMode())){ + } else if ("数量管理".equals(detail.getManageMode())) { //目前数量管理的设备都是工具 //将在库数量减掉增加维修数量 int re3 = mapper.updateToolNum(detail); @@ -121,7 +121,7 @@ public class RepairServiceImpl implements RepairService { @Transactional(rollbackFor = Exception.class) public AjaxResult updateRepairData(ToBeRepair bean) { try { - if (bean.getChangeId()==null){ + if (bean.getChangeId() == null) { throw new Exception("缺少任务ID"); } if (bean.getToBeRepairList().size() <= 0) { @@ -135,19 +135,19 @@ public class RepairServiceImpl implements RepairService { } String username = SecurityUtils.getLoginUser().getSysUser().getNickName(); //先删除详情中被驳回的数据 - int re1 = mapper.deleteChangeDetailsByChangeId(bean); + int re1 = mapper.deleteChangeDetailsByChangeId(bean); if (re1 < 1) { throw new Exception("删除设备详情失败"); } for (ToBeRepair toBeRepair : bean.getToBeRepairList()) { - if (!StringHelper.isNullOrEmptyString(toBeRepair.getStatus()) && "通过".equals(toBeRepair.getStatus())){ + if (!StringHelper.isNullOrEmptyString(toBeRepair.getStatus()) && "通过".equals(toBeRepair.getStatus())) { //过滤掉通过的数据 continue; } toBeRepair.setChangeId(bean.getChangeId()); toBeRepair.setCreateUser(username); if (!StringHelper.isNullOrEmptyString(toBeRepair.getIsScrap())) { - if (toBeRepair.getBmFileInfos()!=null && toBeRepair.getBmFileInfos().size() > 0) { + if (toBeRepair.getBmFileInfos() != null && toBeRepair.getBmFileInfos().size() > 0) { if ("0".equals(toBeRepair.getIsScrap())) { toBeRepair.setRepairUrl(toBeRepair.getBmFileInfos().get(0).getFileUrl()); } else { @@ -314,9 +314,9 @@ public class RepairServiceImpl implements RepairService { public List getRepairDetailsList(ToBeRepair bean) { try { List list = mapper.getRepairDetailsList(bean); - if (!list.isEmpty()){ - for (ToBeRepair toBeRepair : list){ - if (!StringHelper.isNullOrEmptyString(toBeRepair.getUrl())){ + if (!list.isEmpty()) { + for (ToBeRepair toBeRepair : list) { + if (!StringHelper.isNullOrEmptyString(toBeRepair.getUrl())) { List bmFileInfos = new ArrayList<>(); BmFileInfo fileInfo = new BmFileInfo(); fileInfo.setFileUrl(toBeRepair.getUrl()); @@ -347,28 +347,28 @@ public class RepairServiceImpl implements RepairService { Long userId = SecurityUtils.getLoginUser().getUserid(); for (ToBeRepair toBeRepair : bean.getToBeRepairList()) { //查询设备是否已经处理过 - if ("编码管理".equals(toBeRepair.getManageMode())){ + if ("编码管理".equals(toBeRepair.getManageMode())) { //1、如果是编码管理,查询状态是否为维修状态 - if ("装备".equals(toBeRepair.getType())){ + if ("装备".equals(toBeRepair.getType())) { ToBeRepair bean1 = mapper.selectMaDevInfoByTypeIdAndCode(toBeRepair); - if (bean1==null || !"5".equals(bean1.getStatus())){ - throw new RuntimeException(toBeRepair.getCode()+"编码设备已经处理过"); + if (bean1 == null || !"5".equals(bean1.getStatus())) { + throw new RuntimeException(toBeRepair.getCode() + "编码设备已经处理过"); } - } else if ("工具".equals(toBeRepair.getType())){ + } else if ("工具".equals(toBeRepair.getType())) { ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair); - if (bean1==null || !"2".equals(bean1.getStatus())){ - throw new RuntimeException(toBeRepair.getCode()+"编码设备已经处理过"); + if (bean1 == null || !"2".equals(bean1.getStatus())) { + throw new RuntimeException(toBeRepair.getCode() + "编码设备已经处理过"); } } - } else if ("数量管理".equals(toBeRepair.getManageMode())){ + } else if ("数量管理".equals(toBeRepair.getManageMode())) { //2、如果是数量管理,查询剩余的维修数量是否够 //todo 目前数量管理的设备都是工具 ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair); - if (bean1==null || bean1.getRepairNum().compareTo(toBeRepair.getRepairNum())<0){ - throw new RuntimeException(toBeRepair.getTypeModelName()+"剩余维修设备数量不足"); + if (bean1 == null || bean1.getRepairNum().compareTo(toBeRepair.getRepairNum()) < 0) { + throw new RuntimeException(toBeRepair.getTypeModelName() + "剩余维修设备数量不足"); } } - if (!StringHelper.isNullOrEmptyString(toBeRepair.getAuditStatus())){ + if (!StringHelper.isNullOrEmptyString(toBeRepair.getAuditStatus())) { toBeRepair.setCreateUser(username); int res = mapper.auditData(toBeRepair); if (res <= 0) { @@ -384,15 +384,15 @@ public class RepairServiceImpl implements RepairService { throw new Exception("审核主表数据失败"); } //如果是审核通过,需要增加周期表数据以及更新台账信息 - if ("2".equals(toBeRepair.getAuditStatus())){ - if ("工具".equals(toBeRepair.getType())){ + if ("2".equals(toBeRepair.getAuditStatus())) { + if ("工具".equals(toBeRepair.getType())) { //根据typeId和code查询台账信息 ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair); - if (bean1 != null && bean1.getId() > 0){ + if (bean1 != null && bean1.getId() > 0) { //1、添加周期表数据 ToBeRepair bean2 = new ToBeRepair(); bean2.setId(bean1.getId()); - bean2.setCreateBy(userId+""); + bean2.setCreateBy(userId + ""); bean2.setCreateUser(username); bean2.setCode(toBeRepair.getCode()); bean2.setRepairNum(toBeRepair.getRepairNum()); @@ -408,12 +408,12 @@ public class RepairServiceImpl implements RepairService { throw new Exception("更新台账信息失败"); } } - } else if ("装备".equals(toBeRepair.getType())){ + } else if ("装备".equals(toBeRepair.getType())) { //更新台账信息 - toBeRepair.setCreateBy(userId+""); + toBeRepair.setCreateBy(userId + ""); toBeRepair.setIsScrapFilter(Integer.valueOf(toBeRepair.getIsScrap())); int re3 = mapper.updateMaDevInfo(toBeRepair); - if (re3<=0){ + if (re3 <= 0) { throw new Exception("更新台账信息失败"); } } @@ -468,7 +468,7 @@ public class RepairServiceImpl implements RepairService { throw new Exception("缺少合格状态数据"); } fillFileUrl(detail); - if ("1".equals(detail.getIsScrap()) && "数量管理".equals(detail.getManageMode())){ + if ("1".equals(detail.getIsScrap()) && "数量管理".equals(detail.getManageMode())) { saveScrapAndQualified(detail); } else { insertDetail(detail); @@ -508,7 +508,6 @@ public class RepairServiceImpl implements RepairService { } - /** * 处理文件 */ @@ -526,6 +525,7 @@ public class RepairServiceImpl implements RepairService { /** * 生成任务编号 + * * @param thisMonthMaxOrder * @return */ diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/back/BackChangeMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/back/BackChangeMapper.xml index d691285..357204b 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/back/BackChangeMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/back/BackChangeMapper.xml @@ -204,7 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" tl.type_id as typeId, tl.id as id FROM tool_ledger tl - LEFT JOIN cs_device_change_details cdc ON tl.tool_code = cdc.dev_code + LEFT JOIN cs_device_change_details cdc ON tl.tool_code = cdc.dev_code AND tl.type_id = cdc.dev_type_id LEFT JOIN cs_device_change cd ON cd.id = cdc.change_id LEFT JOIN tool_type tt ON tl.type_id = tt.type_id LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.type_id @@ -251,7 +251,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" tl.type_id as typeId, tl.id as id FROM tool_ledger tl - LEFT JOIN cs_device_change_details cdc ON tl.type_id = cdc.dev_type_id + LEFT JOIN cs_device_change_details cdc ON tl.type_id = cdc.dev_type_id AND cdc.dev_code = '/' LEFT JOIN cs_device_change cd ON cd.id = cdc.change_id LEFT JOIN tool_type tt ON tl.type_id = tt.type_id LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.type_id diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentTypeMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentTypeMapper.xml index 5755de1..28c23a9 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentTypeMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devConfig/EquipmentTypeMapper.xml @@ -17,26 +17,6 @@ type_id, type_name, parent_id, level, create_time, update_time, create_by, update_by - + \ No newline at end of file diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml index 8704f2b..c2e8390 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml @@ -137,9 +137,10 @@ cds.user_name AS userName, cds.user_phone AS userPhone, cds.change_unit AS changeUnit, - - -- 修正点:使用 SUM 计算数量总和,并用 IFNULL 处理没有明细的情况 - IFNULL(SUM(dcd.num), 0) AS devNum, + CASE + WHEN cds.type = 2 THEN IFNULL(SUM(dcd.real_num), 0) + ELSE IFNULL(SUM(dcd.num), 0) + END AS devNum, CASE WHEN cds.change_status = 1 THEN '在库' @@ -176,6 +177,9 @@ and cds.type=#{type} + + AND is_finished in ('1','2') + and cds.create_time between #{startTime} and #{endTime} @@ -248,15 +252,20 @@ dev.working_hours as workingHours, dev.max_working_hours as maxWorkingHours FROM - cs_device_change_details dcd - LEFT JOIN ma_dev_info dev ON dcd.dev_code = dev.code - LEFT JOIN bm_company_info bci ON bci.company_id = dev.on_company - INNER JOIN ma_type_view mt ON mt.typeId = dev.type_id - LEFT JOIN (SELECT max(next_check_time) next_check_time, ma_id FROM ma_dev_qc GROUP BY ma_id) mdq ON dev.ma_id = mdq.ma_id - LEFT JOIN jj_sing_project pro ON pro.pro_code = dev.on_project + cs_device_change_details dcd + LEFT JOIN ma_dev_info dev ON dcd.dev_code = dev.code + LEFT JOIN bm_company_info bci ON bci.company_id = dev.on_company + INNER JOIN ma_type_view mt ON mt.typeId = dev.type_id + LEFT JOIN (SELECT max(next_check_time) next_check_time, ma_id FROM ma_dev_qc GROUP BY ma_id) mdq ON dev.ma_id = + mdq.ma_id + LEFT JOIN jj_sing_project pro ON pro.pro_code = dev.on_project WHERE - is_active = 1 - AND dcd.change_id = #{id} + is_active = 1 + AND dcd.change_id = #{id} + + + AND dcd.real_num is NOT null + UNION ALL @@ -292,22 +301,25 @@ '' AS workingHours, '' AS maxWorkingHours FROM - cs_device_change_details dcd -- 关联工具台账(变更详情的设备编码 = 工具编码) - LEFT JOIN cs_device_change dc on dc.id=dcd.change_id - LEFT JOIN tool_ledger tl - ON dcd.dev_type = '2' - AND dcd.dev_type_id = tl.type_id - AND (dcd.dev_code = '/' OR dcd.dev_code = tl.tool_code) - LEFT JOIN tool_type tt ON tl.type_id = tt.type_id - LEFT JOIN tool_type tt1 on tt.parent_id=tt1.type_id - LEFT JOIN tool_type tt2 on tt1.parent_id=tt2.type_id - LEFT JOIN tool_type tt3 on tt2.parent_id=tt3.type_id - LEFT JOIN tool_type tt4 on tt3.parent_id=tt4.type_id - AND tt.del_flag = '0' -- 关联公司信息(工具所属公司) - LEFT JOIN bm_company_info bci ON tl.company_id = bci.company_id + cs_device_change_details dcd -- 关联工具台账(变更详情的设备编码 = 工具编码) + LEFT JOIN cs_device_change dc on dc.id=dcd.change_id + LEFT JOIN tool_ledger tl + ON dcd.dev_type = '2' + AND dcd.dev_type_id = tl.type_id + AND (dcd.dev_code = '/' OR dcd.dev_code = tl.tool_code) + LEFT JOIN tool_type tt ON tl.type_id = tt.type_id + LEFT JOIN tool_type tt1 on tt.parent_id=tt1.type_id + LEFT JOIN tool_type tt2 on tt1.parent_id=tt2.type_id + LEFT JOIN tool_type tt3 on tt2.parent_id=tt3.type_id + LEFT JOIN tool_type tt4 on tt3.parent_id=tt4.type_id + AND tt.del_flag = '0' -- 关联公司信息(工具所属公司) + LEFT JOIN bm_company_info bci ON tl.company_id = bci.company_id WHERE - dcd.change_id = #{id} - and dcd.dev_type='2' + dcd.change_id = #{id} + and dcd.dev_type='2' + + AND dcd.real_num is NOT null + @@ -748,9 +760,11 @@ END, '' ) AS typeName, - COALESCE(cdcd.num, 0) - COALESCE(cdcd.real_num, 0) AS outNum + COALESCE(cdcd.num, 0) - COALESCE(cdcd.real_num, 0) AS outNum, + cdc.pro_code AS proCode, + cdcd.use_end_time AS useEndTime FROM cs_device_change_details cdcd - + LEFT JOIN cs_device_change cdc ON cdc.id = cdcd.change_id LEFT JOIN ma_dev_info a ON cdcd.dev_type = '1' AND cdcd.dev_code = a.`code` @@ -1064,9 +1078,11 @@ END, '' ) AS id, cdcd.devType AS devType, - COALESCE(cdcd.num, 0) - COALESCE(cdcd.real_num, 0) AS outNum + COALESCE(cdcd.num, 0) - COALESCE(cdcd.real_num, 0) AS outNum, + moi.pro_code AS proCode, + cdcd.rent_end_time AS useEndTime FROM ma_order_details cdcd - + LEFT JOIN ma_order_info moi ON moi.order_id = cdcd.order_id LEFT JOIN ma_dev_info a ON cdcd.devType = '0' AND cdcd.ma_id = a.ma_id @@ -1081,6 +1097,17 @@ FROM tool_ledger WHERE id = #{id} + + @@ -1211,14 +1238,18 @@ UPDATE ma_dev_info - set ma_status = '2', - change_status = '2' + set ma_status = '2', + change_status = '2', + on_project = #{proCode}, + expiration_time = #{useEndTime} WHERE ma_id = #{id} UPDATE ma_dev_info set ma_status = '3', - change_status = '3' + change_status = '3', + on_project = #{proCode}, + expiration_time = #{useEndTime} WHERE ma_id = #{id} diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevRetireWarningMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevRetireWarningMapper.xml index c11751b..5804bce 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevRetireWarningMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevRetireWarningMapper.xml @@ -56,7 +56,7 @@ mdi.ma_id=mdq.ma_id LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_id LEFT JOIN sys_cnarea sc ON sc.area_code = mdi.province_id - WHERE mdi.is_active = 1 and mdi.entry_status = '1' + WHERE mdi.is_active = 1 and mdi.entry_status = '1' AND mdi.ma_status != '99' AND mdi.device_name like concat('%',#{name},'%') diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/MaDevQcMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/MaDevQcMapper.xml index 2de37f4..5ece4e5 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/MaDevQcMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/MaDevQcMapper.xml @@ -64,34 +64,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m1.qc_code AS qcCode, m1.qc_user AS qcUser, m1.qc_time AS qcTime, - m3.maintenance_alarm_day, - su.nick_name AS createBy, m1.next_check_time AS nextCheckTime, + mdq1.qc_time AS upCheckTime, m1.create_time AS updateTime, aa.create_time AS createTime, m1.phonenumber AS phonenumber, CASE - WHEN DATEDIFF(m1.next_check_time, CURDATE()) < 0 THEN '已超期' - WHEN DATEDIFF(m1.next_check_time, CURDATE()) <= 30 THEN '一月内到期' + WHEN mdq.next_check_time <= CURRENT_DATE() THEN '已超期' + WHEN mdq.next_check_time <= DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH) THEN '一月内到期' ELSE '正常' END AS alert FROM ma_dev_info m2 LEFT JOIN ma_dev_qc m1 ON m1.ma_id = m2.ma_id - INNER JOIN ma_type m3 ON m2.type_id = m3.type_id - LEFT JOIN sys_user su ON su.user_id = m1.create_by LEFT JOIN ( SELECT count(*) as num, ma_id, MAX( qc_time ) AS max_qc_time FROM ma_dev_qc GROUP BY ma_id ) latest_qc ON m1.ma_id = latest_qc.ma_id LEFT JOIN ( SELECT ma_id, min( create_time ) AS create_time FROM ma_dev_qc GROUP BY ma_id ) aa ON m1.ma_id = aa.ma_id - LEFT JOIN jj_sing_project jsp ON m2.on_project = jsp.pro_code - LEFT JOIN sys_dept sd ON sd.dept_id = m2.on_company LEFT JOIN (SELECT max( next_check_time) next_check_time,ma_id from ma_dev_qc GROUP BY ma_id ) mdq on m2.ma_id=mdq.ma_id - LEFT JOIN ma_supplier ms ON ms.supplier_id = m2.supplier_id - LEFT JOIN sys_cnarea sc ON sc.area_code = m2.province_id + LEFT JOIN ( + SELECT + ma_id, + qc_time + FROM ( + -- 内层:按ma_id分组,给next_check_time降序排名 + SELECT + ma_id, + qc_time, + ROW_NUMBER() OVER (PARTITION BY ma_id ORDER BY qc_time DESC) AS rn + FROM ma_dev_qc + -- 过滤掉next_check_time为NULL的记录(可选,根据业务需求) + WHERE qc_time IS NOT NULL + ) t + -- 筛选排名为2的记录(第二大) + WHERE t.rn = 2 + ) mdq1 ON m2.ma_id = mdq1.ma_id - m2.is_active = '1' and m2.entry_status = '1' + m2.is_active = '1' and m2.entry_status = '1' AND m2.ma_status != '99' and m2.code like concat('%',#{deviceCode},'%') @@ -113,6 +123,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and m2.on_company = #{qcCom} + + + + + and mdq.next_check_time <= CURRENT_DATE() + + + + and mdq.next_check_time <= DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH) + + + + and mdq.next_check_time > DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH) + + + GROUP BY m2.ma_id ORDER BY @@ -146,6 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and DATE_FORMAT(mdq.create_time,'%Y-%m-%d') between #{createStartTime} and #{createEndTime} + ORDER BY mdq.qc_time DESC diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/toolLedger/ToolLedgerMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/toolLedger/ToolLedgerMapper.xml index 56b3502..96029e6 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/toolLedger/ToolLedgerMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/toolLedger/ToolLedgerMapper.xml @@ -287,7 +287,7 @@ INNER JOIN tool_type tt1 ON tt1.type_id = tt.parent_id WHERE tl.status = #{status} AND tl.type_id = #{typeId} - AND tl.manage_mode = #{type} + AND (tl.company_id = #{companyId} OR tl.company_id IS NULL)