Merge remote-tracking branch 'origin/master'

# Conflicts:
#	op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapOrderServiceImpl.java
master
Yangwl 11 months ago
commit 72917fbe68

@ -31,6 +31,7 @@ public class DeviceTaskController {
*/
@PostMapping("/createSpotCheckPlanTask")
public R createSpotCheckPlanTask() {
System.out.println("点检判断");
AjaxResult result = taskService.createSpotCheckPlanTask();
if(result.isSuccess()){
return R.ok("点检计划生成成功");
@ -57,6 +58,7 @@ public class DeviceTaskController {
*/
@PostMapping("/createMaintenancePlanTask")
public R createMaintenancePlanTask() {
System.out.println("保养判断");
AjaxResult result = taskService.createMaintenancePlanTask();
if(result.isSuccess()){
return R.ok("保养计划生成成功");

@ -102,33 +102,41 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
List<EquOrder> handleList = new ArrayList<>();
long nowTime = DateUtils.getNowDate().getTime();
long dayMs = 86400000l;
if (orderList!=null) {
long hourMs = 1000 * 60 * 60;
if (orderList != null) {
for (EquOrder order : orderList) {
long diff = nowTime - order.getCreateTime().getTime();
if (order.getPlanLoopType().equals("day")){
if (diff < (dayMs * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
}
if (order.getPlanLoopType().equals("week")){
if (diff < (dayMs*7 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
}
if (order.getPlanLoopType().equals("month")){
if (diff < (dayMs*30 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
}
if (order.getPlanLoopType().equals("season")){
if (diff < (dayMs*30*3 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
}
if (order.getPlanLoopType().equals("year")){
if (diff < (dayMs*365 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
switch (order.getPlanLoopType()) {
case "hour":
if (diff < 1000 * 60 * 60 * Long.valueOf(order.getPlanLoop())) {
handleList.add(order);
}
break;
case "day":
if (diff < (dayMs * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
break;
case "week":
if (diff < (dayMs * 7 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
break;
case "month":
if (diff < (dayMs * 30 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
break;
case "season":
if (diff < (dayMs * 30 * 3 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
break;
case "year":
if (diff < (dayMs * 365 * Long.valueOf(order.getPlanLoop()))) {
handleList.add(order);
}
break;
}
}
}
@ -395,7 +403,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
equOrder.setOrderEnd(DateUtils.getNowDate());
// 用时(分钟)
long diff = equOrder.getOrderEnd().getTime() - equOrder.getOrderStart().getTime();
equOrder.setOrderCostTime(String.valueOf(diff/60000));
equOrder.setOrderCostTime(String.valueOf(diff / 60000));
// 创建设备对象用于更新设备状态
Equipment equ = new Equipment();
equ.setEquipmentCode(equOrder.getEquipmentCode());
@ -403,10 +411,10 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
// 费用
BigDecimal sparePartsCost = equSpareApplyMapper.getSparePartsCost(equOrder.getOrderCode());
BigDecimal orderCost = equOrder.getOrderCost();
if (orderCost!=null) {
if (sparePartsCost==null) {
if (orderCost != null) {
if (sparePartsCost == null) {
equOrder.setOrderCost(orderCost);
}else {
} else {
equOrder.setOrderCost(sparePartsCost.add(orderCost));
}
}
@ -664,6 +672,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
/**
*
*
* @param equipmentCode
* @return
*/
@ -703,7 +712,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
for (EquOrderStandard standardList : standardLists) {
//每个检查标准里面的照片
String imageType = "4";
List<BaseFileData> files = equOrderStandardMapper.getBaseFileBatch(standardList.getId(),imageType);
List<BaseFileData> files = equOrderStandardMapper.getBaseFileBatch(standardList.getId(), imageType);
if (!CollectionUtils.isEmpty(files)) {
standardList.setPicturePaths(files);
}
@ -752,7 +761,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
equRepairWorkOrder.setWorkEndTime(DateUtils.getNowDate());
//2.计算维修工单用时
if(list.getWorkStartTime()!= null && equRepairWorkOrder.getWorkEndTime()!= null){
if (list.getWorkStartTime() != null && equRepairWorkOrder.getWorkEndTime() != null) {
//2.1计算日期差值
ZoneId zoneId = ZoneId.systemDefault();
@ -769,18 +778,18 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
double hours = tempDateTime.until(end, ChronoUnit.HOURS);
// tempDateTime = tempDateTime.plusHours(hours);
double minutes = ((tempDateTime.until(end, ChronoUnit.MINUTES)*1.0)%60)/60;
double minutes = ((tempDateTime.until(end, ChronoUnit.MINUTES) * 1.0) % 60) / 60;
// tempDateTime = tempDateTime.plusMinutes(minutes);
double seconds = ((tempDateTime.until(end, ChronoUnit.SECONDS)*1.0)%3600)/3600;
double seconds = ((tempDateTime.until(end, ChronoUnit.SECONDS) * 1.0) % 3600) / 3600;
double hour = BigDecimal.valueOf(hours + minutes + seconds).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
//2.2查询完好率报表
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String time = sdf.format(equRepairWorkOrder.getWorkEndTime());
EquOperation equOperation = equOperationMapper.selectEquipmentIntegrityRate(time,equRepairWorkOrder.getEquipmentCode());
EquOperation equOperation = equOperationMapper.selectEquipmentIntegrityRate(time, equRepairWorkOrder.getEquipmentCode());
//2.3修改完好率报表
if(equOperation != null){
if (equOperation != null) {
if (list.getWorkDownMachine().equals("1")) {
DecimalFormat df = new DecimalFormat("#.##");
//实际运行时间 = 实际运行时间 - 故障时间
@ -791,10 +800,10 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
BigDecimal operationTimeBD = new BigDecimal(equOperation.getOperationTime());//运行时间
equOperation.setActualOperationTime(String.valueOf(df.format(result)));//实际运行时间
equOperation.setFaultTime(String.valueOf(faultTime));//故障时间
equOperation.setFailureRate(faultTimeBD.multiply(new BigDecimal(100)).divide(operationTimeBD,2, RoundingMode.HALF_UP).toString()+"%");
equOperation.setShutdownTimes(equOperation.getShutdownTimes()+1);//停机次数加1
equOperation.setFailureRate(faultTimeBD.multiply(new BigDecimal(100)).divide(operationTimeBD, 2, RoundingMode.HALF_UP).toString() + "%");
equOperation.setShutdownTimes(equOperation.getShutdownTimes() + 1);//停机次数加1
}
equOperation.setFailureTimes(equOperation.getFailureTimes()+1);//故障次数加1
equOperation.setFailureTimes(equOperation.getFailureTimes() + 1);//故障次数加1
equOperation.setUpdateBy(SecurityUtils.getUsername());
equOperation.setUpdateTime(DateUtils.getNowDate());
equOperationMapper.updateEquOperation(equOperation);
@ -803,7 +812,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
////3.更新每一项点检/巡检检查项信息
//判空
if(StringUtils.isNotEmpty(equRepairWorkOrder.getDetailList())){
if (StringUtils.isNotEmpty(equRepairWorkOrder.getDetailList())) {
List<EquOrder> checkLists = equRepairWorkOrder.getDetailList();
for (EquOrder checkList : checkLists) {
checkList.setUpdateBy(SecurityUtils.getUsername());
@ -812,7 +821,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
for (EquOrderStandard standardList : standardLists) {
//先删除每个检查项标准图片
String imageType = "4";
equOrderStandardMapper.deleteBaseFileBySourceId(standardList.getId(),imageType);
equOrderStandardMapper.deleteBaseFileBySourceId(standardList.getId(), imageType);
//图片批量新增
if (StringUtils.isNotEmpty(standardList.getPicturePath())) {
String[] ids = standardList.getPicturePath().split(",");
@ -844,7 +853,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
////4.新建申领单
//判空
if(StringUtils.isNotEmpty(equRepairWorkOrder.getApplyList())){
if (StringUtils.isNotEmpty(equRepairWorkOrder.getApplyList())) {
List<EquSpareApply> equSpareApplies = equRepairWorkOrder.getApplyList();
for (EquSpareApply equSpareApply : equSpareApplies) {
//生成领料单code
@ -954,26 +963,26 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
List<EquFaultTypeTree> firstTree = new ArrayList<>();
// 判空
if (!CollectionUtils.isEmpty(firstLevel)) {
for(EquFaultType equFaultType : firstLevel){
EquFaultTypeTree equFaultTypeParentTree = new EquFaultTypeTree();
equFaultTypeParentTree.setValue(equFaultType.getDictValue());
equFaultTypeParentTree.setLabel(equFaultType.getDictLabel());
//二级
List <EquFaultType> secondLevel = equFaultTypeMapper.selectSecondLevelList(equFaultType.getDictValue());
// 二级list
List<EquFaultTypeTree> secondTree = new ArrayList<>();
// 判空
if (!CollectionUtils.isEmpty(secondLevel)) {
for(EquFaultType second : secondLevel) {
EquFaultTypeTree equFaultTypeChildTree = new EquFaultTypeTree();
equFaultTypeChildTree.setValue(second.getFaultCode());
equFaultTypeChildTree.setLabel(second.getFaultSubclass());
secondTree.add(equFaultTypeChildTree);
}
}
equFaultTypeParentTree.setChildren(secondTree);
firstTree.add(equFaultTypeParentTree);
}
for (EquFaultType equFaultType : firstLevel) {
EquFaultTypeTree equFaultTypeParentTree = new EquFaultTypeTree();
equFaultTypeParentTree.setValue(equFaultType.getDictValue());
equFaultTypeParentTree.setLabel(equFaultType.getDictLabel());
//二级
List<EquFaultType> secondLevel = equFaultTypeMapper.selectSecondLevelList(equFaultType.getDictValue());
// 二级list
List<EquFaultTypeTree> secondTree = new ArrayList<>();
// 判空
if (!CollectionUtils.isEmpty(secondLevel)) {
for (EquFaultType second : secondLevel) {
EquFaultTypeTree equFaultTypeChildTree = new EquFaultTypeTree();
equFaultTypeChildTree.setValue(second.getFaultCode());
equFaultTypeChildTree.setLabel(second.getFaultSubclass());
secondTree.add(equFaultTypeChildTree);
}
}
equFaultTypeParentTree.setChildren(secondTree);
firstTree.add(equFaultTypeParentTree);
}
}
return success(firstTree);
}
@ -992,11 +1001,12 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
/**
*
*
* @param equipmentCode
* @param operationType /
* @param type /
* @param type /
*/
private void updateOperationRecord(String equipmentCode,String operationType,String type) {
private void updateOperationRecord(String equipmentCode, String operationType, String type) {
// 设备最后一条运行记录
EquOperationRecord lastRecord = equOperationRecordMapper.selectLastOperationRecordByEquipmentCode(equipmentCode);
// 如果在维修中则不添加运行记录

@ -134,9 +134,9 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
new LinkedBlockingQueue<Runnable>());
try {
dateSources.forEach(dateSource -> {
logger.info("++++++++++++" + dateSource.get("poolName") + "++++巡检开始++++++++++");
Runnable run = () -> createPatrolCheckPlanFunc(dateSource.get("poolName"));
executorService.execute(run);
logger.info("++++++++++++" + dateSource.get("poolName") + "++++巡检开始++++++++++");
Runnable run = () -> createPatrolCheckPlanFunc(dateSource.get("poolName"));
executorService.execute(run);
});
} catch (Exception e) {
logger.error("service == dataClearTask == exception", e);
@ -180,6 +180,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
/**
*
*
* @return
*/
@Override
@ -213,6 +214,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
/**
*
*
* @return
*/
@Override
@ -244,19 +246,19 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
return success();
}
public void createSpotCheckPlanFunc(String poolName){
public void createSpotCheckPlanFunc(String poolName) {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
/**equ_plan equ_plan_equ**/
EquPlan equPlan = new EquPlan();
equPlan.setPlanType("spotInspection");
List<EquPlan> plans = deviceTaskMapper.getPlans(equPlan);
for(EquPlan plan:plans){
for (EquPlan plan : plans) {
EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan);
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){
if (hasTask == null || Integer.parseInt(plan.getPlanLoop()) <= hasTask.getDays() || checkHourTask(hasTask, plan)) {
//生成点检计划
int m = this.createOrderPlan(plan);
if(m==0){
if (m == 0) {
error("equ_order相关添加失败");
}
}
@ -264,19 +266,19 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
logger.info("++++++++++++" + poolName + "++++点检结束++++++++++");
}
public void createPatrolCheckPlanFunc(String poolName){
public void createPatrolCheckPlanFunc(String poolName) {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
/**equ_plan equ_plan_equ**/
EquPlan equPlan = new EquPlan();
equPlan.setPlanType("inspection");
List<EquPlan> plans = deviceTaskMapper.getPlans(equPlan);
for(EquPlan plan:plans){
for (EquPlan plan : plans) {
EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan);
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){
if (hasTask == null || Integer.parseInt(plan.getPlanLoop()) <= hasTask.getDays() || checkHourTask(hasTask, plan)) {
//生成巡检计划
int m = this.createOrderPlan(plan);
if(m==0){
if (m == 0) {
error("equ_order相关添加失败");
}
}
@ -284,29 +286,29 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
logger.info("++++++++++++" + poolName + "++++巡检结束++++++++++");
}
public void createMaintenancePlanFunc(String poolName){
public void createMaintenancePlanFunc(String poolName) {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
/**equ_plan equ_plan_equ**/
EquPlan equPlan = new EquPlan();
equPlan.setPlanType("maintenance");
List<EquPlan> plans = deviceTaskMapper.getPlans(equPlan);
for(EquPlan plan:plans){
for (EquPlan plan : plans) {
EquOrder hasTask = null;
if("1".equals(plan.getCalculationRule())){
if ("1".equals(plan.getCalculationRule())) {
//根据order_start//1按上次保养时间
hasTask = deviceTaskMapper.getNewTaskOrder0(plan);
}else if("0".equals(plan.getCalculationRule())){
} else if ("0".equals(plan.getCalculationRule())) {
//根据createTime//0按固定周期
hasTask = deviceTaskMapper.getNewTaskOrder(plan);
}else if("2".equals(plan.getCalculationRule())){
} else if ("2".equals(plan.getCalculationRule())) {
//单次生成保养计划
}
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){
if (hasTask == null || Integer.parseInt(plan.getPlanLoop()) <= hasTask.getDays() || checkHourTask(hasTask, plan)) {
//生成保养计划
int m = this.createOrderPlan(plan);
if(m==0){
if (m == 0) {
error("equ_order相关添加失败");
}
}
@ -314,7 +316,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
logger.info("++++++++++++" + poolName + "++++保养结束++++++++++");
}
private int createOrderPlan(EquPlan plan){
private int createOrderPlan(EquPlan plan) {
Date nowtime = DateUtils.getNowDate();
String createBy = "job";
String factory = plan.getFactoryCode();
@ -322,21 +324,21 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
/**equ_plan->equ_order********************************************************************/
EquOrder order = new EquOrder();
//源->目标
BeanUtils.copyProperties(plan,order);
BeanUtils.copyProperties(plan, order);
order.setOrderId(IdUtils.fastSimpleUUID());
order.setCreateBy(createBy);
order.setCreateTime(nowtime);
// 流水号
String serialNum = String.format("%03d",equOrderMapper.selectSerialNumber());
String orderCode = "O"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+serialNum;
String serialNum = String.format("%03d", equOrderMapper.selectSerialNumber());
String orderCode = "O" + DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + serialNum;
order.setOrderCode(orderCode);
if("1".equals(plan.getUpkeep())) {//1委外工单
order.setOutsourceCode("BW"+orderCode);
if ("1".equals(plan.getUpkeep())) {//1委外工单
order.setOutsourceCode("BW" + orderCode);
}
/**equ_order**/
sce = equOrderMapper.insertEquOrder(order);
System.out.println(plan.getPlanCode()+"========equ_order:"+sce);
System.out.println(plan.getPlanCode() + "========equ_order:" + sce);
/**equ_plan_equ_spare->equ_spare_apply*************************************************************/
EquPlanEquSpare equPlanEquSpare = new EquPlanEquSpare();
equPlanEquSpare.setParentCode(plan.getPlanEquId());
@ -347,7 +349,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
for (EquPlanEquSpare spare : spares) {
EquSpareApply apply = new EquSpareApply();
apply.setApplyId(IdUtils.fastSimpleUUID());
apply.setApplyCode("A"+orderCode+String.format("%02d",applySerialNum));
apply.setApplyCode("A" + orderCode + String.format("%02d", applySerialNum));
applySerialNum++;
apply.setSpareCode(spare.getMaterialCode());
apply.setSpareName(spare.getMaterialDesc());
@ -381,13 +383,13 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
List<EquPlanStandard> standards = new ArrayList<>();
List<EquPlanStandard> standards0 = null;
for(EquPlanDetail itme:details){
for (EquPlanDetail itme : details) {
String detailId = IdUtils.fastSimpleUUID();
EquPlanStandard standardqo = new EquPlanStandard();
//equ_plan_detail的id
standardqo.setParentCode(itme.getId());
standards0 = equPlanStandardMapper.selectEquPlanStandardList(standardqo);
for(EquPlanStandard standard:standards0) {
for (EquPlanStandard standard : standards0) {
standard.setId(IdUtils.fastSimpleUUID());
standard.setCreateTime(nowtime);
standard.setCreateBy(createBy);
@ -403,19 +405,19 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
itme.setDelFlag("0");
itme.setParentCode(orderCode);
}
if(!CollectionUtils.isEmpty(details)) {
if (!CollectionUtils.isEmpty(details)) {
sce = equOrderDetailMapper.insertEquOrderDetails(details);
System.out.println(plan.getPlanCode() + "========equ_order_detail:" + sce);
}
/**equ_plan_standard->equ_order_standard*******************************************************/
if(!CollectionUtils.isEmpty(standards)) {
if (!CollectionUtils.isEmpty(standards)) {
sce = equOrderStandardMapper.insertEquOrderStandards(standards);
System.out.println(plan.getPlanCode() + "========equ_order_standard:" + sce);
}
/**equ_plan_person->equ_order_standard*********************************************************/
if("1".equals(plan.getUpkeep())){//1委外
if ("1".equals(plan.getUpkeep())) {//1委外
EquOutsourceWork equOutsourceWork = new EquOutsourceWork();
BeanUtils.copyProperties(plan,equOutsourceWork);
BeanUtils.copyProperties(plan, equOutsourceWork);
equOutsourceWork.setWorkId(IdUtils.fastSimpleUUID());
equOutsourceWork.setWorkCode(order.getOutsourceCode());
equOutsourceWork.setWorkType("1");//1委外保养0委外维修
@ -425,7 +427,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
equOutsourceWork.setRepairCode(orderCode);
sce = equOutsourceWorkMapper.insertEquOutsourceWork(equOutsourceWork);
System.out.println(plan.getPlanCode() + "========equ_outsource_work:" + sce);
}else {
} else {
EquPlanPerson equPlanPerson = new EquPlanPerson();
equPlanPerson.setPlanCode(plan.getPlanCode());
List<EquPlanPerson> persons = equPlanPersonMapper.selectEquPlanPersonList(equPlanPerson);
@ -445,7 +447,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
return sce;
}
private void createEquipmentOperation(String poolName){
private void createEquipmentOperation(String poolName) {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
// 当天未生成过运行记录
int checkNum = equOperationMapper.checkInsertOperation();
@ -457,7 +459,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
// 统一处理数据
for (EquOperation operation : operationList) {
operation.setId(IdUtils.fastSimpleUUID());// id
operation.setFactoryCode(poolName.replace("ds_",""));// 工厂
operation.setFactoryCode(poolName.replace("ds_", ""));// 工厂
operation.setOperationTime(DateUtils.getTime());// 日期
operation.setOperationTime(operationTime);// 运行时间(默认运行时间)
operation.setActualOperationTime(operationTime);// 实际运行时间(默认运行时间)
@ -468,18 +470,18 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
int batchSize = 100;// 批次数量
// 分批次处理
int batchCount = (operationList.size() + batchSize - 1)/batchSize;// 计算批次数量
for (int i = 0;i < batchCount; i++) {
int batchCount = (operationList.size() + batchSize - 1) / batchSize;// 计算批次数量
for (int i = 0; i < batchCount; i++) {
int startIndex = i * batchSize;// 索引开始值
int endIndex = Math.min((i + 1)*batchSize,operationList.size());// 索引结束值
int endIndex = Math.min((i + 1) * batchSize, operationList.size());// 索引结束值
// 截取列表
List<EquOperation> subList = operationList.subList(startIndex,endIndex);
List<EquOperation> subList = operationList.subList(startIndex, endIndex);
int num = equOperationMapper.insertEquOperationByBatch(subList);
System.out.println("数据源:"+poolName+"--->"+"第"+(i+1)+"轮"+"开始索引:"+startIndex+"________结束索引:"+endIndex+"________成功插入数量:"+num);
System.out.println("数据源:" + poolName + "--->" + "第" + (i + 1) + "轮" + "开始索引:" + startIndex + "________结束索引:" + endIndex + "________成功插入数量:" + num);
}
}else {
System.out.println("数据源:"+poolName+"当天生成过运行记录");
} else {
System.out.println("数据源:" + poolName + "当天生成过运行记录");
}
}
@ -494,28 +496,43 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
int insertSize = 100;// 新增批次数量
// 分批次备份
int batchCount = (insertNum + insertSize - 1)/insertSize;// 计算批次数量
for (int i = 0;i < batchCount; i++) {
int batchCount = (insertNum + insertSize - 1) / insertSize;// 计算批次数量
for (int i = 0; i < batchCount; i++) {
int startIndex = i * insertSize;// 索引开始值
int endIndex = Math.min((i + 1)*insertSize,insertNum);// 索引结束值
int endIndex = Math.min((i + 1) * insertSize, insertNum);// 索引结束值
// 备份至数据库
int num = equOperationMapper.backupOperation(startIndex,insertSize);
int num = equOperationMapper.backupOperation(startIndex, insertSize);
System.out.println("数据源:"+poolName+"--->"+"第"+(i+1)+"轮备份"+"开始索引:"+startIndex+"________结束索引:"+endIndex+"________成功插入数量:"+num);
System.out.println("数据源:" + poolName + "--->" + "第" + (i + 1) + "轮备份" + "开始索引:" + startIndex + "________结束索引:" + endIndex + "________成功插入数量:" + num);
}
// 删除源数据库数据
int delSize = 100;// 删除批次数量
for (int i = 0; i < insertNum/delSize+1; i++) {
for (int i = 0; i < insertNum / delSize + 1; i++) {
// 在源数据库中删除
int num = equOperationMapper.deleteOperation(delSize);
System.out.println("数据源:"+poolName+"--->"+"第"+(i+1)+"轮删除"+"------>成功删除数量:"+num);
System.out.println("数据源:" + poolName + "--->" + "第" + (i + 1) + "轮删除" + "------>成功删除数量:" + num);
}
}else {
System.out.println("数据源:"+poolName+"---->"+"年份:"+( LocalDate.now().getYear()-2) +"--->已备份");
} else {
System.out.println("数据源:" + poolName + "---->" + "年份:" + (LocalDate.now().getYear() - 2) + "--->已备份");
}
}
// 循环类型为小时
private boolean checkHourTask(EquOrder order, EquPlan plan) {
if (order == null) {
return true;
}
Long loop = 1L;
Long diff = 0L;
if (plan.getPlanLoopType().equals("hour")) {
loop = Long.valueOf(plan.getPlanLoop()) * 60 * 60 * 1000;
diff = DateUtils.getNowDate().getTime() - order.getCreateTime().getTime();
}
return diff >= loop;
}
public static void main(String[] args) {
@ -523,14 +540,14 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
int batchSize = 200;// 批次数量
// 分批次处理
int batchCount = (500 + batchSize - 1)/batchSize;// 计算批次数量
for (int i = 0;i < batchCount; i++) {
int batchCount = (500 + batchSize - 1) / batchSize;// 计算批次数量
for (int i = 0; i < batchCount; i++) {
int startIndex = i * batchSize;
int endIndex = Math.min((i + 1)*batchSize,500);
System.out.println("第"+i+"轮"+"开始:"+startIndex+"------结束:"+endIndex);
int endIndex = Math.min((i + 1) * batchSize, 500);
System.out.println("第" + i + "轮" + "开始:" + startIndex + "------结束:" + endIndex);
}
System.out.println("------>"+batchCount);
System.out.println("------>" + batchCount);
}
}

@ -38,12 +38,12 @@
</select>
<select id="getNewTaskOrder" resultType="com.op.device.domain.EquOrder">
select top 1 order_code orderCode,
create_time createTime,
<if test='planLoopType=="day"'> DATEDIFF (day, create_time, GETDATE()) days </if>
<if test='planLoopType=="week"'> DATEDIFF (week, create_time, GETDATE()) days </if>
<if test='planLoopType=="month"'> DATEDIFF (month, create_time, GETDATE()) days </if>
<if test='planLoopType=="season"'> DATEDIFF (month, create_time, GETDATE())/3 days </if>
<if test='planLoopType=="year"'> DATEDIFF (year, create_time, GETDATE()) days </if>
create_time createTime
<if test="planLoopType=='day'">, DATEDIFF (day, create_time, GETDATE()) days </if>
<if test="planLoopType=='week'">, DATEDIFF (week, create_time, GETDATE()) days </if>
<if test="planLoopType=='month'">, DATEDIFF (month, create_time, GETDATE()) days </if>
<if test="planLoopType=='season'">, DATEDIFF (month, create_time, GETDATE())/3 days </if>
<if test="planLoopType=='year'">, DATEDIFF (year, create_time, GETDATE()) days </if>
from equ_order
where plan_type = #{planType} and plan_code = #{planCode} and equipment_code = #{equipmentCode}
order by create_time desc

@ -177,7 +177,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="spareInventoryFloor != null and spareInventoryFloor != ''"> and womsn.spare_inventory_floor = #{spareInventoryFloor}</if>
<if test="spareInventoryUpper != null and spareInventoryUpper != ''"> and womsn.spare_inventory_upper = #{spareInventoryUpper}</if>
<if test="spareType != null and spareType != ''"> and womsn.spare_type = #{spareType}</if>
<if test="ownEquipmentName != null and ownEquipmentName != ''"> and womsna.own_equipment_name like concat('%', #{ownEquipmentName}, '%')</if>
and womsn.del_flag = '0'
</where>

@ -411,6 +411,11 @@ public class MesReportWorkController extends BaseController {
return rlist;
}
/**获取报工打印信息**/
@PutMapping("/getPutInOrderList")
public AjaxResult getPutInOrderList(@RequestBody MesReportWork mesReportWorks) {
return success(mesReportWorkService.getPutInOrderList(mesReportWorks));
}
public static void main(String args[]){
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00");

@ -221,6 +221,35 @@ public class MesReportWork extends BaseEntity {
private String workCenter;
private String shiftId;
private String keywords;
private String workshopName;
//凭证
private String voucher;
//版本
private String version;
public String getVoucher() {
return voucher;
}
public void setVoucher(String voucher) {
this.voucher = voucher;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getWorkshopName() {
return workshopName;
}
public void setWorkshopName(String workshopName) {
this.workshopName = workshopName;
}
public String getKeywords() {
return keywords;

@ -129,4 +129,6 @@ public interface MesReportWorkMapper {
List<MesReportWork> selectMesReportWorkList_S(MesReportWork mesReportWork);
int reportSapCancel(MesReportWork mesReportWork);
List<MesReportWork> getPutInOrderList(MesReportWork mesReportWorks);
}

@ -103,4 +103,6 @@ public interface IMesReportWorkService {
List<MesReportWork> selectMesReportWorkList_S(MesReportWork mesReportWork);
int reportSapCancel(MesReportWork mesReportWork);
List<MesReportWork> getPutInOrderList(MesReportWork mesReportWorks);
}

@ -184,6 +184,12 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
return m;
}
@Override
@DS("#header.poolName")
public List<MesReportWork> getPutInOrderList(MesReportWork mesReportWorks) {
return mesReportWorkMapper.getPutInOrderList(mesReportWorks);
}
/**
*
*
@ -458,8 +464,6 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
return dtos;
}
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
Date now = calendar.getTime();

@ -640,8 +640,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY
mrw.create_time DESC
</select>
<select id="getPutInOrderList" resultType="com.op.mes.domain.MesReportWork">
select mrw.workorder_code workorderCode,
pow.workorder_code_sap workorderCodeSap,
pow.product_code productCode,
pow.product_name productName,
mrw.batch,
mrw.quantity quantity,
mrw.quantity_feedback quantityFeedback,
mrw.unit,
pow.factory_code factoryCode,
equ.workshop_name workshopName,
pow.attr2 version
from mes_report_work mrw
left join pro_order_workorder pow on mrw.workorder_code = pow.workorder_code
left join base_equipment equ on equ.equipment_code = mrw.machine_code
left join pro_order po on po.order_code = pow.order_code
where mrw.parent_order = '0'
and mrw.workorder_code = #{workorderCode}
and mrw.del_flag = '0' and po.del_flag = '0'
</select>
<insert id="insertMesReportWork" parameterType="MesReportWork">
<insert id="insertMesReportWork" parameterType="MesReportWork">
insert into mes_report_work
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>

@ -101,7 +101,7 @@ public class ProOrder extends TreeEntity {
/** $column.columnComment */
private String atrr1;
/** $column.columnComment */
/** 订单版本*/
private String atrr2;
/** $column.columnComment */

@ -240,10 +240,10 @@ public class QuaController extends BaseController {
}
/**不良类型**/
@PutMapping("/getDefectListPDA")
@PostMapping("/getDefectListPDA")
public List<QcDefectType> getDefectListPDA(@RequestBody QcDefectType qcDefectType) {
DynamicDataSourceContextHolder.push(qcDefectType.getFactoryCode());
return qcCheckTaskIncomeService.getDefectList(qcDefectType);
return qcCheckTaskIncomeService.getDefectListPDA(qcDefectType);
}
/**获取生产工单列表**/

@ -73,6 +73,15 @@ public class QcDefectType extends BaseEntity {
// 创建日期结束
private String createTimeEnd;
private String checkType;
public String getCheckType() {
return checkType;
}
public void setCheckType(String checkType) {
this.checkType = checkType;
}
public List<Date> getCreateTimeArray() {
return createTimeArray;

@ -89,4 +89,6 @@ public interface QcCheckUnqualifiedMapper {
int repeatCheckTaskDefect(QcCheckTaskIncome recheck);
int repeatCheckTaskDetail(QcCheckTaskIncome recheck);
int repeatCheckTaskUser(QcCheckTaskIncome recheck);
List<QcDefectType> getDefectListPDA(QcDefectType qcDefectType);
}

@ -89,4 +89,6 @@ public interface IQcCheckTaskIncomeService {
List<QcCheckTaskIncome> getProductWorkOrder(QcCheckTaskIncome qcCheckTaskIncome);
List<QcCheckTaskIncome> getCkeckProjectXJList(QcCheckTaskIncome qcCheckTaskIncome);
List<QcDefectType> getDefectListPDA(QcDefectType qcDefectType);
}

@ -170,6 +170,15 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
return 0;//没有找到检测项目
}
/**qc_sample_rule**/
QcCheckTaskIncome sampQua = new QcCheckTaskIncome();
sampQua.setCheckType(qcCheckTaskIncome.getCheckType());
sampQua.setQuality(qcCheckTaskIncome.getQuality());
String sampNum = qcSampleRuleMapper.getSampNum(sampQua);
if(StringUtils.isNotBlank(sampNum)){
qcCheckTaskIncome.setSampleQuality(new BigDecimal(sampNum));
}
/**qc_check_task**/
String beLongId = IdUtils.fastSimpleUUID();
qcCheckTaskIncome.setRecordId(beLongId);
@ -238,11 +247,6 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
}
}
qcCheckTaskIncome.setNoOkQuality(noOkQuality);
/**qc_sample_rule**/
String sampNum = qcSampleRuleMapper.getSampNum(qcCheckTaskIncome);
if(StringUtils.isNotBlank(sampNum)){
qcCheckTaskIncome.setSampleQuality(new BigDecimal(sampNum));
}
/**qc_check_task**/
qcCheckTaskIncomeMapper.insertQcCheckTaskIncome(qcCheckTaskIncome);
@ -478,6 +482,12 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
return qcCheckUnqualifiedMapper.getDefectList(qcDefectType);
}
@Override
@DS("#header.poolName")
public List<QcDefectType> getDefectListPDA(QcDefectType qcDefectType) {
return qcCheckUnqualifiedMapper.getDefectListPDA(qcDefectType);
}
@Override
@DS("#header.poolName")
public List<QcCheckTaskIncome> getLLWorkOrder(QcCheckTaskIncome qcCheckTaskIncome) {

@ -79,6 +79,9 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
@Autowired
private IQcCheckTaskDefectService qcCheckTaskDefectService;
@Autowired
private QcSampleRuleMapper qcSampleRuleMapper;
/**
*
*
@ -226,6 +229,16 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
}
}
qcCheckTaskProduce.setNoOkQuality(noOkQuality);
/**qc_sample_rule**/
QcCheckTaskIncome sampQua = new QcCheckTaskIncome();
sampQua.setCheckType(qcCheckTaskProduce.getCheckType());
sampQua.setQuality(qcCheckTaskProduce.getQuality());
String sampNum = qcSampleRuleMapper.getSampNum(sampQua);
if(StringUtils.isNotBlank(sampNum)){
qcCheckTaskProduce.setSampleQuality(new BigDecimal(sampNum));
}
/**qc_check_task**/
qcCheckTaskProduceMapper.insertQcCheckTaskProduce(qcCheckTaskProduce);

@ -56,6 +56,8 @@ public class QcCheckTaskWarehousingServiceImpl implements IQcCheckTaskWarehousin
private QcCheckTaskIncomeMapper qcCheckTaskIncomeMapper;
@Autowired
private IQcCheckTaskDefectService qcCheckTaskDefectService;
@Autowired
private QcSampleRuleMapper qcSampleRuleMapper;
/**
*
@ -208,7 +210,14 @@ public class QcCheckTaskWarehousingServiceImpl implements IQcCheckTaskWarehousin
}
}
qcCheckTaskWarehousing.setNoOkQuality(noOkQuality);
/**qc_sample_rule**/
QcCheckTaskIncome sampQua = new QcCheckTaskIncome();
sampQua.setCheckType(qcCheckTaskWarehousing.getCheckType());
sampQua.setQuality(qcCheckTaskWarehousing.getQuality());
String sampNum = qcSampleRuleMapper.getSampNum(sampQua);
if(StringUtils.isNotBlank(sampNum)){
qcCheckTaskWarehousing.setSampleQuality(new BigDecimal(sampNum));
}
/**qc_check_task**/
int n = qcCheckTaskWarehousingMapper.insertQcCheckTaskWarehousing(qcCheckTaskWarehousing);
logger.info("qc_check_task:"+n+"成功");

@ -138,6 +138,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="orderNo != null">and wpp.work_order like concat like ('%',#{orderNo})</if>
order by wpp.create_time desc
</select>
<select id="getDefectListPDA" resultType="com.op.quality.domain.QcDefectType">
select qdt.defect_code defectCode,
qdt.defect_subclass defectSubclass
from qc_defect_type qdt
left join qc_check_type qct on qdt.defect_type = qct.type_code
where qct.order_code = #{checkType} and qdt.del_flag='0'
order by qdt.create_time
</select>
<insert id="insertQcCheckUnqualified" parameterType="QcCheckUnqualified">
insert into qc_check_unqualified

@ -34,7 +34,7 @@ import java.util.Map;
@Service
public class SapOrderServiceImpl implements SapOrderService {
private static final Logger log = LoggerFactory.getLogger(SapOrderServiceImpl.class);
private static final String END_DATE = "99991231";
private static final String END_DATE="99991231";
@Autowired
private JCoDestination dest;
@ -46,29 +46,29 @@ public class SapOrderServiceImpl implements SapOrderService {
// 获取调用 RFC 函数对象
//获取连接
//JCoDestination dest = SAPConnUtils.connect();
log.info("订单同步入参-----" + sapShopOrderQuery.toString());
log.info("订单同步入参-----"+sapShopOrderQuery.toString());
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRO_TO");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
JCoParameterList jCoParameterList = func.getTableParameterList();
JCoParameterList js = func.getExportParameterList();
JCoParameterList jCoParameterList= func.getTableParameterList();
JCoParameterList js= func.getExportParameterList();
// System.out.println(js);
// System.out.println(jCoParameterList);
// 配置传入参数
// S_WERKS(工厂) S_AUFNR订单号 S_MATNR物料号 S_ERDAT(创建日期) 例如20230923
if (!StringUtils.isNull(sapShopOrderQuery.getWerk())) {
if (!StringUtils.isNull(sapShopOrderQuery.getWerk())){
JCoTable S_WERKS = func.getTableParameterList().getTable("S_PWERK");
S_WERKS.appendRow();
S_WERKS.setValue(Constants.SIGN, "I");
S_WERKS.setValue(Constants.OPTION, "EQ");
S_WERKS.setValue(Constants.LOW, sapShopOrderQuery.getWerk());
}
if (!StringUtils.isNull(sapShopOrderQuery.getAufnr())) {
if (!StringUtils.isNull(sapShopOrderQuery.getAufnr())){
JCoTable S_AUFNR = func.getTableParameterList().getTable("S_AUFNR");
S_AUFNR.appendRow();
S_AUFNR.setValue(Constants.SIGN, "I");
@ -76,14 +76,14 @@ public class SapOrderServiceImpl implements SapOrderService {
S_AUFNR.setValue(Constants.LOW, sapShopOrderQuery.getAufnr());
}
if (!StringUtils.isNull(sapShopOrderQuery.getMatnr())) {
if (!StringUtils.isNull(sapShopOrderQuery.getMatnr())){
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow();
S_MATNR.setValue(Constants.SIGN, "I");
S_MATNR.setValue(Constants.OPTION, "EQ");
S_MATNR.setValue(Constants.LOW, sapShopOrderQuery.getMatnr());
S_MATNR.setValue(Constants.LOW,sapShopOrderQuery.getMatnr());
}
if (!StringUtils.isNull(sapShopOrderQuery.getErdat())) {
if (!StringUtils.isNull(sapShopOrderQuery.getErdat())){
JCoTable S_ERDAT = func.getTableParameterList().getTable("S_ERDAT");
S_ERDAT.appendRow();
S_ERDAT.setValue(Constants.SIGN, "I");
@ -93,11 +93,14 @@ public class SapOrderServiceImpl implements SapOrderService {
}
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("ZMES_PRO");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
// System.out.println("###" + metaData.toString());
// System.out.println("###" + metaData.toString());
List<SapProOrder> proOrderList = new ArrayList<>();
// 循环输出 Table 数据
@ -118,8 +121,7 @@ public class SapOrderServiceImpl implements SapOrderService {
String ERDAT = maraTable.getString("ERDAT");
String STTXT = maraTable.getString("STTXT");
String VERID = maraTable.getString("VERID");
log.info("订单输出------" + "订单号:" + AUFNR + " - 订单类型:" + AUART + " - 生产版本:" + VERID + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
log.info("订单输出------"+"订单号:" + AUFNR + " - 订单类型:" + AUART + "-生产版本:"+ VERID +" -上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
+ " - 订单的计划工厂:" + PWERK + " - 订单数量总计:" + GAMNG + " - 基本计量单位:" + GMEIN + " - 任务清单组码:" + PLNNR + " - 基本开始日期:" + GSTRP
+ " - 基本完成日期:" + GLTRP + " - 输入者:" + ERNAM + " - 创建日期:" + ERDAT + " - 系统状态:" + STTXT);
// System.out.println("订单号:" + AUFNR + " - 订单类型:" + AUART + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
@ -160,11 +162,11 @@ public class SapOrderServiceImpl implements SapOrderService {
@Override
public R<List<Map<String, String>>> SapCreateOrder(List<SapCreateOrder> sapCreateOrderList) {
String L_MSG = null;
String L_MSG=null;
try {
//获取连接
// JCoDestination dest = SAPConnUtils.connect();
log.info("订单创建入参-----" + JSONObject.toJSONString(sapCreateOrderList));
// JCoDestination dest = SAPConnUtils.connect();
log.info("订单创建入参-----"+JSONObject.toJSONString(sapCreateOrderList));
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CREATE");
if (func == null) {
@ -174,39 +176,38 @@ public class SapOrderServiceImpl implements SapOrderService {
// 配置传入参数
JCoParameterList jCoParameterList = func.getImportParameterList();
if (sapCreateOrderList != null && sapCreateOrderList.size() > 0) {
List<Map<String, String>> LV_ORDER_NUM_List = new ArrayList<>();
for (SapCreateOrder sapCreateOrder : sapCreateOrderList) {
jCoParameterList.setValue("P_WERKS", sapCreateOrder.getWerks());
jCoParameterList.setValue("P_AUFPAR", sapCreateOrder.getAufpar());
jCoParameterList.setValue("P_MATNR", sapCreateOrder.getMatnr());
jCoParameterList.setValue("P_QUANTITY", sapCreateOrder.getQuantity());
jCoParameterList.setValue("P_DATES", sapCreateOrder.getDates());
jCoParameterList.setValue("P_DATEE", sapCreateOrder.getDatee());
jCoParameterList.setValue("P_VERID", sapCreateOrder.getVerid());
if (sapCreateOrderList!=null && sapCreateOrderList.size()>0){
List<Map<String,String>> LV_ORDER_NUM_List=new ArrayList<>();
for (SapCreateOrder sapCreateOrder:sapCreateOrderList){
jCoParameterList.setValue("P_WERKS",sapCreateOrder.getWerks());
jCoParameterList.setValue("P_AUFPAR",sapCreateOrder.getAufpar());
jCoParameterList.setValue("P_MATNR",sapCreateOrder.getMatnr());
jCoParameterList.setValue("P_QUANTITY",sapCreateOrder.getQuantity());
jCoParameterList.setValue("P_DATES",sapCreateOrder.getDates());
jCoParameterList.setValue("P_DATEE",sapCreateOrder.getDatee());
func.execute(dest);//执行调用函数
JCoParameterList J = func.getExportParameterList();
JCoParameterList J= func.getExportParameterList();
System.out.println(func.getExportParameterList());
L_MSG = func.getExportParameterList().getString("L_MSG");
JCoTable LT_ZGD = func.getTableParameterList().getTable("LT_ZGD");
for (int i = 0; i < LT_ZGD.getNumRows(); i++) {
L_MSG= func.getExportParameterList().getString("L_MSG");
JCoTable LT_ZGD=func.getTableParameterList().getTable("LT_ZGD");
for (int i = 0; i <LT_ZGD.getNumRows(); i++) {
LT_ZGD.setRow(i);
Map map = new HashMap();
Map map=new HashMap();
String LEAD_AUFNR = LT_ZGD.getString("LEAD_AUFNR");
String AUFNR = LT_ZGD.getString("AUFNR");
map.put("LEAD_AUFNR", LEAD_AUFNR);
map.put("AUFNR", AUFNR);
map.put("LEAD_AUFNR",LEAD_AUFNR);
map.put("AUFNR",AUFNR);
LV_ORDER_NUM_List.add(map);
}
}
log.info("订单创建结果----" + L_MSG + "|" + JSONObject.toJSONString(LV_ORDER_NUM_List));
return R.ok(LV_ORDER_NUM_List, L_MSG);
} else {
log.info("订单创建结果----"+L_MSG+"|"+JSONObject.toJSONString(LV_ORDER_NUM_List));
return R.ok(LV_ORDER_NUM_List,L_MSG);
}else {
log.error("接收的数据为空");
return R.fail("接收的数据为空");
}
} catch (Exception e) {
log.error(L_MSG + e.getMessage());
}catch (Exception e){
log.error(L_MSG+e.getMessage());
return R.fail(L_MSG);
}
@ -214,11 +215,12 @@ public class SapOrderServiceImpl implements SapOrderService {
@Override
public R sapCloseOrder(SapCloseOrderQuery sapCloseOrderQuery) {
StringBuilder Msg = new StringBuilder();
try {
//获取连接
// JCoDestination dest = SAPConnUtils.connect();
log.info("订单关闭入参------" + sapCloseOrderQuery.toString());
// JCoDestination dest = SAPConnUtils.connect();
log.info("订单关闭入参------"+sapCloseOrderQuery.toString());
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CLOSE");
if (func == null) {
@ -227,40 +229,41 @@ public class SapOrderServiceImpl implements SapOrderService {
// 配置传入参数
JCoParameterList jCoParameterList = func.getImportParameterList();
if (StringUtils.isEmpty(sapCloseOrderQuery.getLeadOrder())) {
if (StringUtils.isEmpty(sapCloseOrderQuery.getLeadOrder())){
return R.fail("母订单号为空");
}
if (StringUtils.isEmpty(sapCloseOrderQuery.getOrder())) {
if (StringUtils.isEmpty(sapCloseOrderQuery.getOrder())){
return R.fail("子订单号为空");
}
//关闭母订单
jCoParameterList.setValue("P_AUFNR", sapCloseOrderQuery.getLeadOrder());
func.execute(dest);//执行调用函数
jCoParameterList.setValue("P_AUFNR",sapCloseOrderQuery.getLeadOrder());
func.execute(dest);//执行调用函数
// JCoParameterList J= func.getExportParameterList();
// System.out.println(J);
String L_MSG1 = func.getExportParameterList().getString("L_MSG");
Msg.append(sapCloseOrderQuery.getLeadOrder() + L_MSG1 + ";");
//关闭子订单
jCoParameterList.setValue("P_AUFNR", sapCloseOrderQuery.getOrder());
String L_MSG1= func.getExportParameterList().getString("L_MSG");
Msg.append(sapCloseOrderQuery.getLeadOrder()+L_MSG1+";");
//关闭子订单
jCoParameterList.setValue("P_AUFNR",sapCloseOrderQuery.getOrder());
func.execute(dest);//执行调用函数
String L_MSG2 = func.getExportParameterList().getString("L_MSG");
Msg.append(sapCloseOrderQuery.getOrder() + L_MSG2);
log.info("订单关闭结果" + Msg.toString());
return R.ok(null, Msg.toString());
} catch (Exception e) {
log.error("订单关闭失败" + e.getMessage());
String L_MSG2= func.getExportParameterList().getString("L_MSG");
Msg.append(sapCloseOrderQuery.getOrder()+L_MSG2);
log.info("订单关闭结果"+Msg.toString());
return R.ok(null,Msg.toString());
}catch (Exception e){
log.error("订单关闭失败"+e.getMessage());
return R.fail(e.getMessage());
}
}
@Override
public R sapRFWOrder(SapRFW sapRFW) {
String json = JSONObject.toJSONString(sapRFW);
String json= JSONObject.toJSONString(sapRFW);
System.out.println(json);
String MESSAGE = null;
String MESSAGE=null;
try {
//获取连接
// JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORDCONF_CREATE_TT");
if (func == null) {
@ -269,26 +272,27 @@ public class SapOrderServiceImpl implements SapOrderService {
// 配置传入参数
JCoParameterList jCoParameterList = func.getImportParameterList();
if (StringUtils.isEmpty(sapRFW.getAufnr())) {
if (StringUtils.isEmpty(sapRFW.getAufnr())){
return R.fail("订单号为空");
}
if (StringUtils.isEmpty(sapRFW.getGamng())) {
if (StringUtils.isEmpty(sapRFW.getGamng())){
return R.fail("报工数量为空");
}
//订单号
jCoParameterList.setValue("P_AUFNR", sapRFW.getAufnr());
jCoParameterList.setValue("P_AUFNR",sapRFW.getAufnr());
//报工数量
jCoParameterList.setValue("P_GAMNG", sapRFW.getGamng());
if (sapRFW.getLt_gs() == null) {
jCoParameterList.setValue("P_GAMNG",sapRFW.getGamng());
if (sapRFW.getLt_gs()==null){
return R.fail("生产订单报工工时为空");
}
if (sapRFW.getLt_hwList() == null) {
if (sapRFW.getLt_hwList()==null){
return R.fail("生产订单报工货物移动为空");
}
/**
* LT_GS
*/
JCoTable LT_GS_jCoTable = func.getTableParameterList().getTable("LT_GS");
// System.out.println("LT_GS_jCoTable"+LT_GS_jCoTable);
LT_GS_jCoTable.appendRow();
LT_GS_jCoTable.setValue("CONF_ACTIVITY1", sapRFW.getLt_gs().getConf_activity1());
LT_GS_jCoTable.setValue("CONF_ACTIVITY2", sapRFW.getLt_gs().getConf_activity2());
@ -300,21 +304,25 @@ public class SapOrderServiceImpl implements SapOrderService {
* MES LT_HW
*/
JCoTable LT_HW_jCoTable = func.getTableParameterList().getTable("LT_HW");
for (SapRFW.lt_hw lt_hw : sapRFW.getLt_hwList()) {
//System.out.println("LT_HW_jCoTable"+LT_HW_jCoTable);
for (SapRFW.lt_hw lt_hw:sapRFW.getLt_hwList()){
LT_HW_jCoTable.appendRow();
LT_HW_jCoTable.setValue("MATERIAL", lt_hw.getMaterial());
LT_HW_jCoTable.setValue("ENTRY_QNT", lt_hw.getEntry_qnt());
}
func.execute(dest);//执行调用函数
String RETCODE = func.getExportParameterList().getString("RETCODE");
MESSAGE = func.getExportParameterList().getString("MESSAGE");
if (Constants.RFW_FAIL.equals(RETCODE)) {
log.error("订单号:" + sapRFW.getAufnr() + "报工失败" + MESSAGE);
return R.fail("订单号:" + sapRFW.getAufnr() + "报工失败" + MESSAGE);
}
log.error("订单号:" + sapRFW.getAufnr() + "报工成功" + MESSAGE);
return R.ok("", MESSAGE);
} catch (Exception e) {
JCoParameterList J= func.getExportParameterList();
System.out.println(func.getExportParameterList());
String RETCODE= func.getExportParameterList().getString("RETCODE");
MESSAGE= func.getExportParameterList().getString("MESSAGE");
if (Constants.FAIL.equals(RETCODE)){
return R.fail("订单号:"+sapRFW.getAufnr()+"报工失败"+MESSAGE);
}
return R.ok("",MESSAGE);
}catch (Exception e){
return R.fail(e.getMessage());
}
}
@ -327,7 +335,7 @@ public class SapOrderServiceImpl implements SapOrderService {
//JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_PROCURE");
JCoParameterList jCoParameterList = func.getTableParameterList();
JCoParameterList jCoParameterList= func.getTableParameterList();
System.out.println(jCoParameterList);
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
@ -337,21 +345,21 @@ public class SapOrderServiceImpl implements SapOrderService {
* S_MATNR
* S_PWERK
*/
if (!StringUtils.isNull(sapPurchaseOrderQuery.getEbeln())) {
if (!StringUtils.isNull(sapPurchaseOrderQuery.getEbeln())){
JCoTable S_EBELN = func.getTableParameterList().getTable("S_EBELN");
S_EBELN.appendRow();
S_EBELN.setValue(Constants.SIGN, "I");
S_EBELN.setValue(Constants.OPTION, "EQ");
S_EBELN.setValue(Constants.LOW, sapPurchaseOrderQuery.getEbeln());
}
if (!StringUtils.isNull(sapPurchaseOrderQuery.getEbelp())) {
if (!StringUtils.isNull(sapPurchaseOrderQuery.getEbelp())){
JCoTable S_EBELP = func.getTableParameterList().getTable("S_EBELP");
S_EBELP.appendRow();
S_EBELP.setValue(Constants.SIGN, "I");
S_EBELP.setValue(Constants.OPTION, "EQ");
S_EBELP.setValue(Constants.LOW, sapPurchaseOrderQuery.getEbelp());
}
if (!StringUtils.isNull(sapPurchaseOrderQuery.getMatnr())) {
if (!StringUtils.isNull(sapPurchaseOrderQuery.getMatnr())){
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow();
S_MATNR.setValue(Constants.SIGN, "I");
@ -359,7 +367,7 @@ public class SapOrderServiceImpl implements SapOrderService {
S_MATNR.setValue(Constants.LOW, sapPurchaseOrderQuery.getMatnr());
}
if (!StringUtils.isNull(sapPurchaseOrderQuery.getPwerk())) {
if (!StringUtils.isNull(sapPurchaseOrderQuery.getPwerk())){
JCoTable S_PWERK = func.getTableParameterList().getTable("S_PWERK");
S_PWERK.appendRow();
S_PWERK.setValue(Constants.SIGN, "I");
@ -371,10 +379,10 @@ public class SapOrderServiceImpl implements SapOrderService {
JCoTable maraTable = func.getTableParameterList().getTable("LT_PROCURE");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
List<SapPurchaseOrderQuery> sapPurchaseOrderQueryList = new ArrayList<>();
List<SapPurchaseOrderQuery> sapPurchaseOrderQueryList=new ArrayList<>();
for (int i = 0; i < maraTable.getNumRows(); i++) {
maraTable.setRow(i);
SapPurchaseOrderQuery sapPCorder = new SapPurchaseOrderQuery();
SapPurchaseOrderQuery sapPCorder=new SapPurchaseOrderQuery();
String EBELN = maraTable.getString("EBELN");
String EBELP = maraTable.getString("EBELP");
String MATNR = maraTable.getString("MATNR");
@ -390,20 +398,20 @@ public class SapOrderServiceImpl implements SapOrderService {
String ELIKZ = maraTable.getString("ELIKZ");
String BEIZHU = maraTable.getString("BEIZHU");
System.out.println(
"采购凭证号" + EBELN +
"采购凭证的项目编号" + EBELP +
"物料号" + MATNR +
"物料描述(短文本)" + MAKTX +
"采购订单数量" + MENGE +
"采购订单的计量单位" + MEINS +
"交货数量" + ZMENGE +
"基本计量单位" + ZMEINS +
"供应商帐户号" + LIFNR +
"工厂" + WERKS +
"库存地点" + LGORT +
"项目交货日期" + EINDT +
"交货已完成标识" + ELIKZ +
"注释" + BEIZHU);
"采购凭证号"+EBELN+
"采购凭证的项目编号"+EBELP+
"物料号"+MATNR+
"物料描述(短文本)"+MAKTX+
"采购订单数量"+MENGE+
"采购订单的计量单位"+MEINS+
"交货数量"+ZMENGE+
"基本计量单位"+ZMEINS+
"供应商帐户号"+LIFNR+
"工厂"+WERKS+
"库存地点"+LGORT+
"项目交货日期"+EINDT+
"交货已完成标识"+ELIKZ+
"注释"+BEIZHU);
sapPCorder.setEbeln(EBELN);
sapPCorder.setEbelp(EBELP);
@ -422,15 +430,16 @@ public class SapOrderServiceImpl implements SapOrderService {
sapPurchaseOrderQueryList.add(sapPCorder);
}
return R.ok(sapPurchaseOrderQueryList);
} catch (Exception e) {
}catch (Exception e){
return R.fail(e.getMessage());
}
}
@Override
public R shopUpdateSync(SapShopOrderQuery sapProOrder) {
try {
log.info("订单修改入参-------" + sapProOrder.toString());
log.info("订单修改入参-------"+sapProOrder.toString());
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CHANGE");
// 配置传入参数
@ -439,27 +448,29 @@ public class SapOrderServiceImpl implements SapOrderService {
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
if (StringUtils.isEmpty(sapProOrder.getAufnr())) {
if (StringUtils.isEmpty(sapProOrder.getAufnr()))
{
return R.fail("订单号为空!");
}
if (StringUtils.isEmpty(sapProOrder.getQuantity())) {
if (StringUtils.isEmpty(sapProOrder.getQuantity()))
{
return R.fail("数量为空!");
}
jCoParameterList.setValue("P_AUFNR", sapProOrder.getAufnr());
jCoParameterList.setValue("P_QUANTITY", sapProOrder.getQuantity());
jCoParameterList.setValue("P_AUFNR",sapProOrder.getAufnr());
jCoParameterList.setValue("P_QUANTITY",sapProOrder.getQuantity());
func.execute(dest);//执行调用函数
JCoParameterList J = func.getExportParameterList();
String RETCODE = func.getExportParameterList().getString("RETCODE");
String MESSAGE = func.getExportParameterList().getString("MESSAGE");
if ((Constants.FAIL).equals(Integer.parseInt(RETCODE))) {
log.error("订单修改结果-----" + MESSAGE);
return R.fail(null, "订单号:" + sapProOrder.getAufnr() + MESSAGE);
} else {
log.info("订单修改结果-----" + MESSAGE);
return R.ok(null, "订单号:" + sapProOrder.getAufnr() + MESSAGE);
}
} catch (Exception e) {
JCoParameterList J= func.getExportParameterList();
String RETCODE= func.getExportParameterList().getString("RETCODE");
String MESSAGE= func.getExportParameterList().getString("MESSAGE");
if ((Constants.FAIL).equals(Integer.parseInt(RETCODE))){
log.error("订单修改结果-----"+MESSAGE);
return R.fail(null,"订单号:"+sapProOrder.getAufnr()+MESSAGE);
}else {
log.info("订单修改结果-----"+MESSAGE);
return R.ok(null,"订单号:"+sapProOrder.getAufnr()+MESSAGE);
}
}catch (Exception e){
log.error(e.getMessage());
return R.fail(e.getMessage());
}
@ -468,7 +479,7 @@ public class SapOrderServiceImpl implements SapOrderService {
@Override
public R sapOrderReceipt(List<Map<String, Object>> mapList) {
try {
log.info("智慧工厂101类型订单收货入参-------" + mapList.toString());
log.info("智慧工厂101类型订单收货入参-------"+mapList.toString());
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_101_MIGO");
//System.out.println(jCoParameterList);
@ -478,30 +489,30 @@ public class SapOrderServiceImpl implements SapOrderService {
// 配置传入参数
JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
for (Map<String, Object> stringObjectMap : mapList) {
for (Map<String, Object> stringObjectMap:mapList){
L_ITEM.appendRow();
L_ITEM.setValue("AUFNR", stringObjectMap.get("AUFNR"));
L_ITEM.setValue("WERKS", stringObjectMap.get("WERKS"));
L_ITEM.setValue("LGORT", stringObjectMap.get("LGORT"));
L_ITEM.setValue("QUANTITY", stringObjectMap.get("QUANTITY"));
L_ITEM.setValue("BATCH", stringObjectMap.get("BATCH"));
L_ITEM.setValue("HSDAT", stringObjectMap.get("HSDAT"));
L_ITEM.setValue("ERFME", stringObjectMap.get("ERFME"));
L_ITEM.setValue("AUFNR",stringObjectMap.get("AUFNR"));
L_ITEM.setValue("WERKS",stringObjectMap.get("WERKS"));
L_ITEM.setValue("LGORT",stringObjectMap.get("LGORT"));
L_ITEM.setValue("QUANTITY",stringObjectMap.get("QUANTITY"));
L_ITEM.setValue("BATCH",stringObjectMap.get("BATCH"));
L_ITEM.setValue("HSDAT",stringObjectMap.get("HSDAT"));
L_ITEM.setValue("ERFME",stringObjectMap.get("ERFME"));
}
func.execute(dest);//执行调用函数
System.out.println(func.getExportParameterList());
String RETCODE = func.getExportParameterList().getString("RETCODE");
String MESSAGE = func.getExportParameterList().getString("L_MSG");
String MATERIALDOCUMENT = func.getExportParameterList().getString("MATERIALDOCUMENT");
if ((Constants.FAIL).equals(Integer.parseInt(RETCODE))) {
log.error("订单收货结果-----" + MESSAGE);
String RETCODE= func.getExportParameterList().getString("RETCODE");
String MESSAGE= func.getExportParameterList().getString("L_MSG");
String MATERIALDOCUMENT= func.getExportParameterList().getString("MATERIALDOCUMENT");
if ((Constants.FAIL).equals(Integer.parseInt(RETCODE))){
log.error("订单收货结果-----"+MESSAGE);
return R.fail(MESSAGE);
} else {
log.info("订单收货结果-----" + MESSAGE);
return R.ok(MATERIALDOCUMENT, MESSAGE);
}else {
log.info("订单收货结果-----"+MESSAGE);
return R.ok(MATERIALDOCUMENT,MESSAGE);
}
} catch (Exception e) {
}catch (Exception e){
log.error(e.getMessage());
return R.fail(e.getMessage());
}
@ -515,7 +526,7 @@ public class SapOrderServiceImpl implements SapOrderService {
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
log.info("采购订单收货过账ZMES_PROMIGO_CREATE-------" + mapList.toString());
log.info("采购订单收货过账ZMES_PROMIGO_CREATE-------"+mapList.toString());
/**
EBELN
EBELP
@ -531,7 +542,7 @@ public class SapOrderServiceImpl implements SapOrderService {
*/
JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
for (Map<String, Object> stringObjectMap : mapList) {
for (Map<String, Object> stringObjectMap:mapList){
L_ITEM.appendRow();
L_ITEM.setValue("EBELN", stringObjectMap.get("EBELN"));
L_ITEM.setValue("EBELP", stringObjectMap.get("EBELP"));
@ -555,28 +566,28 @@ public class SapOrderServiceImpl implements SapOrderService {
for (int i = 0; i < LT_RETURN.getNumRows(); i++) {
LT_RETURN.setRow(i);
String MESSAGE = LT_RETURN.getString("MESSAGE");
Msg.append(MESSAGE + "/");
Msg.append(MESSAGE+"/");
}
String L_MSG = func.getExportParameterList().getString("L_MSG");
String RETCODE = func.getExportParameterList().getString("RETCODE");
String MATERIALDOCUMENT = func.getExportParameterList().getString("MATERIALDOCUMENT");
String MATDOCUMENTYEAR = func.getExportParameterList().getString("MATDOCUMENTYEAR");
System.out.println("L_MSG" + L_MSG);
System.out.println("返回值0-没有错误1-有错误:" + RETCODE);
System.out.println("物料凭证编号" + MATERIALDOCUMENT);
System.out.println("物料凭证年度" + MATDOCUMENTYEAR);
if (!("0").equals(RETCODE)) {
return R.fail("", Msg.toString());
} else {
Map map = new HashMap();
map.put("MATERIALDOCUMENT", MATERIALDOCUMENT);
map.put("MATDOCUMENTYEAR", MATDOCUMENTYEAR);
return R.ok(map, Msg.toString());
String L_MSG= func.getExportParameterList().getString("L_MSG");
String RETCODE= func.getExportParameterList().getString("RETCODE");
String MATERIALDOCUMENT= func.getExportParameterList().getString("MATERIALDOCUMENT");
String MATDOCUMENTYEAR= func.getExportParameterList().getString("MATDOCUMENTYEAR");
System.out.println("L_MSG"+L_MSG);
System.out.println("返回值0-没有错误1-有错误:"+RETCODE);
System.out.println("物料凭证编号"+MATERIALDOCUMENT);
System.out.println("物料凭证年度"+MATDOCUMENTYEAR);
if (!("0").equals(RETCODE)){
return R.fail("",Msg.toString());
}else {
Map map=new HashMap();
map.put("MATERIALDOCUMENT",MATERIALDOCUMENT);
map.put("MATDOCUMENTYEAR",MATDOCUMENTYEAR);
return R.ok(map,Msg.toString());
}
} catch (Exception e) {
}catch (Exception e){
log.error(e.getMessage());
return R.fail(e.getMessage());
}

@ -171,7 +171,6 @@ public class ProProcessController extends BaseController {
*/
@GetMapping("/getWorkCenterList")
public TableDataInfo getWorkCenterList(SysFactory sysFactory) {
startPage();
List<SysFactory> list = proProcessService.getWorkCenterList(sysFactory);
return getDataTable(list);
}
@ -181,9 +180,8 @@ public class ProProcessController extends BaseController {
*/
@GetMapping("/getEquipmentTypeList")
public TableDataInfo getEquipmentTypeList(Equipment equipment) {
startPage();
public AjaxResult getEquipmentTypeList(Equipment equipment) {
List<Equipment> list = proProcessService.getEquipmentTypeList(equipment);
return getDataTable(list);
return success(list);
}
}

@ -324,6 +324,7 @@
from base_equipment
where del_flag = '0'
group by equipment_type_code,equipment_type_name
order by equipment_type_name desc
</select>
</mapper>

Loading…
Cancel
Save