编辑代码

import groovy.json.*
import java.text.SimpleDateFormat
class ReqParam{
    Integer cardType
    String idcard
    String checkNumber
    Integer dateType
    Date endDate
    Date startDate
}
def paramConvert(param){
    def identityType = null
    if(param.identityType != null){
        identityType = param.identityType[0].toInteger()
    }
    def reqDateType = null
    if(param.dateType != null){
       reqDateType = param.dateType[0].toInteger()
    }
    def reqStartDate = null
    if(param.startDate!=null){
        reqStartDate = Date.parse('yyyy-MM-dd HH:mm:ss',param.startDate[0])
    }
    def reqEndDate = null
    if(param.endDate!=null){
        reqEndDate = Date.parse('yyyy-MM-dd HH:mm:ss',param.endDate[0])
    }
    def reqIdentityNo = null
    if(param.identityNo != null){
        reqIdentityNo = param.identityNo[0]
    }
    def checkCode = null
    if(param.checkCode != null){
        checkCode = param.checkCode[0]
    }
    println reqDateType
    def reqParam = new ReqParam(cardType:identityType,idcard:reqIdentityNo,checkNumber:checkCode,dateType:reqDateType,
    startDate:reqStartDate,endDate:reqEndDate)
    return JsonOutput.toJson(reqParam)
}