领料接口优化

This commit is contained in:
sxu 2024-11-13 10:19:50 +08:00
parent dfdf56a8c8
commit d4db651eec
8 changed files with 256 additions and 6 deletions

View File

@ -49,6 +49,8 @@ public class MaterialConstants {
*/
public static final Integer TEN_CONSTANT = 10;
public final static String STRING_ADMIN = "admin";
/** 协议号的开头字母 */
public static final String AGREEMENT_PREFIX = "H";

View File

@ -1,6 +1,8 @@
package com.bonus.material.lease.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
@ -127,5 +129,8 @@ public class LeaseApplyInfo extends BaseEntity {
@ApiModelProperty(value = "费用承担方(01项目03分包)")
private String costBearingParty;
/** 机具规格详情列表 */
@ApiModelProperty(value = "机具规格详情列表")
List<LeaseApplyDetails> leaseApplyDetails;
}

View File

@ -2,8 +2,11 @@ package com.bonus.material.task.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.task.domain.vo.TmTaskRequestVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -116,4 +119,33 @@ public class TmTaskController extends BaseController {
public AjaxResult remove(@PathVariable Long[] taskIds) {
return toAjax(tmTaskService.deleteTmTaskByTaskIds(taskIds));
}
/**
* 查询机具领料申请列表个人
*
* @param task 筛选条件
* @param souceBy app为1 web为0
* @return 列表
*/
@ApiOperation(value = "查询机具领料申请列表")
@PreventRepeatSubmit
@RequiresPermissions("task:task:query")
@SysLog(title = "任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->查询机具领料申请列表")
@GetMapping(value = "getLeaseAuditListAll")
public AjaxResult getLeaseAuditListAll(TmTaskRequestVo task, Integer souceBy) {
if (StringUtils.isNull(task)) {
return AjaxResult.error("参数错误");
}
List<TmTaskRequestVo> leaseAuditList;
if (souceBy != null && souceBy == 1) {
leaseAuditList = tmTaskService.getLeaseAuditList(task);
return AjaxResult.success(leaseAuditList);
} else {
startPage();
leaseAuditList = tmTaskService.getLeaseAuditList(task);
return AjaxResult.success(getDataTable(leaseAuditList));
}
}
}

View File

@ -42,12 +42,6 @@ public class TmTaskRequestVo extends BaseEntity {
@ApiModelProperty(value = "任务当月序号 例如:1 插入及查询时请携带任务类型")
private Integer monthOrder;
@ApiModelProperty(value = "领料任务汇总")
private LeaseApplyInfo leaseApplyInfo;
@ApiModelProperty(value = "领料任务物资列表")
private List<LeaseApplyDetails> leaseApplyDetailsList;
@ApiModelProperty(value = "协议id")
private Long agreementId;
@ -69,4 +63,21 @@ public class TmTaskRequestVo extends BaseEntity {
@ApiModelProperty(value = "工程id")
private Long projectId;
/**
* 预领料合计数
*/
@ApiModelProperty(value = "预领料合计数")
private Integer preCountNum;
/**
* 领料任务实体集合
*/
@ApiModelProperty(value = "领料任务实体集合")
private List<LeaseApplyInfo> leaseApplyInfoList;
@ApiModelProperty(value = "领料任务汇总")
private LeaseApplyInfo leaseApplyInfo;
@ApiModelProperty(value = "领料任务物资列表")
private List<LeaseApplyDetails> leaseApplyDetailsList;
}

View File

@ -1,7 +1,11 @@
package com.bonus.material.task.mapper;
import java.util.List;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.domain.LeaseApplyInfo;
import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.domain.vo.TmTaskRequestVo;
import org.apache.ibatis.annotations.Param;
/**
@ -84,4 +88,12 @@ public interface TmTaskMapper {
int updateStatusById(@Param("updatedStatus") Integer updatedStatus, @Param("id") String id);
int deleteTmTaskByPurchaseIds(Long[] ids);
List<TmTaskRequestVo> getAuditListByLeaseTmTask(@Param("record") TmTaskRequestVo tmTaskRequestVo);
List<TmTaskRequestVo> getAuditListByLeaseTmTaskByPeople(@Param("record") TmTaskRequestVo tmTaskRequestVo);
List<LeaseApplyInfo> getAuditListByLeaseInfo(@Param("record") TmTaskRequestVo record);
List<LeaseApplyDetails> getLeaseApplyDetails(@Param("record") LeaseApplyInfo record);
}

View File

@ -2,6 +2,7 @@ package com.bonus.material.task.service;
import java.util.List;
import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.domain.vo.TmTaskRequestVo;
/**
* 任务Service接口
@ -57,4 +58,6 @@ public interface ITmTaskService {
* @return 结果
*/
public int deleteTmTaskByTaskId(Long taskId);
List<TmTaskRequestVo> getLeaseAuditList(TmTaskRequestVo tmTask);
}

View File

@ -1,8 +1,15 @@
package com.bonus.material.task.service.impl;
import java.util.List;
import java.util.Set;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.domain.LeaseApplyInfo;
import com.bonus.material.task.domain.vo.TmTaskRequestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.material.task.mapper.TmTaskMapper;
@ -95,4 +102,53 @@ public class TmTaskServiceImpl implements ITmTaskService {
public int deleteTmTaskByTaskId(Long taskId) {
return tmTaskMapper.deleteTmTaskByTaskId(taskId);
}
/**
* 获取单个申请列表
*/
@Override
public List<TmTaskRequestVo> getLeaseAuditList(TmTaskRequestVo tmTaskRequestVo) {
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
List<TmTaskRequestVo> tmTaskList;
if (roles.contains(MaterialConstants.STRING_ADMIN)) {
tmTaskList = tmTaskMapper.getAuditListByLeaseTmTask(tmTaskRequestVo);
} else {
String username = SecurityUtils.getLoginUser().getUsername();
tmTaskRequestVo.setCreateBy(username);
tmTaskList = tmTaskMapper.getAuditListByLeaseTmTaskByPeople(tmTaskRequestVo);
}
for (TmTaskRequestVo tmTask : tmTaskList) {
int count = 0;
if (tmTask != null) {
// 去查询任务分单表
List<LeaseApplyInfo> auditListByLeaseInfo = tmTaskMapper.getAuditListByLeaseInfo(tmTask);
if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) {
// 对领料任务集合查询具体详情
for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) {
if (leaseApplyInfo != null) {
// 去查询领料任务详情表
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyDetails(leaseApplyInfo);
if (leaseApplyDetails != null && !leaseApplyDetails.isEmpty()) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
// 统计预领数量
count += leaseApplyDetail.getPreNum();
}
}
// 塞入领料任务详情的集合中
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
}
}
}
// 存入领料任务实体集合
tmTask.setLeaseApplyInfoList(auditListByLeaseInfo);
tmTask.setRemark(auditListByLeaseInfo.get(0).getRemark());
}
// 塞入预领的合计数量
tmTask.setPreCountNum(count);
}
}
return tmTaskList;
}
}

View File

@ -128,4 +128,133 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
)
</delete>
<select id="getAuditListByLeaseTmTask" resultType="com.bonus.material.task.domain.vo.TmTaskRequestVo">
SELECT DISTINCT
tt.*, su.phonenumber AS phoneNumber, sd.dept_name as deptName,
bpl.lot_id as proId,bpl.lot_name as proName,
bui.unit_id as unitId,bui.unit_name as unitName,
lai.lease_person as leasePerson, lai.phone as leasePhone, tt.create_by as applyFor,d.`name` as taskName,lai.lease_type as leaseType,lai.estimate_lease_time as estimateLeaseTime,
case when d.id = '31' then lai.company_audit_remark
when d.id = '32' then lai.dept_audit_remark
when d.id = '33' then lai.direct_audit_remark
when d.id = '98' then lai.company_audit_remark
when d.id = '99' then lai.dept_audit_remark
when d.id = '100' then lai.direct_audit_remark
end examineStatus,
d.id as examineStatusId,
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
tm_task tt
LEFT JOIN sys_user su ON tt.create_by = su.user_name
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
WHERE
tt.task_type = '29' and tt.status = '1'
<if test="record.taskId != null and record.taskId != '' ">
AND tt.task_id = #{record.taskId}
</if>
<if test="record.startTime != null and record.startTime != '' and record.endTime != null and record.endTime != '' ">
AND tt.update_time BETWEEN CONCAT(#{record.startTime}, ' 00:00:00') AND CONCAT(#{record.endTime}, ' 23:59:59')
</if>
<if test="record.unitId != null and record.unitId != ''">
AND bui.unit_id = #{record.unitId}
</if>
<if test="record.projectId != null and record.projectId != ''">
AND bpl.lot_id = #{record.projectId}
</if>
<if test="record.keyWord != null and record.keyWord != ''">
AND (bai.agreement_code like concat('%', #{record.keyWord}, '%') or
tt.code like concat('%', #{record.keyWord}, '%'))
</if>
GROUP BY tt.task_id
ORDER BY tt.update_time DESC
</select>
<select id="getAuditListByLeaseTmTaskByPeople" resultType="com.bonus.material.task.domain.vo.TmTaskRequestVo">
SELECT DISTINCT
tt.*, su.phonenumber AS phoneNumber, sd.dept_name as deptName,
bpl.lot_id as proId,bpl.lot_name as proName,
bui.unit_id as unitId,bui.unit_name as unitName,
lai.lease_person as leasePerson, lai.phone as leasePhone, tt.create_by as applyFor,d.`name` as taskName,lai.lease_type as leaseType,lai.estimate_lease_time as estimateLeaseTime,
case when d.id = '31' then lai.company_audit_remark
when d.id = '32' then lai.dept_audit_remark
when d.id = '33' then lai.direct_audit_remark
when d.id = '98' then lai.company_audit_remark
when d.id = '99' then lai.dept_audit_remark
when d.id = '100' then lai.direct_audit_remark
end examineStatus ,
d.id as examineStatusId,
bai.agreement_code as agreementCode,
tt.create_time as createTimes, tt.update_time as updateTimes
FROM
tm_task tt
LEFT JOIN sys_user su ON tt.create_by = su.user_name
LEFT JOIN sys_dept sd ON su.dept_id = sd.dept_id
LEFT JOIN tm_task_agreement tta ON tt.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN lease_apply_info lai ON lai.task_id = tt.task_id
LEFT JOIN sys_dic d ON d.id = tt.task_status
WHERE
tt.task_type = '29' and tt.status = '1' and tt.create_by = #{record.createBy}
<if test="record.taskId != null and record.taskId != '' ">
AND tt.task_id = #{record.taskId}
</if>
<if test="record.startTime != null and record.startTime != '' and record.endTime != null and record.endTime != '' ">
AND tt.update_time BETWEEN CONCAT(#{record.startTime}, ' 00:00:00') AND CONCAT(#{record.endTime}, ' 23:59:59')
</if>
<if test="record.unitId != null and record.unitId != ''">
AND bui.unit_id = #{record.unitId}
</if>
<if test="record.projectId != null and record.projectId != ''">
AND bpl.lot_id = #{record.projectId}
</if>
<if test="record.keyWord != null and record.keyWord != ''">
AND (bai.agreement_code like concat('%', #{record.keyWord}, '%') or
tt.code like concat('%', #{record.keyWord}, '%'))
</if>
GROUP BY tt.task_id
ORDER BY tt.update_time DESC
</select>
<select id="getAuditListByLeaseInfo" resultType="com.bonus.material.lease.domain.LeaseApplyInfo">
SELECT
lai.*
FROM
lease_apply_info lai
WHERE
lai.task_id = #{record.taskId} AND lai.`code` = #{record.code}
</select>
<select id="getLeaseApplyDetails" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
lad.*, mt.type_name AS typeModelName, mt1.type_name AS typeName,mt.unit_name as unitName, mt.manage_type as manageType,
case WHEN mt.manage_type = '0' then '编号' else '计数' end manageTypeName,
mt.num, (lad.pre_num - IF(lad.al_num IS NULL,'0',lad.al_num)) AS outNum,mm.ma_code as maCode
FROM
lease_apply_details lad
LEFT JOIN ma_type mt ON lad.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
LEFT JOIN ma_machine mm ON lad.type_id = mm.type_id
WHERE
lad.parent_id = #{record.id} AND lad.company_id = #{record.companyId}
GROUP BY
lad.id
</select>
</mapper>