package org.jeecg.modules.mdcJc.service.impl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper;
|
import org.jeecg.modules.mdc.util.DateUtils;
|
import org.jeecg.modules.mdcJc.entity.MdcProductDayschedule;
|
import org.jeecg.modules.mdcJc.entity.ProductDayschedule;
|
import org.jeecg.modules.mdcJc.mapper.MdcProductDayscheduleMapper;
|
import org.jeecg.modules.mdcJc.service.IClassMonthlyScheduleService;
|
import org.jeecg.modules.mdcJc.service.IMdcProductDayScheduleService;
|
import org.jeecg.modules.utils.BeanMapper;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.time.LocalDate;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
import java.util.stream.Stream;
|
|
/**
|
* @author Lius
|
* @date 2024/7/30 15:14
|
*/
|
@Service
|
public class MdcProductDayScheduleServiceImpl extends ServiceImpl<MdcProductDayscheduleMapper, MdcProductDayschedule> implements IMdcProductDayScheduleService {
|
|
@Resource
|
private IClassMonthlyScheduleService classMonthlyScheduleService;
|
|
@Resource
|
private MdcEquipmentMapper mdcEquipmentMapper;
|
|
private final List<String> equipments = Stream.of("5045-7110", "5045-7115", "5045-7118").collect(Collectors.toList());
|
|
|
@Override
|
public boolean scheduleProductDayList() {
|
String date = DateUtils.format(DateUtils.getNow(),DateUtils.STR_DATE);
|
List<ProductDayschedule> list = classMonthlyScheduleService.findListProductDay(date);
|
if (list == null || list.isEmpty()) {
|
return true;
|
}
|
List<String> mdcListIds = super.baseMapper.selectDateList(date);
|
if (mdcListIds != null && !mdcListIds.isEmpty()) {
|
this.removeBatchByIds(mdcListIds);
|
}
|
List<MdcProductDayschedule> mesC = new ArrayList<>();
|
Map<String, String> map = new HashMap<>();
|
map.put("5899-8026", "1818119280110690306");
|
map.put("5899-8027", "1818119094416269313");
|
map.put("5899-8060", "1818118942234337281");
|
map.put("5899-8061", "1818119019862515714");
|
for (ProductDayschedule c : list) {
|
if (map.containsKey(c.getEquipmentId())) {
|
String productionId = map.get(c.getEquipmentId());
|
List<String> equipmentList = new ArrayList<>();
|
if ("5899-8060".equals(c.getEquipmentId()) && "后传动箱壳体".equals(c.getProductName())) {
|
// 3.8.11号机 后传动箱壳体
|
equipmentList = equipments;
|
} else if ("5899-8060".equals(c.getEquipmentId()) && "传动箱壳体".equals(c.getProductName())) {
|
// 除 3.8.11号机之外 传动箱壳体
|
List<String> queryIdsByProduction = mdcEquipmentMapper.queryIdsByProduction(productionId);
|
equipmentList = queryIdsByProduction.stream().filter(equipment -> !equipments.contains(equipment)).collect(Collectors.toList());
|
} else {
|
equipmentList = mdcEquipmentMapper.queryIdsByProduction(productionId);
|
}
|
|
if (equipmentList != null && !equipmentList.isEmpty()) {
|
for (String equipmentId : equipmentList) {
|
MdcProductDayschedule mdc = new MdcProductDayschedule();
|
BeanMapper.copy(c, mdc);
|
mdc.setEquipmentId(equipmentId);
|
mesC.add(mdc);
|
}
|
}
|
} else {
|
MdcProductDayschedule mdc = new MdcProductDayschedule();
|
BeanMapper.copy(c, mdc);
|
mesC.add(mdc);
|
}
|
}
|
boolean b = this.saveBatch(mesC);
|
return b;
|
}
|
|
@Override
|
public MdcProductDayschedule findYesterdayData() {
|
String date = LocalDate.now().plusDays(-1).toString();
|
return this.baseMapper.findYesterdayData(date);
|
}
|
|
@Override
|
public String findClazz(String equipmentId) {
|
return this.baseMapper.findClazz(equipmentId);
|
}
|
}
|