|
|
|
@ -9,9 +9,10 @@ import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.common.core.utils.bean.BeanUtils;
|
|
|
|
|
import com.op.common.core.utils.http.HttpUtils;
|
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
|
import com.op.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.op.mes.domain.*;
|
|
|
|
|
import com.op.mes.domain.buffer.JsonRootBean;
|
|
|
|
|
import com.op.mes.domain.dto.BaseEquipmentDto;
|
|
|
|
|
import com.op.mes.domain.dto.LGInfoDto;
|
|
|
|
|
import com.op.mes.mapper.MesMapper;
|
|
|
|
|
import com.op.mes.mapper.MesReportWorkConsumeMapper;
|
|
|
|
@ -21,13 +22,12 @@ import com.op.mes.service.IWCSInterfaceService;
|
|
|
|
|
import com.op.system.api.RemoteSapService;
|
|
|
|
|
import com.op.system.api.RemoteUserService;
|
|
|
|
|
import com.op.system.api.domain.SysDept;
|
|
|
|
|
import com.op.system.api.domain.SysSapLog;
|
|
|
|
|
import com.op.system.api.domain.SysUser;
|
|
|
|
|
import com.op.system.api.domain.dto.BoardDTO;
|
|
|
|
|
import com.op.system.api.domain.dto.WCSDTO;
|
|
|
|
|
import com.op.system.api.domain.dto.WCSDataDTO;
|
|
|
|
|
import com.op.system.api.domain.mes.ProOrderWorkorderDTO;
|
|
|
|
|
import com.op.system.api.domain.mes.ProRfidProcessDetail;
|
|
|
|
|
import com.op.system.api.domain.sap.SapCloseOrderQuery;
|
|
|
|
|
import com.op.system.api.domain.sap.SapRFW;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
@ -47,7 +47,8 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.op.common.core.web.domain.AjaxResult.error;
|
|
|
|
|
import static com.op.common.core.web.domain.AjaxResult.success;
|
|
|
|
|
/**
|
|
|
|
|
* wcs接口业务层处理
|
|
|
|
|
*
|
|
|
|
@ -638,4 +639,86 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**白坯工厂,修正设备**/
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult changeTransferResultTask() {
|
|
|
|
|
// 加载sf-cloud库的sys_datasource
|
|
|
|
|
DynamicDataSourceContextHolder.push("ds_999");// 这是数据源的key
|
|
|
|
|
|
|
|
|
|
BaseEquipmentDto edto = new BaseEquipmentDto();
|
|
|
|
|
edto.setEquipmentTypeCode("equTypeCxj");
|
|
|
|
|
List<BaseEquipmentDto> cxjList = mesMapper.getAllEquipments(edto);
|
|
|
|
|
ExecutorService executorService = new ThreadPoolExecutor(
|
|
|
|
|
cxjList.size(),
|
|
|
|
|
cxjList.size(),
|
|
|
|
|
0L, TimeUnit.MILLISECONDS,
|
|
|
|
|
new LinkedBlockingQueue<Runnable>());
|
|
|
|
|
try {
|
|
|
|
|
cxjList.forEach(cxj -> {
|
|
|
|
|
Runnable run = () -> changeTransferResultFunc(cxj);
|
|
|
|
|
executorService.execute(run);
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("service == changeTransferResultTask == exception", e);
|
|
|
|
|
return error("service == changeTransferResultTask == exception");
|
|
|
|
|
} finally {
|
|
|
|
|
executorService.shutdown();
|
|
|
|
|
}
|
|
|
|
|
return success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新T-1天的mes_material_transfer_result数据
|
|
|
|
|
* @param cxj
|
|
|
|
|
*/
|
|
|
|
|
private R changeTransferResultFunc(BaseEquipmentDto cxj){
|
|
|
|
|
logger.info("++++++++++++" + cxj.getEquipmentCode() + "++++班次交接最后一车数据修正++++++++++");
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 定义日期格式
|
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
|
String ymdT0 = today.format(formatter); // 格式化今天的日期
|
|
|
|
|
LocalDate yesterday = today.minusDays(1);
|
|
|
|
|
String ymd = yesterday.format(formatter); // 格式化昨天的日期
|
|
|
|
|
cxj.setYmd("'"+ymdT0+"','"+ymd+"'");
|
|
|
|
|
List<MesShift> changeInfos = mesMapper.getChangeInfos(cxj);
|
|
|
|
|
if(CollectionUtils.isEmpty(changeInfos)){
|
|
|
|
|
logger.info("++++++++++++班次交接最后一车数据修正:无数据++++++++++"+JSONObject.toJSONString(cxj));
|
|
|
|
|
return R.fail("班次交接最后一车数据修正:无数据");
|
|
|
|
|
}
|
|
|
|
|
List<MesStationArrive> todoList = new ArrayList<>();
|
|
|
|
|
for(int m=0;m<changeInfos.size()-1;m++){
|
|
|
|
|
Date startTime = changeInfos.get(m).getStartTime();
|
|
|
|
|
Date endTime = changeInfos.get(m+1).getStartTime();
|
|
|
|
|
|
|
|
|
|
MesStationArrive qo = new MesStationArrive();
|
|
|
|
|
qo.setShiftId(changeInfos.get(m).getShiftId());
|
|
|
|
|
qo.setStartTime(startTime);
|
|
|
|
|
qo.setEndTime(endTime);
|
|
|
|
|
qo.setStationNo(cxj.getEquipmentCode());//成型机编码
|
|
|
|
|
logger.info("++++++++++++班次交接最后一车数据修正:开始修正++++++++++"+JSONObject.toJSONString(qo));
|
|
|
|
|
List<MesStationArrive> todos1 = mesMapper.getUnChangeList(qo);//需要调整的数据
|
|
|
|
|
todoList.addAll(todos1);
|
|
|
|
|
|
|
|
|
|
if(!CollectionUtils.isEmpty(todoList)){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qo.setReqCode(ymd);//工单日期
|
|
|
|
|
ProOrderWorkorderDTO actOrderWork = mesMapper.getActOrderWork(qo);
|
|
|
|
|
if(actOrderWork != null){//给需要调整的数据,重新赋值新的班次,工单Id
|
|
|
|
|
Date nowDate = DateUtils.getNowDate();
|
|
|
|
|
for(MesStationArrive newtodo:todoList){
|
|
|
|
|
newtodo.setChangeOrderWorkId(actOrderWork.getWorkorderId());
|
|
|
|
|
newtodo.setShiftId(Integer.parseInt(actOrderWork.getShiftId()));
|
|
|
|
|
newtodo.setChangeWorkDate(actOrderWork.getProductDate());
|
|
|
|
|
newtodo.setChangeTime(nowDate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**mes_material_transfer_result**/
|
|
|
|
|
int n = mesMapper.updateTransferResult(todoList);
|
|
|
|
|
logger.info("++++++++++++班次交接最后一车数据修正:修正成功"+n+"++++++++++"+JSONObject.toJSONString(todoList));
|
|
|
|
|
}
|
|
|
|
|
logger.info("++++++++++++班次交接最后一车数据修正:数据条数++++++++++"+todoList.size());
|
|
|
|
|
return R.fail("班次交接最后一车数据修正:完成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|