package com.cim.idm.service.Impl;

import cn.hutool.core.text.CharSequenceUtil;
import com.cim.idm.constants.CustomExceptionCode;
import com.cim.idm.constants.MsgConstants;
import com.cim.idm.constants.PolicyDef;
import com.cim.idm.constants.SqlStatement;
import com.cim.idm.framework.IDMFrameServiceProxy;
import com.cim.idm.framework.data.EventInfo;
import com.cim.idm.framework.exception.IDMFrameDBErrorSignal;
import com.cim.idm.framework.orm.info.KeyInfo;
import com.cim.idm.framework.orm.service.CommonServiceDAO;
import com.cim.idm.framework.util.time.TimeStampUtil;
import com.cim.idm.model.*;
import com.cim.idm.model.bo.StorageObject;
import com.cim.idm.model.dto.StoragePrintDto;
import com.cim.idm.mwmsextend.generic.util.CommonUtil;
import com.cim.idm.wmsextend.generic.errorHandler.CustomException;
import com.cim.idm.wmsextend.generic.util.ObjectUtil;
import com.cim.idm.wmspackage.storage.StorageServiceProxy;
import com.cim.idm.wmspackage.storage.management.data.StorageSpec;
import com.cim.idm.wmspackage.storage.management.data.StorageSpecKey;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.Document;
import org.jdom.Element;
import org.springframework.beans.BeansException;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.lang.reflect.Field;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
@Slf4j
public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> implements ApplicationContextAware {
	@SuppressWarnings("unused")
	private ApplicationContext	applicationContext;
	
	private BSLabelHistoryServiceImpl historyService;
	private BSLabelHistoryDataAdaptor historyDataAdaptor;
	
	private static final RestTemplate restTemplate = new RestTemplateBuilder().build();
	private static Log log = LogFactory.getLog(BSLabelServiceImpl.class);

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
		
		historyService = (BSLabelHistoryServiceImpl) applicationContext.getBean(BSLabelHistoryServiceImpl.class);
		historyDataAdaptor = (BSLabelHistoryDataAdaptor) applicationContext.getBean(BSLabelHistoryDataAdaptor.class);
	}
	
	
//    public static HttpHeaders getRequestHeaders(){
//        HttpHeaders requestHeaders = new HttpHeaders();
//        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
//        requestHeaders.setContentType(type);
//        requestHeaders.add("Accept", MediaType.APPLICATION_JSON.toString());
//        return requestHeaders;
//        }
	
	/**
	 * 
	 * This function is labelPrint
	 * @param data --any data
	 * @param requestURL
	 * @param printRequest
	 * @param nameParams  -- labelAssign parameter
	 * @throws CustomException
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 * @author ZXY Team. 
	 * @date 2022年5月6日
	 */
	public String labelPrint(Object data, String requestURL, PrintRequest printRequest,List<String> nameParams) throws CustomException 
			 {
		if (data != null && nameParams.size() > 0) {
			Map<String, String> namedDataSources = new HashMap<String, String>();
			Field[] fields = data.getClass().getDeclaredFields();
			for (String key : nameParams) {
				namedDataSources.put(key, StringUtils.EMPTY);
				for (Field field : fields) {
					if (field.getName().equals("key")) {
						KeyInfo sourceKey = ObjectUtil.getKeyInfo(data);
						Field[] keyFields = sourceKey.getClass().getDeclaredFields();
						boolean isPut = false;
						for (Field keyField : keyFields) {
							if (key.toUpperCase().equals(keyField.getName().toUpperCase())) {
								keyField.setAccessible(true);
								try {
									namedDataSources.put(key, String.valueOf(keyField.get(sourceKey)));
								} catch (IllegalArgumentException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								} catch (IllegalAccessException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
								isPut = true;
								break;
							}
						}
						if (isPut) break;
					}
					if (key.toUpperCase().equals(field.getName().toUpperCase())) {
						field.setAccessible(true);
						
						if("CREATETIME".equals(field.getName().toUpperCase())) {
							Timestamp time = null;
							try {
								time = (Timestamp) field.get(data);
							}
							catch (Exception e) {
								try {
									namedDataSources.put(key, String.valueOf(field.get(data)));
								} catch (IllegalArgumentException e1) {
									// TODO Auto-generated catch block
									e1.printStackTrace();
								} catch (IllegalAccessException e1) {
									// TODO Auto-generated catch block
									e1.printStackTrace();
								}
								break;
							}
							String timeKey = new SimpleDateFormat("yyyy/MM/dd*HH:mm:SS").format(time);
							namedDataSources.put(key, timeKey);
							break;
						}
						
						try {
							namedDataSources.put(key, String.valueOf(field.get(data)));
						} catch (IllegalArgumentException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						} catch (IllegalAccessException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						break;
					}
				}
			}
			printRequest.setNamedDataSources(namedDataSources);
			Map<String, String> dataEntryControls = new HashMap<>();
			printRequest.setDataEntryControls(dataEntryControls );
		}
		
		ObjectMapper objectMapper = new ObjectMapper();
		String labelRequestParameter = "";
		try {
			labelRequestParameter = objectMapper.writeValueAsString(printRequest);
		} catch (JsonProcessingException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		log.info("---------------------------labelRequestParameter---------------------------------");
		log.info(labelRequestParameter);
		String bodyinfo = "";
		try {
			//35 服务器装了 bartender服务:   
			//1.可以连接打印机，把本地btw文件发给斑马打印机；
			//2.可以给文件绑定key-value，给模板传值；
			//3.暴露接口：  服务地址、打印文件地址、打印文件里面key-value绑定对象、打印机名称。
			//流程：1.通过服务地址找到文件模板， 解析模板，模板里面绑定key，通过 绑定对象把value传给key(相当于替换模板内容)；
			//2.通过我们传过去的打印机名称，去找打印机IP，下发打印任务。
			//重点关注:1.服务地址，2.模板的具名数据源(KEY)，3.key-value绑定对象(>=key,名称一样)，4.打印机名称，5.模板路径
//			PrintSuccess result = 
			//PrintSuccess forObject = restTemplate.getForObject(requestURL, PrintSuccess.class, printRequest);
//			HttpEntity<String> requestEntity = new HttpEntity<>(JSONObject.toJSONString(data), BSLabelServiceImpl.getRequestHeaders());
	        // 返回值为BaseEntity实体类，只有一个字段时不用配置请求头也能正常解析，但存在两个字段及以上时会出现415异常（问题未知，有人知道求告知）
			
			
			HttpHeaders headers = new HttpHeaders();
			headers.setContentType(MediaType.APPLICATION_JSON);
			HttpEntity<PrintRequest> entity = new HttpEntity<>(printRequest, headers);
			// 1.获取开始时间
			long startTime = System.currentTimeMillis();
			ResponseEntity<String> response = restTemplate.exchange(requestURL, HttpMethod.POST, entity, String.class);
			long endTime = System.currentTimeMillis(); //获取结束时间
			String conTime = "程序运行时间：" + (endTime - startTime) + "ms";
			log.info("标签打印-批次号:" + printRequest.getNamedDataSources().get("batch") + "的打印时间为"
			        + conTime +"毫秒"); //输出程序运行时间
//			log.info("标签打印:"+response.getBody());
			bodyinfo = response.getBody();
			
//			HttpHeaders headers = new HttpHeaders();
//			headers.setContentType(MediaType.APPLICATION_JSON);
//			HttpEntity<PrintRequest> httpEntity = new HttpEntity<>(printRequest, headers);
//			new RestTemplateBuilder().build().exchange(requestURL, "POST", httpEntity, String.class);
//			PrintSuccess postForObject = new RestTemplateBuilder().build().postForObject(requestURL, httpEntity, PrintSuccess.class, printRequest);
//					//PrintSuccess postForObject = new RestTemplateBuilder().build().postForObject(requestURL, printRequest, PrintSuccess.class);//requestURL(1)printRequest(2~5)
			
		} catch (Exception e) {
			e.printStackTrace();
			throw new CustomException(e.getMessage().toString());
		}
		
		return bodyinfo;
		
	}
	
	private void setEventInfo(BSLabel data, EventInfo eventInfo) {
		data.setLastEventName(eventInfo.getEventName());
		data.setLastEventComment(eventInfo.getEventComment());
		data.setLastEventTime(eventInfo.getEventTime());
		data.setLastEventTimeKey(eventInfo.getEventTimeKey());
		data.setLastEventUser(eventInfo.getEventUser());
	}
	
	/**
	 * 
	 * This function is labelAction(Create&Delete&Modify)
	 * @param doc
	 * @throws IDMFrameDBErrorSignal
	 * @throws CustomException
	 * @author ZXY Team. 
	 * @date 2022年5月6日
	 */
	public void labelAction(Document doc, EventInfo eventInfo) throws IDMFrameDBErrorSignal, CustomException {
		Element body = doc.getRootElement().getChild(MsgConstants.XPATH_TAG_BODY);//Body
		String actionType = body.getChildText(MsgConstants.TAG_ACTION);//ACTION
		String labelID = body.getChildText(MsgConstants.TAG_LABELID);
		String labelGroup = body.getChildText(MsgConstants.TAG_LABELGROUP);
		String labelType = body.getChildText(MsgConstants.TAG_LABELTYPE);
		String labelDrive = body.getChildText(MsgConstants.TAG_LABELDRIVE);
		String labelName = body.getChildText(MsgConstants.TAG_LABELNAME);
		String labelAddress = body.getChildText(MsgConstants.TAG_LABELADDRESS);
		String description = body.getChildText(MsgConstants.TAG_DESCRIPTION);
		String server = body.getChildText(MsgConstants.TAG_SERVER);
		
		Map<String, Object> bindMap = new HashMap<>();
		bindMap.put(MsgConstants.TAG_LABELID, labelID);//LABELID
		bindMap.put(MsgConstants.TAG_LABELGROUP, labelGroup);//LABELGROUP
		bindMap.put(MsgConstants.TAG_LABELTYPE, labelType);//LABELTYPE
		bindMap.put(MsgConstants.TAG_LABELDRIVE, labelDrive);//LABELDRIVE
		bindMap.put(MsgConstants.TAG_LABELNAME, labelName);//LABELNAME
		bindMap.put(MsgConstants.TAG_LABELADDRESS, labelAddress);//LABELADDRESS
		bindMap.put(MsgConstants.TAG_SERVER, server);//LABELADDRESS
		bindMap.put(MsgConstants.TAG_DESCRIPTION, description);//DESCRIPTION
		
		BSLabelKey labelKey = new BSLabelKey(labelID);
		if (StringUtils.equals(actionType, "Create")) {
			eventInfo.setEventName("LabelCreate");
			String str="SELECT LABELID FROM BSLABEL WHERE LABELID = :LABELID";
			List<Map<String, Object>> result = IDMFrameServiceProxy.getSqlTemplate().queryForList(str, bindMap);
			if (result.size() > 0) {
				throw new CustomException("", labelID);
			}
			BSLabel data = new BSLabel();
			data.setKey(labelKey);
			data.setLabelGroup(labelGroup);
			data.setLabelType(labelType);
			data.setLabelDrive(labelDrive);
			data.setLabelName(labelName);
			data.setLabelAddress(labelAddress);
			data.setDescription(description);
			data.setServer(server);
			data.setCreateUser(eventInfo.getEventUser());
			data.setCreateTime(eventInfo.getEventTime());
			setEventInfo(data, eventInfo);
			String sqlinsert="INSERT INTO BSLABEL (LABELID, LABELTYPE, LABELGROUP, LABELDRIVE, LABELNAME, LABELADDRESS, DESCRIPTION,SERVER) "
					+ "VALUES(:LABELID, :LABELTYPE, :LABELGROUP, :LABELDRIVE, :LABELNAME, :LABELADDRESS, :DESCRIPTION,:SERVER)";
			IDMFrameServiceProxy.getSqlTemplate().update(sqlinsert, bindMap);
		}
		
		if (StringUtils.equals(actionType,"Modify")) {
			eventInfo.setEventName("LabelModify");
			BSLabel data = new BSLabel();
			data.setLabelGroup(labelGroup);
			data.setLabelType(labelType);
			data.setLabelDrive(labelDrive);
			data.setLabelName(labelName);
			data.setLabelAddress(labelAddress);
			data.setDescription(description);
			data.setServer(server);
			setEventInfo(data, eventInfo);
            String sqlmodify="UPDATE BSLABEL SET LABELTYPE=:LABELTYPE, LABELGROUP=:LABELGROUP, "
            		+ "LABELDRIVE=:LABELDRIVE, LABELNAME=:LABELNAME, LABELADDRESS=:LABELADDRESS, "
            		+ "DESCRIPTION=:DESCRIPTION,SERVER=:SERVER  WHERE LABELID=:LABELID";
			int result = IDMFrameServiceProxy.getSqlTemplate().update(sqlmodify, bindMap);
			if (result == 0) {
				throw new CustomException("", labelID);
			}
		}
		
		if (StringUtils.equals(actionType, "Delete")) {
			String sqldel="DELETE FROM BSLABEL WHERE LABELID=:LABELID";
			int result = IDMFrameServiceProxy.getSqlTemplate().update(sqldel, bindMap);
			if (result == 0) {
				throw new CustomException("", labelID);
			}
		}
	}
	
	/**
	 * 
	 * This function is labelAssignFGCodeAction
	 * @param doc
	 * @throws IDMFrameDBErrorSignal
	 * @throws CustomException
	 * @author ZXY Team. 
	 * @date 2022年5月6日
	 */
	public void labelAssignFGCodeAction(Document doc) throws IDMFrameDBErrorSignal, CustomException{
		Element body = doc.getRootElement().getChild(MsgConstants.XPATH_TAG_BODY);
		Element header = doc.getRootElement().getChild(MsgConstants.XPATH_TAG_HEADER);
		Element labelListElement = body.getChild(MsgConstants.TAG_LABELLIST);
		if (labelListElement.getChildren() == null) {
			return;
		}
		
		String factoryName = header.getChildText(MsgConstants.TAG_SHOPNAME);
		String actionType = body.getChildText(MsgConstants.TAG_ACTION);
		String operation = body.getChildText(MsgConstants.TAG_PROCESSOPERATIONNAME);
		String printerName = body.getChildText(MsgConstants.TAG_PRINTERNAME);
		String printQty = body.getChildText(MsgConstants.TAG_PRINTQTY);
		String fgCode = body.getChildText(MsgConstants.TAG_PRODUCTSPECNAME);
		
		Map<String, Object> bindMap = new HashMap<>();
		bindMap.put(MsgConstants.TAG_PRODUCTSPECNAME, fgCode);
		bindMap.put(MsgConstants.TAG_PROCESSOPERATIONNAME, operation);
		bindMap.put(MsgConstants.TAG_PRINTERNAME, printerName);
		bindMap.put(MsgConstants.TAG_PRINTQTY, printQty);
		bindMap.put(MsgConstants.TAG_FACTORYNAME, factoryName);
		
		if (StringUtils.equals(actionType, PolicyDef.Action_Create)) {
			for (Iterator<?> iter = labelListElement.getChildren().iterator(); iter.hasNext(); ) {
				Element label = (Element)iter.next();
				String labelID = label.getChildText(MsgConstants.TAG_LABELID);
				bindMap.put(MsgConstants.TAG_LABELID, labelID);
				IDMFrameServiceProxy.getSqlTemplate().update(SqlStatement.INSERT_BSLABELASSIGNFGCODE_ALL, bindMap);
			}
		}
		if (StringUtils.equals(actionType, PolicyDef.Action_Delete)) {
			for (Iterator<?> iter = labelListElement.getChildren().iterator(); iter.hasNext(); ) {
				Element label = (Element)iter.next();
				String labelID = label.getChildText(MsgConstants.TAG_LABELID);
				bindMap.put(MsgConstants.TAG_LABELID, labelID);
				IDMFrameServiceProxy.getSqlTemplate().update(SqlStatement.DELETE_BSLABELASSIGNFGCODE_BY_ID, bindMap);
			}
		}
	}
	
	/**
	 * 
	 * This function is labelAssignParameter
	 * @param doc
	 * @throws IDMFrameDBErrorSignal
	 * @throws CustomException
	 * @author ZXY Team. 
	 * @date 2022年5月6日
	 */
	public void labelAssignParameter(Document doc, EventInfo eventInfo) throws IDMFrameDBErrorSignal, CustomException{
		Element body = doc.getRootElement().getChild(MsgConstants.XPATH_TAG_BODY);
		Element labelListElement = body.getChild(MsgConstants.TAG_LABELLIST);
		if (labelListElement.getChildren() == null) {
			return;
		}
		
		String labelID = body.getChildText(MsgConstants.TAG_LABELID);
		Map<String, Object> bindMap = new HashMap<>();
		bindMap.put(MsgConstants.TAG_LABELID, labelID);
		
		List<Object[]> prams = new ArrayList<>();
		List<Object[]> pramsHis = new ArrayList<>();
		for (Iterator<?> iter = labelListElement.getChildren().iterator(); iter.hasNext(); ) {
			Element label = (Element)iter.next();
			String parameterName = label.getChildText(MsgConstants.TAG_PARAMETERNAME);
			String description = label.getChildText(MsgConstants.TAG_DESCRIPTION);
			prams.add(new Object[] {labelID,parameterName, description,eventInfo.getEventUser(),
					eventInfo.getEventName(),eventInfo.getEventComment(),eventInfo.getEventTimeKey(),eventInfo.getEventTime()});
			pramsHis.add(new Object[] {eventInfo.getEventTimeKey(),labelID,parameterName, description,eventInfo.getEventUser(),
					eventInfo.getEventName(),eventInfo.getEventComment(),eventInfo.getEventTime()});
		}
		
		try {
			IDMFrameServiceProxy.getTxDataSourceManager().beginTransaction();
			
			IDMFrameServiceProxy.getSqlTemplate().update(SqlStatement.DELETE_LABEL_PARAM, bindMap);
			IDMFrameServiceProxy.getSqlTemplate().updateBatch(SqlStatement.INSERT_LABEL_PARAM, prams);
			IDMFrameServiceProxy.getSqlTemplate().updateBatch(SqlStatement.INSERT_LABEL_PARAM_HIS, pramsHis);
			
			IDMFrameServiceProxy.getTxDataSourceManager().commitTransaction();
		} catch (Exception e) {
			IDMFrameServiceProxy.getTxDataSourceManager().rollbackTransaction();
			throw new CustomException(CustomExceptionCode.DATA_ERROR, "SQL Execute Error.");
		}
	}
	
	/**
	 * 
	 * This function is OIC Management labelPrintTest
	 * @param doc
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 * @throws CustomException
	 * @author ZXY Team. 
	 * @date 2022年5月6日
	 */
	public void labelPrintTest(Document doc) throws IllegalArgumentException, IllegalAccessException, JsonProcessingException, CustomException {
		Element body = doc.getRootElement().getChild(MsgConstants.XPATH_TAG_BODY);
//		String labelID = body.getChildText(MsgConstants.TAG_LABELID);
//		String labelGroup = body.getChildText(MsgConstants.TAG_LABELGROUP);
//		String labelType = body.getChildText(MsgConstants.TAG_LABELTYPE);
//		String labelDrive = body.getChildText(MsgConstants.TAG_LABELDRIVE);
//		String labelName = body.getChildText(MsgConstants.TAG_LABELNAME);
		String labelAddress = body.getChildText(MsgConstants.TAG_LABELADDRESS);
		String printer = body.getChildText(MsgConstants.TAG_PRINTERNAME);
		
		if (StringUtils.isEmpty(printer)) {
			printer = getDefaultPrinter();
		}
		String labelPath = getLabelAbsolutePath(labelAddress);
		
		PrintRequest pr = new PrintRequest();
		pr.setLibraryID(UUID.randomUUID().toString());
		pr.setAbsolutePath(labelPath);
		pr.setCopies(1);
		pr.setSerialNumbers(0);
		pr.setStartingPosition(0);
		pr.setPrinter(printer);
		pr.setPrintRequestID(UUID.randomUUID().toString());
		
		String requestUrl = CommonUtil.getEnumDefValueStringByEnumName(PolicyDef.Enum_LabelRequestURL);
		labelPrint(null, requestUrl, pr, null);
	}
	
	/**
	 * getDefaultPrinter
	 * @return
	 */
	private String getDefaultPrinter() {
		String enumValue = "";
    	String sql = "SELECT ENUMVALUE FROM ENUMDEFVALUE WHERE ENUMNAME = :enumName and defaultflag = 'Y' order by seq";

    	Map<String, String> bindMap = new HashMap<String, String>();
    	bindMap.put("enumName", "LabelPrinter");

    	List<Map<String, Object>> sqlResult = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bindMap);
    	if(sqlResult.size() > 0){
    		enumValue = sqlResult.get(0).get("ENUMVALUE").toString();
    	}

    	return enumValue;
	}

	/**
	 * getLabelAbsolutePath
	 * @param ftpAddress
	 * @return
	 */
	private String getLabelAbsolutePath(String ftpAddress) {
		String path = StringUtils.EMPTY;
		
		String[] split = ftpAddress.split("/");
		StringBuffer buf = new StringBuffer();
		for (int i = 3; i < split.length; i++) {
			buf.append("\\");
			buf.append(split[i]);
		}
		path = CommonUtil.getEnumDefValueStringByEnumName(PolicyDef.Enum_LabelPathPrefix);
		path += buf.toString();
		return path;
	}
	
	/**
	 * getLabelAssignParameter
	 * @param labelId
	 * @return
	 */
	private List<String> getLabelAssignParameter(String labelId){
		List<String> result = new ArrayList<String>();
		List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(SqlStatement.SELECT_LABEL_PARAM, labelId);
		for (Map<String, Object> map : queryForList) {
			result.add(map.get("PARAMETERNAME").toString());
		}
		return result;
	}
	
	/**
	 * getRequestUrlByServer
	 * @param server
	 * @return
	 */
	private String getRequestUrlByServer( String server )
    {
    	String enumValue = "";
    	String sql = "SELECT ENUMVALUE,SUPER FROM ENUMDEFVALUE WHERE ENUMNAME = :enumName order by seq";

    	Map<String, String> bindMap = new HashMap<String, String>();
    	bindMap.put("enumName", PolicyDef.Enum_LabelRequestURL);

    	List<Map<String, Object>> sqlResult = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bindMap);

    	if(sqlResult.size() > 0){
    		for (Map<String, Object> map : sqlResult) {
				if (map.get("SUPER") == null) {
					continue;
				}
				
				if (StringUtils.equals(server, map.get("SUPER").toString())) {
					enumValue = map.get("ENUMVALUE").toString();
					break;
				}
			}
    		
    		if (StringUtils.isEmpty(enumValue)) {
    			enumValue = sqlResult.get(0).get("ENUMVALUE").toString();
    		}
    	}
    	return enumValue;
    }
	
	/**
	 * labelPrint type
	 * 
	 * InnerBox
	 * OuterBox
	 * Pallet
	 * PalletList
	 * RMAPanel
	 * ModuleName
	 * ArriveMaterial
	 * RMABox
	 * VirtualLot
	 * 
	 * @param doc
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 * @throws CustomException
	 */
//	public void labelPrint(Document doc) throws IllegalArgumentException, IllegalAccessException, JsonProcessingException, CustomException {
//		Element body = doc.getRootElement().getChild(MsgConstants.XPATH_TAG_BODY);
//		String labelId = body.getChildText(MsgConstants.TAG_LABELID);
//		String labelType = body.getChildText(MsgConstants.TAG_LABELTYPE);
//		String labelAddress = body.getChildText(MsgConstants.TAG_LABELADDRESS);
//		String printer = body.getChildText(MsgConstants.TAG_PRINTERNAME);
//		String printQty = body.getChildText(MsgConstants.TAG_PRINTQTY);
//		String fgCode = body.getChildText(MsgConstants.TAG_PRODUCTSPECNAME);
//		String inputID = body.getChildText(MsgConstants.TAG_INPUTID);
//		String serialNumbers = body.getChildText(MsgConstants.TAG_SERIALNUMBERS);
//		String server = body.getChildText(MsgConstants.TAG_SERVER);
//		
//		String po = body.getChildText(MsgConstants.TAG_PO);
//		String materialSpec = body.getChildText(MsgConstants.TAG_MATERIALSPEC);
//		String materialDesc = body.getChildText(MsgConstants.TAG_MATERIALDESC);
//		String supplierName = body.getChildText(MsgConstants.TAG_SUPPLIERNAME);
//		String supplierID = body.getChildText(MsgConstants.TAG_SUPPLIERID);
//		String version = body.getChildText(MsgConstants.TAG_VERSION);
//		String quantity = body.getChildText(MsgConstants.TAG_QUANTITY);
////		String boxNumber = body.getChildText(MsgConstants.TAG_BOXNUMBER);
//		String dateInProduced = body.getChildText(MsgConstants.TAG_DATEINPRODUCED);
//		String expiryDate = body.getChildText(MsgConstants.TAG_EXPIRYDATE);
//		String expiryDay = body.getChildText(MsgConstants.TAG_EXPIRYDAY);
//		String lotNo = body.getChildText(MsgConstants.TAG_LOTNO);
//		String materialUnit = body.getChildText(MsgConstants.TAG_CONSUMABLEUNIT);
//		
//		if (StringUtils.isEmpty(printer)) {
//			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Printer.");
//		}
//		
//		String labelPath = getLabelAbsolutePath(labelAddress);
//		log.info("***************************PrintLabel Path is : " + labelPath);
//		List<String> params = getLabelAssignParameter(labelId);
//		log.info("***************************PrintLabel Assign params is : " + params.toString());
//		
//		PrintRequest pr = new PrintRequest();
//		pr.setLibraryID(UUID.randomUUID().toString());
//		pr.setAbsolutePath(labelPath);
//		pr.setCopies(Integer.parseInt(printQty));
//		pr.setSerialNumbers(0);
//		pr.setStartingPosition(0);
//		pr.setPrinter(printer);
//		pr.setPrintRequestID(UUID.randomUUID().toString());
//		
//		String requestUrl = getRequestUrlByServer(server);
//		log.info("***************************PrintLabel Use URL is : " + requestUrl);
//		
//		// Type dispatch
//		if (StringUtils.equals(labelType, PolicyDef.LabelType_InnerBox) 
//				|| StringUtils.equals(labelType, PolicyDef.LabelType_VirtualLot)
//				|| StringUtils.equals(labelType, PolicyDef.LabelType_RMABox)) {
//			ProcessGroup pgData = CommonUtil.getProcessGroupByProcesessGroupName(inputID);
//			printBoxLabel(fgCode,pgData,requestUrl,pr,params);
//		}
//		// calculate PanelQty
//		else if (StringUtils.equals(labelType, PolicyDef.LabelType_OuterBox)
//				|| StringUtils.equals(labelType, PolicyDef.LabelType_Pallet)) {
//			ProcessGroup pgData = CommonUtil.getProcessGroupByProcesessGroupName(inputID);
//			printBoxLabelCaculatePanelQty(fgCode, pgData, requestUrl, pr, params);
//		}
//		else if (StringUtils.equals(labelType, PolicyDef.LabelType_Lot)) {
//			Lot lotData = CommonUtil.getLotDataByLotName(inputID);
//			if (!StringUtils.equals(fgCode, lotData.getProductSpecName())) {
//				throw new CustomException(CustomExceptionCode.DATA_ERROR,"Data FGCode is Mismatch : "+ lotData.getProductSpecName());
//			}
//			labelPrint(lotData, requestUrl, pr, params);
//		}
//		else if (StringUtils.equals(labelType, PolicyDef.LabelType_RMAPanel)) {
//			pr.setSerialNumbers(Integer.parseInt(serialNumbers));
//			printRMAPanelLabel(fgCode,requestUrl,pr,params);
//		}
//		else if (StringUtils.equals(labelType, PolicyDef.LabelType_ModuleName)) {
//			pr.setSerialNumbers(Integer.parseInt(serialNumbers));
//			
//			Calendar now = Calendar.getInstance();
//			int year = now.get(Calendar.YEAR);
//			int month = now.get(Calendar.MONTH) +1;
//			int day = now.get(Calendar.DAY_OF_MONTH);
//			
//			String m = String.valueOf(month);
//			String ymd = getYMD(year, month, day);
//			
//			StringBuffer prams = new StringBuffer();
//			
//			switch (month) {
//			case 10:
//				prams.append("A");
//				m = "X";
//				break;
//			case 11:
//				prams.append("B");
//				m = "Y";
//				break;
//			case 12:
//				prams.append("C");
//				m = "Z";
//				break;
//			default:
//				prams.append(month);
//				break;
//			}
//			
//			prams.append(String.format("%02d",day));
//			
//			switch (year) {
//			case 2023:
//				prams.append("D");
//				break;
//			case 2024:
//				prams.append("E");
//				break;
//			case 2025:
//				prams.append("F");
//				break;
//			case 2026:
//				prams.append("G");
//				break;
//			case 2027:
//				prams.append("H");
//				break;
//			case 2028:
//				prams.append("I");
//				break;
//			case 2029:
//				prams.append("J");
//				break;
//			default:
//				String s = String.valueOf(year);
//				prams.append(s.substring(s.length()-1, s.length()));
//				break;
//			}
//			
//			LabelParameterObject obj = new LabelParameterObject();
//			obj.setMddy(prams.toString());
//			obj.setM(m);
//			obj.setYmd(ymd);
//			
//			labelPrint(obj, requestUrl, pr, params);
//		}
//		else if (StringUtils.equals(labelType, PolicyDef.LabelType_PalletList)) {
//			ProcessGroup pgData = CommonUtil.getProcessGroupByProcesessGroupName(inputID);
//			printPalletListLabel(fgCode,pgData,requestUrl,pr,params);
//		}
//		else if (StringUtils.equals(labelType, PolicyDef.LabelType_ArriveMaterial)) {
////			boxNumber = String.format("%04d", Integer.parseInt(boxNumber));
//			quantity = String.format("%04d", Integer.parseInt(quantity));
//			expiryDate = String.format("%02d", Integer.parseInt(expiryDate));
//			
//			StringBuffer snPrefixBuf = new StringBuffer();
//			snPrefixBuf.append(materialSpec);
//			snPrefixBuf.append("|");
//			snPrefixBuf.append(dateInProduced);
//			snPrefixBuf.append("|");
//			snPrefixBuf.append(expiryDay);
//			snPrefixBuf.append("|");
//			snPrefixBuf.append(supplierID);
////			snPrefixBuf.append(boxNumber);
//			snPrefixBuf.append("|");
//			
////			ConsumableSpec conSpecData = CommonUtil.getConsumableSpecData(materialSpec, PolicyDef.Factory_Default);
////			quantity = quantity + " " + conSpecData.getConsumeUnit();
//			
//			int count = 1;
//			if (StringUtils.isNotEmpty(serialNumbers)) {
//				count = Integer.parseInt(serialNumbers);
//			}
//			for (int i = 0; i < count; i++) {
//				ExtendedObjectProxy.getNameRuleAttrService().checkMinSplit(PolicyDef.NamingRule_ArriveMaterialSNPrefix, snPrefixBuf.toString());
//				String snPrefix = NameServiceProxy.getNameRuleDefService().generateSplitName(PolicyDef.NamingRule_ArriveMaterialSNPrefix, snPrefixBuf.toString(), new ArrayList<>());
//				
//				String sn = snPrefix.substring(snPrefix.length() - 3, snPrefix.length());
//				
//				LabelParameterObject obj = new LabelParameterObject();
//				obj.setPo(po);
//				obj.setSupplierName(supplierName);
//				obj.setSupplierID(supplierID);
//				obj.setMaterialDesc(materialDesc);
//				obj.setMaterialSpec(materialSpec);
//				obj.setVersion(version);
//				obj.setQuantity(quantity);
//				obj.setRealQuantity(quantity);
//				obj.setDateInProduced(dateInProduced);
//				obj.setExpiryDate(expiryDate);
//				obj.setExpiryDay(expiryDay);
//				obj.setLotNo(lotNo);
//				obj.setSn(sn);
//				obj.setMaterialUnit(materialUnit);
//				
//				labelPrint(obj, requestUrl, pr, params);
//			}
//		}
//		else {
//			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Undefined Execute Type : "+ labelType);
//		}
//		
//	}

	/**
	 * printRMAPanelLabel
	 * @param fgCode
	 * @param requestUrl
	 * @param pr
	 * @param params
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 * @throws CustomException
	 */
	private void printRMAPanelLabel(String fgCode, String requestUrl, PrintRequest pr, List<String> params) throws IllegalArgumentException, IllegalAccessException, JsonProcessingException, CustomException {
		LabelParameterObject obj = new LabelParameterObject();
		obj.setProductSpecName(fgCode);
		
		Timestamp now = TimeStampUtil.getCurrentTimestamp();
		SimpleDateFormat st = new SimpleDateFormat("yyyy/MM/dd HH:mm");
		obj.setDateTime(st.format(now));
		
		labelPrint(obj, requestUrl, pr, params);
	}

	/**
	 * printBoxLabel
	 * @param fgCode
	 * @param pgData
	 * @param requestUrl
	 * @param pr
	 * @param params
	 * @throws CustomException
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 */
//	private void printBoxLabel(String fgCode, ProcessGroup pgData, String requestUrl, PrintRequest pr, List<String> params) throws CustomException, IllegalArgumentException, IllegalAccessException, JsonProcessingException {
////		if (!StringUtils.equals(fgCode, pgData.getProductSpecName())) {
////			throw new CustomException(CustomExceptionCode.DATA_ERROR,"Data FGCode is Mismatch : "+ pgData.getProductSpecName());
////		}
//		
//		labelPrint(pgData, requestUrl, pr, params);
//	}
	
	/**
	 * printPalletListLabel
	 * @param fgCode
	 * @param pgData
	 * @param requestUrl
	 * @param pr
	 * @param params
	 * @throws CustomException
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 */
//	private void printPalletListLabel(String fgCode, ProcessGroup pgData, String requestUrl, PrintRequest pr, List<String> params) throws CustomException, IllegalArgumentException, IllegalAccessException, JsonProcessingException {
////		if (!StringUtils.equals(fgCode, pgData.getProductSpecName())) {
////			throw new CustomException(CustomExceptionCode.DATA_ERROR,"Data FGCode is Mismatch : "+ pgData.getProductSpecName());
////		}
//		List<ProcessGroup> listData = ProcessGroupServiceProxy.getProcessGroupService().allProcessGroupsBySuperProcessGroup(pgData.getKey().getProcessGroupName());
//		listData = listData.stream().sorted((e1,e2) -> {
//			return e1.getKey().getProcessGroupName().compareTo(e2.getKey().getProcessGroupName());
//		}).collect(Collectors.toList());
//		int count = listData.size();
//		int printQty = (count / 20 ) + 1;
//		
//		for (int i = 0; i < printQty; i++) {
//			LabelParameterObject obj = new LabelParameterObject();
//			obj.setMaterialQuantity(String.valueOf(20));
//			int parameterPrint = count - (printQty * 20);
//			if (parameterPrint < 0) {
//				parameterPrint = count % 20;
//				obj.setMaterialQuantity(String.valueOf(parameterPrint));
//			}
//			else {
//				parameterPrint = 20;
//			}
//			for (int j = 0; j < parameterPrint; j++) {
//				ObjectUtil.copyFieldValue( ObjectUtil.getField(obj, "boxName" + (j+1)), obj,  listData.get(i*20 + j).getKey().getProcessGroupName());
//			}
//			
//			if (parameterPrint < 20) {
//				for (int j = parameterPrint; j < 20; j++) {
//					ObjectUtil.copyFieldValue( ObjectUtil.getField(obj, "boxName" + (j+1)), obj,  "");
//				}
//			}
//			
//			labelPrint(obj, requestUrl, pr, params);
//		}
//		
//	}
//	
	/**
	 * printBoxLabelCaculatePanelQty
	 * @param fgCode
	 * @param pgData
	 * @param requestUrl
	 * @param pr
	 * @param params
	 * @throws CustomException
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 */
//	private void printBoxLabelCaculatePanelQty(String fgCode, ProcessGroup pgData, String requestUrl, PrintRequest pr, List<String> params) throws CustomException, IllegalArgumentException, IllegalAccessException, JsonProcessingException {
////		if (!StringUtils.equals(fgCode, pgData.getProductSpecName())) {
////			throw new CustomException(CustomExceptionCode.DATA_ERROR,"Data FGCode is Mismatch : "+ pgData.getProductSpecName());
////		}
//		List<Map<String, Object>> result = IDMFrameServiceProxy.getSqlTemplate().queryForList(SqlStatement.SELECT_LOTNAME_BY_GROUP, pgData.getKey().getProcessGroupName());
//		pgData.setMaterialQuantity(result.size());
//		
//		labelPrint(pgData, requestUrl, pr, params);
//	}

	/**
	 * 货位打印
	 */
	public String storagePrint(StoragePrintDto data) throws IllegalArgumentException, CustomException {
		// 获取数据
		StorageSpecKey storageSpecKey = new StorageSpecKey();
		storageSpecKey.setStorageName(data.getStorageName());
		storageSpecKey.setSiteName(data.getSiteName());
		StorageSpec storageSpec = null;
		try {
			storageSpec = StorageServiceProxy.getStorageSpecService().selectByKey(storageSpecKey);
		} catch (Exception e) {
			throw new CustomException("未找到该货位！");
		}
		StorageObject storageObject = new StorageObject();
		storageObject.setCODE(storageSpec.getKey().getStorageName());
		storageObject.setNAME(storageSpec.getDescription());

		// 打印机数据
		// 名称
		String printer = CharSequenceUtil.isEmpty(data.getPrinterName())
				? getDefaultPrinter() : data.getPrinterName();
		// 地址
		String requestUrl = getRequestUrlByServer("LabelRequestURL");
		// 参数（BSLABELASSIGNPARAMETER 表中映射关系）
		List<String> params = getLabelAssignParameter("storageLabel001");
		// 模板
		String labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\storage.btw";

		// 打印请求
		PrintRequest pr = new PrintRequest();
		pr.setLibraryID(UUID.randomUUID().toString());
		pr.setAbsolutePath(labelPath);
		pr.setCopies(1);
		pr.setSerialNumbers(0);
		pr.setStartingPosition(0);
		pr.setPrinter(printer);
		pr.setPrintRequestID(UUID.randomUUID().toString());
		return labelPrint(storageObject, requestUrl, pr, params);
	}
	
	/**
	 * rePrintArriveMaterial
	 * @param UserId
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 * @throws CustomException
	 */
	public String rePrintArriveMaterial(String MaterialPackingName,String UserId,String printName) throws IllegalArgumentException, IllegalAccessException, JsonProcessingException, CustomException {
//		String labelType = body.getChildText(MsgConstants.TAG_LABELTYPE);
		String labelAddress ="Sdk2.btw"  ;
		String printer = printName == null || "".equals(printName) ? getDefaultPrinter() : printName;//	"\\\\ZXYNB10810864P.boe.com.cn\\TSC MA3400P";
		String server = "LabelRequestURL";
		String MATERIALPACKINGNAME = MaterialPackingName;
		
		
//		if (StringUtils.isEmpty(printer)) {
//			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Printer.");
//		}
		String sql = "SELECT\r\n" + 
				"					m.MATERIALPACKINGNAME barcode,m2.materialtype,\r\n" + 
				"					m.MATERIALSPECNAME partNo,\r\n" + 
				"					m.PHASE state,\r\n" + 
				"					ss.SPECNAME sdkSpec,\r\n" + 
				"					m2.DESC_CN partName,m2.description,\r\n" + 
				"					m.TRUEGG PracticalSpec,\r\n" + 
				"					m.MATERIALQUANTITY || ' ' || m3.FNAME qty,\r\n" + 
				"					m.RECEIVEREQUESTNAME orderNo,\r\n" + 
				"					m.RECEIVEUSER operater,\r\n" + 
				"					m.CHARGE lotNo,NVL(m.suppliername,'') supplierNo,\r\n" + 
				"					m.REMARK remark,TO_CHAR(m.RECEIVETIME,'YYYYMMDD') jumboRollBatch,"
				+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate\r\n" + 
				"FROM\r\n" + 
				"					MATERIALPACKING m\r\n" + 
				"LEFT JOIN SDK_SPEC ss ON\r\n" + 
				"					m.SDK_ID = ss.SDK_ID\r\n" + 
				"LEFT JOIN MATERIALSPEC m2 ON\r\n" + 
				"					m.MATERIALSPECNAME = m2.MATERIALSPECNAME\r\n" + 
				"LEFT JOIN MATERIALUNIT m3 ON\r\n" + 
				"	m.UNIT = m3.FNUMBER\r\n" + 
				"WHERE\r\n" + 
				"	m.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
		Map<String, Object> hashMap = new HashMap<String,Object> ();
		hashMap.put("MATERIALPACKINGNAME", MATERIALPACKINGNAME);
		List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap);
		
		
		
		List<String> params = getLabelAssignParameter("testLabel002");
		log.info("***************************PrintLabel Assign params is : " + params.toString());
		
		if (queryForList == null || queryForList.size() < 1) {
			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Undefined Execute Type : ");
		} else {
			String materialType =queryForList.get(0).get("materialtype").toString(); 
			if (materialType !=  null && (materialType.startsWith("103")  || materialType.startsWith("106")  || materialType.startsWith("260"))) {
				labelAddress = "胶水原材.btw";
			}
		}
		String labelPath = getLabelAbsolutePath(labelAddress);
		labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\WMS\\" + labelAddress;
		log.info("***************************PrintLabel Path is : " + labelPath);
		PrintRequest pr = new PrintRequest();
		pr.setLibraryID(UUID.randomUUID().toString());
		pr.setAbsolutePath(labelPath);
		pr.setCopies(1);
		pr.setSerialNumbers(0);
		pr.setStartingPosition(0);
		pr.setPrinter(printer);
		pr.setPrintRequestID(UUID.randomUUID().toString());
		
		String requestUrl = getRequestUrlByServer(server);
		log.info("***************************PrintLabel Use URL is : " + requestUrl);
		String labelUrl = "";
		if (queryForList != null && queryForList.size() > 0) {
			LabelParameterObject obj = new LabelParameterObject();
//			obj.setReceiverequestname(queryForList.get(0).get("RECEIVEREQUESTNAME") != null ? queryForList.get(0).get("RECEIVEREQUESTNAME").toString() : "");
//			obj.setMaterialpackingname(queryForList.get(0).get("MATERIALPACKINGNAME") != null ? queryForList.get(0).get("MATERIALPACKINGNAME").toString() : "");
//			obj.setMaterialSpec(queryForList.get(0).get("MATERIALSPEC") != null ? queryForList.get(0).get("MATERIALSPEC").toString() : "");
//			obj.setMaterialspecname(queryForList.get(0).get("MATERIALSPECNAME") != null ? queryForList.get(0).get("MATERIALSPECNAME").toString() : "");
//			obj.setDesc_cn(queryForList.get(0).get("DESC_CN") != null ? queryForList.get(0).get("DESC_CN").toString() : "");
//			obj.setSupplierno(queryForList.get(0).get("SUPPLIERNO") != null ? queryForList.get(0).get("SUPPLIERNO").toString() : "");
//			obj.setSupplierName(queryForList.get(0).get("SUPPLIERNAME") != null ? queryForList.get(0).get("SUPPLIERNAME").toString() : "");
//			obj.setMakedate(queryForList.get(0).get("MAKEDATE") != null ? queryForList.get(0).get("MAKEDATE").toString() : "");
//			obj.setExpiringdate(queryForList.get(0).get("EXPIRINGDATE") != null ? queryForList.get(0).get("EXPIRINGDATE").toString() : "");
//			obj.setExpirationday(queryForList.get(0).get("EXPIRATIONDAY") != null ? queryForList.get(0).get("EXPIRATIONDAY").toString() : "");
//			obj.setQrcode(queryForList.get(0).get("QRCODE") != null ? queryForList.get(0).get("QRCODE").toString() : "");
//			obj.setErplocation(queryForList.get(0).get("ERPLOCATION") != null ? queryForList.get(0).get("ERPLOCATION").toString() : "");
//			obj.setMaterialQuantity(queryForList.get(0).get("MATERIALQUANTITY") != null ? queryForList.get(0).get("MATERIALQUANTITY").toString() : "");
			
			//**********************************************************斯迪克字段************************************************//
			//**********************************************************斯迪克字段************************************************//
			//**********************************************************斯迪克字段************************************************//
//			private String  barcode;
			obj.setBarcode(queryForList.get(0).get("barcode") != null ? queryForList.get(0).get("barcode").toString() : "");
			obj.setMakedate(queryForList.get(0).get("makedate") != null ? queryForList.get(0).get("makedate").toString() : "");
			obj.setExpdate(queryForList.get(0).get("expdate") != null ? queryForList.get(0).get("expdate").toString() : "");
			obj.setDescription(queryForList.get(0).get("description") != null ? queryForList.get(0).get("description").toString() : "");
//			private String  partNo;
			obj.setPartNo(queryForList.get(0).get("partNo") != null ? queryForList.get(0).get("partNo").toString() : "");
//			private String  state;
			obj.setState(queryForList.get(0).get("state") != null ? queryForList.get(0).get("state").toString() : "");
//			private String  sdkSpec;
			obj.setSdkSpec(queryForList.get(0).get("sdkSpec") != null ? queryForList.get(0).get("sdkSpec").toString() : "");
//			private String  partName;
			obj.setPartName(queryForList.get(0).get("partName") != null ? queryForList.get(0).get("partName").toString() : "");
//			private String  ParticalSpec;
			obj.setPracticalSpec(queryForList.get(0).get("PracticalSpec") != null ? queryForList.get(0).get("PracticalSpec").toString() : "");
//			private String  qty;
			obj.setQty(queryForList.get(0).get("qty") != null ? queryForList.get(0).get("qty").toString() : "");
//			private String  orderNo;
			obj.setOrderNo(queryForList.get(0).get("orderNo") != null ? queryForList.get(0).get("orderNo").toString() : "");
//			private String  operater;
			//obj.setOperater(queryForList.get(0).get("operater") != null ? queryForList.get(0).get("operater").toString() : "");
			obj.setOpreater(UserId);
//			private String  lotNo;
			obj.setLotNo(queryForList.get(0).get("lotNo") != null ? queryForList.get(0).get("lotNo").toString() : "");
//			private String  remark;
			obj.setRemark(queryForList.get(0).get("remark") != null ? queryForList.get(0).get("remark").toString() : "");
//			obj.setJumboRollBatch(queryForList.get(0).get("jumboRollBatch") != null ? queryForList.get(0).get("jumboRollBatch").toString() : "");
			obj.setJumboRollBatch(queryForList.get(0).get("makedate") != null ? queryForList.get(0).get("makedate").toString() : "");
			obj.setSupplierno(queryForList.get(0).get("supplierNo") != null ? queryForList.get(0).get("supplierNo").toString() : "");
			obj.setOperater(queryForList.get(0).get("OPERATER") != null ? queryForList.get(0).get("OPERATER").toString() : "");
			labelUrl = labelPrint(obj, requestUrl, pr, params);
			
		}
		return labelUrl;
	}
	

	public void rePrintArriveMaterial1(String MaterialPackingName,String UserId,String printName,String DESC_CN,String labelType) throws IllegalArgumentException, IllegalAccessException, JsonProcessingException, CustomException {
		String sql = "";
//		String labelAddress ="Sdk2.btw"  ;
		String labelAddress = labelType;
		String MATERIALPACKINGNAME = MaterialPackingName;
		String printer = printName == null || "".equals(printName) ? getDefaultPrinter() : printName;//	"\\\\ZXYNB10810864P.boe.com.cn\\TSC MA3400P";
		String server = "LabelRequestURL";
		String requestUrl = getRequestUrlByServer(server);
		List<String> params = getLabelAssignParameter("testLabel002");

		String labelPath = getLabelAbsolutePath(labelAddress);
		labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\WMS\\" + labelAddress;
		log.info("***************************PrintLabel Path is : " + labelPath);
		PrintRequest pr = new PrintRequest();
		pr.setLibraryID(UUID.randomUUID().toString());
		pr.setAbsolutePath(labelPath);
		pr.setCopies(1);
		pr.setSerialNumbers(0);
		pr.setStartingPosition(0);
		pr.setPrinter(printer);
		pr.setPrintRequestID(UUID.randomUUID().toString());

		//czy-2024-9-13-增加成品标签模板
		List<Map<String, Object>> queryForListProduct = new ArrayList<>();
		if(labelAddress != null && (labelAddress.equals("SDK_02.btw") || labelAddress.equals("SDK_01.btw") || labelAddress.equals("10成品发货标签英文.btw"))) {
			sql = "SELECT \n" +
					"\tM.MATERIALPACKINGNAME ,\n" +
					"\tL.BARCODE barcode,\n" +
					"\tL.MATERIALCODE materialCode,\n" +
					"\tL.STAGECODE stageCode,\n" +
					"\tL.SDKSPECIFICATIONS sdkSpecifications,\n" +
					"\tL.MATERIALNAME materialname,\n" +
					"\tL.SPECIFICATIONS specifications,\n" +
					"\tL.PRACTICALSPEC PracticalSpec,\n" +
					"\tL.SOURCEORDER sourceOrder,\n" +
					"\tM.MATERIALPACKINGNAME jumboRollBatch,\n" +
					"\tL.BATCH batch,\n" +
					"\tL.CUSTOMERCODE customerCode,\n" +
					"\tL.MAINQTY mainQty,\n" +
					"\tL.MAINUOM mainUom,\n" +
					"\tL.OPERATOR operator,\n" +
					"\tL.OPERATOR operatorJumbo,\n" +
					"\tL.DEFINEITEM9 defineItem9,\n" +
					"\tL.REMARKS remarks,\n" +
					"\tL.ITEM1 item1,\n" +
					"\tL.ITEM2 item2,\n" +
					"\tL.ITEM3 item3,\n" +
					"\tL.ITEM4 item4,\n" +
					"\tL.ITEM5 item5\n" +
					"FROM MATERIALPACKING M \n" +
					"LEFT JOIN BS_MES_LABELPRINTINFO L\n" +
					"ON M.CHARGE = L.BATCH\n" +
					"AND M.MATERIALSPECNAME = L.MATERIALCODE\n" +
					"WHERE M.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
			Map<String, Object> hashMap = new HashMap<String,Object> ();
			hashMap.put("MATERIALPACKINGNAME", MATERIALPACKINGNAME);
			queryForListProduct = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap);
			if (queryForListProduct != null && queryForListProduct.size() > 0) {
				LabelParameterObject obj = new LabelParameterObject();
				obj.setBarcode(queryForListProduct.get(0).get("barcode") == null ? "" : queryForListProduct.get(0).get("barcode").toString());
				obj.setMaterialCode(queryForListProduct.get(0).get("materialCode") == null ? "" : queryForListProduct.get(0).get("materialCode").toString());
				obj.setStageCode(queryForListProduct.get(0).get("stageCode") == null ? "" : queryForListProduct.get(0).get("stageCode").toString());
				obj.setSdkSpecifications(queryForListProduct.get(0).get("sdkSpecifications") == null ? "" : queryForListProduct.get(0).get("sdkSpecifications").toString());
				obj.setMaterialname(queryForListProduct.get(0).get("materialName") == null ? "" : queryForListProduct.get(0).get("materialName").toString());
				obj.setSpecifications(queryForListProduct.get(0).get("specifications") == null ? "" : queryForListProduct.get(0).get("specifications").toString());
				obj.setPracticalSpec(queryForListProduct.get(0).get("PracticalSpec") == null ? "" : queryForListProduct.get(0).get("PracticalSpec").toString());
				obj.setSourceOrder(queryForListProduct.get(0).get("sourceOrder") == null ? "" : queryForListProduct.get(0).get("sourceOrder").toString());
				obj.setCustomerCode(queryForListProduct.get(0).get("mainQty") == null ? "" : queryForListProduct.get(0).get("mainQty").toString());
				obj.setMainQty(queryForListProduct.get(0).get("stageCode") == null ? "" : queryForListProduct.get(0).get("stageCode").toString());
				obj.setMainUom(queryForListProduct.get(0).get("mainUom") == null ? "" : queryForListProduct.get(0).get("mainUom").toString());
				obj.setOperator(queryForListProduct.get(0).get("operator") == null ? "" : queryForListProduct.get(0).get("operator").toString());
				obj.setOperatorJumbo(queryForListProduct.get(0).get("operatorJumbo") == null ? "" : queryForListProduct.get(0).get("operatorJumbo").toString());
				obj.setDefineItem9(queryForListProduct.get(0).get("defineItem9") == null ? "" : queryForListProduct.get(0).get("defineItem9").toString());
				obj.setRemarks(queryForListProduct.get(0).get("remarks") == null ? "" : queryForListProduct.get(0).get("remarks").toString());
				obj.setItem1(queryForListProduct.get(0).get("item1") == null ? "" : queryForListProduct.get(0).get("item1").toString());
				obj.setItem2(queryForListProduct.get(0).get("item2") == null ? "" : queryForListProduct.get(0).get("item2").toString());
				obj.setItem3(queryForListProduct.get(0).get("item3") == null ? "" : queryForListProduct.get(0).get("item3").toString());
				obj.setItem4(queryForListProduct.get(0).get("item4") == null ? "" : queryForListProduct.get(0).get("item4").toString());
				obj.setItem5(queryForListProduct.get(0).get("item5") == null ? "" : queryForListProduct.get(0).get("item5").toString());
				labelPrint(obj, requestUrl, pr, params);
			}
		}


//		if (StringUtils.isEmpty(printer)) {
//			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Printer.");
//		}

		sql = "SELECT\r\n" +
				"					m.MATERIALPACKINGNAME barcode,m2.materialtype,\r\n" + 
				"					m.MATERIALSPECNAME partNo,\r\n" + 
				"					m.PHASE state,\r\n" + 
				"					ss.SPECNAME sdkSpec,\r\n" + 
				"					m2.DESC_CN partName,m2.description,\r\n" + 
				"					m.TRUEGG PracticalSpec,\r\n" + 
				"					m.MATERIALQUANTITY || ' ' || m3.FNAME qty,\r\n" + 
				"					m.RECEIVEREQUESTNAME orderNo,\r\n" + 
				"					m.RECEIVEUSER operater,\r\n" + 
				"					m.CHARGE lotNo,NVL(m.suppliername,'') supplierNo,\r\n" + 
				"					m.REMARK remark,TO_CHAR(m.RECEIVETIME,'YYYYMMDD') jumboRollBatch,"
				+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER  opreater\r\n" + 
				"FROM\r\n" + 
				"					MATERIALPACKING m\r\n" + 
				"LEFT JOIN SDK_SPEC ss ON\r\n" + 
				"					m.SDK_ID = ss.SDK_ID\r\n" + 
				"LEFT JOIN MATERIALSPEC m2 ON\r\n" + 
				"					m.MATERIALSPECNAME = m2.MATERIALSPECNAME\r\n" + 
				"LEFT JOIN MATERIALUNIT m3 ON\r\n" + 
				"	m.UNIT = m3.FNUMBER\r\n" + 
				"WHERE\r\n" + 
				"	m.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
		Map<String, Object> hashMap = new HashMap<String,Object> ();
		hashMap.put("MATERIALPACKINGNAME", MATERIALPACKINGNAME);
		List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap);

		log.info("***************************PrintLabel Assign params is : " + params.toString());
		if (queryForList == null || queryForList.size() < 1) {
			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Undefined Execute Type : ");
		} else {
			String materialType =queryForList.get(0).get("materialtype").toString();
			if (materialType !=  null && (materialType.startsWith("103")  || materialType.startsWith("106")  || materialType.startsWith("260"))) {
				labelAddress = "胶水原材.btw";
			}
		}


		log.info("***************************PrintLabel Use URL is : " + requestUrl);
		if (queryForList != null && queryForList.size() > 0) {
			LabelParameterObject obj = new LabelParameterObject();
//			obj.setReceiverequestname(queryForList.get(0).get("RECEIVEREQUESTNAME") != null ? queryForList.get(0).get("RECEIVEREQUESTNAME").toString() : "");
//			obj.setMaterialpackingname(queryForList.get(0).get("MATERIALPACKINGNAME") != null ? queryForList.get(0).get("MATERIALPACKINGNAME").toString() : "");
//			obj.setMaterialSpec(queryForList.get(0).get("MATERIALSPEC") != null ? queryForList.get(0).get("MATERIALSPEC").toString() : "");
//			obj.setMaterialspecname(queryForList.get(0).get("MATERIALSPECNAME") != null ? queryForList.get(0).get("MATERIALSPECNAME").toString() : "");
//			obj.setDesc_cn(queryForList.get(0).get("DESC_CN") != null ? queryForList.get(0).get("DESC_CN").toString() : "");
//			obj.setSupplierno(queryForList.get(0).get("SUPPLIERNO") != null ? queryForList.get(0).get("SUPPLIERNO").toString() : "");
//			obj.setSupplierName(queryForList.get(0).get("SUPPLIERNAME") != null ? queryForList.get(0).get("SUPPLIERNAME").toString() : "");
//			obj.setMakedate(queryForList.get(0).get("MAKEDATE") != null ? queryForList.get(0).get("MAKEDATE").toString() : "");
//			obj.setExpiringdate(queryForList.get(0).get("EXPIRINGDATE") != null ? queryForList.get(0).get("EXPIRINGDATE").toString() : "");
//			obj.setExpirationday(queryForList.get(0).get("EXPIRATIONDAY") != null ? queryForList.get(0).get("EXPIRATIONDAY").toString() : "");
//			obj.setQrcode(queryForList.get(0).get("QRCODE") != null ? queryForList.get(0).get("QRCODE").toString() : "");
//			obj.setErplocation(queryForList.get(0).get("ERPLOCATION") != null ? queryForList.get(0).get("ERPLOCATION").toString() : "");
//			obj.setMaterialQuantity(queryForList.get(0).get("MATERIALQUANTITY") != null ? queryForList.get(0).get("MATERIALQUANTITY").toString() : "");
			//**********************************************************斯迪克字段************************************************//
			//**********************************************************斯迪克字段************************************************//
			//**********************************************************斯迪克字段************************************************//
//			private String  barcode;
			obj.setBarcode(queryForList.get(0).get("barcode") != null ? queryForList.get(0).get("barcode").toString() : "");
			obj.setMakedate(queryForList.get(0).get("makedate") != null ? queryForList.get(0).get("makedate").toString() : "");
			obj.setExpdate(queryForList.get(0).get("expdate") != null ? queryForList.get(0).get("expdate").toString() : "");
			obj.setDescription(queryForList.get(0).get("description") != null ? queryForList.get(0).get("description").toString() : "");
//			private String  partNo;
			obj.setPartNo(queryForList.get(0).get("partNo") != null ? queryForList.get(0).get("partNo").toString() : "");
//			private String  state;
			obj.setState(queryForList.get(0).get("state") != null ? queryForList.get(0).get("state").toString() : "");
//			private String  sdkSpec;
			obj.setSdkSpec(queryForList.get(0).get("sdkSpec") != null ? queryForList.get(0).get("sdkSpec").toString() : "");
//			private String  partName;
//			obj.setPartName(queryForList.get(0).get("partName") != null ? queryForList.get(0).get("partName").toString() : "");
			if (!"".equals(DESC_CN) && DESC_CN != "") {
				obj.setPartName(DESC_CN);
			} else {
				obj.setPartName(queryForList.get(0).get("partName") != null ? queryForList.get(0).get("partName").toString() : "");
			}
			//private String  ParticalSpec;
			obj.setPracticalSpec(queryForList.get(0).get("PracticalSpec") != null ? queryForList.get(0).get("PracticalSpec").toString() : "");
//			private String  qty;
			obj.setQty(queryForList.get(0).get("qty") != null ? queryForList.get(0).get("qty").toString() : "");
//			private String  orderNo;
			obj.setOrderNo(queryForList.get(0).get("orderNo") != null ? queryForList.get(0).get("orderNo").toString() : "");
//			private String  operater;
			obj.setOpreater(queryForList.get(0).get("operater") != null ? queryForList.get(0).get("operater").toString() : "");
//			obj.setOpreater(UserId);
//			private String  lotNo;
			obj.setLotNo(queryForList.get(0).get("lotNo") != null ? queryForList.get(0).get("lotNo").toString() : "");
//			private String  remark;
			obj.setRemark(queryForList.get(0).get("remark") != null ? queryForList.get(0).get("remark").toString() : "");
//			obj.setJumboRollBatch(queryForList.get(0).get("jumboRollBatch") != null ? queryForList.get(0).get("jumboRollBatch").toString() : "");
			obj.setJumboRollBatch(queryForList.get(0).get("makedate") != null ? queryForList.get(0).get("makedate").toString() : "");
			obj.setSupplierno(queryForList.get(0).get("supplierNo") != null ? queryForList.get(0).get("supplierNo").toString() : "");
			labelPrint(obj, requestUrl, pr, params);
		}
	}
	
	/**
	 * rePrintArriveMaterial
	 * @param UserId
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 * @throws CustomException
	 */
	public void rePrintArriveMaterial2(String MaterialPackingName,String UserId,String printName,String qty) throws IllegalArgumentException, IllegalAccessException, JsonProcessingException, CustomException {
//		String labelType = body.getChildText(MsgConstants.TAG_LABELTYPE);
		String labelAddress ="Sdk2.btw"  ;
		String printer = printName == null || "".equals(printName) ? getDefaultPrinter() : printName;//	"\\\\ZXYNB10810864P.boe.com.cn\\TSC MA3400P";
		String server = "LabelRequestURL";
		String MATERIALPACKINGNAME = MaterialPackingName;
		
		Map<String, Object> hashMap1 = new HashMap<String,Object> ();
		String qrsql = "SELECT M.QTY FROM BS_MES_SHIPPED M WHERE M.LOTNAME = :LOTNAME";
		hashMap1.put("LOTNAME", MATERIALPACKINGNAME);
		List<Map<String, Object>> queryForList1 = IDMFrameServiceProxy.getSqlTemplate().queryForList(qrsql, hashMap1);
		
		if (queryForList1 == null || queryForList1.size() < 1) {
			throw new CustomException("标签没查到");
		} 
		
//		if (StringUtils.isEmpty(printer)) {
//			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Printer.");
//		}
		String sql = "SELECT\r\n" + 
				"									m.LOTNAME barcode,m2.materialtype,\r\n" + 
				"									m.PRODUCTSPECNAME partNo,\r\n" + 
				"									m.PHASE state,\r\n" + 
				"									ss.SPECNAME sdkSpec,\r\n" + 
				"									m2.DESC_CN partName,m2.description,\r\n" + 
				"									m.TRUEGG PracticalSpec,\r\n" + 
				"									:QTY || ' ' || m3.FNAME qty,\r\n" + 
				"									m.REQUESTNAME orderNo,\r\n" + 
				"									m.SHIPUSER operater,\r\n" + 
				"									m.CHARGE lotNo,NVL(NULL,'') supplierNo,\r\n" + 
				"									m.REMARK remark,TO_CHAR(m.SHIPTIME,'YYYYMMDD') jumboRollBatch,\r\n" + 
				"				TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(m.MAKEDATE  + m2.EXPIRATIONDAY,'YYYYMMDD') expdate\r\n" + 
				"				FROM\r\n" + 
				"									BS_MES_SHIPPED m\r\n" + 
				"				LEFT JOIN SDK_SPEC ss ON\r\n" + 
				"									m.SDK_ID = ss.SDK_ID\r\n" + 
				"				LEFT JOIN MATERIALSPEC m2 ON\r\n" + 
				"									m.PRODUCTSPECNAME = m2.MATERIALSPECNAME\r\n" + 
				"				LEFT JOIN MATERIALUNIT m3 ON\r\n" + 
				"					m.UNIT = m3.FNUMBER\r\n" + 
				"				WHERE\r\n" + 
				"					m.LOTNAME = :MATERIALPACKINGNAME";
		Map<String, Object> hashMap = new HashMap<String,Object> ();
		hashMap.put("MATERIALPACKINGNAME", MATERIALPACKINGNAME);
		hashMap.put("QTY", qty);
		List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap);
		
		
		
		List<String> params = getLabelAssignParameter("testLabel002");
		log.info("***************************PrintLabel Assign params is : " + params.toString());
		
		if (queryForList == null || queryForList.size() < 1) {
			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Undefined Execute Type : ");
		} else {
			if ("103".equals(queryForList.get(0).get("materialtype").toString()) || "106".equals(queryForList.get(0).get("materialtype").toString())) {
				labelAddress = "胶水原材.btw";
			}
		}
		String labelPath = getLabelAbsolutePath(labelAddress);
		labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\WMS\\" + labelAddress;
		log.info("***************************PrintLabel Path is : " + labelPath);
		PrintRequest pr = new PrintRequest();
		pr.setLibraryID(UUID.randomUUID().toString());
		pr.setAbsolutePath(labelPath);
		pr.setCopies(1);
		pr.setSerialNumbers(0);
		pr.setStartingPosition(0);
		pr.setPrinter(printer);
		pr.setPrintRequestID(UUID.randomUUID().toString());
		
		String requestUrl = getRequestUrlByServer(server);
		log.info("***************************PrintLabel Use URL is : " + requestUrl);
		
		if (queryForList != null && queryForList.size() > 0) {
			LabelParameterObject obj = new LabelParameterObject();
//			obj.setReceiverequestname(queryForList.get(0).get("RECEIVEREQUESTNAME") != null ? queryForList.get(0).get("RECEIVEREQUESTNAME").toString() : "");
//			obj.setMaterialpackingname(queryForList.get(0).get("MATERIALPACKINGNAME") != null ? queryForList.get(0).get("MATERIALPACKINGNAME").toString() : "");
//			obj.setMaterialSpec(queryForList.get(0).get("MATERIALSPEC") != null ? queryForList.get(0).get("MATERIALSPEC").toString() : "");
//			obj.setMaterialspecname(queryForList.get(0).get("MATERIALSPECNAME") != null ? queryForList.get(0).get("MATERIALSPECNAME").toString() : "");
//			obj.setDesc_cn(queryForList.get(0).get("DESC_CN") != null ? queryForList.get(0).get("DESC_CN").toString() : "");
//			obj.setSupplierno(queryForList.get(0).get("SUPPLIERNO") != null ? queryForList.get(0).get("SUPPLIERNO").toString() : "");
//			obj.setSupplierName(queryForList.get(0).get("SUPPLIERNAME") != null ? queryForList.get(0).get("SUPPLIERNAME").toString() : "");
//			obj.setMakedate(queryForList.get(0).get("MAKEDATE") != null ? queryForList.get(0).get("MAKEDATE").toString() : "");
//			obj.setExpiringdate(queryForList.get(0).get("EXPIRINGDATE") != null ? queryForList.get(0).get("EXPIRINGDATE").toString() : "");
//			obj.setExpirationday(queryForList.get(0).get("EXPIRATIONDAY") != null ? queryForList.get(0).get("EXPIRATIONDAY").toString() : "");
//			obj.setQrcode(queryForList.get(0).get("QRCODE") != null ? queryForList.get(0).get("QRCODE").toString() : "");
//			obj.setErplocation(queryForList.get(0).get("ERPLOCATION") != null ? queryForList.get(0).get("ERPLOCATION").toString() : "");
//			obj.setMaterialQuantity(queryForList.get(0).get("MATERIALQUANTITY") != null ? queryForList.get(0).get("MATERIALQUANTITY").toString() : "");
			
			//**********************************************************斯迪克字段************************************************//
			//**********************************************************斯迪克字段************************************************//
			//**********************************************************斯迪克字段************************************************//
//			private String  barcode;
			obj.setBarcode(queryForList.get(0).get("barcode") != null ? queryForList.get(0).get("barcode").toString() : "");
			obj.setMakedate(queryForList.get(0).get("makedate") != null ? queryForList.get(0).get("makedate").toString() : "");
			obj.setExpdate(queryForList.get(0).get("expdate") != null ? queryForList.get(0).get("expdate").toString() : "");
			obj.setDescription(queryForList.get(0).get("description") != null ? queryForList.get(0).get("description").toString() : "");
//			private String  partNo;
			obj.setPartNo(queryForList.get(0).get("partNo") != null ? queryForList.get(0).get("partNo").toString() : "");
//			private String  state;
			obj.setState(queryForList.get(0).get("state") != null ? queryForList.get(0).get("state").toString() : "");
//			private String  sdkSpec;
			obj.setSdkSpec(queryForList.get(0).get("sdkSpec") != null ? queryForList.get(0).get("sdkSpec").toString() : "");
//			private String  partName;
			obj.setPartName(queryForList.get(0).get("partName") != null ? queryForList.get(0).get("partName").toString() : "");
//			private String  ParticalSpec;
			obj.setPracticalSpec(queryForList.get(0).get("PracticalSpec") != null ? queryForList.get(0).get("PracticalSpec").toString() : "");
//			private String  qty;
			obj.setQty(queryForList.get(0).get("qty") != null ? queryForList.get(0).get("qty").toString() : "");
//			private String  orderNo;
			obj.setOrderNo(queryForList.get(0).get("orderNo") != null ? queryForList.get(0).get("orderNo").toString() : "");
//			private String  operater;
			//obj.setOperater(queryForList.get(0).get("operater") != null ? queryForList.get(0).get("operater").toString() : "");
			obj.setOpreater(UserId);
//			private String  lotNo;
			obj.setLotNo(queryForList.get(0).get("lotNo") != null ? queryForList.get(0).get("lotNo").toString() : "");
//			private String  remark;
			obj.setRemark(queryForList.get(0).get("remark") != null ? queryForList.get(0).get("remark").toString() : "");
//			obj.setJumboRollBatch(queryForList.get(0).get("jumboRollBatch") != null ? queryForList.get(0).get("jumboRollBatch").toString() : "");
			obj.setJumboRollBatch(queryForList.get(0).get("makedate") != null ? queryForList.get(0).get("makedate").toString() : "");
			obj.setSupplierno(queryForList.get(0).get("supplierNo") != null ? queryForList.get(0).get("supplierNo").toString() : "");
			labelPrint(obj, requestUrl, pr, params);
			
//			更新数量
			// 旧的qty
			String oldQty = queryForList1.get(0).get("QTY").toString();
			String qrsq2 = "UPDATE BS_MES_SHIPPED M SET M.OLDQTY = :oldQty,M.QTY = :QTY WHERE M.LOTNAME = :LOTNAME";
			hashMap1.put("oldQty", oldQty);  // 旧的值
			hashMap1.put("QTY", qty); // 新的值
			IDMFrameServiceProxy.getSqlTemplate().update(qrsq2, hashMap1);
		}
	}
	
	//现存量打印
	public String rePrintArriveMaterial3(String MaterialPackingName,String UserId,String printName,String DESC_CN,String labelType) throws IllegalArgumentException, IllegalAccessException, JsonProcessingException, CustomException {
		String sql = "";
//		String labelAddress ="Sdk2.btw"  ;
		String labelAddress = labelType;
		String MATERIALPACKINGNAME = MaterialPackingName;
		String printer = printName == null || "".equals(printName) ? getDefaultPrinter() : printName;//	"\\\\ZXYNB10810864P.boe.com.cn\\TSC MA3400P";
		String server = "LabelRequestURL";
		String requestUrl = getRequestUrlByServer(server);
		List<String> params = getLabelAssignParameter("testLabel002");

		String labelPath = getLabelAbsolutePath(labelAddress);
		labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\WMS\\" + labelAddress;
		log.info("***************************PrintLabel Path is : " + labelPath);
		PrintRequest pr = new PrintRequest();
		pr.setLibraryID(UUID.randomUUID().toString());
		pr.setAbsolutePath(labelPath);
		pr.setCopies(1);
		pr.setSerialNumbers(0);
		pr.setStartingPosition(0);
		pr.setPrinter(printer);
		pr.setPrintRequestID(UUID.randomUUID().toString());

		//czy-2024-9-13-增加成品标签模板
		List<Map<String, Object>> queryForListProduct = new ArrayList<>();
		if(labelAddress != null && (labelAddress.equals("SDK_02.btw") || labelAddress.equals("SDK_01.btw") || labelAddress.equals("10成品发货标签英文.btw"))) {
			sql = "SELECT \n" +
					"\tM.MATERIALPACKINGNAME ,\n" +
					"\tL.BARCODE barcode,\n" +
					"\tL.MATERIALCODE materialCode,\n" +
					"\tL.STAGECODE stageCode,\n" +
					"\tL.SDKSPECIFICATIONS sdkSpecifications,\n" +
					"\tL.MATERIALNAME materialname,\n" +
					"\tL.SPECIFICATIONS specifications,\n" +
					"\tL.PRACTICALSPEC PracticalSpec,\n" +
					"\tL.SOURCEORDER sourceOrder,\n" +
					"\tM.MATERIALPACKINGNAME jumboRollBatch,\n" +
					"\tL.BATCH batch,\n" +
					"\tL.CUSTOMERCODE customerCode,\n" +
					"\tL.MAINQTY mainQty,\n" +
					"\tL.MAINUOM mainUom,\n" +
					"\tL.OPERATOR operator,\n" +
					"\tL.OPERATOR operatorJumbo,\n" +
					"\tL.DEFINEITEM9 defineItem9,\n" +
					"\tL.REMARKS remarks,\n" +
					"\tL.ITEM1 item1,\n" +
					"\tL.ITEM2 item2,\n" +
					"\tL.ITEM3 item3,\n" +
					"\tL.ITEM4 item4,\n" +
					"\tL.ITEM5 item5\n" +
					"FROM MATERIALPACKING M \n" +
					"LEFT JOIN BS_MES_LABELPRINTINFO L\n" +
					"ON M.CHARGE = L.BATCH\n" +
					"AND M.MATERIALSPECNAME = L.MATERIALCODE\n" +
					"WHERE M.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
			Map<String, Object> hashMap = new HashMap<String,Object> ();
			hashMap.put("MATERIALPACKINGNAME", MATERIALPACKINGNAME);
			queryForListProduct = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap);
			if (queryForListProduct != null && queryForListProduct.size() > 0) {
				LabelParameterObject obj = new LabelParameterObject();
				obj.setBarcode(queryForListProduct.get(0).get("barcode") == null ? "" : queryForListProduct.get(0).get("barcode").toString());
				obj.setMaterialCode(queryForListProduct.get(0).get("materialCode") == null ? "" : queryForListProduct.get(0).get("materialCode").toString());
				obj.setStageCode(queryForListProduct.get(0).get("stageCode") == null ? "" : queryForListProduct.get(0).get("stageCode").toString());
				obj.setSdkSpecifications(queryForListProduct.get(0).get("sdkSpecifications") == null ? "" : queryForListProduct.get(0).get("sdkSpecifications").toString());
				obj.setMaterialname(queryForListProduct.get(0).get("materialName") == null ? "" : queryForListProduct.get(0).get("materialName").toString());
				obj.setSpecifications(queryForListProduct.get(0).get("specifications") == null ? "" : queryForListProduct.get(0).get("specifications").toString());
				obj.setPracticalSpec(queryForListProduct.get(0).get("PracticalSpec") == null ? "" : queryForListProduct.get(0).get("PracticalSpec").toString());
				obj.setSourceOrder(queryForListProduct.get(0).get("sourceOrder") == null ? "" : queryForListProduct.get(0).get("sourceOrder").toString());
				obj.setCustomerCode(queryForListProduct.get(0).get("mainQty") == null ? "" : queryForListProduct.get(0).get("mainQty").toString());
				obj.setMainQty(queryForListProduct.get(0).get("stageCode") == null ? "" : queryForListProduct.get(0).get("stageCode").toString());
				obj.setMainUom(queryForListProduct.get(0).get("mainUom") == null ? "" : queryForListProduct.get(0).get("mainUom").toString());
				obj.setOperator(queryForListProduct.get(0).get("operator") == null ? "" : queryForListProduct.get(0).get("operator").toString());
				obj.setOperatorJumbo(queryForListProduct.get(0).get("operatorJumbo") == null ? "" : queryForListProduct.get(0).get("operatorJumbo").toString());
				obj.setDefineItem9(queryForListProduct.get(0).get("defineItem9") == null ? "" : queryForListProduct.get(0).get("defineItem9").toString());
				obj.setRemarks(queryForListProduct.get(0).get("remarks") == null ? "" : queryForListProduct.get(0).get("remarks").toString());
				obj.setItem1(queryForListProduct.get(0).get("item1") == null ? "" : queryForListProduct.get(0).get("item1").toString());
				obj.setItem2(queryForListProduct.get(0).get("item2") == null ? "" : queryForListProduct.get(0).get("item2").toString());
				obj.setItem3(queryForListProduct.get(0).get("item3") == null ? "" : queryForListProduct.get(0).get("item3").toString());
				obj.setItem4(queryForListProduct.get(0).get("item4") == null ? "" : queryForListProduct.get(0).get("item4").toString());
				obj.setItem5(queryForListProduct.get(0).get("item5") == null ? "" : queryForListProduct.get(0).get("item5").toString());

				labelPrint(obj, requestUrl, pr, params);
			}
		}


//		if (StringUtils.isEmpty(printer)) {
//			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Printer.");
//		}

//		sql = "SELECT\r\n" +
//				"					m.MATERIALPACKINGNAME barcode,m2.materialtype,\r\n" + 
//				"					m.MATERIALSPECNAME partNo,\r\n" + 
//				"					m.PHASE state,\r\n" + 
//				"					ss.SPECNAME sdkSpec,\r\n" + 
//				"					m2.DESC_CN partName,m2.description,\r\n" + 
//				"					m.TRUEGG PracticalSpec,\r\n" + 
//				"					m.MATERIALQUANTITY || ' ' || m3.FNAME qty,\r\n" + 
//				"					m.RECEIVEREQUESTNAME orderNo,\r\n" + 
//				"					m.RECEIVEUSER operater,\r\n" + 
//				"					m.CHARGE lotNo,NVL(m.suppliername,'') supplierNo,\r\n" + 
//				"					m.REMARK remark,TO_CHAR(m.RECEIVETIME,'YYYYMMDD') jumboRollBatch,"
//				+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER  opreater\r\n" + 
//				"FROM\r\n" + 
//				"					MATERIALPACKING m\r\n" + 
//				"LEFT JOIN SDK_SPEC ss ON\r\n" + 
//				"					m.SDK_ID = ss.SDK_ID\r\n" + 
//				"LEFT JOIN MATERIALSPEC m2 ON\r\n" + 
//				"					m.MATERIALSPECNAME = m2.MATERIALSPECNAME\r\n" + 
//				"LEFT JOIN MATERIALUNIT m3 ON\r\n" + 
//				"	m.UNIT = m3.FNUMBER\r\n" + 
//				"WHERE\r\n" + 
//				"	m.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
		if(labelAddress != null && (labelAddress.equals("成品标签-太仓.btw") || labelAddress.equals("成品标签-重庆.btw") || labelAddress.equals("成品标签-东莞.btw"))) {
			sql = "SELECT \r\n" + 
					"	L.SOURCEORDER sourceOrder,\r\n" + 
					"    L.PIECE piece,\r\n" + 
					"--    L.JUMBOROLLBATCH jumboRollBatch,\r\n" + 
					"--    L.SPECIFICATIONS specifications,\r\n" + 
					"--    L.PRACTICALSPEC PracticalSpec,\r\n" + 
					"--	L.CUSTOMERCODE customerCode,\r\n" + 
					"--	L.SDKSPECIFICATIONS sdkSpec,\r\n" + 
					"    m.MJPC jumboRollBatch,\r\n" + 
					"	m.TRUEGG truege,\r\n" + 
					"	m.CUSTOMNO customerCode,\r\n" + 
					"	m.CUSTOMNO customNo,\r\n" + 
					"	m.MATERIALPACKINGNAME barcode,\r\n" + 
					"	m2.materialtype, \r\n" + 
					"	m.MATERIALSPECNAME partNo, \r\n" + 
					"	m.PHASE state,\r\n" + 
					"	ss.SPECNAME sdkSpec, \r\n" + 
					"	m2.DESC_CN partName,\r\n" + 
					"	m2.description, 	\r\n" + 
					"	m2.description specifications, \r\n" + 
					"	m.TRUEGG PracticalSpec, \r\n" + 
					"	DECODE(SUBSTR(m.MATERIALQUANTITY,1,1),'.','0'||m.MATERIALQUANTITY,m.MATERIALQUANTITY) || ' ' || m3.FNAME qty, \r\n" +
					"	m.RECEIVEREQUESTNAME orderNo, \r\n" + 
					"	m.RECEIVEUSER operater, 	\r\n" + 
					"	m.CHARGE lotNo,\r\n" + 
					"	NVL(m.suppliername, '') supplierNo, \r\n" + 
					"	m.REMARK remarks,\r\n" + 
					"	TO_CHAR(m.RECEIVETIME, 'YYYYMMDD') receiveTime,\r\n" + 
					"	TO_CHAR(MAKEDATE, 'YYYYMMDD') makedate,\r\n" + 
					"	TO_CHAR(EXPIRINGDATE, 'YYYYMMDD') expdate \r\n" + 
					"FROM \r\n" + 
					"	MATERIALPACKING m\r\n" + 
					"LEFT JOIN SDK_SPEC ss ON\r\n" + 
					"	m.SDK_ID = ss.SDK_ID\r\n" + 
					"LEFT JOIN MATERIALSPEC m2 ON\r\n" + 
					"	m.MATERIALSPECNAME = m2.MATERIALSPECNAME\r\n" + 
					"LEFT JOIN MATERIALUNIT m3 ON\r\n" + 
					"	m.UNIT = m3.FNUMBER\r\n" + 
					"LEFT JOIN BS_MES_LABELPRINTINFO L\r\n" + 
					"	ON M.CHARGE = L.BATCH\r\n" + 
					"AND M.MATERIALSPECNAME = L.MATERIALCODE \r\n" + 
					"WHERE\r\n" + 
					"	m.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
			
		}else {
			
			sql = "SELECT\r\n" +
					"					m.MATERIALPACKINGNAME barcode,m2.materialtype,\r\n" + 
					"					m.MATERIALSPECNAME partNo,\r\n" + 
					"					m.PHASE state,\r\n" + 
					"					ss.SPECNAME sdkSpec,\r\n" + 
					"					m2.DESC_CN partName,m2.description,\r\n" + 
					"					m.TRUEGG PracticalSpec,\r\n" + 
					"					DECODE(SUBSTR(m.MATERIALQUANTITY,1,1),'.','0'||m.MATERIALQUANTITY,m.MATERIALQUANTITY) || ' ' || m3.FNAME qty,\r\n" +
					"					m.RECEIVEREQUESTNAME orderNo,\r\n" + 
					"					m.RECEIVEUSER operater,\r\n" + 
					"					m.CHARGE lotNo,NVL(m.suppliername,'') supplierNo,\r\n" + 
					"					m.REMARK remark,TO_CHAR(m.RECEIVETIME,'YYYYMMDD') jumboRollBatch,"
					+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER  opreater\r\n" + 
					"FROM\r\n" + 
					"					MATERIALPACKING m\r\n" + 
					"LEFT JOIN SDK_SPEC ss ON\r\n" + 
					"					m.SDK_ID = ss.SDK_ID\r\n" + 
					"LEFT JOIN MATERIALSPEC m2 ON\r\n" + 
					"					m.MATERIALSPECNAME = m2.MATERIALSPECNAME\r\n" + 
					"LEFT JOIN MATERIALUNIT m3 ON\r\n" + 
					"	m.UNIT = m3.FNUMBER\r\n" + 
					"WHERE\r\n" + 
					"	m.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
		}
		
		Map<String, Object> hashMap = new HashMap<String,Object> ();
		hashMap.put("MATERIALPACKINGNAME", MATERIALPACKINGNAME);
		List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap);

		log.info("***************************PrintLabel Assign params is : " + params.toString());
		if (queryForList == null || queryForList.size() < 1) {
			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Undefined Execute Type : ");
		} else {
			if ("103".equals(queryForList.get(0).get("materialtype").toString()) || "106".equals(queryForList.get(0).get("materialtype").toString())) {
				labelAddress = "胶水原材.btw";
			}
		}


		log.info("***************************PrintLabel Use URL is : " + requestUrl);
		String labelUrl = "";
		if (queryForList != null && queryForList.size() > 0) {
			LabelParameterObject obj = new LabelParameterObject();
//			obj.setReceiverequestname(queryForList.get(0).get("RECEIVEREQUESTNAME") != null ? queryForList.get(0).get("RECEIVEREQUESTNAME").toString() : "");
//			obj.setMaterialpackingname(queryForList.get(0).get("MATERIALPACKINGNAME") != null ? queryForList.get(0).get("MATERIALPACKINGNAME").toString() : "");
//			obj.setMaterialSpec(queryForList.get(0).get("MATERIALSPEC") != null ? queryForList.get(0).get("MATERIALSPEC").toString() : "");
//			obj.setMaterialspecname(queryForList.get(0).get("MATERIALSPECNAME") != null ? queryForList.get(0).get("MATERIALSPECNAME").toString() : "");
//			obj.setDesc_cn(queryForList.get(0).get("DESC_CN") != null ? queryForList.get(0).get("DESC_CN").toString() : "");
//			obj.setSupplierno(queryForList.get(0).get("SUPPLIERNO") != null ? queryForList.get(0).get("SUPPLIERNO").toString() : "");
//			obj.setSupplierName(queryForList.get(0).get("SUPPLIERNAME") != null ? queryForList.get(0).get("SUPPLIERNAME").toString() : "");
//			obj.setMakedate(queryForList.get(0).get("MAKEDATE") != null ? queryForList.get(0).get("MAKEDATE").toString() : "");
//			obj.setExpiringdate(queryForList.get(0).get("EXPIRINGDATE") != null ? queryForList.get(0).get("EXPIRINGDATE").toString() : "");
//			obj.setExpirationday(queryForList.get(0).get("EXPIRATIONDAY") != null ? queryForList.get(0).get("EXPIRATIONDAY").toString() : "");
//			obj.setQrcode(queryForList.get(0).get("QRCODE") != null ? queryForList.get(0).get("QRCODE").toString() : "");
//			obj.setErplocation(queryForList.get(0).get("ERPLOCATION") != null ? queryForList.get(0).get("ERPLOCATION").toString() : "");
//			obj.setMaterialQuantity(queryForList.get(0).get("MATERIALQUANTITY") != null ? queryForList.get(0).get("MATERIALQUANTITY").toString() : "");
			//**********************************************************斯迪克字段************************************************//
			//**********************************************************斯迪克字段************************************************//
			//**********************************************************斯迪克字段************************************************//
//			private String  barcode;
			obj.setBarcode(queryForList.get(0).get("barcode") != null ? queryForList.get(0).get("barcode").toString() : "");
			obj.setMakedate(queryForList.get(0).get("makedate") != null ? queryForList.get(0).get("makedate").toString() : "");
			obj.setExpdate(queryForList.get(0).get("expdate") != null ? queryForList.get(0).get("expdate").toString() : "");
			obj.setDescription(queryForList.get(0).get("description") != null ? queryForList.get(0).get("description").toString() : "");
//			private String  partNo;
			obj.setPartNo(queryForList.get(0).get("partNo") != null ? queryForList.get(0).get("partNo").toString() : "");
//			private String  state;
			obj.setState(queryForList.get(0).get("state") != null ? queryForList.get(0).get("state").toString() : "");
//			private String  sdkSpec;
			obj.setSdkSpec(queryForList.get(0).get("sdkSpec") != null ? queryForList.get(0).get("sdkSpec").toString() : "");
//			private String  partName;
//			obj.setPartName(queryForList.get(0).get("partName") != null ? queryForList.get(0).get("partName").toString() : "");
			if (!"".equals(DESC_CN) && DESC_CN != "") {
				obj.setPartName(DESC_CN);
			} else {
				obj.setPartName(queryForList.get(0).get("partName") != null ? queryForList.get(0).get("partName").toString() : "");
			}
			//private String  ParticalSpec;
			obj.setPracticalSpec(queryForList.get(0).get("PracticalSpec") != null ? queryForList.get(0).get("PracticalSpec").toString() : "");
//			private String  qty;
			obj.setQty(queryForList.get(0).get("qty") != null ? queryForList.get(0).get("qty").toString() : "");
//			private String  orderNo;
			obj.setOrderNo(queryForList.get(0).get("orderNo") != null ? queryForList.get(0).get("orderNo").toString() : "");
			obj.setSourceOrder(queryForList.get(0).get("sourceOrder") != null ? queryForList.get(0).get("sourceOrder").toString() : "");
			obj.setPiece(queryForList.get(0).get("piece") != null ? queryForList.get(0).get("piece").toString() : "");
			obj.setOperater(queryForList.get(0).get("operater") != null ? queryForList.get(0).get("operater").toString() : "");
//			private String  operater;
//			obj.setOpreater(queryForList.get(0).get("operater") != null ? queryForList.get(0).get("operater").toString() : "");
			obj.setJumboRollBatch(queryForList.get(0).get("jumboRollBatch") != null ? queryForList.get(0).get("jumboRollBatch").toString() : "");
			obj.setSpecifications(queryForList.get(0).get("specifications") != null ? queryForList.get(0).get("specifications").toString() : "");
			obj.setPracticalSpec(queryForList.get(0).get("PracticalSpec") != null ? queryForList.get(0).get("PracticalSpec").toString() : "");
			obj.setCustomNo(queryForList.get(0).get("customNo") != null ? queryForList.get(0).get("customNo").toString() : "");
			//			obj.setOpreater(UserId);
//			private String  lotNo;
			obj.setLotNo(queryForList.get(0).get("lotNo") != null ? queryForList.get(0).get("lotNo").toString() : "");
//			private String  remark;
			obj.setRemark(queryForList.get(0).get("remark") != null ? queryForList.get(0).get("remark").toString() : "");
			obj.setRemarks(queryForList.get(0).get("remarks") != null ? queryForList.get(0).get("remarks").toString() : "");
//			obj.setJumboRollBatch(queryForList.get(0).get("jumboRollBatch") != null ? queryForList.get(0).get("jumboRollBatch").toString() : "");
			obj.setMakedate(queryForList.get(0).get("makedate") != null ? queryForList.get(0).get("makedate").toString() : "");
			obj.setSupplierno(queryForList.get(0).get("supplierNo") != null ? queryForList.get(0).get("supplierNo").toString() : "");
			obj.setDescription(queryForList.get(0).get("description") != null ? queryForList.get(0).get("description").toString() : "");
			
			
			labelUrl = labelPrint(obj, requestUrl, pr, params);
		}
		return labelUrl;
	}
	
	/**
	 * deGradePalletLabelPrint
	 * @param doc
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws JsonProcessingException
	 * @throws CustomException
	 */
//	public void deGradePalletLabelPrint(Document doc) throws IllegalArgumentException, IllegalAccessException, JsonProcessingException, CustomException {
//		Element body = doc.getRootElement().getChild(MsgConstants.XPATH_TAG_BODY);
//		String labelId = body.getChildText(MsgConstants.TAG_LABELID);
////		String labelType = body.getChildText(MsgConstants.TAG_LABELTYPE);
//		String labelAddress = body.getChildText(MsgConstants.TAG_LABELADDRESS);
//		String printer = body.getChildText(MsgConstants.TAG_PRINTERNAME);
//		String printQty = body.getChildText(MsgConstants.TAG_PRINTQTY);
////		String fgCode = body.getChildText(MsgConstants.TAG_PRODUCTSPECNAME);
//		String inputID = body.getChildText(MsgConstants.TAG_INPUTID);
////		String serialNumbers = body.getChildText(MsgConstants.TAG_SERIALNUMBERS);
//		String server = body.getChildText(MsgConstants.TAG_SERVER);
//		
//		if (StringUtils.isEmpty(printer)) {
//			throw new CustomException(CustomExceptionCode.DATA_NOT_FOUND,"Printer.");
//		}
//		
//		String labelPath = getLabelAbsolutePath(labelAddress);
//		log.info("***************************PrintLabel Path is : " + labelPath);
//		List<String> params = getLabelAssignParameter(labelId);
//		log.info("***************************PrintLabel Assign params is : " + params.toString());
//		
//		PrintRequest pr = new PrintRequest();
//		pr.setLibraryID(UUID.randomUUID().toString());
//		pr.setAbsolutePath(labelPath);
//		pr.setCopies(Integer.parseInt(printQty));
//		pr.setSerialNumbers(0);
//		pr.setStartingPosition(0);
//		pr.setPrinter(printer);
//		pr.setPrintRequestID(UUID.randomUUID().toString());
//		
//		String requestUrl = getRequestUrlByServer(server);
//		log.info("***************************PrintLabel Use URL is : " + requestUrl);
//		
//		ProcessGroup pgData = CommonUtil.getProcessGroupByProcesessGroupName(inputID);
//		List<ProcessGroup> groupList = ProcessGroupServiceProxy.getProcessGroupService().allProcessGroupsBySuperProcessGroup(inputID);
//		
//		int count = 0;
//		for (ProcessGroup data : groupList) {
//			count += data.getMaterialQuantity();
//		}
//		
//		pgData.setMaterialQuantity(count);
//		labelPrint(pgData, requestUrl, pr, params);
//	}
	
	/**
	 * get 年月日
	 * @param year
	 * @param month
	 * @param day
	 * @return
	 */
	private String getYMD(int year, int month, int day) {
		StringBuffer result = new StringBuffer();
		String yearChar = String.valueOf(year).substring(3);
		result.append(yearChar);
		switch (month) {
		case 10:
			result.append("A");
			break;
		case 11:
			result.append("B");
			break;
		case 12:
			result.append("C");
			break;
		default:
			result.append(month);
			break;
		}
		result.append(month);
		return result.toString();
	}

	@Override
	public int delete(BSLabelKey arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int[] delete(List<BSLabelKey> arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int[] delete(BSLabelKey[] arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * @Override public int delete(String arg0, Object[] arg1, Class<?> arg2) throws
	 * IDMFrameDBErrorSignal { // TODO Auto-generated method stub return 0; }
	 */

	@Override
	public int insert(BSLabel arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int[] insert(List<BSLabel> arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int[] insert(BSLabel[] arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<BSLabel> select(String arg0, Object[] arg1, Class<?> arg2) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BSLabel selectByKey(BSLabelKey arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<BSLabel> selectByKey(List<BSLabelKey> arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BSLabel[] selectByKeyForBatch(BSLabelKey[] arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BSLabel selectByKeyForUpdate(BSLabelKey arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BSLabel[] selectByKeyForUpdateForBatch(BSLabelKey[] arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int update(BSLabel arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int[] update(List<BSLabel> arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int[] update(BSLabel[] arg0) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int update(BSLabel arg0, String arg1, Object[] arg2) throws IDMFrameDBErrorSignal {
		// TODO Auto-generated method stub
		return 0;
	}
	
	
}
