工控程序接口

master
philip 4 years ago
parent 7a53834f91
commit ee874a035d

@ -85,8 +85,9 @@ public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper,
if (byId==null){ if (byId==null){
throw new BaseException("未找到检验任务"); throw new BaseException("未找到检验任务");
} }
if(StringUtil.notBlank(byId.getResult())){ String result= byId.getResult();
throw new BaseException("检验任务已经保存完成!"); if(StringUtil.notBlank(result)&&result.equals(Constants.RSESULT_OK)){
throw new BaseException("检验任务已经保存合格!");
} }
task.setComments((String) paramMap.get("COMMENTS")); task.setComments((String) paramMap.get("COMMENTS"));
task.setStatus(Constants.INSPECTION_TASK_STATUS_COMPLETE); task.setStatus(Constants.INSPECTION_TASK_STATUS_COMPLETE);

@ -22,6 +22,7 @@ import com.foreverwin.mesnac.common.service.PrintLogService;
import com.foreverwin.mesnac.common.service.ProdReadyTaskDetailService; import com.foreverwin.mesnac.common.service.ProdReadyTaskDetailService;
import com.foreverwin.mesnac.common.service.ProdReadyTaskService; import com.foreverwin.mesnac.common.service.ProdReadyTaskService;
import com.foreverwin.mesnac.common.service.SfcDispatchCommonService; import com.foreverwin.mesnac.common.service.SfcDispatchCommonService;
import com.foreverwin.mesnac.common.util.DateUtil;
import com.foreverwin.mesnac.common.util.StringUtil; import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.meapi.dto.BomComponentDto; import com.foreverwin.mesnac.meapi.dto.BomComponentDto;
import com.foreverwin.mesnac.meapi.model.Item; import com.foreverwin.mesnac.meapi.model.Item;
@ -33,18 +34,20 @@ import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.exception.BusinessException; import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.CommonMethods; import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage; import com.foreverwin.modular.core.util.FrontPage;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.jms.ConnectionFactory;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.concurrent.TimeUnit;
import java.util.Map;
import java.util.UUID;
/** /**
* <p> * <p>
@ -65,7 +68,8 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
public static final String STATUS_DOING = "DOING"; public static final String STATUS_DOING = "DOING";
public static final String STATUS_FINISH = "FINISH"; public static final String STATUS_FINISH = "FINISH";
public static final String STATUS_CANCEL = "CANCEL"; public static final String STATUS_CANCEL = "CANCEL";
@Value("${spring.activemq.brokerUrl}")
String brokerURL;
@Value("${print.server}") @Value("${print.server}")
private String printServer; private String printServer;
@Autowired @Autowired
@ -268,7 +272,7 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
public List<Map<String, Object>> getInspectionDetailList(Map<String, String> param) { public List<Map<String, Object>> getInspectionDetailList(Map<String, String> param) {
String type = param.get("type"); String type = param.get("type");
String dispatchNo = param.get("dispatchNo"); String dispatchNo = param.get("dispatchNo");
List<Map<String, Object>> returnMap = null; List<Map<String, Object>> returnMap = new ArrayList<>();
String site = CommonMethods.getSite(); String site = CommonMethods.getSite();
if (type.equals(P01)) { if (type.equals(P01)) {
//物料接收数据 //物料接收数据
@ -278,6 +282,18 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
returnMap = prodReadyTaskMapper.getToolDetail(site, LocaleContextHolder.getLocale().getLanguage(), dispatchNo); returnMap = prodReadyTaskMapper.getToolDetail(site, LocaleContextHolder.getLocale().getLanguage(), dispatchNo);
} else { } else {
//通过加工的零件号、设备类型、设备获取发布状态的工控程序 //通过加工的零件号、设备类型、设备获取发布状态的工控程序
SfcDispatchDto sfcdispatch=new SfcDispatchDto();
sfcdispatch.setHandle(HandleEnum.SFC_DISPATCH.getHandle(site,dispatchNo));
sfcdispatch = sfcDispatchCommonService.findSfcDispatchBySfc(sfcdispatch);
Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(site, sfcdispatch.getSfc()));
String itemBo = sfcServiceById.getItemBo();
JSONObject jsonObject = sendToDnc(StringUtil.trimHandle(itemBo), sfcdispatch.getResrce(), sfcdispatch.getResourceType());
Map<String, Object> map=new HashMap<>();
map.put("RESOURCE",sfcdispatch.getResrce());
map.put("RESOURCE_TYPE",sfcdispatch.getResourceType());
map.put("RESULT",jsonObject.get("RESULT"));
map.put("MESSAGE",jsonObject.get("MESSAGE"));
returnMap.add(map);
} }
return returnMap; return returnMap;
} }
@ -406,4 +422,47 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
} }
public JSONObject sendToDnc(String item, String resource, String resourceType) {
String site = CommonMethods.getSite();
String queue="resource.check.process";
JSONObject messageObject=new JSONObject();
String tranid = UUID.randomUUID().toString();
messageObject.put("TRANID", tranid);
String dateTime = DateUtil.formatDate(new Date());
messageObject.put("DATE_TIME", dateTime);
messageObject.put("SITE", site);
messageObject.put("MESSAGE_ID", queue);
messageObject.put("ITEM", item);
messageObject.put("RESOURCE", resource);
messageObject.put("RESOURCE_TYPE", resourceType);
String causeMessage = null;
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
ActiveMQConnection.DEFAULT_USER,
ActiveMQConnection.DEFAULT_PASSWORD, brokerURL);
JmsMessagingTemplate jmsMessagingTemplate = new JmsMessagingTemplate(connectionFactory);
jmsMessagingTemplate.getJmsTemplate().setReceiveTimeout(TimeUnit.SECONDS.toMillis(30));
String message = jmsMessagingTemplate.convertSendAndReceive(queue, messageObject.toString(), String.class);
if (StringUtil.isBlank(message)) {
causeMessage = "队列消息消费超时或者未返回消费数据";
} else {
JSONObject jsonNode = JSONObject.parseObject(message);
String result = jsonNode.getString("STATUS");
if ("S".equalsIgnoreCase(result)) {
return jsonNode;
} else {
causeMessage = jsonNode.getString("MESSAGE");
}
}
JSONObject messageFailObject = new JSONObject();
messageFailObject.put("TRANID", tranid);
messageFailObject.put("RESULT", "E");
messageFailObject.put("MESSAGE", causeMessage);
return messageFailObject;
}
} }
Loading…
Cancel
Save