功能优化

This commit is contained in:
mashuai 2025-09-03 02:29:08 +08:00
parent ed8924f9bc
commit 714959eb41
19 changed files with 230 additions and 56 deletions

View File

@ -32,13 +32,6 @@ public interface MaterialLeaseInfoMapper {
*/
List<MaterialLeaseApplyInfo> selectLeaseApplyInfoList(MaterialLeaseApplyInfo leaseApplyInfo);
/**
* 查询领料任务数量
* @param applyInfo
* @return
*/
BigDecimal getNumList(MaterialLeaseApplyInfo applyInfo);
/**
* 查询总站点领料记录数据
* @param leaseApplyInfo

View File

@ -137,7 +137,6 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
}
// 处理剩余数据
if (!CollectionUtils.isEmpty(sortedList)) {
processLeaseApplyInfo(sortedList);
// 关键字过滤
String keyWord = leaseApplyInfo.getKeyWord();
if (!StringUtils.isBlank(keyWord)) {
@ -187,28 +186,6 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
return list;
}
/**
* 处理数据
*
* @param list
*/
private void processLeaseApplyInfo(List<MaterialLeaseApplyInfo> list) {
for (MaterialLeaseApplyInfo applyInfo : list) {
// 根据id查询已领料出库数据
BigDecimal num = materialLeaseInfoMapper.getNumList(applyInfo);
if (num == null) {
num = BigDecimal.ZERO;
}
applyInfo.setAlNum(num);
applyInfo.setWaitCountNum(applyInfo.getPreCountNum().subtract(num).compareTo(BigDecimal.ZERO) <= 0 ?
BigDecimal.ZERO : applyInfo.getPreCountNum().subtract(num));
if (StringUtils.isNotBlank(applyInfo.getLeaseSignUrl())) {
applyInfo.setIsElectronicSign(0);
} else {
applyInfo.setIsElectronicSign(1);
}
}
}
/**
* 关键字搜索

View File

@ -181,6 +181,18 @@ public class LeaseApplyInfoController extends BaseController {
return success(leaseApplyInfoService.selectLeaseApplyInfoById(id, keyWord, publishTask));
}
/**
* 获取领料出库详细信息
* @param bean
* @return
*/
@ApiOperation(value = "获取领料出库详细信息")
//@RequiresPermissions("lease:info:query")
@GetMapping(value = "/getOutInfo")
public AjaxResult getOutInfo(LeaseApplyInfo bean) {
return success(leaseApplyInfoService.getOutInfo(bean));
}
/**
* 获取领料任务详细信息
*/

View File

@ -192,4 +192,11 @@ public interface ILeaseApplyInfoService {
* @return
*/
AjaxResult updateLeaseNum(LeaseApplyDetails leaseApplyDetails);
/**
* 获取领料出库详细信息
* @param bean
* @return
*/
List<LeaseApplyDetails> getOutInfo(LeaseApplyInfo bean);
}

View File

@ -41,7 +41,6 @@ import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.domain.TmTaskAgreement;
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
import com.bonus.material.task.mapper.TmTaskMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
@ -781,6 +780,123 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
}
}
/**
* 获取领料出库详细信息
* @param bean
* @return
*/
@Override
public List<LeaseApplyDetails> getOutInfo(LeaseApplyInfo bean) {
// 性能监控开始
long startTime = System.currentTimeMillis();
Map<String, Long> stepTimes = new LinkedHashMap<>();
String keyword = bean.getKeyWord();
String publishTask = bean.getPublishTask();
try {
// 步骤1: 初始化查询对象和获取用户信息
long step1Start = System.currentTimeMillis();
LeaseApplyInfo leaseApplyInfo = new LeaseApplyInfo();
leaseApplyInfo.setId(bean.getId());
Long userId = SecurityUtils.getLoginUser().getUserid();
stepTimes.put("初始化和获取用户信息", System.currentTimeMillis() - step1Start);
// 步骤2: 查询用户绑定的物资类型
long step2Start = System.currentTimeMillis();
List<Long> typeIdList = leaseApplyInfoMapper.selectTypeIdList(userId);
stepTimes.put("查询用户绑定物资类型", System.currentTimeMillis() - step2Start);
// 步骤3: 设置查询参数
if (!CollectionUtils.isEmpty(typeIdList)) {
leaseApplyInfo.setTypeIdList(typeIdList);
} else {
leaseApplyInfo.setUserId(userId);
}
if (StringUtils.isNotBlank(keyword)) {
leaseApplyInfo.setKeyWord(keyword);
}
if (StringUtils.isNotBlank(publishTask)) {
leaseApplyInfo.setPublishTask(publishTask);
}
// 步骤8: 获取领料单详情
long step8Start = System.currentTimeMillis();
List<LeaseApplyDetails> details;
if (!CollectionUtils.isEmpty(typeIdList)) {
details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(bean.getId(), keyword, null, typeIdList));
} else {
details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(bean.getId(), keyword, userId, null));
}
stepTimes.put("获取领料单详情", System.currentTimeMillis() - step8Start);
// 步骤81: 获取领料单详情
long step81Start = System.currentTimeMillis();
// 走单独的领用详情查询
if (StringUtils.isNotBlank(publishTask)) {
// 根据领用批次查询领用详情
details = leaseApplyDetailsMapper.getDetailsPublish(leaseApplyInfo);
if (!CollectionUtils.isEmpty(details)) {
for (LeaseApplyDetails detail : details) {
// 根据parent_id和type_id查询出库数量
BigDecimal outNum = leaseApplyDetailsMapper.getOutNum(detail);
detail.setAlNum(outNum);
detail.setOutNum(detail.getPreNum().subtract(outNum));
if (detail.getPreNum().compareTo(detail.getAlNum()) == 0) {
detail.setStatus("2");
} else {
detail.setStatus("1");
}
}
}
}
if (details.size() > 0) {
for (LeaseApplyDetails detail : details) {
//查询类型的库存和总待出库数量
LeaseApplyDetails pendingOutNum = mapper.selectPendingOutNum(detail);
detail.setPendingOutNum(pendingOutNum.getPendingOutNum());
detail.setStorageNum(pendingOutNum.getStorageNum());
}
}
stepTimes.put("领用发布查询", System.currentTimeMillis() - step81Start);
if (!CollectionUtils.isEmpty(details)) {
// 收集所有typeId
List<Long> typeIds = details.stream()
.map(LeaseApplyDetails::getTypeId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(typeIds)) {
// 一次性批量查询所有编码详情
List<MaCodeVo> allMaCodeList = leaseApplyDetailsMapper.getCodeListBatch(bean.getId(), typeIds);
// 按typeId分组
Map<String, List<MaCodeVo>> maCodeMap = allMaCodeList.stream()
.filter(maCode -> maCode.getTypeId() != null)
.collect(Collectors.groupingBy(MaCodeVo::getTypeId));
// 分配给对应的detail
for (LeaseApplyDetails detail : details) {
if (detail.getTypeId() != null) {
List<MaCodeVo> maCodeVoList = maCodeMap.get(detail.getTypeId().toString());
if (!CollectionUtils.isEmpty(maCodeVoList)) {
detail.setMaCodeVoList(maCodeVoList);
}
}
}
}
}
return details;
} catch (Exception e) {
// 记录异常日志和性能数据
long totalTime = System.currentTimeMillis() - startTime;
log.error("selectLeaseApplyInfoById执行异常耗时: {}ms, id: {}, 错误: {}", totalTime, bean.getId(), e.getMessage());
DateTimeHelper.logPerformanceAnalysis("selectLeaseApplyInfoById(异常)", totalTime, stepTimes);
System.err.println("Error occurred while selecting lease apply info by ID: " + bean.getId() + e.getMessage());
throw new RuntimeException("查询失败,请联系管理员");
}
}
/**
* 关键字搜索

View File

@ -349,8 +349,31 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService {
*/
@Override
public List<LeaseApplyInfo> selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo) {
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
leaseApplyInfo.setDeptId(deptId == 0 ? null : deptId);
Long userId = SecurityUtils.getLoginUser().getUserid();
leaseApplyInfo.setUserId(userId == 0 ? null : userId);
leaseApplyInfo.setUserId(userId == 1 ? null : userId);
if(userId == 1 || deptId == 101 || deptId == 345) {
leaseApplyInfo.setDeptId(null);
} else {
//判断祖籍有没有101
String ancestors = mapper.getAncestors(deptId);
boolean contains101 = false;
if (ancestors != null && !ancestors.isEmpty()) {
String[] parts = ancestors.split(",");
for (String part : parts) {
if ("101".equals(part.trim())) {
contains101 = true;
break;
}
}
}
if(contains101){
leaseApplyInfo.setDeptId(null);
} else {
leaseApplyInfo.setDeptId(deptId);
}
}
List<LeaseApplyInfo> list = mapper.selectLeaseApplyInfoList(leaseApplyInfo);
if (!CollectionUtils.isEmpty(list)) {
for (LeaseApplyInfo applyInfo : list) {
@ -540,8 +563,12 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService {
}
TmTask tmTask = tmTaskMapper.selectTmTaskByTaskId(leaseApplyInfo.getTaskId());
if (statusFlag == 0) {
// 判断该任务是否已经在sys_workflow_record表中创建
int result = sysWorkflowRecordService.selectSysWorkflowRecordByTaskId(leaseApplyInfo);
if (result == 0) {
sysWorkflowRecordService.addSysWorkflowRecord(leaseApplyInfo.getTaskId().intValue(), tmTask.getCode(), 19);
}
}
// 修改外层info
leaseApplyInfo.setCode(tmTask.getCode());
mapper.updateLeaseApplyInfo(leaseApplyInfo);

View File

@ -42,11 +42,11 @@ public class UseMaintenanceWarningController extends BaseController
}
/**
* 查询安全工器具检修过期列表
* 查询安全工器具检修列表
* @param bean
* @return
*/
@ApiOperation(value = "查询安全工器具检修过期列表")
@ApiOperation(value = "查询安全工器具检修列表")
@GetMapping("/getOverTimeList")
public TableDataInfo getOverTimeList(UseMaintenanceWarningBean bean)
{

View File

@ -130,4 +130,7 @@ public class UseMaintenanceWarningBean extends BaseEntity {
private String userName;
private Long userId;
@ApiModelProperty(value = "状态筛选")
private Integer status;
}

View File

@ -33,7 +33,7 @@ public interface UseMaintenanceWarningMapper
List<UseMaintenanceWarningBean> getUserManger(UseMaintenanceWarningBean bean);
/**
* 查询安全工器具检修过期列表
* 查询安全工器具检修列表
* @param bean
* @return
*/

View File

@ -38,7 +38,7 @@ public class UseMaintenanceWarningServiceImpl implements UseMaintenanceWarningSe
}
/**
* 查询安全工器具检修过期列表
* 查询安全工器具检修列表
* @param bean
* @return
*/

View File

@ -1,8 +1,8 @@
package com.bonus.material.work.mapper;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.material.work.domain.SysWorkflowRecord;
import com.bonus.material.work.domain.SysWorkflowRecordHistory;
import com.bonus.material.work.domain.SysWorkflowType;
import com.bonus.material.work.domain.dto.SysWorkflowAuditDto;
import org.apache.ibatis.annotations.Param;
@ -32,5 +32,12 @@ public interface SysWorkflowRecordMapper {
int updateSysWorkflowType(SysWorkflowRecord sysWorkflowRecord);
/**
* 判断该任务是否已经在sys_workflow_record表中创建
* @param leaseApplyInfo
* @return
*/
int selectSysWorkflowRecordByTaskId(LeaseApplyInfo leaseApplyInfo);
int selectLeaseAgreementIdByRecordId(Integer taskId);
}

View File

@ -1,8 +1,16 @@
package com.bonus.material.work.service;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
public interface SysWorkflowRecordService {
int addSysWorkflowRecord(int taskId,String taskCode,int taskType);
/**
* 判断该任务是否已经在sys_workflow_record表中创建
* @param leaseApplyInfo
* @return
*/
int selectSysWorkflowRecordByTaskId(LeaseApplyInfo leaseApplyInfo);
}

View File

@ -1,5 +1,6 @@
package com.bonus.material.work.service.impl;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.biz.enums.TmTaskTypeEnum;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
@ -16,10 +17,8 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
public class SysWorkflowRecordServiceImpl implements SysWorkflowRecordService {
@ -120,4 +119,14 @@ public class SysWorkflowRecordServiceImpl implements SysWorkflowRecordService {
sysWorkflowRecordHistoryMapper.addSysWorkflowRecordHistory(sysWorkflowRecordHistory);
return newId;
}
/**
* 判断该任务是否已经在sys_workflow_record表中创建
* @param leaseApplyInfo
* @return
*/
@Override
public int selectSysWorkflowRecordByTaskId(LeaseApplyInfo leaseApplyInfo) {
return sysWorkflowRecordMapper.selectSysWorkflowRecordByTaskId(leaseApplyInfo);
}
}

View File

@ -375,6 +375,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE
sai.`status` = '0' and sai.`is_slt` = '0'
AND (sai.source = 1 OR sai.source is NULL)
AND sai.end_time IS NULL
AND sai.back_id IS NULL
GROUP BY mt.type_id

View File

@ -75,7 +75,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
lai.team_id as teamId,
bt.unit_name as teamName,
IFNULL(sum(lad.pre_num),0) as preCountNum,
IFNULL(sum(lad.al_num),0) as alNum,
IFNULL(lod.num,0) as alNum,
IFNULL(sum(lad.pre_num),0) - IFNULL(lod.num,0) as waitCountNum,
GROUP_CONCAT(DISTINCT mt1.type_name) as maTypeNames,
bp.contract_part as contractPart,
sd.dept_name as impUnitName,
@ -85,13 +86,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bt.bzz_idcard,
bai.unit_id,
bai.project_id as projectId,
bt.link_man as relName
bt.link_man as relName,
CASE WHEN lai.lease_sign_url IS NOT NULL
THEN 0
ELSE 1
END as isElectronicSign
from
clz_lease_apply_info lai
left join tm_task tt on lai.task_id = tt.task_id
left join tm_task_agreement tta ON tt.task_id = tta.task_id
left join clz_bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
left join clz_lease_apply_details lad on lai.id = lad.parent_id
LEFT JOIN (SELECT IFNULL( sum(out_num ), 0) AS num, parent_id from clz_lease_out_details
WHERE is_finished = 1 GROUP BY parent_id) lod ON lai.id = lod.parent_id
left join bm_project bp on bp.pro_id = lai.project_id
left join bm_unit bt on bt.unit_id = lai.team_id
left join sys_dept sd on sd.dept_id = bp.imp_unit
@ -413,16 +420,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
GROUP BY lai.id
ORDER BY tt.task_status,tt.create_time desc
</select>
<select id="getNumList" resultType="java.math.BigDecimal">
SELECT
SUM(IFNULL( out_num, 0 ))
FROM
clz_lease_out_details
WHERE
parent_id = #{id}
ORDER BY tt.create_time desc
</select>
<select id="getTotalList" resultType="com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo">

View File

@ -543,7 +543,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getUnitListLeasePerson" resultType="com.bonus.material.basic.domain.BmUnit">
SELECT
pau.`name` as leasePerson,
pau.id_number as idCard
pau.id_number as idCard,
pau.phone as telphone
FROM
pro_authorize_info pai
LEFT JOIN pro_authorize_user pau ON pai.id = pau.parent_id
@ -603,7 +604,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
id
FROM
`data_center`.dx_fb_son
WHERE project_status = '在建'
WHERE
1 = 1
<if test="departId != null and departId != ''">
AND project_dept_id = #{departId}
</if>

View File

@ -450,7 +450,7 @@
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if>
<if test="directId != null ">and lai.direct_id = #{directId}</if>
<if test="deptId != null ">and bp.imp_unit = #{deptId}</if>
<if test="leaseType != null and leaseType != ''">and lai.lease_type = #{leaseType}</if>
<if test="estimateLeaseTime != null ">and lai.estimate_lease_time = #{estimateLeaseTime}</if>
<if test="costBearingParty != null and costBearingParty != ''">and lai.cost_bearing_party =

View File

@ -231,7 +231,12 @@
mm.ma_status='2' and sai.is_slt = 0
AND bp.pro_name is not null
AND mt.jiju_type = 2
AND mm.next_check_time &lt;= CURDATE()
<if test="status != null and status == 0">
AND mm.next_check_time &gt;= CURDATE()
</if>
<if test="status != null and status == 1">
AND mm.next_check_time &lt; CURDATE()
</if>
<if test="keyWord != null and keyWord != ''">
and (
mt4.type_name like concat('%', #{keyWord}, '%') or

View File

@ -66,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and a.workflow_id = #{workflowId}
</if>
</where>
LIMIT 1
</select>
<select id="getAuditStatus" resultType="com.bonus.material.work.domain.SysWorkflowRecordHistory">
@ -79,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sys_workflow_record a
where task_id = #{taskId}
LIMIT 1
</select>
<select id="getAuditUserByTaskId" resultType="com.bonus.material.work.domain.SysWorkflowRecordHistory">
@ -111,6 +113,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and sp.is_examine = 0
</select>
<select id="selectSysWorkflowRecordByTaskId" resultType="java.lang.Integer">
select
count(1)
from sys_workflow_record
where task_id = #{taskId}
</select>
<select id="selectLeaseAgreementIdByRecordId" resultType="java.lang.Integer">
select
dai.lease_agreement_id as leaseAgreementId