<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.qianwen.mdc.mapper.MachineAccountMapper">
|
<resultMap id="BaseResultMap" type="com.qianwen.mdc.domain.MachineAccount">
|
|
<id column="id" jdbcType="INTEGER" property="id" />
|
<result column="machine_id" jdbcType="INTEGER" property="machineId" />
|
<result column="machine_name" jdbcType="VARCHAR" property="machineName" />
|
<result column="uuid" jdbcType="VARCHAR" property="uuid" />
|
<result column="specification" jdbcType="VARCHAR" property="specification" />
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
<result column="device_type_id" jdbcType="INTEGER" property="deviceTypeId" />
|
<result column="category" jdbcType="VARCHAR" property="category" />
|
<result column="cnc_system" jdbcType="VARCHAR" property="cncSystem" />
|
<result column="accounting_attribute" jdbcType="VARCHAR" property="accountingAttribute" />
|
<result column="manage_type" jdbcType="VARCHAR" property="manageType" />
|
<result column="location" jdbcType="VARCHAR" property="location" />
|
<result column="department" jdbcType="INTEGER" property="department" />
|
<result column="elec_comp_factor" jdbcType="INTEGER" property="elecCompFactor" />
|
<result column="mech_comp_factor" jdbcType="INTEGER" property="mechCompFactor" />
|
<result column="country" jdbcType="VARCHAR" property="country" />
|
<result column="manufacturer" jdbcType="VARCHAR" property="manufacturer" />
|
<result column="production_date" jdbcType="TIMESTAMP" property="productionDate" />
|
<result column="original_value" jdbcType="REAL" property="originalValue" />
|
<result column="present_value" jdbcType="REAL" property="presentValue" />
|
<result column="weight" jdbcType="INTEGER" property="weight" />
|
<result column="pic" jdbcType="VARCHAR" property="pic" />
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
</resultMap>
|
|
<select id="queryPage" parameterType="com.qianwen.mdc.dto.account.MachineAccountQueryDTO" resultType="com.qianwen.mdc.dto.account.MachineAccountDTO">
|
select
|
a.id,
|
a.machine_id machineId,
|
a.machine_name machineName,
|
a.uuid,
|
a.specification,
|
a.type,
|
a.device_type_id deviceTypeId,
|
a.category,
|
a.accounting_attribute accountingAttribute,
|
a.location,
|
a.department,
|
ud.name as departmentName,
|
a.elec_comp_factor elecCompFactor,
|
a.mech_comp_factor mechCompFactor,
|
a.country,
|
a.manufacturer,
|
a.production_date productionDate,
|
a.original_value originalValue,
|
a.present_value presentValue,
|
a.weight,
|
a.pic,
|
a.remark,
|
a.manage_type manageType,
|
ms.status
|
from machine_account a
|
left join use_department ud on a.department=ud.id
|
left join (select max(id) id,machine_id,status from machine_status group by machine_id,status) ms on a.machine_id=ms.machine_id
|
<where>
|
<if test="dto.uuid != null and dto.uuid != ''">
|
<bind name="uuid" value="'%' + dto.uuid + '%'" />
|
and a.uuid like #{uuid}
|
</if>
|
<if test="dto.type != null and dto.type != ''">
|
<bind name="type" value="'%' + dto.type + '%'" />
|
and a.type like #{type}
|
</if>
|
<if test="dto.specification != null and dto.specification != ''">
|
<bind name="specification" value="'%' + dto.specification + '%'" />
|
and a.specification like #{specification}
|
</if>
|
|
<if test="dto.productionDateBegin != null">
|
and a.production_date >= #{dto.productionDateBegin}
|
</if>
|
<if test="dto.productionDateEnd != null">
|
and a.production_date <= #{dto.productionDateEnd}
|
</if>
|
|
|
<if test="dto.manufacturer != null and dto.manufacturer != ''">
|
<bind name="manufacturer" value="'%' + dto.manufacturer + '%'" />
|
and a.manufacturer like #{manufacturer}
|
</if>
|
<if test="dto.country != null and dto.country != ''">
|
<bind name="country" value="'%' + dto.country + '%'" />
|
and a.country like #{country}
|
</if>
|
<if test="dto.remark != null and dto.remark != ''">
|
<bind name="remark" value="'%' + dto.remark + '%'" />
|
and a.remark like #{remark}
|
</if>
|
<if test="dto.category != null and dto.category != ''">
|
and a.category = #{dto.category}
|
</if>
|
<if test="dto.department != null">
|
and a.department = #{dto.department}
|
</if>
|
|
<if test="dto.accountingAttribute != null and dto.accountingAttribute != ''">
|
and a.accounting_attribute = #{dto.accountingAttribute}
|
</if>
|
<if test="dto.manageType != null and dto.manageType != ''">
|
and a.manage_type = #{dto.manageType}
|
</if>
|
<if test="dto.deviceTypeId != null">
|
and a.device_type_id = #{dto.deviceTypeId}
|
</if>
|
|
</where>
|
</select>
|
|
<!-- 查询某个厂房id下的所有机床 -->
|
<select id="queryRemainingAccount" resultType="com.qianwen.mdc.dto.account.MachineAccountDTO">
|
select
|
a.id,
|
a.machine_name as machineName,
|
a.machine_id machineId,
|
a.uuid,
|
a.specification,
|
a.type,
|
a.category,
|
a.accounting_attribute accountingAttribute,
|
a.location,
|
a.department,
|
ud.name as departmentName,
|
a.elec_comp_factor elecCompFactor,
|
a.mech_comp_factor mechCompFactor,
|
a.country,
|
a.manufacturer,
|
a.production_date productionDate,
|
a.original_value originalValue,
|
a.present_value presentValue,
|
a.weight,
|
a.pic,
|
a.remark,
|
a.manage_type manageType
|
from machine_account a
|
left join use_department ud on a.department=ud.id
|
inner join machine m on a.machine_id=m.id
|
where m.plant_id is null
|
</select>
|
|
<select id="selectSameTypes" parameterType="com.qianwen.mdc.domain.MachineAccount" resultType="String">
|
select machine_name
|
from mdc_machine_account
|
where types_id = #{typesId} and machine_name != #{machineName}
|
</select>
|
|
|
<select id="lastByMachineId" resultType="com.qianwen.mdc.domain.MachineAccount">
|
select
|
a.machine_id machineId,
|
a.uuid,
|
a.id,
|
a.specification,
|
a.type,
|
a.category,
|
a.accounting_attribute accountingAttribute,
|
a.location,
|
a.department,
|
a.elec_comp_factor elecCompFactor,
|
a.mech_comp_factor mechCompFactor,
|
a.country,
|
a.manufacturer,
|
a.production_date productionDate,
|
a.original_value originalValue,
|
a.present_value presentValue,
|
a.weight,
|
a.pic,
|
a.remark,
|
a.manage_type manageType
|
from machine_account a
|
where machine_id=#{machineId}
|
limit 1
|
</select>
|
</mapper>
|