问题修改

This commit is contained in:
jiang 2025-12-22 10:37:07 +08:00
parent 3a0500117e
commit cf547a0424
22 changed files with 386 additions and 153 deletions

View File

@ -28,6 +28,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import static com.bonus.common.biz.constant.MaterialConstants.ADMIN_ID; import static com.bonus.common.biz.constant.MaterialConstants.ADMIN_ID;
@ -93,9 +95,12 @@ public class BackChangeServiceImpl implements BackChangeService {
) )
public AjaxResult addDevDetails(BackCsDeviceVo csDeviceVo) { public AjaxResult addDevDetails(BackCsDeviceVo csDeviceVo) {
try { try {
if (csDeviceVo == null || csDeviceVo.getDevInfo() == null || CollectionUtils.isEmpty(csDeviceVo.getDevDetailsList())) { if (csDeviceVo == null || csDeviceVo.getDevInfo() == null || CollectionUtils.isEmpty(csDeviceVo.getDevDetailsList())) {
return AjaxResult.error("请选择需要添加的设备"); return AjaxResult.error("请选择需要添加的设备");
} }
// 判断提交的数据csDeviceVo.getDevDetailsList()中是否存在相同编号或者数量设备typeId相同的数据 // 判断提交的数据csDeviceVo.getDevDetailsList()中是否存在相同编号或者数量设备typeId相同的数据
Set<String> devCodeSet = new HashSet<>(); Set<String> devCodeSet = new HashSet<>();
Set<Long> typeIdSet = new HashSet<>(); Set<Long> typeIdSet = new HashSet<>();
@ -104,6 +109,18 @@ public class BackChangeServiceImpl implements BackChangeService {
if (details == null) { if (details == null) {
continue; 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(); String devCode = details.getDevCode();
if (!devCode.equals("/") && StringUtils.isNotBlank(devCode) && devCodeSet.contains(devCode)) { if (!devCode.equals("/") && StringUtils.isNotBlank(devCode) && devCodeSet.contains(devCode)) {
@ -150,7 +167,7 @@ public class BackChangeServiceImpl implements BackChangeService {
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new RuntimeException("添加失败"); throw new RuntimeException(e.getMessage());
} }
return AjaxResult.success("退库申请提交成功,等待审批", csDeviceVo.getDevInfo().getId()); return AjaxResult.success("退库申请提交成功,等待审批", csDeviceVo.getDevInfo().getId());
} }
@ -411,7 +428,7 @@ public class BackChangeServiceImpl implements BackChangeService {
if (CollectionUtils.isNotEmpty(devDetailsList)) { if (CollectionUtils.isNotEmpty(devDetailsList)) {
// 创建维修任务 // 创建维修任务
String re = createRepairTask(devDetailsList); String re = createRepairTask(devDetailsList);
if ("-1".equals(re)){ if ("-1".equals(re)) {
throw new RuntimeException("创建维修任务失败"); throw new RuntimeException("创建维修任务失败");
} }
@ -479,27 +496,27 @@ public class BackChangeServiceImpl implements BackChangeService {
return AjaxResult.success("审核成功"); return AjaxResult.success("审核成功");
} }
private String createRepairTask(List<BackCsDeviceDetails> devDetailsList){ private String createRepairTask(List<BackCsDeviceDetails> devDetailsList) {
try { try {
//在此处将需要维修的设备生成一个维修单 //在此处将需要维修的设备生成一个维修单
List<ToBeRepair> toBeRepairList = new ArrayList<>(); List<ToBeRepair> toBeRepairList = new ArrayList<>();
for (BackCsDeviceDetails csDeviceDetails : devDetailsList){ for (BackCsDeviceDetails csDeviceDetails : devDetailsList) {
if ("1".equals(csDeviceDetails.getIsRepair())){ if ("1".equals(csDeviceDetails.getIsRepair())) {
ToBeRepair toBeRepair = new ToBeRepair(); ToBeRepair toBeRepair = new ToBeRepair();
toBeRepair.setCode(csDeviceDetails.getDevCode()); toBeRepair.setCode(csDeviceDetails.getDevCode());
toBeRepair.setDevType(csDeviceDetails.getDevType()); toBeRepair.setDevType(csDeviceDetails.getDevType());
toBeRepair.setRepairNum(csDeviceDetails.getRealNum()); toBeRepair.setRepairNum(csDeviceDetails.getRealNum());
toBeRepair.setTypeId(csDeviceDetails.getTypeId()+ ""); toBeRepair.setTypeId(csDeviceDetails.getTypeId() + "");
toBeRepairList.add(toBeRepair); toBeRepairList.add(toBeRepair);
} }
} }
//如果有需要维修的设备 //如果有需要维修的设备
if (toBeRepairList.size() > 0){ if (toBeRepairList.size() > 0) {
//创建维修任务 //创建维修任务
String userName = SecurityUtils.getLoginUser().getSysUser().getNickName(); String userName = SecurityUtils.getLoginUser().getSysUser().getNickName();
Long changeId = addRepairTask(userName); Long changeId = addRepairTask(userName);
//保存明细 //保存明细
for (ToBeRepair toBeRepair : toBeRepairList){ for (ToBeRepair toBeRepair : toBeRepairList) {
toBeRepair.setChangeId(changeId); toBeRepair.setChangeId(changeId);
toBeRepair.setCreateUser(userName); toBeRepair.setCreateUser(userName);
repairMapper.addRepairData(toBeRepair); repairMapper.addRepairData(toBeRepair);
@ -539,6 +556,7 @@ public class BackChangeServiceImpl implements BackChangeService {
/** /**
* 生成维修任务编号 * 生成维修任务编号
*
* @param thisMonthMaxOrder * @param thisMonthMaxOrder
* @return * @return
*/ */

View File

@ -9,16 +9,21 @@ package com.bonus.material.devConfig.controller;
// EquipmentTypeController.java // 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.common.core.web.domain.AjaxResult;
import com.bonus.material.devConfig.domain.PageResult; import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.material.devConfig.domain.EquipmentTypeDTO; import com.bonus.material.devConfig.domain.*;
import com.bonus.material.devConfig.domain.EquipmentType;
import com.bonus.material.devConfig.domain.EquipmentTypeQuery;
import com.bonus.material.devConfig.service.EquipmentTypeService; 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.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -26,7 +31,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/equipment/type") @RequestMapping("/equipment/type")
public class EquipmentTypeController { public class EquipmentTypeController extends BaseController {
@Autowired @Autowired
private EquipmentTypeService equipmentTypeService; private EquipmentTypeService equipmentTypeService;
@ -47,11 +52,27 @@ public class EquipmentTypeController {
//获取列表 //获取列表
@GetMapping("/list") @GetMapping("/list")
public AjaxResult getEquipmentTypeList(EquipmentTypeQuery query) { public TableDataInfo getEquipmentTypeList(EquipmentTypeEntity query) {
PageResult<EquipmentType> result = equipmentTypeService.getEquipmentTypeList(query); try {
return AjaxResult.success(result); startPage();
List<EquipmentTypeEntity> 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<EquipmentTypeEntity> list = equipmentTypeService.getEquipmentTypeList(query);
ExcelUtil<EquipmentTypeEntity> util = new ExcelUtil<>(EquipmentTypeEntity.class);
util.exportExcel(response, list, "装备类型数据");
}
//获取详细信息 //获取详细信息
@GetMapping("/detail/{id}") @GetMapping("/detail/{id}")
public AjaxResult getEquipmentTypeDetail(@PathVariable Long id) { public AjaxResult getEquipmentTypeDetail(@PathVariable Long id) {

View File

@ -82,4 +82,5 @@ public class EquipmentType {
* 删除标志0代表存在 2代表删除默认值0 * 删除标志0代表存在 2代表删除默认值0
*/ */
private String delFlag = "0"; private String delFlag = "0";
} }

View File

@ -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;
}

View File

@ -3,6 +3,7 @@ package com.bonus.material.devConfig.mapper;
// EquipmentTypeMapper.java // EquipmentTypeMapper.java
import com.bonus.material.devConfig.domain.EquipmentType; import com.bonus.material.devConfig.domain.EquipmentType;
import com.bonus.material.devConfig.domain.EquipmentTypeEntity;
import com.bonus.material.devConfig.domain.EquipmentTypeQuery; import com.bonus.material.devConfig.domain.EquipmentTypeQuery;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -18,7 +19,7 @@ public interface EquipmentTypeMapper {
/** /**
* 查询装备分类列表 * 查询装备分类列表
*/ */
List<EquipmentType> selectEquipmentTypeList(EquipmentTypeQuery query); List<EquipmentTypeEntity> selectEquipmentTypeList(EquipmentTypeEntity query);
/** /**
* 查询装备分类数量 * 查询装备分类数量

View File

@ -4,10 +4,7 @@ package com.bonus.material.devConfig.service;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.devConfig.domain.PageResult; import com.bonus.material.devConfig.domain.*;
import com.bonus.material.devConfig.domain.EquipmentTypeDTO;
import com.bonus.material.devConfig.domain.EquipmentType;
import com.bonus.material.devConfig.domain.EquipmentTypeQuery;
import java.util.List; import java.util.List;
@ -20,7 +17,7 @@ public interface EquipmentTypeService {
List<EquipmentTypeDTO> getEquipmentCascader(); List<EquipmentTypeDTO> getEquipmentCascader();
PageResult<EquipmentType> getEquipmentTypeList(EquipmentTypeQuery query); List<EquipmentTypeEntity> getEquipmentTypeList(EquipmentTypeEntity query);
EquipmentType getEquipmentTypeDetail(Long id); EquipmentType getEquipmentTypeDetail(Long id);

View File

@ -2,11 +2,8 @@ package com.bonus.material.devConfig.service.impl;
import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.devConfig.domain.PageResult; import com.bonus.material.devConfig.domain.*;
import com.bonus.material.devConfig.domain.EquipmentTypeDTO;
import com.bonus.material.devConfig.domain.EquipmentType;
import com.bonus.material.devConfig.mapper.EquipmentTypeMapper; import com.bonus.material.devConfig.mapper.EquipmentTypeMapper;
import com.bonus.material.devConfig.domain.EquipmentTypeQuery;
import com.bonus.material.devConfig.service.EquipmentTypeService; import com.bonus.material.devConfig.service.EquipmentTypeService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -39,15 +36,8 @@ public class EquipmentTypeServiceImpl implements EquipmentTypeService {
} }
@Override @Override
public PageResult<EquipmentType> getEquipmentTypeList(EquipmentTypeQuery query) { public List<EquipmentTypeEntity> getEquipmentTypeList(EquipmentTypeEntity query) {
// 计算offset修正分页参数 return equipmentTypeMapper.selectEquipmentTypeList(query);
if (query.getPageNum() != null && query.getPageSize() != null) {
query.setOffset((query.getPageNum() - 1) * query.getPageSize());
}
List<EquipmentType> list = equipmentTypeMapper.selectEquipmentTypeList(query);
Long total = equipmentTypeMapper.countEquipmentTypeList(query);
return new PageResult<>(total, list, query.getPageNum(), query.getPageSize());
} }
@Override @Override

View File

@ -93,8 +93,6 @@ public class CsDeviceDetails {
@ApiModelProperty(value = "数据所属组织") @ApiModelProperty(value = "数据所属组织")
private Long companyId; private Long companyId;
/** /**
* 下次维保日期 * 下次维保日期
*/ */
@ -105,4 +103,6 @@ public class CsDeviceDetails {
private String remainingYears; private String remainingYears;
private String proCode;
} }

View File

@ -298,4 +298,8 @@ public interface DevChangeMapper {
BigDecimal getToolNum(CsDeviceDetails entity); BigDecimal getToolNum(CsDeviceDetails entity);
BigDecimal getMaNum(CsDeviceDetails entity);
DevChangeVo getChange(CsDeviceChangeDetailsVo vo);
} }

View File

@ -539,6 +539,17 @@ public class DevChangeServiceImpl implements DevChangeService {
try { try {
//装备 //装备
if (entity.getDevType().equals("1")) { 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); mapper.updateZb(entity);
} else { } else {
BigDecimal toolNum = mapper.getToolNum(entity); BigDecimal toolNum = mapper.getToolNum(entity);
@ -621,6 +632,20 @@ public class DevChangeServiceImpl implements DevChangeService {
shortage.stripTrailingZeros().toPlainString() 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 @Override
public List<DevChangeVo> getDevDetails(CsDeviceChangeDetailsVo vo) { public List<DevChangeVo> getDevDetails(CsDeviceChangeDetailsVo vo) {
try { try {
DevChangeVo entity = mapper.getChange(vo);
vo.setType(entity.getType());
List<DevChangeVo> list = mapper.getDevDetails(vo); List<DevChangeVo> list = mapper.getDevDetails(vo);
for (DevChangeVo devChangeVo : list) { for (DevChangeVo devChangeVo : list) {
if (devChangeVo.getWorkingHours() == null) { if (devChangeVo.getWorkingHours() == null) {

View File

@ -40,6 +40,12 @@ public class MaDevQc extends BaseEntity implements Serializable {
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date nextCheckTime; private Date nextCheckTime;
@ApiModelProperty(value = "上次检验日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date upCheckTime;
@ApiModelProperty(value = "质检编码") @ApiModelProperty(value = "质检编码")
private String qcCode; private String qcCode;

View File

@ -81,7 +81,7 @@ public interface DevMergeMapper {
List<MaDevInfo> getDeviceByOrderId(MaDevInfo o); List<MaDevInfo> getDeviceByOrderId(MaDevInfo o);
void interFile(MaDevFile item); Integer interFile(MaDevFile item);
Integer updateDeviceByMaId(MaDevInfo maDevInfo); Integer updateDeviceByMaId(MaDevInfo maDevInfo);

View File

@ -449,7 +449,9 @@ public class DevMergeServiceImpl implements DevMergeService {
list = list.stream().filter(item -> StringUtils.isNotBlank(item.getProfession())).collect(Collectors.toList()); list = list.stream().filter(item -> StringUtils.isNotBlank(item.getProfession())).collect(Collectors.toList());
// 3. 再次检查过滤后是否有有效数据 // 3. 再次检查过滤后是否有有效数据
if (list.isEmpty()) {return AjaxResult.error("表格内没有有效数据");} if (list.isEmpty()) {
return AjaxResult.error("表格内没有有效数据");
}
if (ObjectUtil.isEmpty(orderId)) { if (ObjectUtil.isEmpty(orderId)) {
DevMergeVo o = new DevMergeVo(); 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())) { if (item.getProductionDate() != null && item.getPurchaseDate() != null && item.getProductionDate().after(item.getPurchaseDate())) {
rowError.append("生产日期不能晚于采购日期;"); rowError.append("生产日期不能晚于采购日期;");
} }
Integer typeId = devMergeMapper.getTypeId(item.getProfession());
if (ObjectUtil.isEmpty(typeId)) {
rowError.append("请选择类别");
}
// 4.5 若当前行有错误记录并继续校验其他行 // 4.5 若当前行有错误记录并继续校验其他行
if (rowError.length() > ("" + (i + 1) + "行:").length()) { if (rowError.length() > ("" + (i + 1) + "行:").length()) {
errorMessages.add(rowError.toString()); errorMessages.add(rowError.toString());
@ -498,7 +503,7 @@ public class DevMergeServiceImpl implements DevMergeService {
// 5. 校验通过执行导入逻辑 // 5. 校验通过执行导入逻辑
try { try {
MaDevInfo maDevInfo = new MaDevInfo(); MaDevInfo maDevInfo = new MaDevInfo();
Integer typeId = devMergeMapper.getTypeId(item.getProfession());
maDevInfo.setTypeId(typeId); maDevInfo.setTypeId(typeId);
maDevInfo.setProductionDate(item.getProductionDate()); maDevInfo.setProductionDate(item.getProductionDate());
maDevInfo.setPurchaseDate(item.getPurchaseDate()); maDevInfo.setPurchaseDate(item.getPurchaseDate());
@ -522,14 +527,14 @@ public class DevMergeServiceImpl implements DevMergeService {
// 从Excel导入的9组特征项数据中提取有效数据 // 从Excel导入的9组特征项数据中提取有效数据
String[] propertyNames = { String[] propertyNames = {
item.getPropertyName1(), item.getPropertyName2(), item.getPropertyName3(), item.getPropertyName1(), item.getPropertyName2(), item.getPropertyName3(),
item.getPropertyName4(), item.getPropertyName5(), item.getPropertyName6(), item.getPropertyName4(), item.getPropertyName5(), item.getPropertyName6(),
item.getPropertyName7(), item.getPropertyName8(), item.getPropertyName9() item.getPropertyName7(), item.getPropertyName8(), item.getPropertyName9()
}; };
String[] propertyValues = { String[] propertyValues = {
item.getPropertyValue1(), item.getPropertyValue2(), item.getPropertyValue3(), item.getPropertyValue1(), item.getPropertyValue2(), item.getPropertyValue3(),
item.getPropertyValue4(), item.getPropertyValue5(), item.getPropertyValue6(), item.getPropertyValue4(), item.getPropertyValue5(), item.getPropertyValue6(),
item.getPropertyValue7(), item.getPropertyValue8(), item.getPropertyValue9() item.getPropertyValue7(), item.getPropertyValue8(), item.getPropertyValue9()
}; };
// 遍历9组特征项只保存有效的特征项名称和特征值都不为空 // 遍历9组特征项只保存有效的特征项名称和特征值都不为空
@ -743,7 +748,7 @@ public class DevMergeServiceImpl implements DevMergeService {
// 4. 核心递归遍历所有层级找出所有Apply-开头的目录 // 4. 核心递归遍历所有层级找出所有Apply-开头的目录
Set<File> applyFolders = new HashSet<>(); Set<File> applyFolders = new HashSet<>();
findAllApplyFolders(tempUnzipDir, applyFolders); findAllApplyFolders(tempUnzipDir, applyFolders);
Integer num = 0;
// 5. 遍历所有Apply-目录并处理 // 5. 遍历所有Apply-目录并处理
for (File applyFolder : applyFolders) { for (File applyFolder : applyFolders) {
String applyFolderName = applyFolder.getName(); String applyFolderName = applyFolder.getName();
@ -786,7 +791,7 @@ public class DevMergeServiceImpl implements DevMergeService {
// 这里编写对每个 image 的处理逻辑比如打印处理等 // 这里编写对每个 image 的处理逻辑比如打印处理等
item.setFileUrl(url); item.setFileUrl(url);
item.setCreator(Math.toIntExact(SecurityUtils.getLoginUser().getUserid())); 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) { if (totalRootFolder == 0) {
return AjaxResult.error(400, "未找到有效的Apply-开头的目录"); return AjaxResult.error(400, "未找到有效的Apply-开头的目录");
} }
if (num == 0) {
return AjaxResult.error(400, "无数据导入,请检查模板");
}
result.put("code", 200); result.put("code", 200);
result.put("msg", "ZIP包解压完成识别到" + totalRootFolder + "个Apply-目录)"); result.put("msg", "ZIP包解压完成识别到" + totalRootFolder + "个Apply-目录)");
result.put("totalRootFolder", totalRootFolder); result.put("totalRootFolder", totalRootFolder);

View File

@ -75,19 +75,19 @@ public class RepairServiceImpl implements RepairService {
String username = getCurrentUsername(); String username = getCurrentUsername();
Long changeId; Long changeId;
if (bean.getChangeId()==null){ if (bean.getChangeId() == null) {
// 1. 创建维修任务 // 1. 创建维修任务
changeId = createRepairTask(username); changeId = createRepairTask(username);
//将申请的设备状态都改为维修 //将申请的设备状态都改为维修
for (ToBeRepair detail : list){ for (ToBeRepair detail : list) {
if ("编码管理".equals(detail.getManageMode()) && !StringHelper.isNullOrEmptyString(detail.getCode())){ if ("编码管理".equals(detail.getManageMode()) && !StringHelper.isNullOrEmptyString(detail.getCode())) {
//1如果是编码管理将设备状态改为维修状态 //1如果是编码管理将设备状态改为维修状态
if ("装备".equals(detail.getType())){ if ("装备".equals(detail.getType())) {
int re1 = mapper.updateDevStatus(detail); int re1 = mapper.updateDevStatus(detail);
} else if ("工具".equals(detail.getType())){ } else if ("工具".equals(detail.getType())) {
int re2 = mapper.updateToolStatus(detail); int re2 = mapper.updateToolStatus(detail);
} }
} else if ("数量管理".equals(detail.getManageMode())){ } else if ("数量管理".equals(detail.getManageMode())) {
//目前数量管理的设备都是工具 //目前数量管理的设备都是工具
//将在库数量减掉增加维修数量 //将在库数量减掉增加维修数量
int re3 = mapper.updateToolNum(detail); int re3 = mapper.updateToolNum(detail);
@ -121,7 +121,7 @@ public class RepairServiceImpl implements RepairService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult updateRepairData(ToBeRepair bean) { public AjaxResult updateRepairData(ToBeRepair bean) {
try { try {
if (bean.getChangeId()==null){ if (bean.getChangeId() == null) {
throw new Exception("缺少任务ID"); throw new Exception("缺少任务ID");
} }
if (bean.getToBeRepairList().size() <= 0) { if (bean.getToBeRepairList().size() <= 0) {
@ -135,19 +135,19 @@ public class RepairServiceImpl implements RepairService {
} }
String username = SecurityUtils.getLoginUser().getSysUser().getNickName(); String username = SecurityUtils.getLoginUser().getSysUser().getNickName();
//先删除详情中被驳回的数据 //先删除详情中被驳回的数据
int re1 = mapper.deleteChangeDetailsByChangeId(bean); int re1 = mapper.deleteChangeDetailsByChangeId(bean);
if (re1 < 1) { if (re1 < 1) {
throw new Exception("删除设备详情失败"); throw new Exception("删除设备详情失败");
} }
for (ToBeRepair toBeRepair : bean.getToBeRepairList()) { for (ToBeRepair toBeRepair : bean.getToBeRepairList()) {
if (!StringHelper.isNullOrEmptyString(toBeRepair.getStatus()) && "通过".equals(toBeRepair.getStatus())){ if (!StringHelper.isNullOrEmptyString(toBeRepair.getStatus()) && "通过".equals(toBeRepair.getStatus())) {
//过滤掉通过的数据 //过滤掉通过的数据
continue; continue;
} }
toBeRepair.setChangeId(bean.getChangeId()); toBeRepair.setChangeId(bean.getChangeId());
toBeRepair.setCreateUser(username); toBeRepair.setCreateUser(username);
if (!StringHelper.isNullOrEmptyString(toBeRepair.getIsScrap())) { 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())) { if ("0".equals(toBeRepair.getIsScrap())) {
toBeRepair.setRepairUrl(toBeRepair.getBmFileInfos().get(0).getFileUrl()); toBeRepair.setRepairUrl(toBeRepair.getBmFileInfos().get(0).getFileUrl());
} else { } else {
@ -314,9 +314,9 @@ public class RepairServiceImpl implements RepairService {
public List<ToBeRepair> getRepairDetailsList(ToBeRepair bean) { public List<ToBeRepair> getRepairDetailsList(ToBeRepair bean) {
try { try {
List<ToBeRepair> list = mapper.getRepairDetailsList(bean); List<ToBeRepair> list = mapper.getRepairDetailsList(bean);
if (!list.isEmpty()){ if (!list.isEmpty()) {
for (ToBeRepair toBeRepair : list){ for (ToBeRepair toBeRepair : list) {
if (!StringHelper.isNullOrEmptyString(toBeRepair.getUrl())){ if (!StringHelper.isNullOrEmptyString(toBeRepair.getUrl())) {
List<BmFileInfo> bmFileInfos = new ArrayList<>(); List<BmFileInfo> bmFileInfos = new ArrayList<>();
BmFileInfo fileInfo = new BmFileInfo(); BmFileInfo fileInfo = new BmFileInfo();
fileInfo.setFileUrl(toBeRepair.getUrl()); fileInfo.setFileUrl(toBeRepair.getUrl());
@ -347,28 +347,28 @@ public class RepairServiceImpl implements RepairService {
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
for (ToBeRepair toBeRepair : bean.getToBeRepairList()) { for (ToBeRepair toBeRepair : bean.getToBeRepairList()) {
//查询设备是否已经处理过 //查询设备是否已经处理过
if ("编码管理".equals(toBeRepair.getManageMode())){ if ("编码管理".equals(toBeRepair.getManageMode())) {
//1如果是编码管理查询状态是否为维修状态 //1如果是编码管理查询状态是否为维修状态
if ("装备".equals(toBeRepair.getType())){ if ("装备".equals(toBeRepair.getType())) {
ToBeRepair bean1 = mapper.selectMaDevInfoByTypeIdAndCode(toBeRepair); ToBeRepair bean1 = mapper.selectMaDevInfoByTypeIdAndCode(toBeRepair);
if (bean1==null || !"5".equals(bean1.getStatus())){ if (bean1 == null || !"5".equals(bean1.getStatus())) {
throw new RuntimeException(toBeRepair.getCode()+"编码设备已经处理过"); throw new RuntimeException(toBeRepair.getCode() + "编码设备已经处理过");
} }
} else if ("工具".equals(toBeRepair.getType())){ } else if ("工具".equals(toBeRepair.getType())) {
ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair); ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair);
if (bean1==null || !"2".equals(bean1.getStatus())){ if (bean1 == null || !"2".equals(bean1.getStatus())) {
throw new RuntimeException(toBeRepair.getCode()+"编码设备已经处理过"); throw new RuntimeException(toBeRepair.getCode() + "编码设备已经处理过");
} }
} }
} else if ("数量管理".equals(toBeRepair.getManageMode())){ } else if ("数量管理".equals(toBeRepair.getManageMode())) {
//2如果是数量管理查询剩余的维修数量是否够 //2如果是数量管理查询剩余的维修数量是否够
//todo 目前数量管理的设备都是工具 //todo 目前数量管理的设备都是工具
ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair); ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair);
if (bean1==null || bean1.getRepairNum().compareTo(toBeRepair.getRepairNum())<0){ if (bean1 == null || bean1.getRepairNum().compareTo(toBeRepair.getRepairNum()) < 0) {
throw new RuntimeException(toBeRepair.getTypeModelName()+"剩余维修设备数量不足"); throw new RuntimeException(toBeRepair.getTypeModelName() + "剩余维修设备数量不足");
} }
} }
if (!StringHelper.isNullOrEmptyString(toBeRepair.getAuditStatus())){ if (!StringHelper.isNullOrEmptyString(toBeRepair.getAuditStatus())) {
toBeRepair.setCreateUser(username); toBeRepair.setCreateUser(username);
int res = mapper.auditData(toBeRepair); int res = mapper.auditData(toBeRepair);
if (res <= 0) { if (res <= 0) {
@ -384,15 +384,15 @@ public class RepairServiceImpl implements RepairService {
throw new Exception("审核主表数据失败"); throw new Exception("审核主表数据失败");
} }
//如果是审核通过需要增加周期表数据以及更新台账信息 //如果是审核通过需要增加周期表数据以及更新台账信息
if ("2".equals(toBeRepair.getAuditStatus())){ if ("2".equals(toBeRepair.getAuditStatus())) {
if ("工具".equals(toBeRepair.getType())){ if ("工具".equals(toBeRepair.getType())) {
//根据typeId和code查询台账信息 //根据typeId和code查询台账信息
ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair); ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair);
if (bean1 != null && bean1.getId() > 0){ if (bean1 != null && bean1.getId() > 0) {
//1添加周期表数据 //1添加周期表数据
ToBeRepair bean2 = new ToBeRepair(); ToBeRepair bean2 = new ToBeRepair();
bean2.setId(bean1.getId()); bean2.setId(bean1.getId());
bean2.setCreateBy(userId+""); bean2.setCreateBy(userId + "");
bean2.setCreateUser(username); bean2.setCreateUser(username);
bean2.setCode(toBeRepair.getCode()); bean2.setCode(toBeRepair.getCode());
bean2.setRepairNum(toBeRepair.getRepairNum()); bean2.setRepairNum(toBeRepair.getRepairNum());
@ -408,12 +408,12 @@ public class RepairServiceImpl implements RepairService {
throw new Exception("更新台账信息失败"); 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())); toBeRepair.setIsScrapFilter(Integer.valueOf(toBeRepair.getIsScrap()));
int re3 = mapper.updateMaDevInfo(toBeRepair); int re3 = mapper.updateMaDevInfo(toBeRepair);
if (re3<=0){ if (re3 <= 0) {
throw new Exception("更新台账信息失败"); throw new Exception("更新台账信息失败");
} }
} }
@ -468,7 +468,7 @@ public class RepairServiceImpl implements RepairService {
throw new Exception("缺少合格状态数据"); throw new Exception("缺少合格状态数据");
} }
fillFileUrl(detail); fillFileUrl(detail);
if ("1".equals(detail.getIsScrap()) && "数量管理".equals(detail.getManageMode())){ if ("1".equals(detail.getIsScrap()) && "数量管理".equals(detail.getManageMode())) {
saveScrapAndQualified(detail); saveScrapAndQualified(detail);
} else { } else {
insertDetail(detail); insertDetail(detail);
@ -508,7 +508,6 @@ public class RepairServiceImpl implements RepairService {
} }
/** /**
* 处理文件 * 处理文件
*/ */
@ -526,6 +525,7 @@ public class RepairServiceImpl implements RepairService {
/** /**
* 生成任务编号 * 生成任务编号
*
* @param thisMonthMaxOrder * @param thisMonthMaxOrder
* @return * @return
*/ */

View File

@ -204,7 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
tl.type_id as typeId, tl.type_id as typeId,
tl.id as id tl.id as id
FROM tool_ledger tl 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 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 tt ON tl.type_id = tt.type_id
LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.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.type_id as typeId,
tl.id as id tl.id as id
FROM tool_ledger tl 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 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 tt ON tl.type_id = tt.type_id
LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.type_id LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.type_id

View File

@ -17,26 +17,6 @@
type_id, type_name, parent_id, level, create_time, update_time, create_by, update_by type_id, type_name, parent_id, level, create_time, update_time, create_by, update_by
</sql> </sql>
<select id="selectEquipmentTypeList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM ma_type
<where>
<if test="deviceName != null and deviceName != '' ">
AND type_name LIKE CONCAT('%', #{deviceName}, '%')
</if>
<if test="parentId != null">
AND parent_id = #{parentId}
</if>
<if test="typeName != null and typeName != ''">
AND type_name LIKE CONCAT('%', #{typeName}, '%')
</if>
AND level != '7'
</where>
ORDER BY create_time DESC
<if test="pageSize != null and pageSize > 0">
LIMIT #{pageSize} OFFSET #{offset}
</if>
</select>
<select id="countEquipmentTypeList" resultType="java.lang.Long"> <select id="countEquipmentTypeList" resultType="java.lang.Long">
SELECT COUNT(*) SELECT COUNT(*)
@ -123,5 +103,34 @@
AND type_name = #{typeName} AND type_name = #{typeName}
AND type_id != #{typeId} <!-- 排除自身 --> AND type_id != #{typeId} <!-- 排除自身 -->
</select> </select>
<select id="selectEquipmentTypeList" resultType="com.bonus.material.devConfig.domain.EquipmentTypeEntity">
SELECT typeId,
proType AS major,
mainGx AS mainProcess,
childGx AS subProcess,
devCategory AS mainCategory,
devSubcategory AS subCategory,
actual_level AS actualLevel,
devName AS branch
FROM ma_type_view
<where>
<if test="keyWord != null and keyWord != '' ">
AND (proType LIKE CONCAT('%', #{keyWord}, '%') or
mainGx LIKE CONCAT('%', #{keyWord}, '%') or
childGx LIKE CONCAT('%', #{keyWord}, '%') or
devCategory LIKE CONCAT('%', #{keyWord}, '%') or
devSubcategory LIKE CONCAT('%', #{keyWord}, '%') or
devName LIKE CONCAT('%', #{keyWord}, '%'))
</if>
<if test="typeId != null and typeId != '' ">
AND (maxTypeId = #{typeId} or
mainGxId = #{typeId} or
childGxId = #{typeId} or
devCategoryId = #{typeId} or
devSubcategoryId = #{typeId} or
devNameId = #{typeId})
</if>
</where>
</select>
</mapper> </mapper>

View File

@ -137,9 +137,10 @@
cds.user_name AS userName, cds.user_name AS userName,
cds.user_phone AS userPhone, cds.user_phone AS userPhone,
cds.change_unit AS changeUnit, cds.change_unit AS changeUnit,
CASE
-- 修正点:使用 SUM 计算数量总和,并用 IFNULL 处理没有明细的情况 WHEN cds.type = 2 THEN IFNULL(SUM(dcd.real_num), 0)
IFNULL(SUM(dcd.num), 0) AS devNum, ELSE IFNULL(SUM(dcd.num), 0)
END AS devNum,
CASE CASE
WHEN cds.change_status = 1 THEN '在库' WHEN cds.change_status = 1 THEN '在库'
@ -176,6 +177,9 @@
<if test="type!=null and type!=''"> <if test="type!=null and type!=''">
and cds.type=#{type} and cds.type=#{type}
</if> </if>
<if test="type!=null and type=='2'">
AND is_finished in ('1','2')
</if>
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' "> <if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
and cds.create_time between #{startTime} and #{endTime} and cds.create_time between #{startTime} and #{endTime}
</if> </if>
@ -248,15 +252,20 @@
dev.working_hours as workingHours, dev.working_hours as workingHours,
dev.max_working_hours as maxWorkingHours dev.max_working_hours as maxWorkingHours
FROM FROM
cs_device_change_details dcd cs_device_change_details dcd
LEFT JOIN ma_dev_info dev ON dcd.dev_code = dev.code 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 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 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 (SELECT max(next_check_time) next_check_time, ma_id FROM ma_dev_qc GROUP BY ma_id) mdq ON dev.ma_id =
LEFT JOIN jj_sing_project pro ON pro.pro_code = dev.on_project mdq.ma_id
LEFT JOIN jj_sing_project pro ON pro.pro_code = dev.on_project
WHERE WHERE
is_active = 1 is_active = 1
AND dcd.change_id = #{id} AND dcd.change_id = #{id}
<if test="type!=null and type==2">
AND dcd.real_num is NOT null
</if>
UNION ALL UNION ALL
@ -292,22 +301,25 @@
'' AS workingHours, '' AS workingHours,
'' AS maxWorkingHours '' AS maxWorkingHours
FROM FROM
cs_device_change_details dcd -- 关联工具台账(变更详情的设备编码 = 工具编码) cs_device_change_details dcd -- 关联工具台账(变更详情的设备编码 = 工具编码)
LEFT JOIN cs_device_change dc on dc.id=dcd.change_id LEFT JOIN cs_device_change dc on dc.id=dcd.change_id
LEFT JOIN tool_ledger tl LEFT JOIN tool_ledger tl
ON dcd.dev_type = '2' ON dcd.dev_type = '2'
AND dcd.dev_type_id = tl.type_id AND dcd.dev_type_id = tl.type_id
AND (dcd.dev_code = '/' OR dcd.dev_code = tl.tool_code) 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 tt ON tl.type_id = tt.type_id
LEFT JOIN tool_type tt1 on tt.parent_id=tt1.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 tt2 on tt1.parent_id=tt2.type_id
LEFT JOIN tool_type tt3 on tt2.parent_id=tt3.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 LEFT JOIN tool_type tt4 on tt3.parent_id=tt4.type_id
AND tt.del_flag = '0' -- 关联公司信息(工具所属公司) AND tt.del_flag = '0' -- 关联公司信息(工具所属公司)
LEFT JOIN bm_company_info bci ON tl.company_id = bci.company_id LEFT JOIN bm_company_info bci ON tl.company_id = bci.company_id
WHERE WHERE
dcd.change_id = #{id} dcd.change_id = #{id}
and dcd.dev_type='2' and dcd.dev_type='2'
<if test="type!=null and type==2">
AND dcd.real_num is NOT null
</if>
</select> </select>
@ -748,9 +760,11 @@
END, '' END, ''
) AS typeName, ) 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 FROM cs_device_change_details cdcd
LEFT JOIN cs_device_change cdc ON cdc.id = cdcd.change_id
LEFT JOIN ma_dev_info a LEFT JOIN ma_dev_info a
ON cdcd.dev_type = '1' ON cdcd.dev_type = '1'
AND cdcd.dev_code = a.`code` AND cdcd.dev_code = a.`code`
@ -1064,9 +1078,11 @@
END, '' END, ''
) AS id, ) AS id,
cdcd.devType AS devType, 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 FROM ma_order_details cdcd
LEFT JOIN ma_order_info moi ON moi.order_id = cdcd.order_id
LEFT JOIN ma_dev_info a LEFT JOIN ma_dev_info a
ON cdcd.devType = '0' ON cdcd.devType = '0'
AND cdcd.ma_id = a.ma_id AND cdcd.ma_id = a.ma_id
@ -1081,6 +1097,17 @@
FROM tool_ledger FROM tool_ledger
WHERE id = #{id} WHERE id = #{id}
</select> </select>
<select id="getMaNum" resultType="java.math.BigDecimal">
SELECT count(1)
FROM ma_dev_info
WHERE ma_id = #{id}
and ma_status = '1'
</select>
<select id="getChange" resultType="com.bonus.material.devchange.domain.DevChangeVo">
SELECT type
FROM cs_device_change
WHERE id = #{id}
</select>
<insert id="addChangeInfoNew" keyProperty="id" useGeneratedKeys="true"> <insert id="addChangeInfoNew" keyProperty="id" useGeneratedKeys="true">
@ -1211,14 +1238,18 @@
</update> </update>
<update id="updateZb"> <update id="updateZb">
UPDATE ma_dev_info UPDATE ma_dev_info
set ma_status = '2', set ma_status = '2',
change_status = '2' change_status = '2',
on_project = #{proCode},
expiration_time = #{useEndTime}
WHERE ma_id = #{id} WHERE ma_id = #{id}
</update> </update>
<update id="updateOrderZb"> <update id="updateOrderZb">
UPDATE ma_dev_info UPDATE ma_dev_info
set ma_status = '3', set ma_status = '3',
change_status = '3' change_status = '3',
on_project = #{proCode},
expiration_time = #{useEndTime}
WHERE ma_id = #{id} WHERE ma_id = #{id}
</update> </update>
<update id="updateOrderGj"> <update id="updateOrderGj">

View File

@ -56,7 +56,7 @@
mdi.ma_id=mdq.ma_id mdi.ma_id=mdq.ma_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_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 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'
<if test="name != null and name != ''"> <if test="name != null and name != ''">
AND mdi.device_name like concat('%',#{name},'%') AND mdi.device_name like concat('%',#{name},'%')
</if> </if>

View File

@ -64,34 +64,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m1.qc_code AS qcCode, m1.qc_code AS qcCode,
m1.qc_user AS qcUser, m1.qc_user AS qcUser,
m1.qc_time AS qcTime, m1.qc_time AS qcTime,
m3.maintenance_alarm_day,
su.nick_name AS createBy,
m1.next_check_time AS nextCheckTime, m1.next_check_time AS nextCheckTime,
mdq1.qc_time AS upCheckTime,
m1.create_time AS updateTime, m1.create_time AS updateTime,
aa.create_time AS createTime, aa.create_time AS createTime,
m1.phonenumber AS phonenumber, m1.phonenumber AS phonenumber,
CASE CASE
WHEN DATEDIFF(m1.next_check_time, CURDATE()) &lt; 0 THEN '已超期' WHEN mdq.next_check_time &lt;= CURRENT_DATE() THEN '已超期'
WHEN DATEDIFF(m1.next_check_time, CURDATE()) &lt;= 30 THEN '一月内到期' WHEN mdq.next_check_time &lt;= DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH) THEN '一月内到期'
ELSE '正常' ELSE '正常'
END AS alert END AS alert
FROM FROM
ma_dev_info m2 ma_dev_info m2
LEFT JOIN ma_dev_qc m1 ON m1.ma_id = m2.ma_id 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 ) 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 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 = 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 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 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 m2.ma_id=mdq.ma_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = m2.supplier_id LEFT JOIN (
LEFT JOIN sys_cnarea sc ON sc.area_code = m2.province_id 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
<where> <where>
m2.is_active = '1' and m2.entry_status = '1' m2.is_active = '1' and m2.entry_status = '1' AND m2.ma_status != '99'
<if test="deviceCode != null and deviceCode != ''"> <if test="deviceCode != null and deviceCode != ''">
and m2.code like concat('%',#{deviceCode},'%') and m2.code like concat('%',#{deviceCode},'%')
</if> </if>
@ -113,6 +123,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="qcCom != null and qcCom != ''"> <if test="qcCom != null and qcCom != ''">
and m2.on_company = #{qcCom} and m2.on_company = #{qcCom}
</if> </if>
<if test="alert != null and alert != ''">
<choose>
<!-- 筛选“已超期” -->
<when test="alert == '已超期'">
and mdq.next_check_time &lt;= CURRENT_DATE()
</when>
<!-- 筛选“一月内到期” -->
<when test="alert == '一月内到期'">
and mdq.next_check_time &lt;= DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH)
</when>
<!-- 筛选“正常” -->
<when test="alert == '正常'">
and mdq.next_check_time &gt; DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH)
</when>
</choose>
</if>
</where> </where>
GROUP BY m2.ma_id GROUP BY m2.ma_id
ORDER BY ORDER BY
@ -146,6 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createStartTime != null and createStartTime != '' and createEndTime != null and createEndTime != ''"> <if test="createStartTime != null and createStartTime != '' and createEndTime != null and createEndTime != ''">
and DATE_FORMAT(mdq.create_time,'%Y-%m-%d') between #{createStartTime} and #{createEndTime} and DATE_FORMAT(mdq.create_time,'%Y-%m-%d') between #{createStartTime} and #{createEndTime}
</if> </if>
ORDER BY mdq.qc_time DESC
</select> </select>
<select id="getQcList" resultType="com.bonus.material.device.domain.MaDevQc"> <select id="getQcList" resultType="com.bonus.material.device.domain.MaDevQc">
SELECT SELECT

View File

@ -193,9 +193,9 @@
mdi.ma_id, mdi.ma_id,
CASE CASE
WHEN ROUND(TIMESTAMPDIFF(DAY, mdi.production_date, CURDATE()) / 365.25, 1) >= mdi.max_working_hours THEN '已超期' WHEN ROUND(TIMESTAMPDIFF(DAY, mdi.production_date, CURDATE()) / 365.25, 1) >= mdi.max_working_hours THEN '已超期'
WHEN (mdi.max_working_hours - ROUND(TIMESTAMPDIFF(DAY, mdi.production_date, CURDATE()) / 365.25, 1)) * 365.25 WHEN (mdi.max_working_hours - ROUND(TIMESTAMPDIFF(DAY, mdi.production_date, CURDATE()) / 365.25, 1))
&lt;= &lt;=
30 THEN '一月内超期' 1 THEN '一月内超期'
ELSE '正常' ELSE '正常'
END AS expire_type END AS expire_type
FROM FROM

View File

@ -423,7 +423,7 @@
tool_ledger tl tool_ledger tl
WHERE WHERE
tl.type_id=#{typeId} tl.type_id=#{typeId}
<if test="code != null and code!=''"> <if test="code != null and code!='/'">
and tl.tool_code=#{code} and tl.tool_code=#{code}
</if> </if>
</select> </select>

View File

@ -287,7 +287,7 @@
INNER JOIN tool_type tt1 ON tt1.type_id = tt.parent_id INNER JOIN tool_type tt1 ON tt1.type_id = tt.parent_id
WHERE tl.status = #{status} WHERE tl.status = #{status}
AND tl.type_id = #{typeId} AND tl.type_id = #{typeId}
AND tl.manage_mode = #{type}
<if test="companyId != null"> <if test="companyId != null">
AND (tl.company_id = #{companyId} OR tl.company_id IS NULL) AND (tl.company_id = #{companyId} OR tl.company_id IS NULL)
</if> </if>