|
@@ -2,6 +2,7 @@ package com.platform.service.sqarepartmanage.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.platform.common.cache.ConfigCache;
|
|
|
import com.platform.common.exception.DeniedException;
|
|
|
import com.platform.common.model.OauthUser;
|
|
|
import com.platform.common.model.UserInfo;
|
|
@@ -10,12 +11,14 @@ import com.platform.dao.bean.MyVOPage;
|
|
|
import com.platform.dao.dto.sqarepartmanage.SparePartUsedDTO;
|
|
|
import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
|
import com.platform.dao.entity.sqarepartmanage.SparePartUsed;
|
|
|
+import com.platform.dao.entity.sqarepartmanage.SpareType;
|
|
|
import com.platform.dao.entity.store.SpareStore;
|
|
|
import com.platform.dao.enums.SparePartUsedStatusEnum;
|
|
|
+import com.platform.dao.enums.SysConfigEnum;
|
|
|
import com.platform.dao.mapper.sqarepartmanage.SparePartInfoMapper;
|
|
|
import com.platform.dao.mapper.sqarepartmanage.SparePartUsedMapper;
|
|
|
+import com.platform.dao.mapper.sqarepartmanage.SpareTypeMapper;
|
|
|
import com.platform.dao.mapper.store.SpareStoreMapper;
|
|
|
-import com.platform.dao.mapper.store.SpareStoreSecondMapper;
|
|
|
import com.platform.dao.vo.report.SparePartInfoReportVO;
|
|
|
import com.platform.dao.vo.spare.SparePartUsedVO;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
@@ -24,6 +27,7 @@ import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
+import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
@@ -41,10 +45,9 @@ import java.util.Map;
|
|
|
@AllArgsConstructor
|
|
|
@Service("sparePartUsedService")
|
|
|
public class SparePartUsedServiceImpl extends BaseServiceImpl<SparePartUsedMapper, SparePartUsed, SparePartUsedDTO> implements SparePartUsedService {
|
|
|
-
|
|
|
- private SpareStoreSecondMapper spareStoreSecondMapper;
|
|
|
private SpareStoreMapper spareStoreMapper;
|
|
|
private SparePartInfoMapper sparePartInfoMapper;
|
|
|
+ private SpareTypeMapper spareTypeMapper;
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
|
ids.forEach(id -> {
|
|
@@ -338,6 +341,59 @@ public class SparePartUsedServiceImpl extends BaseServiceImpl<SparePartUsedMappe
|
|
|
super.saveModelByDTO(model);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public MyVOPage<SparePartUsedVO> selectUpdateAlertPage(SparePartUsedDTO record, int pageNum, int pageSize) {
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ // 查询预警天数
|
|
|
+ String alertDays = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SPARE_UPDATE_ALERT_DAY.name());
|
|
|
+ record.setChangeDate(LocalDate.now().plusDays(Integer.parseInt(alertDays)));
|
|
|
+ if(StringUtils.isNotBlank(record.getKeyword())){
|
|
|
+ record.setKeyword(record.getKeyword().trim());
|
|
|
+ }
|
|
|
+ // 根据备件类型查询
|
|
|
+ if (StringUtils.isNotBlank(record.getTypeId())) {
|
|
|
+ Weekend<SpareType> weekend = new Weekend<>(SpareType.class);
|
|
|
+ WeekendCriteria<SpareType, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andEqualTo(SpareType::getParentId, record.getTypeId());
|
|
|
+ List<SpareType> childList = spareTypeMapper.selectByExample(weekend);
|
|
|
+ List<String> typeIds = new ArrayList<String>();
|
|
|
+ typeIds.add(record.getTypeId());
|
|
|
+ if (!CollectionUtils.isEmpty(childList)) {
|
|
|
+ childList.forEach(item -> {
|
|
|
+ typeIds.add(item.getId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ record.setTypeIds(typeIds);
|
|
|
+ }
|
|
|
+ return new MyVOPage<>(mapper.selectUpdateAlert(record));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SparePartUsedVO> selectUpdateAlertList(SparePartUsedDTO record) {
|
|
|
+ // 查询预警天数
|
|
|
+ String alertDays = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SPARE_UPDATE_ALERT_DAY.name());
|
|
|
+ record.setChangeDate(LocalDate.now().plusDays(Integer.parseInt(alertDays)));
|
|
|
+ if(StringUtils.isNotBlank(record.getKeyword())){
|
|
|
+ record.setKeyword(record.getKeyword().trim());
|
|
|
+ }
|
|
|
+ // 根据备件类型查询
|
|
|
+ if (StringUtils.isNotBlank(record.getTypeId())) {
|
|
|
+ Weekend<SpareType> weekend = new Weekend<>(SpareType.class);
|
|
|
+ WeekendCriteria<SpareType, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andEqualTo(SpareType::getParentId, record.getTypeId());
|
|
|
+ List<SpareType> childList = spareTypeMapper.selectByExample(weekend);
|
|
|
+ List<String> typeIds = new ArrayList<String>();
|
|
|
+ typeIds.add(record.getTypeId());
|
|
|
+ if (!CollectionUtils.isEmpty(childList)) {
|
|
|
+ childList.forEach(item -> {
|
|
|
+ typeIds.add(item.getId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ record.setTypeIds(typeIds);
|
|
|
+ }
|
|
|
+ return mapper.selectUpdateAlert(record);
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
int year = localDate.getYear();
|