Merge remote-tracking branch 'origin/master'

master
陈恒杰 1 year ago
commit 8e96bc5717

@ -85,10 +85,10 @@ public interface RemoteSapService {
public R sapProductWarehousing(@RequestBody(required = false) List<Map<String, Object>> mapList);
/**获取采购订单*/
@PostMapping("/sapPurchaseOrderSync")
@PostMapping("/sap/sapPurchaseOrderSync")
public R sapPurchaseOrderSync(@RequestBody SapPurchaseOrderQuery sapPurchaseOrderQuery);
/**采购订单收货过账*/
@PostMapping("/sapPOrderGoodsReceipt")
@PostMapping("/sap/sapPOrderGoodsReceipt")
public R sapPOrderGoodsReceipt(@RequestBody(required = false) List<Map<String, Object>> mapList);
}

@ -66,4 +66,7 @@ public interface DeviceInterfaceMapper {
* @return
*/
List<Map<String, Integer>> selectEquipmentFaultNumForMonth(String groupCode);
// 通过设备编码获取设备运行记录
Map<String, Double> selectSumEquipmentOperation(String equipmentCode);
}

@ -32,6 +32,8 @@ public class DeviceInterfaceServiceImpl implements IDeviceInterfaceService {
private DeviceInterfaceMapper deviceInterfaceMapper;
@Autowired
private EquOperationRecordMapper equOperationRecordMapper;
@Autowired
private EquOperationMapper equOperationMapper;
/**
*
@ -64,64 +66,6 @@ public class DeviceInterfaceServiceImpl implements IDeviceInterfaceService {
public AjaxResult getEquipmentInfo() {
// 获取所有设备信息
List<IEquipmentVO> equipmentVOList = deviceInterfaceMapper.selectEquipmentList();
for (IEquipmentVO equipmentVO : equipmentVOList) {
// 设备状态
if (equipmentVO.getEquipmentStatus().equals("1")) {
equipmentVO.setEquipmentStatus("正常");
} else {
equipmentVO.setEquipmentStatus("停用");
}
/* 停机故障率逻辑 */
double totalTime = 0;// 运行总时间
double downTime = 0;// 停机时间
// 通过设备编码获取运行记录中的运行记录List
List<EquOperationRecord> operationRecordList = equOperationRecordMapper.selectEquOperationRecordByEquipmentCode(equipmentVO.getEquipmentCode());
if (operationRecordList.size() != 0) {
for (EquOperationRecord operationRecord : operationRecordList) {
// 运行时间差值
double diffTime = operationRecord.getEndTime().getTime() - operationRecord.getStartTime().getTime();
// 开机运行时间运行总时间累加
if (operationRecord.getType().equals("on")) {
totalTime += diffTime;
}
// 维修停机时间累加(故障)
if (operationRecord.getMaintenanceType().equals("repair")) {
downTime += diffTime;
}
}
// 设置停机故障率
if (downTime == 0L) {
// 如果未查到该设备停机故障时间
equipmentVO.setFailureRate(0D);
} else {
// 计算故障停机率(设备停机时间总和/一定时间内运行总时间(年))
double failureRate = downTime / totalTime;
System.out.println(failureRate);
equipmentVO.setFailureRate(failureRate);
}
}
/* 设备有效利用率逻辑(每月) */
// 查询该设备下报工单信息(年月日可在该sql中修改)
MesReportWork reportWork = deviceInterfaceMapper.selectReportWorkByEquipmentCode(equipmentVO.getEquipmentCode());
if (reportWork != null) {
BigDecimal theoryQuantity = reportWork.getQuantity();// 理论产量
BigDecimal actualQuantity = reportWork.getQuantityFeedback();// 实际产量
// 计算该设备有效利用率(实际产量/理论产量)
BigDecimal utilizationRatio = actualQuantity.divide(theoryQuantity, 2, BigDecimal.ROUND_HALF_UP);
equipmentVO.setUtilizationRatio(utilizationRatio.doubleValue());
} else {
// 如果未查到该信息则默认设置为0
equipmentVO.setUtilizationRatio(0D);
}
}
return success(equipmentVOList);
}
@ -204,6 +148,7 @@ public class DeviceInterfaceServiceImpl implements IDeviceInterfaceService {
@DS("#header.poolName")
public AjaxResult getEquipmentIntactRate(EquOperation equOperation) {
//查询所有设备(设备停用的除外)
// CAST(SUM(CASE WHEN equipment_status = '1' or equipment_status = '3' THEN 1 Else 0 END)*100.00/COUNT(*) as decimal(18,2)) AS intactRate
EquOperation equipmentIntactRate = deviceInterfaceMapper.getEquipmentIntactRate(equOperation);
return success(equipmentIntactRate);
}

@ -366,7 +366,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
equ.setStatus("1");
equOrderMapper.updateEquipmentStatus(equ);
// 更新设备运行记录
updateOperationRecord(equOrder.getEquipmentCode(),"on","");
// updateOperationRecord(equOrder.getEquipmentCode(),"on","");
//上传附件
if (StringUtils.isNotEmpty(equOrder.getPicturePath())) {
String[] ids = equOrder.getPicturePath().split(",");
@ -501,20 +501,20 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
Equipment equ = new Equipment();
equ.setEquipmentCode(order.getEquipmentCode());
// 运行记录类型
String operationType;
// 停机保养
if (pdadto.getShutDown().equals("1")){
operationType = "off";
}else {
operationType = "on";
}
// String operationType;
// // 停机保养
// if (pdadto.getShutDown().equals("1")){
// operationType = "off";
// }else {
// operationType = "on";
// }
// 更改设备状态为保养中
equ.setStatus("3");
equOrderMapper.updateEquipmentStatus(equ);
// 更新设备运行记录
updateOperationRecord(order.getEquipmentCode(),operationType,"upkeep");
// updateOperationRecord(order.getEquipmentCode(),operationType,"upkeep");
// 设置开始时间
order.setOrderStart(DateUtils.getNowDate());

@ -476,7 +476,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
List<EquOperation> subList = operationList.subList(startIndex,endIndex);
int num = equOperationMapper.insertEquOperationByBatch(subList);
System.out.println("数据源:"+poolName+"--->"+"第"+i+"轮"+"开始索引:"+startIndex+"________结束索引:"+endIndex+"________成功插入数量:"+num);
System.out.println("数据源:"+poolName+"--->"+"第"+(i+1)+"轮"+"开始索引:"+startIndex+"________结束索引:"+endIndex+"________成功插入数量:"+num);
}
}else {
System.out.println("数据源:"+poolName+"当天生成过运行记录");

@ -21,13 +21,22 @@
</select>
<select id="selectEquipmentList" resultType="com.op.device.domain.vo.IEquipmentVO">
select be.equipment_code AS 'equipmentCode', be.equipment_name AS 'equipmentName',be.equipment_status AS 'equipmentStatus'
select be.equipment_code AS 'equipmentCode', be.equipment_name AS 'equipmentName',be.equipment_status AS 'equipmentStatus', (SELECT ROUND(
SUM(CAST(fault_time AS FLOAT)) /
SUM(CAST(actual_operation_time AS FLOAT)),
2)
FROM equ_operation
WHERE equipment_code = be.equipment_code) AS 'failureRate', (
SELECT ROUND(SUM(mrw.quantity_feedback) / SUM(mrw.quantity), 2)
FROM mes_report_work mrw
WHERE mrw.del_flag = '0'
AND mrw.status = 'PREPARE'
AND mrw.machine_code = be.equipment_code
AND mrw.feedback_time >= DATEADD(MONTH, -1, GETDATE())
) AS 'utilizationRatio'
from base_equipment be
where be.equipment_code in (select wo.equipment_code
from equ_repair_work_order wo
where wo.del_flag = '0'
and wo.work_status = '1'
GROUP BY wo.equipment_code)
where be.del_flag = '0'
and be.equipment_category = '0'
</select>
<select id="selectRepairEquipmentList" resultType="com.op.device.domain.vo.IEquipmentVO">
@ -78,10 +87,19 @@
<!--完好设备占比-->
<select id="getEquipmentIntactRate" parameterType="EquOperation" resultType="com.op.device.domain.EquOperation">
SELECT
SUM(CASE WHEN equipment_status = '1' or equipment_status = '3' THEN 1 Else 0 END) AS operationEquipment,
SUM(CASE WHEN equipment_status = '0' or equipment_status = '2' THEN 1 Else 0 END) AS faultEquipment,
COUNT(*) AS totalEquipment,
CAST(SUM(CASE WHEN equipment_status = '1' or equipment_status = '3' THEN 1 Else 0 END)*100.00/COUNT(*) as decimal(18,2)) AS intactRate
SUM(CASE WHEN equipment_status = '1' or equipment_status = '3' THEN 1 Else 0 END) AS operationEquipment,
SUM(CASE WHEN equipment_status = '0' or equipment_status = '2' THEN 1 Else 0 END) AS faultEquipment,
COUNT(*) AS totalEquipment,
(
SELECT COUNT(id)
FROM equ_operation
WHERE '4%' > failure_rate AND CONVERT(date, create_time) = CONVERT(date, GETDATE())
)*100 /
(
SELECT COUNT(id)
FROM equ_operation
WHERE CONVERT(date, create_time) = CONVERT(date, GETDATE())
) AS intactRate
FROM base_equipment
WHERE del_flag = '0' AND status = '1'
</select>
@ -105,4 +123,12 @@
ORDER BY MONTH (eo.create_time)
</select>
<select id="selectSumEquipmentOperation" resultType="java.util.Map">
SELECT
SUM(CAST(actual_operation_time AS FLOAT)) AS actualOperationTime,
SUM(CAST(fault_time AS FLOAT)) AS faultTime
FROM equ_operation
WHERE equipment_code = #{equipmentCode};
</select>
</mapper>

@ -89,6 +89,7 @@
<if test="createTimeStart != null "> and CONVERT(date,create_time) >= #{createTimeStart}</if>
<if test="createTimeEnd != null "> and #{createTimeEnd} >= CONVERT(date,create_time)</if>
</where>
order by CAST(create_time AS DATE) desc,group_line
</select>
<select id="selectEquOperationById" parameterType="String" resultMap="EquOperationResult">

@ -184,8 +184,15 @@ public WmsToWCSDTO packingMaterialsOutBoundCompleted(@RequestBody WmsToWCSDTO wc
Integer result= odsProcureOrderService.ProductionMaterialRequisitionAdd(orderList);
return success(result);
}
/**
*
* @param odsProcureOrder
* @return
*/
@PostMapping("/sapPurchaseOrderSync")
public AjaxResult sapPurchaseOrderSync(@RequestBody OdsProcureOrder odsProcureOrder){
AjaxResult result= odsProcureOrderService.sapPurchaseOrderSync(odsProcureOrder);
return result;
}

@ -8,10 +8,7 @@ import com.alibaba.fastjson.JSONObject;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import com.op.common.core.domain.R;
@ -22,6 +19,7 @@ import com.op.common.security.utils.SecurityUtils;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.sap.SapBackflushMPQuery;
import com.op.system.api.domain.sap.SapMaterialPosting;
import com.op.system.api.domain.sap.SapPurchaseOrderQuery;
import okhttp3.OkHttpClient;
import okhttp3.MediaType;
import okhttp3.RequestBody;
@ -30,6 +28,7 @@ import okhttp3.Response;
import java.io.IOException;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.utils.uuid.IdUtils;
@ -554,13 +553,19 @@ public class OdsProcureOrderServiceImpl implements IOdsProcureOrderService {
sapBackflushMPQueryList.add(sapBackflushMPQuery);
R result2= remoteSapService.sapBackflushMP(sapBackflushMPQueryList);//x
int code= result2.getCode();
String msg= result2.getMsg();
odsProcureOutOrder.setUserDefined11(msg);
if (code==200){//过账成功
Map map=new HashMap();
map= (Map) result2.getData();
String userDefined9= (String) map.get("MATERIALDOCUMENT");
odsProcureOutOrder.setUserDefined9(userDefined9);
odsProcureOutOrder.setUserDefined10("2");//成功
odsProcureOutOrderMapper.updateOdsProcureOutOrderByid(odsProcureOutOrder);
}else {//
odsProcureOutOrder.setUserDefined9("");
odsProcureOutOrder.setUserDefined10("3");//失败
odsProcureOutOrderMapper.updateOdsProcureOutOrderByid(odsProcureOutOrder);
}
@ -578,14 +583,20 @@ public class OdsProcureOrderServiceImpl implements IOdsProcureOrderService {
sapMaterialPosting.setBatch(odsProcureOutOrder.getUserDefined2()); //批号
sapMaterialPostingList.add(sapMaterialPosting);
R result= remoteSapService.sapMaterialPosting(sapMaterialPostingList);
int code= result.getCode();
String msg= result.getMsg();
odsProcureOutOrder.setUserDefined11(msg);
if (code==200){//过账成功
Map map=new HashMap();
map= (Map) result.getData();
String userDefined9= (String) map.get("MATERIALDOCUMENT");
odsProcureOutOrder.setUserDefined9(userDefined9);
odsProcureOutOrder.setUserDefined10("2");//成功
odsProcureOutOrderMapper.updateOdsProcureOutOrderByid(odsProcureOutOrder);
}else {//
odsProcureOutOrder.setUserDefined9("");
odsProcureOutOrder.setUserDefined10("3");//失败
odsProcureOutOrderMapper.updateOdsProcureOutOrderByid(odsProcureOutOrder);
}
@ -597,7 +608,13 @@ public class OdsProcureOrderServiceImpl implements IOdsProcureOrderService {
@Override
public AjaxResult sapPurchaseOrderSync(OdsProcureOrder odsProcureOrder) {
//remoteSapService.sapPurchaseOrderSync();
DynamicDataSourceContextHolder.push("ds_" +odsProcureOrder.getFactoryCode());
SapPurchaseOrderQuery sapPurchaseOrderQuery=new SapPurchaseOrderQuery();
sapPurchaseOrderQuery.setEbeln(odsProcureOrder.getProcureCode());
R result= remoteSapService.sapPurchaseOrderSync(sapPurchaseOrderQuery);
List<SapPurchaseOrderQuery> sapPurchaseOrderQueryList=new ArrayList<>();
sapPurchaseOrderQueryList= (List<SapPurchaseOrderQuery>) result.getData();
// sapPurchaseOrderQueryList
return null;
}

@ -281,6 +281,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateOdsProcureOutOrderByid">
update ods_procure_out_order
set User_Defined10 = #{userDefined10},
User_Defined9 = #{userDefined9},
User_Defined11 = #{userDefined11}
where ID = #{ID}
</update>

Loading…
Cancel
Save