修试入库导出,班组进出场优化

This commit is contained in:
mashuai 2025-11-03 17:13:50 +08:00
parent ce2e0fb2b5
commit b16ed60636
10 changed files with 365 additions and 31 deletions

View File

@ -0,0 +1,176 @@
package com.bonus.common.biz.domain.repair;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 修试后入库对象 repair_input_details
*
* @author xsheng
* @date 2024-10-16
*/
@Data
@ToString
public class RepairInputExportDetails extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 任务ID */
@ApiModelProperty(value = "任务ID")
private Long taskId;
@ApiModelProperty(value = "任务ID集合")
private List<RePairDto> outTaskList;
/** 维修审核ID */
@ApiModelProperty(value = "维修审核ID")
private Long auditId;
/** 维修ID */
@ApiModelProperty(value = "维修ID")
private Long repairId;
/** 机具ID */
@ApiModelProperty(value = "机具ID")
private Long maId;
/** 规格ID */
@ApiModelProperty(value = "规格ID")
private Long typeId;
@ApiModelProperty(value = "机具状态")
private String maStatus;
@ApiModelProperty(value = "入库方式 0编码1数量2二维码3标准箱")
private Integer inputType;
@ApiModelProperty(value = "二维码code")
private String qrCode;
/**
* 退料单位名称
*/
@ApiModelProperty(value = "退料单位名称")
@Excel(name = "退料单位",sort = 1)
private String backUnit;
/**
* 退料工程名称
*/
@ApiModelProperty(value = "退料工程名称")
@Excel(name = "退料工程",sort = 2, width = 30)
private String backPro;
@ApiModelProperty(value = "修饰入库编码")
@Excel(name = "入库单号",sort = 3)
private String inputCode;
@ApiModelProperty(value = "物资名称")
@Excel(name = "物资名称",sort = 4)
private String typeName;
@ApiModelProperty(value = "规格型号")
@Excel(name = "规格型号",sort = 6)
private String typeModelName;
@ApiModelProperty(value = "机具编码")
@Excel(name = "机具编码",sort = 7)
private String maCode;
@ApiModelProperty(value = "待入库数量")
@Excel(name = "待入库数量",sort = 8, cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT)
private BigDecimal pendingInputNum;
/** 入库数量 */
@ApiModelProperty(value = "入库数量")
@Excel(name = "已入库数量",sort = 9, cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT)
private BigDecimal inputNum;
@ApiModelProperty(value = "驳回数量")
@Excel(name = "被驳回数量",sort = 10, cellType = Excel.ColumnType.NUMERIC, align = HorizontalAlignment.RIGHT)
private BigDecimal rejectNum;
/** 0未审核1已入库2驳回 */
@Excel(name = "状态", sort = 11, readConverterExp = "0=入库进行中,1=入库完成,2=入库驳回")
private String statusName;
@ApiModelProperty(value = "维修单号")
@Excel(name = "维修单号",sort = 12)
private String repairCode;
@ApiModelProperty(value = "退料单号")
@Excel(name = "退料单号",sort = 13)
private String backCode;
@ApiModelProperty(value = "创建人")
private String createBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss", width = 20)
private Date createTime;
private String remark;
@ApiModelProperty(value = "驳回原因")
private String rejectReason;
@ApiModelProperty(value = "任务状态")
private Integer taskStatus;
/** 维修合格数量 */
@ApiModelProperty(value = "维修合格数量")
private BigDecimal repairNum;
/** 0未审核1已入库2驳回 */
@ApiModelProperty(value = "0未审核1已入库2驳回")
private String status;
/** 数据所属组织 */
@ApiModelProperty(value = "数据所属组织")
private Long companyId;
@ApiModelProperty(value = "协议号")
private Integer agreementId;
private String manageType;
/**
* 关键字
*/
private String keyWord;
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
@ApiModelProperty(value = "退料ID")
private Long backId;
@ApiModelProperty(value = "审核人id")
private Long auditBy;
@ApiModelProperty(value = "审核人")
private String auditByName;
@ApiModelProperty(value = "审核时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date auditTime;
@ApiModelProperty(value = "登录用户id")
private Long userId;
}

View File

@ -400,9 +400,16 @@ public class MaterialMachineController extends BaseController {
@ApiOperation(value = "导出班组进出场记录")
@PostMapping("/exportTeamInOrOutInfo")
public void exportTeamInOrOutInfo(HttpServletResponse response, TeamVo bean) {
String fileName = "班组进出场记录";
List<TeamVo> list = materialMachineService.getTeamInOrOutInfo(bean);
// 根据list集合数去填充序号
for (int i = 0; i < list.size(); i++) {
list.get(i).setSeq(i + 1);
}
ExcelUtil<TeamVo> util = new ExcelUtil<>(TeamVo.class);
util.exportExcel(response, list, "导出班组进出场记录");
// 获取当前年月日导出时间用括号拼接在后面
String title = "班组进出场记录" + "(导出时间:" + DateUtils.getTime() + "";
util.exportExcel(response, list, fileName, title);
}
/**

View File

@ -27,6 +27,10 @@ public class TeamVo {
*/
private Long id;
@ApiModelProperty(value = "序号")
@Excel(name = "序号", cellType = Excel.ColumnType.NUMERIC, width = 5)
private Integer seq;
@ApiModelProperty(value = "分公司")
@Excel(name = "分公司")
private String impUnitName;

View File

@ -1068,25 +1068,7 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
*/
@Override
public List<TeamVo> getTeamInOrOutInfo(TeamVo bean) {
List<TeamVo> list = materialMachineMapper.getTeamInOrOutInfo(bean);
if (list.size()>0){
// 查询所有未结算的工程
List<String> projectIdList = mapper.getUnsettledProId();
// 使用 HashSet 来加速查找过程
Set<String> unsettledProjectIds = new HashSet<>(projectIdList);
// 过滤掉不在未结算工程集合内的工程
Iterator<TeamVo> iterator = list.iterator();
while (iterator.hasNext()) {
TeamVo info = iterator.next();
String proId = info.getProId() != null ?
info.getProId().toString() : null;
if (proId == null || !unsettledProjectIds.contains(proId)) {
iterator.remove();
}
}
}
return list;
return materialMachineMapper.getTeamInOrOutInfo(bean);
}
/**

View File

@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.convert.Convert;
import com.bonus.common.biz.annotation.StoreLog;
import com.bonus.common.biz.config.ListPagingUtil;
import com.bonus.common.biz.domain.repair.RepairInputExportDetails;
import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.back.domain.vo.MaCodeVo;
@ -61,12 +62,11 @@ public class RepairInputDetailsController extends BaseController {
*/
@ApiOperation(value = "导出修试后入库列表")
@PreventRepeatSubmit
@RequiresPermissions("repair:details:export")
@SysLog(title = "修试后入库", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出修试后入库")
@PostMapping("/export")
public void export(HttpServletResponse response, RepairInputDetails repairInputDetails) {
List<RepairInputDetails> list = repairInputDetailsService.selectRepairInputDetailsList(repairInputDetails);
ExcelUtil<RepairInputDetails> util = new ExcelUtil<RepairInputDetails>(RepairInputDetails.class);
List<RepairInputExportDetails> list = repairInputDetailsService.selectExportDetails(repairInputDetails);
ExcelUtil<RepairInputExportDetails> util = new ExcelUtil<RepairInputExportDetails>(RepairInputExportDetails.class);
util.exportExcel(response, list, "修试后入库数据");
}

View File

@ -2,6 +2,7 @@ package com.bonus.material.repair.mapper;
import java.util.List;
import com.bonus.common.biz.domain.repair.RepairInputExportDetails;
import com.bonus.material.back.domain.vo.MaCodeVo;
import com.bonus.common.biz.domain.repair.RepairInputDetails;
import com.bonus.material.basic.domain.BmQrcodeInfo;
@ -159,4 +160,11 @@ public interface RepairInputDetailsMapper {
* @return
*/
RepairInputDetails selectInfoNum(RepairInputDetails repairInputDetails);
/**
* 导出修试后入库列表
* @param repairInputDetails
* @return
*/
List<RepairInputExportDetails> selectExportDetails(RepairInputDetails repairInputDetails);
}

View File

@ -2,6 +2,7 @@ package com.bonus.material.repair.service;
import java.util.List;
import com.bonus.common.biz.domain.repair.RepairInputExportDetails;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.back.domain.vo.MaCodeVo;
import com.bonus.common.biz.domain.repair.RepairInputDetails;
@ -94,4 +95,11 @@ public interface IRepairInputDetailsService {
int sanInput(RepairInputDetails repairInputDetails);
int sanQrBoxInput(RepairInputDetails repairInputDetails);
/**
* 导出修试后入库列表
* @param repairInputDetails
* @return
*/
List<RepairInputExportDetails> selectExportDetails(RepairInputDetails repairInputDetails);
}

View File

@ -13,6 +13,7 @@ import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.constant.GlobalConstants;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.common.biz.domain.repair.RepairInputExportDetails;
import com.bonus.common.biz.enums.*;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
@ -905,6 +906,23 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService
return result;
}
/**
* 导出修试后入库列表
* @param repairInputDetails
* @return
*/
@Override
public List<RepairInputExportDetails> selectExportDetails(RepairInputDetails repairInputDetails) {
Long userId = SecurityUtils.getLoginUser().getUserid();
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
repairInputDetails.setUserId(userId == 0 ? null : userId);
}
return repairInputDetailsMapper.selectExportDetails(repairInputDetails);
}
private int updateBoxStatus(RepairInputDetails input) {
int result = 0;
result = repairInputDetailsMapper.updateBoxStatus(input);

View File

@ -1069,7 +1069,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getTeamInOrOutInfo" resultType="com.bonus.material.clz.domain.TeamVo">
SELECT DISTINCT
sd.dept_name AS impUnitName,
bp.pro_center AS departName,
df.project_dept AS departName,
bzgl_bz.ssfbdw AS subcontractor,
bzgl_bz.bzmc AS teamName,
bzgl_bz.bzz_name AS teamLeaderName,
@ -1082,7 +1082,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
END AS teamStatusName,
bp.pro_id AS proId,
bzgl_bz.project_name AS projectName,
org_user.mobile AS teamLeaderPhone,
bzgl_bz.sfjs AS isDismiss,
CASE bzgl_bz.sfjs
WHEN '0' THEN '否'
@ -1094,9 +1093,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.imp_unit AS impUnit
FROM
`micro-tool`.bzgl_bz bzgl_bz
LEFT JOIN `uni_org`.org_user org_user ON bzgl_bz.bzz_idcard = org_user.id_card
LEFT JOIN bm_project bp ON bp.external_id = bzgl_bz.project_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE 1 = 1
<if test="proId != null and proId != ''">
AND bp.pro_id = #{proId}
@ -1105,13 +1104,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND bp.imp_unit = #{impUnit}
</if>
<if test="impUnitName != null and impUnitName != ''">
AND sd.dept_name like concat('%',#{impUnitName},'%')
AND sd.dept_name = #{impUnitName}
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center like concat('%',#{departName},'%')
AND df.project_dept = #{departName}
</if>
<if test="teamName != null and teamName != ''">
AND bzgl_bz.bzmc like concat('%',#{teamName},'%')
AND bzgl_bz.bzmc = #{teamName}
</if>
<if test="keyWord != null and keyWord != ''">
AND (
@ -2095,7 +2094,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND bp.pro_name = #{proName}
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center = #{departName}
AND df.project_dept = #{departName}
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name = #{typeName}
@ -2171,7 +2170,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND bp.pro_name = #{proName}
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center = #{departName}
AND df.project_dept = #{departName}
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name = #{typeName}

View File

@ -602,6 +602,138 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<select id="selectExportDetails" resultType="com.bonus.common.biz.domain.repair.RepairInputExportDetails">
SELECT * FROM (
SELECT
rd.task_id AS taskId,
tt1.CODE AS repairCode,
bai.`code` AS backCode,
rd.create_time AS createTime,
tt.task_status AS taskStatus,
rd.status AS statusName,
rd.remark AS remark,
bui.unit_name AS backUnit,
bpi.pro_name AS backPro,
su.nick_name AS createBy,
tt.CODE AS inputCode,
IFNULL(rd.repair_num,0) - IFNULL(rd.input_num,0) - IFNULL(rd.reject_num,0) as pendingInputNum,
IFNULL(rd.input_num,0) as inputNum,
IFNULL(rd.reject_num,0) as rejectNum,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mm.ma_code AS maCode
FROM
repair_input_details rd
LEFT JOIN ma_type mt on rd.type_id = mt.type_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
LEFT JOIN tm_task tt on rd.task_id = tt.task_id
LEFT JOIN tm_task tt1 on rd.repair_id = tt1.task_id
LEFT JOIN ma_machine mm ON rd.ma_id = mm.ma_id
LEFT JOIN (
SELECT
rad.task_id,
rad.back_id,
rad.create_time
FROM
repair_apply_details rad
GROUP BY rad.task_id
) rad ON rad.task_id = rd.repair_id
LEFT JOIN back_apply_info bai ON rad.back_id = bai.id
LEFT JOIN tm_task_agreement tta ON rd.repair_id = tta.task_id
LEFT JOIN bm_agreement_info bai2 ON tta.agreement_id = bai2.agreement_id
LEFT JOIN bm_unit bui ON bai2.unit_id = bui.unit_id
LEFT JOIN bm_project bpi ON bai2.project_id = bpi.pro_id and bpi.del_flag = '0'
left join sys_user su on rd.create_by = su.user_id
<if test="userId != null">
JOIN ma_type_keeper mtr ON mtr.type_id = rd.type_id AND mtr.user_id = #{userId}
</if>
<where>
rad.create_time &lt; '2025-08-20 00:00:00'
<if test="keyWord != null and keyWord != ''">
and (
tt1.CODE LIKE CONCAT('%',#{keyWord},'%')
OR bai.`code` LIKE CONCAT('%',#{keyWord},'%')
OR bui.unit_name LIKE CONCAT('%',#{keyWord},'%')
OR bpi.pro_name LIKE CONCAT('%',#{keyWord},'%')
OR tt.CODE LIKE CONCAT('%',#{keyWord},'%')
OR mt2.type_name LIKE CONCAT('%',#{keyWord},'%')
)
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[and DATE_FORMAT( rd.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
</if>
<if test="taskStatus != null">
and rd.status = #{taskStatus}
</if>
</where>
GROUP BY rd.task_id,
rd.type_id,
rd.ma_id
UNION
SELECT
rd.task_id AS taskId,
tt1.CODE AS repairCode,
bai.`code` AS backCode,
rd.create_time AS createTime,
tt.task_status AS taskStatus,
rd.status AS statusName,
rd.remark AS remark,
bui.unit_name AS backUnit,
bpi.pro_name AS backPro,
su.nick_name AS createBy,
tt.CODE AS inputCode,
IFNULL(rd.repair_num,0) - IFNULL(rd.input_num,0) - IFNULL(rd.reject_num,0) as pendingInputNum,
IFNULL(rd.input_num,0) as inputNum,
IFNULL(rd.reject_num,0) as rejectNum,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mm.ma_code AS maCode
FROM
repair_input_details rd
LEFT JOIN ma_type mt on rd.type_id = mt.type_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
LEFT JOIN ma_machine mm ON rd.ma_id = mm.ma_id
LEFT JOIN tm_task tt on rd.task_id = tt.task_id
LEFT JOIN repair_apply_details rad ON rad.id = rd.repair_id
LEFT JOIN back_apply_info bai ON rad.back_id = bai.id
LEFT JOIN tm_task tt1 on rad.task_id = tt1.task_id
LEFT JOIN tm_task_agreement tta ON rd.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai2 ON tta.agreement_id = bai2.agreement_id
LEFT JOIN bm_unit bui ON bai2.unit_id = bui.unit_id
LEFT JOIN bm_project bpi ON bai2.project_id = bpi.pro_id and bpi.del_flag = '0'
left join sys_user su on rd.create_by = su.user_id
<if test="userId != null">
JOIN ma_type_keeper mtr ON mtr.type_id = rd.type_id AND mtr.user_id = #{userId}
</if>
<where>
rad.create_time &gt;= '2025-08-20 00:00:00'
<if test="keyWord != null and keyWord != ''">
and (
tt1.CODE LIKE CONCAT('%',#{keyWord},'%')
OR bai.`code` LIKE CONCAT('%',#{keyWord},'%')
OR bui.unit_name LIKE CONCAT('%',#{keyWord},'%')
OR bpi.pro_name LIKE CONCAT('%',#{keyWord},'%')
OR tt.CODE LIKE CONCAT('%',#{keyWord},'%')
OR mt2.type_name LIKE CONCAT('%',#{keyWord},'%')
)
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[and DATE_FORMAT( rd.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
</if>
<if test="taskStatus != null">
and rd.status = #{taskStatus}
</if>
</where>
GROUP BY rd.task_id,
rd.type_id,
rd.ma_id
) AS combined_results
ORDER BY
createTime DESC
</select>
<update id="updateBoxStatus">
update bm_qrcode_box set box_status = 6
where box_code = #{boxCode}