代码提交
This commit is contained in:
parent
205b9b5801
commit
9db8a043a9
|
|
@ -1,8 +1,6 @@
|
||||||
package com.bonus.material.equipment.mapper;
|
package com.bonus.material.equipment.mapper;
|
||||||
|
|
||||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||||
import io.lettuce.core.dynamic.annotation.Param;
|
|
||||||
import org.apache.ibatis.annotations.Delete;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?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.bonus.material.equipment.mapper.DeptEquipmentConfigMapper">
|
||||||
|
<delete id="deleteByDeptIdAndTypeId">
|
||||||
|
DELETE FROM ma_dept_config WHERE dept_id = #{deptId} AND type_id = #{typeId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectConfig" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<select id="selectConfigByDept" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
||||||
|
SELECT * FROM dept_equipment_config WHERE dept_id = #{deptId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertOrUpdateBatch" parameterType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
||||||
|
INSERT INTO ma_dept_config (
|
||||||
|
dept_id,
|
||||||
|
type_id,
|
||||||
|
config_type,
|
||||||
|
config_value,
|
||||||
|
config_rate,
|
||||||
|
config_description,
|
||||||
|
remark
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="configs" item="item" separator=",">
|
||||||
|
(
|
||||||
|
#{deptId},
|
||||||
|
#{equipmentId},
|
||||||
|
#{item.configurationType},
|
||||||
|
#{item.basicConfig},
|
||||||
|
#{item.configurationRate},
|
||||||
|
#{item.configurationDescription},
|
||||||
|
#{remark}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
config_value = VALUES(config_value),
|
||||||
|
config_rate = VALUES(config_rate),
|
||||||
|
config_description = VALUES(config_description),
|
||||||
|
remark = VALUES(remark),
|
||||||
|
update_time = CURRENT_TIMESTAMP
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,231 @@
|
||||||
|
<?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.bonus.material.equipment.mapper.SysDeptMapper">
|
||||||
|
<sql id="selectDeptVo">
|
||||||
|
select d.dept_id,
|
||||||
|
d.parent_id,
|
||||||
|
d.ancestors,
|
||||||
|
d.dept_name,
|
||||||
|
d.order_num,
|
||||||
|
d.leader,
|
||||||
|
d.phone,
|
||||||
|
d.email,
|
||||||
|
d.status,
|
||||||
|
d.del_flag,
|
||||||
|
d.create_by,
|
||||||
|
d.create_time
|
||||||
|
from sys_dept d
|
||||||
|
</sql>
|
||||||
|
<resultMap type="com.bonus.system.api.domain.SysDept" id="SysDeptResult">
|
||||||
|
<id property="deptId" column="dept_id" />
|
||||||
|
<result property="parentId" column="parent_id" />
|
||||||
|
<result property="ancestors" column="ancestors" />
|
||||||
|
<result property="deptName" column="dept_name" />
|
||||||
|
<result property="orderNum" column="order_num" />
|
||||||
|
<result property="leader" column="leader" />
|
||||||
|
<result property="phone" column="phone" />
|
||||||
|
<result property="email" column="email" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="delFlag" column="del_flag" />
|
||||||
|
<result property="parentName" column="parent_name" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="menuTemplateId" column="menu_template_id" />
|
||||||
|
<result property="province" column="province" />
|
||||||
|
<result property="city" column="city" />
|
||||||
|
<result property="district" column="district" />
|
||||||
|
<result property="address" column="address" />
|
||||||
|
<result property="deptAbbreviation" column="dept_abbreviation" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="logo" column="logo" />
|
||||||
|
<result property="adminUserId" column="admin_user_id" />
|
||||||
|
<result property="initPassword" column="init_password" />
|
||||||
|
</resultMap>
|
||||||
|
<select id="selectDeptTree">
|
||||||
|
SELECT * FROM sys_dept WHERE del_flag = '0' ORDER BY parent_id, order_num
|
||||||
|
</select>
|
||||||
|
<select id="selectDeptList" parameterType="com.bonus.system.api.domain.SysDept" resultMap="SysDeptResult">
|
||||||
|
<include refid="selectDeptVo"/>
|
||||||
|
where d.del_flag = '0'
|
||||||
|
|
||||||
|
<if test="deptName != null and deptName != ''">
|
||||||
|
AND dept_name like concat('%', #{deptName}, '%')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<select id="selectUserList" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
||||||
|
SELECT
|
||||||
|
mt.type_id AS equipmentId,
|
||||||
|
mt2.type_name AS equipmentName,
|
||||||
|
mt.type_name AS equipmenttype,
|
||||||
|
CASE
|
||||||
|
WHEN MAX(mdc.config_value) IS NOT NULL AND MAX(mdc.config_value) != '' THEN '已配置'
|
||||||
|
ELSE '未配置'
|
||||||
|
END AS configStatus
|
||||||
|
FROM ma_type mt
|
||||||
|
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||||
|
LEFT JOIN ma_dept_config mdc
|
||||||
|
ON mdc.type_id = mt.type_id
|
||||||
|
AND mdc.dept_id = #{deptId}
|
||||||
|
WHERE mt.level = 3
|
||||||
|
<if test="equipmentName != null and equipmentName != ''">
|
||||||
|
AND mt.type_name LIKE CONCAT('%', #{equipmentName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="equipmenttype != null and equipmenttype != ''">
|
||||||
|
AND mt2.type_name LIKE CONCAT('%', #{equipmenttype}, '%')
|
||||||
|
</if>
|
||||||
|
GROUP BY mt.type_id, mt2.type_name, mt.type_name
|
||||||
|
</select>
|
||||||
|
<select id="selectConfigList" resultType="com.bonus.material.equipment.domain.ConfigEntity">
|
||||||
|
SELECT
|
||||||
|
config_value AS basicConfig,
|
||||||
|
config_type AS configurationType,
|
||||||
|
config_rate AS configurationRate,
|
||||||
|
config_description AS configurationDescription
|
||||||
|
FROM ma_dept_config
|
||||||
|
WHERE dept_id = #{deptId}
|
||||||
|
AND type_id = #{typeId}
|
||||||
|
</select>
|
||||||
|
<select id="getTree" resultType="com.bonus.material.equipment.domain.DeptTreeSelect">
|
||||||
|
SELECT
|
||||||
|
mt.type_id AS id,
|
||||||
|
|
||||||
|
mt.type_name AS name
|
||||||
|
FROM ma_type mt
|
||||||
|
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||||
|
LEFT JOIN ma_dept_config mdc
|
||||||
|
ON mdc.type_id = mt.type_id
|
||||||
|
|
||||||
|
WHERE mt.level = 3
|
||||||
|
GROUP BY mt.type_id, mt2.type_name, mt.type_name
|
||||||
|
</select>
|
||||||
|
<select id="selectDeptConfigRatePivot"
|
||||||
|
resultType="com.bonus.material.equipment.domain.DeptConfigRateSummary">
|
||||||
|
SELECT
|
||||||
|
my.type_name AS deptName,
|
||||||
|
sd.dept_name AS companyName,
|
||||||
|
mdc.dept_id AS companyId,
|
||||||
|
mdc.config_type AS configType,
|
||||||
|
mdc.config_value AS configValue,
|
||||||
|
mdc.config_rate AS configRate,
|
||||||
|
IFNULL(order_stat.order_count, 0) AS orderCount
|
||||||
|
FROM
|
||||||
|
ma_dept_config mdc
|
||||||
|
LEFT JOIN sys_dept sd ON sd.dept_id = mdc.dept_id
|
||||||
|
LEFT JOIN ma_type my ON my.type_id = mdc.type_id
|
||||||
|
|
||||||
|
-- 设备订单数量子查询
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
sd.dept_id AS dept_id,
|
||||||
|
mt2.type_id AS parent_type_id,
|
||||||
|
COUNT(md.ma_id) AS order_count
|
||||||
|
FROM
|
||||||
|
ma_order_details md
|
||||||
|
LEFT JOIN ma_order_info moi ON md.order_id = moi.order_id
|
||||||
|
LEFT JOIN ma_dev_info mdi ON md.ma_id = mdi.ma_id
|
||||||
|
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||||
|
LEFT JOIN sys_dept sd ON moi.buyer_company = sd.dept_id
|
||||||
|
GROUP BY sd.dept_id, mt2.type_id
|
||||||
|
) order_stat
|
||||||
|
ON order_stat.dept_id = mdc.dept_id
|
||||||
|
AND order_stat.parent_type_id = mdc.type_id
|
||||||
|
|
||||||
|
WHERE 1 = 1
|
||||||
|
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<select id="selectDeptConfigTypeSummary"
|
||||||
|
resultType="com.bonus.material.equipment.domain.DeptConfigTypeSummary">
|
||||||
|
SELECT mt1.type_name AS typeName,
|
||||||
|
mt2.type_name AS parentTypeName,
|
||||||
|
CAST(mdc.config_rate AS DECIMAL(10, 2)) AS configRate,
|
||||||
|
mdc.config_description AS configDescription
|
||||||
|
FROM ma_dept_config mdc
|
||||||
|
LEFT JOIN ma_type mt1 ON mt1.type_id = mdc.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
||||||
|
WHERE mdc.dept_id = #{deptId}
|
||||||
|
</select>
|
||||||
|
<select id="detailsInfo" resultType="com.bonus.material.equipment.domain.EquipmentDetail">
|
||||||
|
SELECT
|
||||||
|
d.dept_id AS companyId,
|
||||||
|
mt.type_name AS NAME,
|
||||||
|
d.config_description as `desc`,
|
||||||
|
SUM(CAST(d.config_rate AS DECIMAL(10, 2))) AS `value`,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END
|
||||||
|
FROM ma_dept_config d2
|
||||||
|
WHERE d2.dept_id = d.dept_id AND d2.config_type = '3'
|
||||||
|
) AS ifExist,
|
||||||
|
|
||||||
|
(
|
||||||
|
SELECT COUNT(md.ma_id)
|
||||||
|
FROM ma_order_details md
|
||||||
|
LEFT JOIN ma_order_info moi ON md.order_id = moi.order_id
|
||||||
|
LEFT JOIN ma_dev_info mdi ON md.ma_id = mdi.ma_id
|
||||||
|
LEFT JOIN ma_type mt1 ON mdi.type_id = mt1.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
||||||
|
WHERE
|
||||||
|
moi.buyer_company = d.dept_id AND
|
||||||
|
mt2.type_id = d.type_id
|
||||||
|
) AS orderCount,
|
||||||
|
|
||||||
|
SUM(CAST(d.config_value AS DECIMAL(10, 2))) AS standard,
|
||||||
|
MAX(own_count) AS own,
|
||||||
|
MAX(rent_count) AS rent
|
||||||
|
|
||||||
|
FROM
|
||||||
|
ma_dept_config d
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT ma_name, SUM(ma_num) AS own_count
|
||||||
|
FROM ma_own_manage
|
||||||
|
WHERE type = '2' AND is_active = '0' and company_id=#{companyId}
|
||||||
|
GROUP BY ma_name
|
||||||
|
) own ON CAST(d.type_id AS CHAR) = own.ma_name
|
||||||
|
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT ma_name, SUM(ma_num) AS rent_count
|
||||||
|
FROM ma_own_manage
|
||||||
|
WHERE type = '1' AND is_active = '0' and company_id=#{companyId}
|
||||||
|
GROUP BY ma_name
|
||||||
|
) rent ON CAST(d.type_id AS CHAR) = rent.ma_name
|
||||||
|
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = d.type_id
|
||||||
|
WHERE
|
||||||
|
1=1
|
||||||
|
<if test="companyId != null">
|
||||||
|
AND d.dept_id = #{companyId}
|
||||||
|
</if>
|
||||||
|
<if test="configType != null">
|
||||||
|
AND d.config_type = #{configType}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
GROUP BY
|
||||||
|
d.dept_id,
|
||||||
|
d.config_type,
|
||||||
|
d.type_id;
|
||||||
|
</select>
|
||||||
|
<select id="listFromDevInfo" resultType="com.bonus.material.equipment.domain.NewmydevInfo">
|
||||||
|
SELECT
|
||||||
|
md.own_co AS companyId,
|
||||||
|
mt2.type_id AS typeId,
|
||||||
|
mt2.type_name as typeName,
|
||||||
|
SUM( 1 ) AS ownCount
|
||||||
|
FROM
|
||||||
|
ma_dev_info md
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = md.type_id
|
||||||
|
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
|
||||||
|
WHERE
|
||||||
|
md.is_active = '1'
|
||||||
|
AND md.own_co = 221
|
||||||
|
|
||||||
|
GROUP BY
|
||||||
|
mt.type_id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?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.bonus.material.owner.mapper.OwnerMapper">
|
||||||
|
<insert id="add">
|
||||||
|
insert into ma_own_manage(
|
||||||
|
ma_type, ma_name, model_id, ma_model, ma_num,
|
||||||
|
creator, remark,company_id,type)
|
||||||
|
values(#{maType}, #{maName}, #{modelId}, #{maModel}, #{maNum}, #{creator}, #{remark}, #{companyId},#{type})
|
||||||
|
</insert>
|
||||||
|
<update id="edit">
|
||||||
|
update ma_own_manage set
|
||||||
|
ma_type = #{maType},
|
||||||
|
ma_name = #{maNameId},
|
||||||
|
model_id = #{modelId},
|
||||||
|
ma_model = #{maModel},
|
||||||
|
ma_num = #{maNum},
|
||||||
|
creator = #{creator},
|
||||||
|
remark = #{remark}
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
<update id="del">
|
||||||
|
update ma_own_manage set
|
||||||
|
is_active =1
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="list" resultType="com.bonus.material.owner.domain.Ownerdomin">
|
||||||
|
SELECT
|
||||||
|
m.id,
|
||||||
|
m.type,
|
||||||
|
t.type_id as maNameId,
|
||||||
|
m.company_id as companyId,
|
||||||
|
m.ma_type AS maType,
|
||||||
|
t.type_name AS maName,
|
||||||
|
m.model_id AS modelId,
|
||||||
|
m.ma_model AS maModel,
|
||||||
|
m.ma_num AS maNum,
|
||||||
|
m.create_time AS createTime,
|
||||||
|
m.creator,
|
||||||
|
m.remark
|
||||||
|
FROM
|
||||||
|
ma_own_manage m
|
||||||
|
LEFT JOIN
|
||||||
|
ma_type t ON m.ma_name = t.type_id
|
||||||
|
<where>
|
||||||
|
is_active = 0
|
||||||
|
<if test="type!= null and type != ''">
|
||||||
|
and type like concat('%', #{type}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="maModel!= null and maModel != ''">
|
||||||
|
and ma_model like concat('%', #{maModel}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="maName != null and maName != ''">
|
||||||
|
and ma_name like concat('%', #{maName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="companyId!= null and companyId != ''">
|
||||||
|
and m.company_id = #{companyId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
<select id="listGrouped" resultType="com.bonus.material.equipment.domain.NewOwnerdomin">
|
||||||
|
SELECT
|
||||||
|
md.own_co AS companyId,
|
||||||
|
sd.dept_name as companyName,
|
||||||
|
mt2.type_name AS maName,
|
||||||
|
COUNT(*) AS maNum
|
||||||
|
FROM
|
||||||
|
ma_dev_info md
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = md.type_id
|
||||||
|
LEFT JOIN sys_dept sd ON sd.dept_id = md.own_co
|
||||||
|
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
|
||||||
|
WHERE
|
||||||
|
md.is_active = '1'
|
||||||
|
GROUP BY
|
||||||
|
md.own_co,
|
||||||
|
mt.type_name
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue