|
|
|
@ -22,6 +22,7 @@ import com.foreverwin.mesnac.common.service.PrintLogService;
|
|
|
|
|
import com.foreverwin.mesnac.common.service.ProdReadyTaskDetailService;
|
|
|
|
|
import com.foreverwin.mesnac.common.service.ProdReadyTaskService;
|
|
|
|
|
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.meapi.dto.BomComponentDto;
|
|
|
|
|
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.util.CommonMethods;
|
|
|
|
|
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.Value;
|
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
|
import org.springframework.jms.core.JmsMessagingTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.jms.ConnectionFactory;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
@ -65,7 +68,8 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
|
|
|
|
|
public static final String STATUS_DOING = "DOING";
|
|
|
|
|
public static final String STATUS_FINISH = "FINISH";
|
|
|
|
|
public static final String STATUS_CANCEL = "CANCEL";
|
|
|
|
|
|
|
|
|
|
@Value("${spring.activemq.brokerUrl}")
|
|
|
|
|
String brokerURL;
|
|
|
|
|
@Value("${print.server}")
|
|
|
|
|
private String printServer;
|
|
|
|
|
@Autowired
|
|
|
|
@ -146,9 +150,9 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
|
|
|
|
|
String accessoryType = bomComponentDto.getAccessoryType();
|
|
|
|
|
//物料P001,校验当前派工单(SFC+工序/步骤)加工是否需要准备物料
|
|
|
|
|
if (accessoryType == null || accessoryType.equals("0")) {
|
|
|
|
|
if (prodReadyTaskDetailList.size()>0){
|
|
|
|
|
if (prodReadyTaskDetailList.size() > 0) {
|
|
|
|
|
long count = prodReadyTaskDetailList.stream().filter(prodReadyTaskDetail -> prodReadyTaskDetail.getInspectionItem().equals(P01)).count();
|
|
|
|
|
if (count>0){
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -164,9 +168,9 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
|
|
|
|
|
prodReadyTaskDetail.setModifiedDateTime(LocalDateTime.now());
|
|
|
|
|
prodReadyTaskDetailList.add(prodReadyTaskDetail);
|
|
|
|
|
} else if (accessoryType.equals("1")) {
|
|
|
|
|
if (prodReadyTaskDetailList.size()>0){
|
|
|
|
|
if (prodReadyTaskDetailList.size() > 0) {
|
|
|
|
|
long count = prodReadyTaskDetailList.stream().filter(prodReadyTaskDetail -> prodReadyTaskDetail.getInspectionItem().equals(P02)).count();
|
|
|
|
|
if (count>0){
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -268,7 +272,7 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
|
|
|
|
|
public List<Map<String, Object>> getInspectionDetailList(Map<String, String> param) {
|
|
|
|
|
String type = param.get("type");
|
|
|
|
|
String dispatchNo = param.get("dispatchNo");
|
|
|
|
|
List<Map<String, Object>> returnMap = null;
|
|
|
|
|
List<Map<String, Object>> returnMap = new ArrayList<>();
|
|
|
|
|
String site = CommonMethods.getSite();
|
|
|
|
|
if (type.equals(P01)) {
|
|
|
|
|
//物料接收数据
|
|
|
|
@ -278,6 +282,18 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
|
|
|
|
|
returnMap = prodReadyTaskMapper.getToolDetail(site, LocaleContextHolder.getLocale().getLanguage(), dispatchNo);
|
|
|
|
|
} 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;
|
|
|
|
|
}
|
|
|
|
@ -289,7 +305,7 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
|
|
|
|
|
if (byId.getStatus().equals(STATUS_CANCEL)) {
|
|
|
|
|
throw new BaseException("产前准备任务任务已取消");
|
|
|
|
|
}
|
|
|
|
|
if (byId.getStatus().equals(STATUS_FINISH)&&byId.getResult().equals(Constants.RSESULT_OK)) {
|
|
|
|
|
if (byId.getStatus().equals(STATUS_FINISH) && byId.getResult().equals(Constants.RSESULT_OK)) {
|
|
|
|
|
throw new BaseException("产前准备任务任务已完成");
|
|
|
|
|
}
|
|
|
|
|
List<ProdReadyTaskDetail> prodReadyTaskDetailList = prodReadyTask.getProdReadyTaskDetailList();
|
|
|
|
@ -314,29 +330,29 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
|
|
|
|
|
String site = CommonMethods.getSite();
|
|
|
|
|
String user = CommonMethods.getUser();
|
|
|
|
|
String sfcDispatchBo = prodReadyTask.getSfcDispatchBo();
|
|
|
|
|
SfcDispatchDto sfcDispatchDto=new SfcDispatchDto();
|
|
|
|
|
SfcDispatchDto sfcDispatchDto = new SfcDispatchDto();
|
|
|
|
|
sfcDispatchDto.setHandle(sfcDispatchBo);
|
|
|
|
|
sfcDispatchDto = sfcDispatchCommonService.findSfcDispatchBySfc(sfcDispatchDto);
|
|
|
|
|
List<PrintLog> printList=new ArrayList<>();
|
|
|
|
|
List<PrintLog> printList = new ArrayList<>();
|
|
|
|
|
List<LabelPrintDto> labelPrintDtoList = new ArrayList<>();
|
|
|
|
|
String printData = null;
|
|
|
|
|
PrintLog printTag=new PrintLog();
|
|
|
|
|
PrintLog printTag = new PrintLog();
|
|
|
|
|
|
|
|
|
|
String resrce = sfcDispatchDto.getResrce();
|
|
|
|
|
String printName = customFieldsService.getCustomFieldsValue(HandleEnum.RESOURCE.getHandle(site, resrce), CustomFieldConstant.RESRCE_CUSTOM_FIELD_PRINT_NAME);
|
|
|
|
|
if (StringUtil.isBlank(printName)){
|
|
|
|
|
if (StringUtil.isBlank(printName)) {
|
|
|
|
|
throw new BaseException("资源维护的打印机不能为空");
|
|
|
|
|
}
|
|
|
|
|
String item = prodReadyTask.getItem();
|
|
|
|
|
Item selectCurrent = itemService.selectCurrent(site, item);
|
|
|
|
|
QueryWrapper<PrintLog> queryWrapper=new QueryWrapper();
|
|
|
|
|
queryWrapper.eq(PrintLog.SFC,prodReadyTask.getSfc());
|
|
|
|
|
queryWrapper.eq(PrintLog.STEP_ID,prodReadyTask.getStepId());
|
|
|
|
|
queryWrapper.eq(PrintLog.RESRCE,prodReadyTask.getResrce());
|
|
|
|
|
queryWrapper.eq(PrintLog.CATEGORY,Constants.PRINT_TYPE_SFC);
|
|
|
|
|
queryWrapper.eq(PrintLog.CATEGORY,Constants.PRINT_TYPE_SFC);
|
|
|
|
|
QueryWrapper<PrintLog> queryWrapper = new QueryWrapper();
|
|
|
|
|
queryWrapper.eq(PrintLog.SFC, prodReadyTask.getSfc());
|
|
|
|
|
queryWrapper.eq(PrintLog.STEP_ID, prodReadyTask.getStepId());
|
|
|
|
|
queryWrapper.eq(PrintLog.RESRCE, prodReadyTask.getResrce());
|
|
|
|
|
queryWrapper.eq(PrintLog.CATEGORY, Constants.PRINT_TYPE_SFC);
|
|
|
|
|
queryWrapper.eq(PrintLog.CATEGORY, Constants.PRINT_TYPE_SFC);
|
|
|
|
|
List<PrintLog> printLogList = printLogService.list(queryWrapper);
|
|
|
|
|
if (printLogList.isEmpty()){
|
|
|
|
|
if (printLogList.isEmpty()) {
|
|
|
|
|
//打印参数
|
|
|
|
|
LabelPrintDto labelPrintDto = new LabelPrintDto();
|
|
|
|
|
labelPrintDto.setPrinter(printName);
|
|
|
|
@ -372,12 +388,12 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
|
|
|
|
|
printTag.setItemDescription(selectCurrent.getDescription());
|
|
|
|
|
|
|
|
|
|
printList.add(printTag);
|
|
|
|
|
printLogService.savePrintLog(site,user,printTag);
|
|
|
|
|
printLogService.savePrintLog(site, user, printTag);
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
printData = printLogList.get(0).getPrintParam();
|
|
|
|
|
}
|
|
|
|
|
String post = HttpUtil.post(printServer,printData , 30000);
|
|
|
|
|
String post = HttpUtil.post(printServer, printData, 30000);
|
|
|
|
|
/**
|
|
|
|
|
* {"msg":"打印成功","code":0}
|
|
|
|
|
* {"msg":"打印失败","code":500}
|
|
|
|
@ -385,20 +401,20 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
|
|
|
|
|
*/
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(post);
|
|
|
|
|
String code = jsonObject.getString("code");
|
|
|
|
|
if (code == null){
|
|
|
|
|
if (code == null) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (post.indexOf("500") != -1){
|
|
|
|
|
if (post.indexOf("500") != -1) {
|
|
|
|
|
throw BusinessException.build("打印失败!");
|
|
|
|
|
}
|
|
|
|
|
if (printLogList.isEmpty()){
|
|
|
|
|
if (printLogList.isEmpty()) {
|
|
|
|
|
printTag.setIsPrint("true");
|
|
|
|
|
printTag.setPrintNum(1);
|
|
|
|
|
printLogService.updateById(printTag);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
PrintLog printLog = printLogList.get(0);
|
|
|
|
|
printTag.setIsPrint("true");
|
|
|
|
|
printTag.setPrintNum(printLog.getPrintNum()+1);
|
|
|
|
|
printTag.setPrintNum(printLog.getPrintNum() + 1);
|
|
|
|
|
printTag.setModifiedDateTime(LocalDateTime.now());
|
|
|
|
|
printTag.setModifyUser(user);
|
|
|
|
|
printLogService.updateById(printLog);
|
|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|