This commit is contained in:
parent
5a89c77c8a
commit
caf296d1e6
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.material.basic.mapper;
|
||||
|
||||
import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||
import com.bonus.material.basic.domain.*;
|
||||
import com.bonus.material.basic.domain.vo.MaTypeSelectInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -166,4 +167,25 @@ public interface ComplexQueryMapper {
|
|||
* @return
|
||||
*/
|
||||
List<RetainedEquipmentInfo> getToolsLedgerDetailsList(RetainedEquipmentInfo bean);
|
||||
|
||||
/**
|
||||
* 根据用户Id,查询班组
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
BmTeam getTeamData(String userId);
|
||||
|
||||
/**
|
||||
* 查询班组下库存
|
||||
* @param bmTeam
|
||||
* @return
|
||||
*/
|
||||
List<RetainedEquipmentInfo> getToolsLedgerListByTeam(BmTeam bmTeam);
|
||||
|
||||
/**
|
||||
* 工器具台账详情查询--班组
|
||||
* @param bean1
|
||||
* @return
|
||||
*/
|
||||
List<RetainedEquipmentInfo> getToolsDetailsListByTeam(MaCodeVo bean1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.bonus.common.biz.enums.MaTypeManageTypeEnum;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||
import com.bonus.material.basic.domain.*;
|
||||
import com.bonus.material.basic.domain.vo.MaTypeSelectInfo;
|
||||
import com.bonus.material.basic.mapper.ComplexQueryMapper;
|
||||
|
|
@ -525,7 +527,19 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
|
|||
public List<RetainedEquipmentInfo> getToolsLedgerList(RetainedEquipmentInfo bean) {
|
||||
List<RetainedEquipmentInfo> list1 =new ArrayList<>();
|
||||
try {
|
||||
List<RetainedEquipmentInfo> list = complexQueryMapper.getToolsLedgerList(bean);
|
||||
//1、获取当前用户Id
|
||||
String userId = SecurityUtils.getUserId().toString();
|
||||
//2、判断用户是否为班组长,且对应的是否有班组
|
||||
BmTeam bmTeam=complexQueryMapper.getTeamData(userId);
|
||||
List<RetainedEquipmentInfo> list=new ArrayList<>();
|
||||
if (bmTeam!=null){
|
||||
//不为空,则 是班组长且对应的有班组
|
||||
//查询班组下工器具库存
|
||||
list = complexQueryMapper.getToolsLedgerListByTeam(bmTeam);
|
||||
} else {
|
||||
//没有班组,则查全部
|
||||
list = complexQueryMapper.getToolsLedgerList(bean);
|
||||
}
|
||||
if (list.size()>0){
|
||||
list1 = groupByThirdTypeId(list);
|
||||
}
|
||||
|
|
@ -543,7 +557,22 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
|
|||
*/
|
||||
@Override
|
||||
public List<RetainedEquipmentInfo> getToolsDetailsList(RetainedEquipmentInfo bean) {
|
||||
List<RetainedEquipmentInfo> list = complexQueryMapper.getToolsDetailsList(bean);
|
||||
try {
|
||||
//1、获取当前用户Id
|
||||
String userId = SecurityUtils.getUserId().toString();
|
||||
//2、判断用户是否为班组长,且对应的是否有班组
|
||||
BmTeam bmTeam=complexQueryMapper.getTeamData(userId);
|
||||
List<RetainedEquipmentInfo> list = new ArrayList<>();
|
||||
if (bmTeam!=null) {
|
||||
//不为空,则 是班组长且对应的有班组
|
||||
MaCodeVo bean1 = new MaCodeVo();
|
||||
bean1.setTeamId(bmTeam.getId());
|
||||
bean1.setTypeId(bean.getTypeId()+"");
|
||||
list = complexQueryMapper.getToolsDetailsListByTeam(bean1);
|
||||
} else {
|
||||
//没有班组,则查全部
|
||||
list = complexQueryMapper.getToolsDetailsList(bean);
|
||||
}
|
||||
if (!CollectionUtil.isEmpty(list)) {
|
||||
for (RetainedEquipmentInfo retainedEquipmentInfo : list) {
|
||||
if (StringUtils.isNotBlank(retainedEquipmentInfo.getNextCheckTime())) {
|
||||
|
|
@ -551,7 +580,8 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
|
|||
// 解析字符串日期(格式:yyyy-MM-dd)
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate targetDate = LocalDate.parse(nextCheckTime, formatter);
|
||||
LocalDate currentDate = LocalDate.now(); // 当前日期
|
||||
// 当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
boolean isFuture = targetDate.isAfter(currentDate);
|
||||
if (!isFuture) {
|
||||
// 已过期
|
||||
|
|
@ -583,6 +613,10 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
|
|||
}
|
||||
}
|
||||
return list;
|
||||
} catch (Exception e){
|
||||
log.error("工器具台账详情查询失败", e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1197,6 +1197,124 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
mm.type_id=#{typeId}
|
||||
and mm.ma_status='1'
|
||||
</select>
|
||||
<select id="getTeamData" resultType="com.bonus.material.basic.domain.BmTeam">
|
||||
SELECT bt.id,
|
||||
bt.team_name as teamName
|
||||
FROM sys_user su
|
||||
LEFT JOIN sys_user_role sur on sur.user_id = su.user_id
|
||||
LEFT JOIN sys_role sr on sr.role_id = sur.role_id
|
||||
LEFT JOIN bm_team bt on bt.rel_name = su.user_name
|
||||
WHERE su.user_id = #{userId}
|
||||
and sr.role_name = '班组长'
|
||||
and bt.id is not null LIMIT 1
|
||||
</select>
|
||||
<select id="getToolsLedgerListByTeam" resultType="com.bonus.material.basic.domain.RetainedEquipmentInfo">
|
||||
SELECT
|
||||
COALESCE(t1.typeName, t2.typeName) AS typeName,
|
||||
COALESCE(t1.typeModelName, t2.typeModelName) AS typeModelName,
|
||||
COALESCE(t1.typeId, t2.typeId) AS typeId,
|
||||
COALESCE(t1.thirdTypeId, t2.thirdTypeId) AS thirdTypeId,
|
||||
CASE COALESCE(t1.manageType, t2.manageType)
|
||||
WHEN 0 THEN
|
||||
'编码'
|
||||
ELSE
|
||||
'数量'
|
||||
END manageType,
|
||||
COALESCE(t1.buyPrice, t2.buyPrice) AS buyPrice,
|
||||
COALESCE(t1.unit, t2.unit) AS unit,
|
||||
COALESCE(t1.storeNum, 0) - COALESCE(t2.storeNum, 0) AS storeNum
|
||||
FROM (
|
||||
SELECT
|
||||
mt2.type_name as typeName,
|
||||
mt1.type_name as typeModelName,
|
||||
lod.type_id as typeId,
|
||||
mt2.type_id as thirdTypeId,
|
||||
mt1.manage_type as manageType,
|
||||
mt1.buy_price as buyPrice,
|
||||
mt1.unit_name as unit,
|
||||
SUM(lod.out_num) as storeNum
|
||||
FROM lease_out_details lod
|
||||
LEFT JOIN lease_apply_info lai ON lai.id = lod.parent_id
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id = lod.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
||||
WHERE lai.team_id = #{id}
|
||||
AND lod.is_finished = '1'
|
||||
GROUP BY lod.type_id
|
||||
) AS t1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
mt2.type_name as typeName,
|
||||
mt1.type_name as typeModelName,
|
||||
bcd.type_id as typeId,
|
||||
mt2.type_id as thirdTypeId,
|
||||
mt1.manage_type as manageType,
|
||||
mt1.buy_price as buyPrice,
|
||||
mt1.unit_name as unit,
|
||||
SUM(bcd.back_num) as storeNum
|
||||
FROM back_check_details bcd
|
||||
LEFT JOIN back_apply_info bai ON bai.id = bcd.parent_id
|
||||
LEFT JOIN tm_task tt ON tt.task_id = bai.task_id
|
||||
LEFT JOIN tm_task_agreement tta ON tta.task_id = tt.task_id
|
||||
LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id = bcd.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
||||
WHERE bagi.team_id = #{id}
|
||||
AND bcd.is_finished = '1'
|
||||
GROUP BY bcd.type_id
|
||||
) AS t2 ON t1.typeId = t2.typeId
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
COALESCE(t1.typeName, t2.typeName) AS typeName,
|
||||
COALESCE(t1.typeModelName, t2.typeModelName) AS typeModelName,
|
||||
COALESCE(t1.typeId, t2.typeId) AS typeId,
|
||||
COALESCE(t1.thirdTypeId, t2.thirdTypeId) AS thirdTypeId,
|
||||
COALESCE(t1.manageType, t2.manageType) AS manageType,
|
||||
COALESCE(t1.buyPrice, t2.buyPrice) AS buyPrice,
|
||||
COALESCE(t1.unit, t2.unit) AS unit,
|
||||
COALESCE(t1.storeNum, 0) - COALESCE(t2.storeNum, 0) AS diff_num
|
||||
FROM (
|
||||
SELECT
|
||||
mt2.type_name as typeName,
|
||||
mt1.type_name as typeModelName,
|
||||
lod.type_id as typeId,
|
||||
mt2.type_id as thirdTypeId,
|
||||
mt1.manage_type as manageType,
|
||||
mt1.buy_price as buyPrice,
|
||||
mt1.unit_name as unit,
|
||||
SUM(lod.out_num) as storeNum
|
||||
FROM lease_out_details lod
|
||||
LEFT JOIN lease_apply_info lai ON lai.id = lod.parent_id
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id = lod.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
||||
WHERE lai.team_id = #{id}
|
||||
AND lod.is_finished = '1'
|
||||
GROUP BY lod.type_id
|
||||
) AS t1
|
||||
RIGHT JOIN (
|
||||
SELECT
|
||||
mt2.type_name as typeName,
|
||||
mt1.type_name as typeModelName,
|
||||
bcd.type_id as typeId,
|
||||
mt2.type_id as thirdTypeId,
|
||||
mt1.manage_type as manageType,
|
||||
mt1.buy_price as buyPrice,
|
||||
mt1.unit_name as unit,
|
||||
SUM(bcd.back_num) as storeNum
|
||||
FROM back_check_details bcd
|
||||
LEFT JOIN back_apply_info bai ON bai.id = bcd.parent_id
|
||||
LEFT JOIN tm_task tt ON tt.task_id = bai.task_id
|
||||
LEFT JOIN tm_task_agreement tta ON tta.task_id = tt.task_id
|
||||
LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id = bcd.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
||||
WHERE bagi.team_id = #{id}
|
||||
AND bcd.is_finished = '1'
|
||||
GROUP BY bcd.type_id
|
||||
) AS t2 ON t1.typeId = t2.typeId
|
||||
WHERE t1.typeId IS NULL
|
||||
</select>
|
||||
|
||||
<select id="getToolsDetailsList" resultType="com.bonus.material.basic.domain.RetainedEquipmentInfo">
|
||||
SELECT
|
||||
|
|
@ -1215,5 +1333,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
AND mm.ma_code like concat('%',#{maCode},'%')
|
||||
</if>
|
||||
</select>
|
||||
<select id="getToolsDetailsListByTeam" resultType="com.bonus.material.basic.domain.RetainedEquipmentInfo">
|
||||
SELECT aa.typeName,
|
||||
aa.typeModelName,
|
||||
mm.ma_code as maCode,
|
||||
msc.this_check_time as thisCheckTime,
|
||||
msc.next_check_time as nextCheckTime
|
||||
FROM (SELECT t1.maId,
|
||||
t1.typeName,
|
||||
t1.typeModelName,
|
||||
t1.typeId,
|
||||
t1.thirdTypeId,
|
||||
t1.manageType
|
||||
FROM (SELECT lod.ma_id as maId,
|
||||
mt2.type_name as typeName,
|
||||
mt1.type_name as typeModelName,
|
||||
lod.type_id as typeId,
|
||||
mt2.type_id as thirdTypeId,
|
||||
mt1.manage_type as manageType,
|
||||
mt1.buy_price as buyPrice,
|
||||
mt1.unit_name as unit,
|
||||
COUNT(*) as count
|
||||
FROM
|
||||
lease_out_details lod
|
||||
LEFT JOIN lease_apply_info lai
|
||||
on lai.id=lod.parent_id
|
||||
LEFT JOIN ma_type mt1 on mt1.type_id=lod.type_id
|
||||
LEFT JOIN ma_type mt2 on mt2.type_id=mt1.parent_id
|
||||
WHERE
|
||||
lai.team_id=#{teamId}
|
||||
and lod.is_finished='1'
|
||||
and lod.type_id=#{typeId}
|
||||
GROUP BY lod.ma_id, lod.type_id) t1
|
||||
LEFT JOIN (SELECT bcd.ma_id as maId,
|
||||
COUNT(*) as count
|
||||
FROM
|
||||
back_check_details bcd
|
||||
LEFT JOIN back_apply_info bai
|
||||
on bai.id=bcd.parent_id
|
||||
LEFT JOIN tm_task tt on tt.task_id = bai.task_id
|
||||
LEFT JOIN tm_task_agreement tta on tta.task_id = tt.task_id
|
||||
LEFT JOIN bm_agreement_info bagi on bagi.agreement_id = tta.agreement_id
|
||||
WHERE
|
||||
bagi.team_id=#{teamId}
|
||||
and bcd.is_finished='1'
|
||||
and bcd.type_id=#{typeId}
|
||||
GROUP BY bcd.ma_id) t2 ON t1.maId = t2.maId
|
||||
WHERE t1.count > IFNULL(t2.count, 0)) aa
|
||||
LEFT JOIN ma_machine mm
|
||||
on aa.maId = mm.ma_id
|
||||
LEFT JOIN ma_station_code msc on mm.ma_code = msc.ma_code
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue