12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- SELECT
- DATE_FORMAT(lastinput.date, '%Y-%m-%d') as dateFormat,
- lastinput.*,
- e.empname putName,
- m.lastAmount aAmount,
- m.startAmount,
- m.useType,
- p.name pastureName,
- de.name departName,
- p.id AS pastureId2,
- m.id AS measureId2,
- m.Multiple,
- m.Multiple rate,
- lastinput.elecConsumption consumption,
- m.meterNumber AS formNumber,
- m.meterName AS formName,
- e.empname employeName1,
- lastinput.price price1
- FROM
- measure m
- LEFT JOIN (
- SELECT
- *
- FROM
- electricity
- WHERE
- id =(
- SELECT
- MAX(w.`id`) id
- FROM
- electricity w
- WHERE
- electricity.measureId = w.measureId
- )
- ) lastinput ON lastinput.measureId = m.id
- INNER JOIN pasture p ON m.pastureId = p.id
- left JOIN department de ON m.departmentId = de.id
- LEFT JOIN emp e ON e.id = lastinput.`employeId`
- where
- (
- lastinput.elecName like concat("%", ?, "%")
- or ? = ''
- )
- and (
- lastinput.elecNumber like concat("%", ?, "%")
- or ? = ''
- )
- and (
- m.useType like concat("%", ?, "%")
- or ? = ''
- )
- and (
- p.name = ?
- or ? = '现代牧业'
- )
- and (
- de.name = ?
- or ? = ''
- )
- and (
- date_format(lastinput.date, '%Y-%m-%d') = ?
- or ? = ''
- )
- and m.meterType = '电表'
- and lastinput.isDel = '0'
- order by
- m.meterNumber
|