diff --git a/newbiest-mm/src/main/java/com/newbiest/mms/print/DefaultPrintStrategy.java b/newbiest-mm/src/main/java/com/newbiest/mms/print/DefaultPrintStrategy.java index d18de1821..e9d6926a0 100644 --- a/newbiest-mm/src/main/java/com/newbiest/mms/print/DefaultPrintStrategy.java +++ b/newbiest-mm/src/main/java/com/newbiest/mms/print/DefaultPrintStrategy.java @@ -1,7 +1,6 @@ package com.newbiest.mms.print; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.newbiest.base.exception.ClientParameterException; import com.newbiest.base.utils.CollectionUtils; import com.newbiest.base.utils.DateUtils; @@ -14,7 +13,6 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; @@ -69,7 +67,8 @@ public void print(PrintContext printContext) { } public Map buildParameters(PrintContext printContext) { - Map parameterMap = Maps.newHashMap(); + Map parameterMap = printContext.getParameterMap(); + log.debug("parameterMap:" + parameterMap); List labelTemplateParameters = printContext.getLabelTemplate().getLabelTemplateParameterList(); if (CollectionUtils.isNotEmpty(labelTemplateParameters)) { for (LabelTemplateParameter parameter : labelTemplateParameters) { @@ -86,6 +85,7 @@ public Map buildParameters(PrintContext printContext) { } if (value != null) { if (value instanceof Date) { + log.debug("value:" + value); SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.DEFAULT_DATE_PATTERN); value = sdf.format(value); } @@ -94,6 +94,7 @@ public Map buildParameters(PrintContext printContext) { value = parameter.getDefaultValue(); } parameterMap.put(parameter.getName(), value); + log.debug("parameterName:" + parameter.getName() + ".value :" + value); } } parameterMap.put("printCount", printContext.getLabelTemplate().getPrintCount()); diff --git a/newbiest-mm/src/main/java/com/newbiest/mms/rest/materiallot/MaterialLotController.java b/newbiest-mm/src/main/java/com/newbiest/mms/rest/materiallot/MaterialLotController.java index 14a2cc97f..4ddc9f4b3 100644 --- a/newbiest-mm/src/main/java/com/newbiest/mms/rest/materiallot/MaterialLotController.java +++ b/newbiest-mm/src/main/java/com/newbiest/mms/rest/materiallot/MaterialLotController.java @@ -2,14 +2,14 @@ import com.newbiest.base.exception.ClientException; import com.newbiest.base.exception.ClientParameterException; +import com.newbiest.base.msg.Request; import com.newbiest.base.rest.AbstractRestController; -import com.newbiest.base.utils.StringUtils; +import com.newbiest.base.threadlocal.ThreadLocalContext; import com.newbiest.mms.dto.MaterialLotAction; import com.newbiest.mms.exception.MmsException; import com.newbiest.mms.model.MaterialLot; import com.newbiest.mms.model.RawMaterial; import com.newbiest.mms.service.MmsService; -import com.newbiest.base.msg.Request; import com.newbiest.mms.service.PrintService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -60,7 +60,8 @@ public MaterialLotResponse execute(@RequestBody MaterialLotRequest request) thro materialLot = mmsService.consumeMLot(materialLot, materialLotAction); } else if (MaterialLotRequest.ACTION_PRINT_LABEL.equals(actionType)) { materialLot = mmsService.getMLotByMLotId(materialLot.getMaterialLotId()); - printService.printMLot(materialLot); + log.debug("transactionIp" + ThreadLocalContext.getTransactionIp()); + printService.printMLot(materialLot, ThreadLocalContext.getTransactionIp()); } else { throw new ClientException(Request.NON_SUPPORT_ACTION_TYPE + requestBody.getActionType()); } diff --git a/newbiest-mm/src/main/java/com/newbiest/mms/service/PrintService.java b/newbiest-mm/src/main/java/com/newbiest/mms/service/PrintService.java index a34b42950..268ef81ac 100644 --- a/newbiest-mm/src/main/java/com/newbiest/mms/service/PrintService.java +++ b/newbiest-mm/src/main/java/com/newbiest/mms/service/PrintService.java @@ -8,5 +8,5 @@ * @date 4/6/21 3:04 PM */ public interface PrintService { - void printMLot(MaterialLot materialLot) throws ClientException; + void printMLot(MaterialLot materialLot, String workStationIp) throws ClientException; } diff --git a/newbiest-mm/src/main/java/com/newbiest/mms/service/impl/PrintServiceImpl.java b/newbiest-mm/src/main/java/com/newbiest/mms/service/impl/PrintServiceImpl.java index ddcdf2eec..d083e42d9 100644 --- a/newbiest-mm/src/main/java/com/newbiest/mms/service/impl/PrintServiceImpl.java +++ b/newbiest-mm/src/main/java/com/newbiest/mms/service/impl/PrintServiceImpl.java @@ -5,7 +5,6 @@ import com.newbiest.base.exception.ClientException; import com.newbiest.base.exception.ClientParameterException; import com.newbiest.base.exception.ExceptionManager; -import com.newbiest.base.threadlocal.ThreadLocalContext; import com.newbiest.base.utils.DateUtils; import com.newbiest.mms.exception.MmsException; import com.newbiest.mms.model.LabelTemplate; @@ -60,16 +59,18 @@ public class PrintServiceImpl implements PrintService { */ @Override @Async - public void printMLot(MaterialLot materialLot) throws ClientException { + public void printMLot(MaterialLot materialLot, String workStationIp) throws ClientException { try { - String transactionIp = ThreadLocalContext.getTransactionIp(); - WorkStation workStation = workStationRepository.findByIpAddress(transactionIp); + if (log.isDebugEnabled()) { + log.debug("workStationIp:" + workStationIp); + } + WorkStation workStation = workStationRepository.findByIpAddress(workStationIp); if (workStation == null) { - throw new ClientParameterException(MmsException.MM_WORK_STATION_IS_NOT_EXIST, transactionIp); + throw new ClientParameterException(MmsException.MM_WORK_STATION_IS_NOT_EXIST, workStationIp); } LabelTemplate labelTemplate = labelTemplateRepository.findOneByName("PrintMLot"); if (labelTemplate == null) { - throw new ClientParameterException(MmsException.MM_LBL_TEMPLATE_IS_NOT_EXIST, transactionIp); + throw new ClientParameterException(MmsException.MM_LBL_TEMPLATE_IS_NOT_EXIST); } List parameterList = labelTemplateParameterRepository.findByLblTemplateRrn(labelTemplate.getObjectRrn()); labelTemplate.setLabelTemplateParameterList(parameterList);