这里我是把Date的转成Long,方法不一,如下:
SELECT
a.accountsid AS "id",
a.accountsId AS "accountsId",
a.userId AS "userId",
a.reimburseId AS "reimburse.id",
a.accountsType AS "accountsType",
a.accountsDate AS "accountsDate",
a.accountsStartData AS "accountsStartData",
a.accountsEndData AS "accountsEndData",
a.roadMoney AS "roadMoney",
a.roadContent AS "roadContent",
a.accountsMoney AS "accountsMoney",
a.accountsKilometres AS "accountsKilometres",
a.accountsSumMoney AS "accountsSumMoney",
a.accountsDescription AS "accountsDescription",
a.accountsRemarks AS "accountsRemarks",
a.auditInfo AS "auditInfo",
a.city AS "city",
a.currency AS "currency",
a.corpaccounts AS "corpaccounts",
a.oid AS "orderInfo.id",
a.corpaccountsName AS "corpaccountsName",
a.corpaccountsNum AS "corpaccountsNum",
a.companyId AS "company.id",
a.packageId AS "packageId",
a.subRuleId AS "subRuleId",
a.subRuleInfo AS "subRuleInfo",
a.staffId AS "staff.id",
a.localMoney AS "localMoney",
a.financialDescription AS "financialDescription",
a.submitMoney AS "submitMoney",
a.exceedReasonId AS "exceedReasonId",
a.createdAt AS "createdAt",
a.updatedAt AS "updatedAt",
a.customerList AS "customerList",
a.financAdjustor AS "financAdjustor",
a.financialAdjusted AS "financialAdjusted",
a.financialMoney AS "financialMoney",
a.financAdjustTime AS "financAdjustTime",
a.depthPath AS "depthPath",
a.preTaxTotal AS "preTaxTotal",
a.taxRate AS "taxRate",
a.accountPolicyId AS "accountPolicyId",
a.accountsSumMoney2 AS "accountsSumMoney2",
a.accountsSumMoney3 AS "accountsSumMoney3",
a.currency2 AS "currency2",
a.currency3 AS "currency3",
a.exchangeRate AS "exchangeRate",
a.exchangeRate2 AS "exchangeRate2",
a.departDepthPath AS "departDepthPath",
a.invoiceId AS "invoiceId",
a.staffId AS "staff.staffId",
s.staffUserEmail AS "staff.staffUserEmail",
s.staffUserEmail AS "staffUserEmail",
s.staffUserName AS "staff.staffUserName",
s.staffUserDepartment AS "staff.staffUserDepartment",
a.companyId AS "company.companyId",
c.companyName AS "company.companyName",
r.reimburseid AS "reimburse.reimburseId",
r.reimbursenum AS "reimburse.reimburseNum",
r.reimbursename AS "reimburse.reimburseName",
r.reimbursemoney AS "reimburse.reimburseMoney",
r.approvalstate AS "reimburse.approvalState",
r.checkstate AS "reimburse.checkState",
r.actiontype AS "reimburse.actionType",
r.projectName AS "reimburse.projectName",
b.proofNo AS "reimburse.bill.proofNo",
b.billDate AS "reimburse.bill.billDate",
af.applyId AS "applyFor.id",
af.applyId AS "applyFor.applyId",
af.txm AS "applyFor.txm",
oi.oId AS "orderInfo.oId",
oi.CODE AS "orderInfo.code",
oi.customid AS "orderInfo.customId",
oi.ordertype AS "orderInfo.orderType",
oi.ordertime AS "orderInfo.orderTime"
FROM
Account a
LEFT JOIN Staff s ON a.staffId = s.staffId
LEFT JOIN Company c ON a.companyId = c.companyId
LEFT JOIN Reimburse r ON a.reimburseId = r.reimburseId
LEFT JOIN Bill b ON b.reimburseId = r.reimburseId
LEFT JOIN ApplyFor af ON r.applyId = af.applyId
LEFT JOIN OrderInfo oi ON a.oId = oi.oId
WHERE
1 = 1
AND a.companyId = '20010'
AND a.accountsDate >= unix_timestamp('2016-12-15 00:00:00.0')*1000
AND a.accountsDate <= unix_timestamp('2018-01-31 00:00:00.0') *1000
ORDER BY
accountsDate
LIMIT 10
需要注意的是,看一下前后转义后的两个long 长度是否一致,
AND a.accountsDate >= unix_timestamp('2016-12-15 00:00:00.0')*1000
AND a.accountsDate <= unix_timestamp('2018-01-31 00:00:00.0') *1000