二级库功能完善、报废功能开发

This commit is contained in:
liang.chao 2025-01-23 13:48:53 +08:00
parent e502bc2fbf
commit af5ef30887
10 changed files with 97 additions and 13 deletions

View File

@ -150,8 +150,7 @@ public class SecondaryWarehouseController extends BaseController {
@ApiOperation(value = "二级库报废申请")
@PostMapping("/seconfScrap")
public AjaxResult seconfScrap(@RequestBody SecondCcrapApplyDetails bean) {
Integer i = service.seconfScrap(bean);
return toAjax(i);
return service.seconfScrap(bean);
}
@ApiOperation(value = "二级库报废审核(通过/驳回)")

View File

@ -1,6 +1,8 @@
package com.bonus.sgzb.material.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
@ -31,6 +33,8 @@ public class SecondCcrapApplyDetails {
// 创建者
private String createBy;
// 创建时间
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
// 更新者
private String updateBy;
@ -45,4 +49,7 @@ public class SecondCcrapApplyDetails {
private String unitName;
private String modelName;
private String typeName;
private String maCode;
private Long deptId;
private Integer parentId;
}

View File

@ -23,4 +23,6 @@ public class SecondLotConfig {
private String updater;
//修改时间
private String updateTime;
// 部门id
private Long deptId;
}

View File

@ -39,6 +39,7 @@ public class SecondaryWarehouse {
*机具id
*/
private String maId;
private Long deptId;
/**
*机具id
*/

View File

@ -23,4 +23,6 @@ public class TeamGroup {
private String updater;
//修改时间
private String updateTime;
private Long deptId;
}

View File

@ -128,7 +128,7 @@ public class TeamLeaseInfo {
*/
private String queryType;
private int outNum;
private Integer outNum;
private Integer teamGroupId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@ -93,4 +93,6 @@ public interface SecondaryWarehouseMapper {
Integer updateDevNum(SecondCcrapApplyDetails secondCcrapApplyDetails);
List<SecondCcrapApplyDetails> getSecondScrapListDetails(SecondCcrapApplyDetails bean);
List<SecondCcrapApplyDetails> getSecondScrapByMaId(@Param("maId") String maId, @Param("typeId") String typeId);
}

View File

@ -45,7 +45,7 @@ public interface SecondaryWarehouseService {
List<SecondCcrapApplyDetails> getSecondScrapList(SecondCcrapApplyDetails bean);
Integer seconfScrap(SecondCcrapApplyDetails bean);
AjaxResult seconfScrap(SecondCcrapApplyDetails bean);
Integer auditSeconfScrap(SecondCcrapApplyDetails bean);

View File

@ -94,11 +94,17 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
@Override
public List<SecondLotConfig> listConfig(SecondLotConfig bean) {
if (!SecurityUtils.getLoginUser().getRoles().contains("admin")) {
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
}
return mapper.listConfig(bean);
}
@Override
public List<TeamGroup> listTeamGroup(TeamGroup bean) {
if (!SecurityUtils.getLoginUser().getRoles().contains("admin")) {
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
}
return mapper.listTeamGroup(bean);
}
@ -150,25 +156,35 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
@Override
public List<MaMachine> getDevStockCount(SecondaryWarehouse bean) {
if (!SecurityUtils.getLoginUser().getRoles().contains("admin")) {
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
}
return mapper.getDevStockCount(bean);
}
@Override
public List<SecondCcrapApplyDetails> getSecondScrapList(SecondCcrapApplyDetails bean) {
if (!SecurityUtils.getLoginUser().getRoles().contains("admin")) {
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
}
return mapper.getSecondScrapList(bean);
}
@Override
public Integer seconfScrap(SecondCcrapApplyDetails teamLeaseInfo) {
public AjaxResult seconfScrap(SecondCcrapApplyDetails teamLeaseInfo) {
teamLeaseInfo.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
Integer num = 0;
String code = "BF" + System.currentTimeMillis();
if (teamLeaseInfo.getTeamLeaseInfos().size() > 0) {
num = 0;
Integer num = 0;
for (TeamLeaseInfo bean : teamLeaseInfo.getTeamLeaseInfos()) {
// 编码设备
if (StringUtils.isNotBlank(bean.getMaIds())) {
for (String maId : bean.getMaIds().split(",")) {
// 先查询是否已经申请了报废
List<SecondCcrapApplyDetails> list = mapper.getSecondScrapByMaId(maId, bean.getTypeId());
if (list.size() > 0) {
return AjaxResult.error(list.get(0).getMaCode() + "已申请报废,请勿重复申请");
}
// 出库
teamLeaseInfo.setMaId(maId);
teamLeaseInfo.setTypeId(bean.getTypeId());
@ -176,7 +192,8 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
teamLeaseInfo.setCode(code);
teamLeaseInfo.setStatus(0);
teamLeaseInfo.setAuditRemark(bean.getAuditRemark());
num = mapper.secondScrapApplyDetails(teamLeaseInfo);
teamLeaseInfo.setId(bean.getId().intValue());
num += mapper.secondScrapApplyDetails(teamLeaseInfo);
}
} else {
// 数量设备
@ -186,17 +203,25 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
teamLeaseInfo.setCode(code);
teamLeaseInfo.setStatus(0);
teamLeaseInfo.setAuditRemark(bean.getAuditRemark());
num = mapper.secondScrapApplyDetails(teamLeaseInfo);
teamLeaseInfo.setId(bean.getId().intValue());
num += mapper.secondScrapApplyDetails(teamLeaseInfo);
}
}
if (num > 0) {
return AjaxResult.success("申请成功");
} else {
return AjaxResult.error("申请失败");
}
} else {
return AjaxResult.error("参数为空");
}
return num;
}
@Override
public Integer auditSeconfScrap(SecondCcrapApplyDetails bean) {
// 目前先做成统一审核后续如果需要对不同机具单独审核在做修改
int num = 0;
bean.setAuditBy(SecurityUtils.getLoginUser().getUserid().intValue());
if (bean.getStatus() == 1) {
//同意
num = mapper.auditSeconfScrap(bean);
@ -205,9 +230,22 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
List<SecondCcrapApplyDetails> list = mapper.getSeconfScrapByCode(bean);
for (SecondCcrapApplyDetails secondCcrapApplyDetails : list) {
if (StringUtils.isNotBlank(secondCcrapApplyDetails.getMaId())) {
// 修改机具状态为报废
mapper.updateMaMachineStatus(secondCcrapApplyDetails.getMaId());
// 更新设备出库数量库存
TeamLeaseInfo teamLeaseInfo = new TeamLeaseInfo();
teamLeaseInfo.setId(secondCcrapApplyDetails.getParentId().longValue());
teamLeaseInfo.setMaId(secondCcrapApplyDetails.getMaId());
mapper.deleteOutNum(teamLeaseInfo);
} else {
// 更新设备库存
mapper.updateDevNum(secondCcrapApplyDetails);
// 更新设备出库数量库存
TeamLeaseInfo teamLeaseInfo = new TeamLeaseInfo();
teamLeaseInfo.setParentId(secondCcrapApplyDetails.getParentId());
teamLeaseInfo.setOutNum(secondCcrapApplyDetails.getScrapNum());
teamLeaseInfo.setTypeId(secondCcrapApplyDetails.getTypeId());
mapper.updateOutNum(teamLeaseInfo);
}
}
}
@ -226,6 +264,9 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
@Override
public List<SecondaryWarehouse> getList(SecondaryWarehouse bean) {
bean.setLeaseType(1);
if (!SecurityUtils.getLoginUser().getRoles().contains("admin")) {
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
}
List<SecondaryWarehouse> list = mapper.getList(bean);
for (SecondaryWarehouse secondaryWarehouse : list) {
Integer warehouse = mapper.selectStockNum(secondaryWarehouse);
@ -302,6 +343,7 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
teamLeaseInfo.setOutNum(bean.getOutNum());
teamLeaseInfo.setTypeId(bean.getTypeId());
teamLeaseInfo.setId(bean.getId());
teamLeaseInfo.setParentId(bean.getId().intValue());
teamLeaseInfo.setMaId(null);
num = mapper.addNewOperate(teamLeaseInfo);
if (teamLeaseInfo.getType() == 3) {

View File

@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
parent_id = #{parentId} and type_id = #{typeId}
</update>
<update id="auditSeconfScrap">
UPDATE second_ccrap_apply_details
UPDATE second_scrap_apply_details
SET
audit_by = #{auditBy},
audit_time = now(),
@ -97,6 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="leaseType != null">
and lai.lease_type = #{leaseType}
</if>
<if test="deptId != null">
and bui.dept_id = #{deptId}
</if>
<if test="keyword != null and keyword != ''">
and (bui.unit_name like concat('%', #{keyword}, '%') or
mt1.type_name like concat('%', #{keyword}, '%') or
@ -105,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
GROUP BY
bui.unit_id,
lod.parent_id,
lod.type_id
</select>
<select id="getList1" resultType="com.bonus.sgzb.material.domain.SecondaryWarehouse">
@ -389,6 +393,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="unitId != null">
and slc.unit_id = #{unitId}
</if>
<if test="deptId != null">
and bui.dept_id = #{deptId}
</if>
</where>
</select>
<select id="listTeamGroup" resultType="com.bonus.sgzb.material.domain.TeamGroup">
@ -401,6 +408,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="unitId != null">
and tg.unit_id = #{unitId}
</if>
<if test="deptId != null">
and bui.dept_id = #{deptId}
</if>
</where>
</select>
<select id="getMaStatusByMaId" resultType="com.bonus.sgzb.base.api.domain.MaMachine">
@ -554,9 +564,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN ma_machine mm ON rd.ma_id = mm.ma_id
LEFT JOIN team_group tg ON rd.team_group_id = tg.id
LEFT JOIN second_lot_config slc ON rd.unit_id = slc.unit_id
LEFT JOIN bm_unit_info bui on bui.unit_id = rd.unit_id
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_status = 132
<if test="deptId != null">
AND bui.dept_id = #{deptId}
</if>
<if test="keyword != null and keyword != ''">
AND tg.NAME like concat('%', #{keyword}, '%')
</if>
@ -580,6 +594,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM receive_detail rd
LEFT JOIN team_group tg ON rd.team_group_id = tg.id
LEFT JOIN second_lot_config slc ON rd.unit_id = slc.unit_id
LEFT JOIN bm_unit_info bui on bui.unit_id = rd.unit_id
LEFT JOIN ma_type mt ON mt.type_id = rd.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE rd.type IN ('1', '2')
@ -587,6 +602,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="unitId != null">
AND rd.unit_id = #{unitId}
</if>
<if test="deptId != null">
AND bui.dept_id = #{deptId}
</if>
<if test="keyword != null and keyword != ''">
AND tg.NAME like concat('%', #{keyword}, '%')
</if>
@ -622,10 +640,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM
second_scrap_apply_details ssd
LEFT JOIN second_lot_config slc ON ssd.unit_id = slc.unit_id
left join bm_unit_info bui on bui.unit_id = slc.unit_id
where 1=1
<if test="unitId != null">
AND ssd.unit_id = #{unitId}
</if>
<if test="deptId != null">
AND bui.dept_id = #{deptId}
</if>
<if test="code != null and code !=''">
AND ssd.code like concat('%', #{code}, '%')
</if>
@ -639,14 +661,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select
ssd.*,
mt.type_name AS modelName,
mm.ma_code AS maCode,
mt2.type_name AS typeName
from
second_scrap_apply_details ssd
left join ma_type mt on ssd.type_id = mt.type_id
left join ma_type mt2 on mt.parent_id = mt2.type_id
left join ma_machine mm on ssd.ma_id = mm.ma_id
where
ssd.code = #{code}
</select>
<select id="getSecondScrapByMaId" resultType="com.bonus.sgzb.material.domain.SecondCcrapApplyDetails">
select mm.ma_code from second_scrap_apply_details ssd
left join ma_machine mm on ssd.ma_id = mm.ma_id
where ssd.ma_id = #{maId} and ssd.type_id = #{typeId} and ssd.status in (0,1)
</select>
<insert id="addConfig">
insert into second_lot_config (name,unit_id,creater,create_time)
@ -664,7 +693,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update ma_type set num = num + #{outNum} where type_id = #{typeId}
</insert>
<insert id="secondScrapApplyDetails">
insert into second_scrap_apply_details (code,ma_id,type_id,scrap_num,create_by,create_time,unit_id,status,audit_remark)
values (#{code},#{maId},#{typeId},#{scrapNum},#{createBy},now(),#{unitId},#{status},#{auditRemark});
insert into second_scrap_apply_details (code,ma_id,type_id,scrap_num,create_by,create_time,unit_id,status,audit_remark,parent_id)
values (#{code},#{maId},#{typeId},#{scrapNum},#{createBy},now(),#{unitId},#{status},#{auditRemark},#{id});
</insert>
</mapper>