forked from I3-YF/i3plus-mes-pcn-yfai
临时存储
parent
797904c87a
commit
36ee2c007a
@ -0,0 +1,12 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.dao;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesScanMonitorContext;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
public interface IMesWorkCellScanMonitorLogDao {
|
||||||
|
|
||||||
|
@ApiOperation(value = "写入工位扫描监控信息")
|
||||||
|
void insertWorkCellScanMonitorLog(StationResultBean resultBean, MesScanMonitorContext scanMonitorContext);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.daoimpl;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesWorkCellScanMonitorLogDao;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesScanMonitorContext;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MesWorkCellScanMonitorLogDao implements IMesWorkCellScanMonitorLogDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertWorkCellScanMonitorLog(StationResultBean resultBean, MesScanMonitorContext scanMonitorContext) {
|
||||||
|
|
||||||
|
if (null == resultBean || null == scanMonitorContext) return;
|
||||||
|
|
||||||
|
StringBuffer builder = new StringBuffer();
|
||||||
|
|
||||||
|
builder.append(" insert into mes_work_cell_scan_monitor_");
|
||||||
|
builder.append(resultBean.getWorkCenterCode().toLowerCase());
|
||||||
|
builder.append("( id, organize_code, is_valid, is_deleted, create_user, create_date_time, modify_user, modify_date_time,");
|
||||||
|
builder.append("( description, remark, system_sync_date_time, system_sync_status,");
|
||||||
|
builder.append(" area_code, work_center_code, work_cell_code, equipment_code, equipment_name, process_code, process_name, craft_code, craft_name,");
|
||||||
|
builder.append(" mould_record_id, scan_info, work_order_no, serial_number, product_sn, cust_sn, part_no, part_name,");
|
||||||
|
builder.append(" step_code, log_type, message, message_type, deal_status, org_work_code)");
|
||||||
|
builder.append(" values ( :id , :organizeCode , :isValid , :isDeleted , :createUser , :createDatetime , :modifyUser , :modifyDatetime ,");
|
||||||
|
builder.append(" :description , :remark , :systemSyncDatetime , :systemSyncStatus ,");
|
||||||
|
builder.append(" :areaCode , :workCenterCode , :workCellCode , :equipmentCode , :equipmentName , :processCode , :processName , :craftCode , :craftName ,");
|
||||||
|
builder.append(" :mouldRecordId , :scanInfo , :workOrderNo , :serialNumber , :productSn , :custSn , :partNo , :partName ,");
|
||||||
|
builder.append(" :stepCode , :logType , :message , :messageType , :dealStatus , :orgWorkCode )");
|
||||||
|
|
||||||
|
Query insert = entityManager.createNativeQuery(builder.toString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEquipVariableStatus(String organizeCode, Integer equipId, Map<Long, String> equipmentLogIdMap, Integer equipVariableStatus) {
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipId) || CollectionUtils.isEmpty(equipmentLogIdMap) || StringUtils.isEmpty(equipVariableStatus)) return;
|
||||||
|
|
||||||
|
StringBuffer builder = new StringBuffer();
|
||||||
|
|
||||||
|
for (int i = 0; i < equipmentLogIdMap.size(); i ++) {
|
||||||
|
|
||||||
|
builder.append(" update mes_equipment_log_");
|
||||||
|
builder.append(equipId);
|
||||||
|
builder.append(" set equip_variable_status = :equipVariableStatus_");
|
||||||
|
builder.append(i);
|
||||||
|
builder.append(" where id = :id_");
|
||||||
|
builder.append(i);
|
||||||
|
builder.append(" and modify_date_time = :modifyDatetime_");
|
||||||
|
builder.append(i);
|
||||||
|
builder.append(" ;");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Query update = entityManager.createNativeQuery(builder.toString());
|
||||||
|
|
||||||
|
Integer index = 0;
|
||||||
|
for (Map.Entry<Long, String> entry : equipmentLogIdMap.entrySet()) {
|
||||||
|
if (null == entry) continue;
|
||||||
|
update.setParameter(String.format("%s_%s", MesPcnExtConstWords.EQUIP_VARIABLE_STATUS, index), equipVariableStatus);
|
||||||
|
update.setParameter(String.format("%s_%s", MesPcnExtConstWords.ID, index), entry.getKey());
|
||||||
|
update.setParameter(String.format("%s_%s", MesPcnExtConstWords.MODIFY_DATE_TIME, index), entry.getValue());
|
||||||
|
index ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
update.executeUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue