Skip to content

Commit

Permalink
获取打印策略修正
Browse files Browse the repository at this point in the history
  • Loading branch information
adomguo committed Apr 6, 2021
1 parent 6443733 commit 5e64733
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @author guoxunbo
* @date 4/6/21 3:07 PM
*/
@Component
@Component("defaultPrintStrategy")
@Slf4j
public class DefaultPrintStrategy implements IPrintStrategy {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class PrintServiceImpl implements PrintService {

public static final String PRINT_MATERIAL_LOT = "printMLot";

@Autowired
Map<String, IPrintStrategy> printStrategyMap;

@Autowired
WorkStationRepository workStationRepository;

Expand All @@ -58,7 +61,7 @@ public void printMLot(MaterialLot materialLot) throws ClientException {
if (workStation == null) {
throw new ClientParameterException(MmsException.MM_WORK_STATION_IS_NOT_EXIST, transactionIp);
}
LabelTemplate labelTemplate = labelTemplateRepository.findOneByName("PRINT_MATERIAL_LOT");
LabelTemplate labelTemplate = labelTemplateRepository.findOneByName("PrintMLot");
if (labelTemplate == null) {
throw new ClientParameterException(MmsException.MM_LBL_TEMPLATE_IS_NOT_EXIST, transactionIp);
}
Expand All @@ -75,7 +78,11 @@ public void printMLot(MaterialLot materialLot) throws ClientException {
parameterMap.put("specification", materialLot.getMaterialDesc());
printContext.setParameterMap(parameterMap);

IPrintStrategy printStrategy = new DefaultPrintStrategy();
IPrintStrategy printStrategy = printStrategyMap.get("PrintMLot");
if (printStrategy == null) {
printStrategy = printStrategyMap.get("defaultPrintStrategy");
}
// IPrintStrategy printStrategy = new DefaultPrintStrategy();
printStrategy.print(printContext);
} catch (Exception e) {
throw ExceptionManager.handleException(e, log);
Expand Down

0 comments on commit 5e64733

Please sign in to comment.