|
|
@ -2,25 +2,26 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProdMouldStatisticsService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProdMouldStatisticsService;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesProdMouldStatisticsDao;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesProdMouldStatisticsDao;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.DateUtil;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.DateUtil;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesMouldMappingCfg;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProdMouldRecord;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProdMouldStatistics;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.IMesMouldMappingCfgRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.IMesMouldMappingCfgRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesProdMouldRecordRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesProdMouldRecordRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesProdMouldStatisticsRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesProdMouldStatisticsRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesProductionRecordRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesProductionRecordRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -54,6 +55,9 @@ public class MesProdMouldStatisticsServiceImpl implements IMesProdMouldStatistic
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesProdMouldStatisticsRepository mesProdMouldStatisticsRDao;
|
|
|
|
private MesProdMouldStatisticsRepository mesProdMouldStatisticsRDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IConfigService configService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void doSumMesProdMouldStatistics(String organizeCode, Integer pageSize, String userName) {
|
|
|
|
public void doSumMesProdMouldStatistics(String organizeCode, Integer pageSize, String userName) {
|
|
|
|
//查询未统计的开模记录数据
|
|
|
|
//查询未统计的开模记录数据
|
|
|
@ -80,6 +84,52 @@ public class MesProdMouldStatisticsServiceImpl implements IMesProdMouldStatistic
|
|
|
|
updateMesProductionRecord(organizeCode, userName, undStatisticsMesProdMouldRecordList.stream().map(MesProdMouldRecord::getId).collect(Collectors.toList()));
|
|
|
|
updateMesProductionRecord(organizeCode, userName, undStatisticsMesProdMouldRecordList.stream().map(MesProdMouldRecord::getId).collect(Collectors.toList()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void doSendMesProdMouldStatistics(String organizeCode, String userName) {
|
|
|
|
|
|
|
|
Map<String, MesConfig> mesConfigMap = getMesConfigMap(organizeCode);
|
|
|
|
|
|
|
|
if (mesConfigMap == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//发送URL
|
|
|
|
|
|
|
|
String sendUrl = getConfigValue(mesConfigMap, MesPcnExtConstWords.SEND_URL);
|
|
|
|
|
|
|
|
//发送data
|
|
|
|
|
|
|
|
String sendData = getConfigValue(mesConfigMap, MesPcnExtConstWords.SEND_DATA);
|
|
|
|
|
|
|
|
//发送item
|
|
|
|
|
|
|
|
String sendItemData = getConfigValue(mesConfigMap, MesPcnExtConstWords.SEND_ITEM_DATA);
|
|
|
|
|
|
|
|
if (Objects.isNull(sendUrl) || Objects.isNull(sendData) || Objects.isNull(sendItemData)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//查询未发送数据
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(CommonEnumUtil.FALSE, "systemSyncStatus", packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringSmallerNotEqualPack(TimeTool.getToday(), "createDatetime", packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getOrderBy("modifyDatetime", CommonEnumUtil.ASC_OR_DESC.ASC.getValue(), packBean);
|
|
|
|
|
|
|
|
List<MesProdMouldStatistics> mesProdMouldStatisticsList = mesProdMouldStatisticsRDao.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(mesProdMouldStatisticsList)) {
|
|
|
|
|
|
|
|
log.info("不存在未发送的数据");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//发送数据
|
|
|
|
|
|
|
|
StringBuilder itemData = new StringBuilder();
|
|
|
|
|
|
|
|
for (MesProdMouldStatistics statistics : mesProdMouldStatisticsList) {
|
|
|
|
|
|
|
|
String time = TimeTool.parseStringFormat(statistics.getCreateDatetime(), "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd'T'HH:mm:ss");
|
|
|
|
|
|
|
|
itemData.append(String.format(sendItemData, statistics.getAssetNum(), statistics.getEquipmentCode(), statistics.getQty(), time, "1117"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String body = HttpRequest.post(sendUrl).header("Content-Type", "text/xml").body(String.format(sendData, itemData)).execute().body();
|
|
|
|
|
|
|
|
//发送成功更新同步状态
|
|
|
|
|
|
|
|
mesProdMouldStatisticsList.forEach(t -> {
|
|
|
|
|
|
|
|
if (!body.contains("messageID")) {
|
|
|
|
|
|
|
|
t.setSystemSyncStatus(CommonEnumUtil.FALSE);
|
|
|
|
|
|
|
|
t.setDescription(body);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
t.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ConvertBean.serviceModelUpdate(t, userName);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
mesProdMouldStatisticsRDao.saveAll(mesProdMouldStatisticsList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void updateMesProductionRecord(String organizeCode, String userName, List<Long> idList) {
|
|
|
|
private void updateMesProductionRecord(String organizeCode, String userName, List<Long> idList) {
|
|
|
|
//查询加工记录表
|
|
|
|
//查询加工记录表
|
|
|
|
List<MesProductionRecord> mesProductionRecordList = getProductionRecordList(organizeCode, idList);
|
|
|
|
List<MesProductionRecord> mesProductionRecordList = getProductionRecordList(organizeCode, idList);
|
|
|
@ -105,6 +155,7 @@ public class MesProdMouldStatisticsServiceImpl implements IMesProdMouldStatistic
|
|
|
|
mesProdMouldStatistic.setWorkDate(mesProdMouldRecordEntry.getKey());
|
|
|
|
mesProdMouldStatistic.setWorkDate(mesProdMouldRecordEntry.getKey());
|
|
|
|
mesProdMouldStatistic.setAssetNum(mesMouldMappingCfg.getAssetNum());
|
|
|
|
mesProdMouldStatistic.setAssetNum(mesMouldMappingCfg.getAssetNum());
|
|
|
|
mesProdMouldStatistic.setMeterName(mesMouldMappingCfg.getMeterName());
|
|
|
|
mesProdMouldStatistic.setMeterName(mesMouldMappingCfg.getMeterName());
|
|
|
|
|
|
|
|
mesProdMouldStatistic.setEquipmentCode(mesMouldMappingCfg.getEquipmentCode());
|
|
|
|
mesProdMouldStatistic.setQty(mesProdMouldRecordEntry.getValue().size());
|
|
|
|
mesProdMouldStatistic.setQty(mesProdMouldRecordEntry.getValue().size());
|
|
|
|
mesProdMouldStatistic.setOrganizeCode(organizeCode);
|
|
|
|
mesProdMouldStatistic.setOrganizeCode(organizeCode);
|
|
|
|
ConvertBean.serviceModelInitialize(mesProdMouldStatistic, userName);
|
|
|
|
ConvertBean.serviceModelInitialize(mesProdMouldStatistic, userName);
|
|
|
@ -141,4 +192,22 @@ public class MesProdMouldStatisticsServiceImpl implements IMesProdMouldStatistic
|
|
|
|
DdlPreparedPack.getInPackList(idList, "mouldRecordId", packBean);
|
|
|
|
DdlPreparedPack.getInPackList(idList, "mouldRecordId", packBean);
|
|
|
|
return mesProductionRecordRDao.findByHqlWhere(packBean);
|
|
|
|
return mesProductionRecordRDao.findByHqlWhere(packBean);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getConfigValue(Map<String, MesConfig> mesConfigMap, String key) {
|
|
|
|
|
|
|
|
MesConfig mesConfig = mesConfigMap.get(key);
|
|
|
|
|
|
|
|
if (Objects.isNull(mesConfig) || StringUtils.isEmpty(mesConfig.getCfgValue())) {
|
|
|
|
|
|
|
|
log.info("参数【{}】未维护", key);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return mesConfig.getCfgValue();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, MesConfig> getMesConfigMap(String organizeCode) {
|
|
|
|
|
|
|
|
List<MesConfig> mesConfigList = configService.findMesConfigByCfgCode(MesPcnExtConstWords.SEND_MES_PROD_MOULD_STATISTICS, organizeCode);
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(mesConfigList)) {
|
|
|
|
|
|
|
|
log.info("发送开模统计参数【{}】未维护", MesPcnExtConstWords.SEND_MES_PROD_MOULD_STATISTICS);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return mesConfigList.stream().collect(Collectors.toMap(MesConfig::getCfgKey, t -> t));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|