ErpMaterial.java 2.84 KB
package com.huaheng.api.general.domain;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.apache.commons.lang.StringEscapeUtils;

import java.math.BigDecimal;

@Data
public class ErpMaterial {
    /**条码值**/
    @JSONField(name = "BarCode")
    public String BarCode;
    /**条码类型**/
    @JSONField(name = "BarType")
    public String BarType;
    /**物料编码**/
    @JSONField(name = "MaterialCode")
    public String MaterialCode;
    /**物料名称**/
    @JSONField(name = "MaterialName")
    public String MaterialName;
    /**物料规格**/
    @JSONField(name = "MaterialSpec")
    public String MaterialSpec;
    /**批号**/
    @JSONField(name = "BatchNo")
    public String BatchNo;
    /**物料单位**/
    @JSONField(name = "MaterialUnit")
    public String MaterialUnit;
    /**条码数量**/
    @JSONField(name = "BarQty")
    public BigDecimal BarQty;
    /**来源单别**/
    @JSONField(name = "SourceBillType")
    public String SourceBillType;
    /**来源单号**/
    @JSONField(name = "SourceBillCode")
    public String SourceBillCode;
    /**来源行号**/
    @JSONField(name = "SourceBillLine")
    public String SourceBillLine;
    /**客户/供应商编号**/
    @JSONField(name = "CustOrSupplyCode")
    public String CustOrSupplyCode;
    /**客户/供应商名称**/
    @JSONField(name = "CustOrSupplyName")
    public String CustOrSupplyName;
    /**客户品号**/
    @JSONField(name = "CustMatCode")
    public String CustMatCode;
    /**客户规格**/
    @JSONField(name = "CustMatName")
    public String CustMatName;

    public static ErpMaterial parse(String msg){
        String json = StringEscapeUtils.unescapeJava(msg);
        ErpMaterial obj = JSON.parseObject(json, ErpMaterial.class);
        return obj;
    }

    public String toRawJsonStr(){
        String s = JSON.toJSONString(this);
//        System.out.println(StringEscapeUtils.escapeJava(s));
        return s;
    }

    public static void main(String args[]){
        String s = "{\"BarCode\":\"181110002691\",\"BarType\":\"2\",\"MaterialCode\":\"AH0010008006\",\"MaterialName\":\"PA 单体PA Driver\",\"MaterialSpec\":\"LDSAT82LS\",\"BatchNo\":\"********************\",\"MaterialUnit\":\"pcs\",\"BarQty\":1.000000,\"SourceBillType\":\"5101\",\"SourceBillCode\":\"82411191973\",\"SourceBillLine\":\"\",\"SaleBillType\":\"2201\",\"SaleBillCode\":\"20180821005\",\"SaleBillLine\":\"0002\",\"CustOrSupplyCode\":\"00023\",\"CustOrSupplyName\":\"AH\",\"CustMatCode\":\"\",\"CustMatName\":\"\",\"CustMatSpec\":\"\",\"Remarks\":\"\",\"BarProperty\":\"M\",\"TaskBillType\":\"\",\"TaskBillCode\":\"\",\"EffectiveDate\":\"2021-03-05 18:15:38\",\"ManufacturingDate\":\"2018-11-10 00:00:00\",\"RecheckDate\":\"1900-01-01 00:00:00\"}";
        ErpMaterial obj = ErpMaterial.parse(s);
        obj.toRawJsonStr();
    }
}