领料接口优化

This commit is contained in:
sxu 2024-11-13 15:20:20 +08:00
parent 3db75704c5
commit e18a20bf1b
6 changed files with 179 additions and 192 deletions

View File

@ -127,25 +127,25 @@ public class TmTaskController extends BaseController {
* @param souceBy app为1 web为0 * @param souceBy app为1 web为0
* @return 列表 * @return 列表
*/ */
@ApiOperation(value = "查询机具领料申请列表") // @ApiOperation(value = "查询机具领料申请列表")
@PreventRepeatSubmit // @PreventRepeatSubmit
@RequiresPermissions("task:task:query") // @RequiresPermissions("task:task:query")
@SysLog(title = "任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->查询机具领料申请列表") // @SysLog(title = "任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->查询机具领料申请列表")
@GetMapping(value = "getLeaseAuditListAll") // @GetMapping(value = "getLeaseAuditListAll")
public AjaxResult getLeaseAuditListAll(TmTaskRequestVo task, Integer souceBy) { // public AjaxResult getLeaseAuditListAll(TmTaskRequestVo task, Integer souceBy) {
if (StringUtils.isNull(task)) { // if (StringUtils.isNull(task)) {
return AjaxResult.error("参数错误"); // return AjaxResult.error("参数错误");
} // }
List<TmTaskRequestVo> leaseAuditList; // List<TmTaskRequestVo> leaseAuditList;
if (souceBy != null && souceBy == 1) { // if (souceBy != null && souceBy == 1) {
leaseAuditList = tmTaskService.getLeaseAuditList(task); // leaseAuditList = tmTaskService.getLeaseAuditList(task);
return AjaxResult.success(leaseAuditList); // return AjaxResult.success(leaseAuditList);
} else { // } else {
startPage(); // startPage();
leaseAuditList = tmTaskService.getLeaseAuditList(task); // leaseAuditList = tmTaskService.getLeaseAuditList(task);
return AjaxResult.success(getDataTable(leaseAuditList)); // return AjaxResult.success(getDataTable(leaseAuditList));
} // }
} // }
} }

View File

@ -89,12 +89,6 @@ public class TmTaskRequestVo extends BaseEntity {
@ApiModelProperty(value = "关键字") @ApiModelProperty(value = "关键字")
private String keyWord; private String keyWord;
/**
* 领料任务实体集合
*/
@ApiModelProperty(value = "领料任务实体集合")
private List<LeaseApplyInfo> leaseApplyInfoList;
@ApiModelProperty(value = "领料任务汇总") @ApiModelProperty(value = "领料任务汇总")
private LeaseApplyInfo leaseApplyInfo; private LeaseApplyInfo leaseApplyInfo;

View File

@ -89,11 +89,11 @@ public interface TmTaskMapper {
int deleteTmTaskByPurchaseIds(Long[] ids); int deleteTmTaskByPurchaseIds(Long[] ids);
List<TmTaskRequestVo> getAuditListByLeaseTmTask(@Param("record") TmTaskRequestVo tmTaskRequestVo); // List<TmTaskRequestVo> getAuditListByLeaseTmTask(@Param("record") TmTaskRequestVo tmTaskRequestVo);
//
List<TmTaskRequestVo> getAuditListByLeaseTmTaskByPeople(@Param("record") TmTaskRequestVo tmTaskRequestVo); // List<TmTaskRequestVo> getAuditListByLeaseTmTaskByPeople(@Param("record") TmTaskRequestVo tmTaskRequestVo);
//
List<LeaseApplyInfo> getAuditListByLeaseInfo(@Param("record") TmTaskRequestVo record); // List<LeaseApplyInfo> getAuditListByLeaseInfo(@Param("record") TmTaskRequestVo record);
//
List<LeaseApplyDetails> getLeaseApplyDetails(@Param("record") LeaseApplyInfo record); // List<LeaseApplyDetails> getLeaseApplyDetails(@Param("record") LeaseApplyInfo record);
} }

View File

@ -59,5 +59,7 @@ public interface ITmTaskService {
*/ */
public int deleteTmTaskByTaskId(Long taskId); public int deleteTmTaskByTaskId(Long taskId);
List<TmTaskRequestVo> getLeaseAuditList(TmTaskRequestVo tmTask); // List<TmTaskRequestVo> getLeaseAuditList(TmTaskRequestVo tmTask);
} }

View File

@ -106,49 +106,50 @@ public class TmTaskServiceImpl implements ITmTaskService {
/** /**
* 获取单个申请列表 * 获取单个申请列表
*/ */
@Override // @Override
public List<TmTaskRequestVo> getLeaseAuditList(TmTaskRequestVo tmTaskRequestVo) { // public List<TmTaskRequestVo> getLeaseAuditList(TmTaskRequestVo tmTaskRequestVo) {
Set<String> roles = SecurityUtils.getLoginUser().getRoles(); // Set<String> roles = SecurityUtils.getLoginUser().getRoles();
List<TmTaskRequestVo> tmTaskList; // List<TmTaskRequestVo> tmTaskList;
if (roles.contains(MaterialConstants.STRING_ADMIN)) { // if (roles.contains(MaterialConstants.STRING_ADMIN)) {
tmTaskList = tmTaskMapper.getAuditListByLeaseTmTask(tmTaskRequestVo); // tmTaskList = tmTaskMapper.getAuditListByLeaseTmTask(tmTaskRequestVo);
} else { // } else {
String username = SecurityUtils.getLoginUser().getUsername(); // String username = SecurityUtils.getLoginUser().getUsername();
tmTaskRequestVo.setCreateBy(username); // tmTaskRequestVo.setCreateBy(username);
tmTaskList = tmTaskMapper.getAuditListByLeaseTmTaskByPeople(tmTaskRequestVo); // tmTaskList = tmTaskMapper.getAuditListByLeaseTmTaskByPeople(tmTaskRequestVo);
} // }
for (TmTaskRequestVo tmTask : tmTaskList) { // for (TmTaskRequestVo tmTask : tmTaskList) {
int count = 0; // int count = 0;
if (tmTask != null) { // if (tmTask != null) {
// 去查询任务分单表 // // 去查询任务分单表
List<LeaseApplyInfo> auditListByLeaseInfo = tmTaskMapper.getAuditListByLeaseInfo(tmTask); // List<LeaseApplyInfo> auditListByLeaseInfo = tmTaskMapper.getAuditListByLeaseInfo(tmTask);
if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) { // if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) {
// 对领料任务集合查询具体详情 // // 对领料任务集合查询具体详情
for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) { // for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) {
if (leaseApplyInfo != null) { // if (leaseApplyInfo != null) {
// 去查询领料任务详情表 // // 去查询领料任务详情表
List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyDetails(leaseApplyInfo); // List<LeaseApplyDetails> leaseApplyDetails = tmTaskMapper.getLeaseApplyDetails(leaseApplyInfo);
if (leaseApplyDetails != null && !leaseApplyDetails.isEmpty()) { // if (leaseApplyDetails != null && !leaseApplyDetails.isEmpty()) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) { // for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) { // if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
// 统计预领数量 // // 统计预领数量
count += leaseApplyDetail.getPreNum(); // count += leaseApplyDetail.getPreNum();
} // }
} // }
// 塞入领料任务详情的集合中 // // 塞入领料任务详情的集合中
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails); // leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
} // }
} // }
} // }
// 存入领料任务实体集合 // // 存入领料任务实体集合
tmTask.setLeaseApplyInfoList(auditListByLeaseInfo); // tmTask.setLeaseApplyInfoList(auditListByLeaseInfo);
tmTask.setRemark(auditListByLeaseInfo.get(0).getRemark()); // tmTask.setRemark(auditListByLeaseInfo.get(0).getRemark());
} // }
// 塞入预领的合计数量 // // 塞入预领的合计数量
tmTask.setPreCountNum(count); // tmTask.setPreCountNum(count);
} // }
} // }
// return tmTaskList;
// }
return tmTaskList;
}
} }

View File

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