新购入库,退料新增优化
This commit is contained in:
parent
ad2f8f7b79
commit
25de32cdd1
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.sgzb.base.controller;
|
||||
|
||||
import com.bonus.sgzb.base.domain.MaPartType;
|
||||
import com.bonus.sgzb.base.domain.vo.MaPartTypeVo;
|
||||
import com.bonus.sgzb.base.service.IPartTypeService;
|
||||
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.sgzb.common.core.web.controller.BaseController;
|
||||
|
|
@ -44,6 +45,19 @@ public class MaPartTypeController extends BaseController {
|
|||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配件类型列表
|
||||
* @param maPartType
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getList")
|
||||
public AjaxResult getList(MaPartType maPartType)
|
||||
{
|
||||
startPage();
|
||||
List<MaPartTypeVo> list = maPartTypeService.getList(maPartType);
|
||||
return AjaxResult.success(getDataTable(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配件管理
|
||||
* @param maPartType
|
||||
|
|
|
|||
|
|
@ -0,0 +1,96 @@
|
|||
package com.bonus.sgzb.base.domain.vo;
|
||||
|
||||
import com.bonus.sgzb.common.core.annotation.Excel;
|
||||
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 配件类型管理ma_part_type(MaPartType)表实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-11-27 16:44:09
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class MaPartTypeVo extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 一级配件类型id
|
||||
*/
|
||||
private Long firstPaId;
|
||||
|
||||
/**
|
||||
* 二级配件类型id
|
||||
*/
|
||||
private Long secondPaId;
|
||||
|
||||
/**
|
||||
* 三级配件类型id
|
||||
*/
|
||||
private Long thirdPaId;
|
||||
|
||||
@Excel(name = "配件类型")
|
||||
private String paType;
|
||||
|
||||
@Excel(name = "配件名称")
|
||||
private String paName;
|
||||
|
||||
@Excel(name = "配件规格")
|
||||
private String paSpec;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
@Excel(name = "实时库存")
|
||||
private String num;
|
||||
|
||||
@Excel(name = "计量单位")
|
||||
private String unitName;
|
||||
|
||||
@Excel(name = "购置价格")
|
||||
private String buyPrice;
|
||||
|
||||
/**
|
||||
* 层级
|
||||
*/
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 数据所属组织
|
||||
*/
|
||||
private String companyId;
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.sgzb.base.mapper;
|
||||
|
||||
import com.bonus.sgzb.base.domain.MaPartType;
|
||||
import com.bonus.sgzb.base.domain.vo.MaPartTypeVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -52,5 +53,12 @@ public interface MaPartTypeMapper {
|
|||
MaPartType getById(Long paId);
|
||||
|
||||
int updateById(MaPartType maPartType);
|
||||
|
||||
/**
|
||||
* 查询配件类型列表
|
||||
* @param maPartType
|
||||
* @return
|
||||
*/
|
||||
List<MaPartTypeVo> getList(MaPartType maPartType);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.sgzb.base.service;
|
|||
|
||||
|
||||
import com.bonus.sgzb.base.domain.MaPartType;
|
||||
import com.bonus.sgzb.base.domain.vo.MaPartTypeVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -58,6 +59,13 @@ public interface IPartTypeService {
|
|||
MaPartType getById(Long paId);
|
||||
|
||||
int updateById(MaPartType maPartType);
|
||||
|
||||
/**
|
||||
* 查询配件类型列表
|
||||
* @param maPartType
|
||||
* @return
|
||||
*/
|
||||
List<MaPartTypeVo> getList(MaPartType maPartType);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.sgzb.base.service.impl;
|
||||
|
||||
import com.bonus.sgzb.base.domain.MaPartType;
|
||||
import com.bonus.sgzb.base.domain.vo.MaPartTypeVo;
|
||||
import com.bonus.sgzb.base.mapper.MaPartTypeMapper;
|
||||
import com.bonus.sgzb.base.service.IPartTypeService;
|
||||
import com.bonus.sgzb.common.core.constant.UserConstants;
|
||||
|
|
@ -98,5 +99,15 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
|
|||
public int updateById(MaPartType maPartType) {
|
||||
return maPartTypeMapper.updateById(maPartType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配件类型列表
|
||||
* @param maPartType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MaPartTypeVo> getList(MaPartType maPartType) {
|
||||
return maPartTypeMapper.getList(maPartType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -698,7 +698,7 @@
|
|||
and bai.back_source =#{backSource}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
AND bai.back_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
||||
AND DATE_FORMAT( bai.back_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
|
||||
</if>
|
||||
GROUP BY
|
||||
bai.id,
|
||||
|
|
|
|||
|
|
@ -99,4 +99,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from ma_part_type
|
||||
where pa_id = #{paId}
|
||||
</select>
|
||||
|
||||
<select id="getList" resultType="com.bonus.sgzb.base.domain.vo.MaPartTypeVo">
|
||||
SELECT
|
||||
mt2.pa_id AS firstPaId,
|
||||
mt1.pa_id AS secondPaId,
|
||||
mt.pa_id AS thirdPaId,
|
||||
mt2.pa_name AS paType,
|
||||
mt1.pa_name AS paName,
|
||||
mt.pa_name AS paSpec,
|
||||
mt.num AS num,
|
||||
mt.LEVEL AS level,
|
||||
mt.remark AS remark,
|
||||
mt.unit_id AS unitName,
|
||||
mt.buy_price AS buyPrice
|
||||
FROM
|
||||
ma_part_type mt
|
||||
LEFT JOIN ma_part_type mt1 ON mt.parent_id = mt1.pa_id
|
||||
LEFT JOIN ma_part_type mt2 ON mt1.parent_id = mt2.pa_id
|
||||
WHERE
|
||||
mt.`level` = '3'
|
||||
AND mt.del_flag = '0'
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND ( mt2.pa_name like concat('%', #{keyWord}, '%') or
|
||||
mt1.pa_name like concat('%', #{keyWord}, '%') or
|
||||
mt.pa_name like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -301,4 +301,7 @@ public class BackApplyInfo extends BaseEntity {
|
|||
|
||||
@ApiModelProperty(value = "总在用数量")
|
||||
private Integer totalUseNum;
|
||||
|
||||
@ApiModelProperty(value = "退料申请数量")
|
||||
private Integer backApplyNum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,6 +167,17 @@ public class PurchaseMacodeInfo extends BaseEntity
|
|||
@ApiModelProperty(value = "类型管理方式")
|
||||
private String manageType;
|
||||
|
||||
@ApiModelProperty(value = "入库数量")
|
||||
private Integer inputNum;
|
||||
|
||||
public Integer getInputNum() {
|
||||
return inputNum;
|
||||
}
|
||||
|
||||
public void setInputNum(Integer inputNum) {
|
||||
this.inputNum = inputNum;
|
||||
}
|
||||
|
||||
public String getUnitName() {
|
||||
return unitName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,4 +192,18 @@ public interface BackApplyMapper {
|
|||
* @return
|
||||
*/
|
||||
List<BackApplyInfo> getUseInfoList(BackApplyInfo bean);
|
||||
|
||||
/**
|
||||
* 获取退料申请数量
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<BackApplyInfo> getBackApplyNum(BackApplyInfo bean);
|
||||
|
||||
/**
|
||||
* 查询已退料数量
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
BackApplyInfo getBackNum(BackApplyInfo backApplyInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,10 +133,10 @@ public interface PurchaseMacodeInfoMapper {
|
|||
|
||||
/**
|
||||
* 修改
|
||||
* @param maType
|
||||
* @param maInputRecord
|
||||
* @return
|
||||
*/
|
||||
int updateTypeByTypeId(MaType maType);
|
||||
int updateTypeByTypeId(MaInputRecord maInputRecord);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
|
|
|
|||
|
|
@ -626,8 +626,38 @@ public class BackApplyServiceImpl implements BackApplyService {
|
|||
*/
|
||||
@Override
|
||||
public AjaxResult getUseInfoList(BackApplyInfo bean) {
|
||||
// 已建退料数据
|
||||
Map<String, Integer> oldBackMap = new HashMap<>();
|
||||
// 根据协议id查询目前在用设备
|
||||
return AjaxResult.success(backApplyMapper.getUseInfoList(bean));
|
||||
List<BackApplyInfo> list = backApplyMapper.getUseInfoList(bean);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
// 查看该协议已建立退料数据(查询back_apply_details表back_status状态为0的数据)
|
||||
List<BackApplyInfo> oldBackTypes = backApplyMapper.getBackApplyNum(bean);
|
||||
if (CollectionUtils.isEmpty(oldBackTypes)) {
|
||||
list.forEach(info -> info.setBackApplyNum(0));
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
// 去back_check_details表查询退料完成数量
|
||||
for (BackApplyInfo backApplyInfo : oldBackTypes) {
|
||||
BackApplyInfo info = backApplyMapper.getBackNum(backApplyInfo);
|
||||
Integer infoBackNum = 0;
|
||||
if (info != null) {
|
||||
infoBackNum = Optional.ofNullable(info.getBackNum()).orElse(0);
|
||||
}
|
||||
// 用backNum减去退料完成数量
|
||||
Integer backNum = Optional.ofNullable(backApplyInfo.getBackNum()).orElse(0);
|
||||
backApplyInfo.setBackNum(Math.max(backNum - infoBackNum, 0));
|
||||
}
|
||||
oldBackMap = oldBackTypes.stream().collect(Collectors.groupingBy(BackApplyInfo::getTypeId,
|
||||
Collectors.summingInt(BackApplyInfo::getBackNum)));
|
||||
// 遍历list,根据typeId,将oldBackMap中的值赋给list
|
||||
for (BackApplyInfo backApplyInfo : list) {
|
||||
backApplyInfo.setBackApplyNum(oldBackMap.get(backApplyInfo.getTypeId()) == null ?
|
||||
0 : oldBackMap.get(backApplyInfo.getTypeId()));
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -356,10 +356,7 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService
|
|||
|
||||
if ("1".equals(checkResult)){
|
||||
MaType maType = purchaseMacodeInfoMapper.selectTypeByTypeId(typeId);
|
||||
// 库存添加
|
||||
maType.setNum((maInputRecord.getInputNum() == null ? new BigDecimal(0) : maInputRecord.getInputNum())
|
||||
.add(maType.getNum() == null ? new BigDecimal(0) : maType.getNum()));
|
||||
purchaseMacodeInfoMapper.updateTypeByTypeId(maType);
|
||||
purchaseMacodeInfoMapper.updateTypeByTypeId(maInputRecord);
|
||||
|
||||
//判断是否是成套机具,是的话配件库存也要增加
|
||||
if ("2".equals(maType.getManageType())) {
|
||||
|
|
@ -606,6 +603,7 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService
|
|||
maps.put("specificationType", bean.getSpecificationType());
|
||||
maps.put("unitName", bean.getUnitName());
|
||||
maps.put("checkNum", bean.getCheckNum());
|
||||
maps.put("inputNum", bean.getInputNum());
|
||||
maps.put("remark", bean.getRemark());
|
||||
return maps;
|
||||
}
|
||||
|
|
@ -620,7 +618,8 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService
|
|||
list.add("类型名称");
|
||||
list.add("规格型号");
|
||||
list.add("计量单位");
|
||||
list.add("数量");
|
||||
list.add("验收数量");
|
||||
list.add("入库数量");
|
||||
list.add("备注");
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1243,4 +1243,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
GROUP BY
|
||||
mt.type_id
|
||||
</select>
|
||||
|
||||
<select id="getBackApplyNum" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
|
||||
SELECT
|
||||
bad.parent_id AS id,
|
||||
bad.back_status AS backStatus,
|
||||
bad.type_id AS typeId,
|
||||
IFNULL(sum( bad.audit_num ), 0) AS backNum
|
||||
FROM
|
||||
back_apply_details bad
|
||||
LEFT JOIN back_apply_info bai ON bai.id = bad.parent_id
|
||||
LEFT JOIN tm_task tt ON bai.task_id = tt.task_id
|
||||
LEFT JOIN tm_task_agreement tta ON tta.task_id = tt.task_id
|
||||
WHERE
|
||||
tt.task_status IN (38, 39)
|
||||
AND bad.back_status = 0
|
||||
AND tta.agreement_id = #{agreementId}
|
||||
GROUP BY
|
||||
bad.parent_id,
|
||||
bad.type_id
|
||||
</select>
|
||||
|
||||
<select id="getBackNum" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
|
||||
SELECT
|
||||
bai.id,
|
||||
bai.task_id AS taskId,
|
||||
bcd.type_id AS typeId,
|
||||
SUM(bcd.back_num) AS backNum,
|
||||
bcd.parent_id AS parentId,
|
||||
bcd.create_by AS createBy,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeCode
|
||||
FROM
|
||||
back_check_details bcd
|
||||
LEFT JOIN back_apply_info bai ON bai.id = bcd.parent_id
|
||||
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
WHERE
|
||||
bcd.is_finished = 1
|
||||
and bcd.parent_id = #{id}
|
||||
and bcd.type_id = #{typeId}
|
||||
GROUP By bcd.type_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -250,7 +250,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<update id="updateByTaskIdTypeId">
|
||||
update purchase_check_details set check_num = #{inputNum},input_num=#{inputNum},input_status='1',input_time=NOW() where task_id = #{taskId} and type_id = #{typeId}
|
||||
update purchase_check_details set input_num = #{inputNum},input_status='1',input_time=NOW() where task_id = #{taskId} and type_id = #{typeId}
|
||||
</update>
|
||||
<update id="updateCheckDetails">
|
||||
update purchase_check_details set status = '0' where task_id = #{taskId}
|
||||
|
|
|
|||
|
|
@ -376,7 +376,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
END AS STATUS,
|
||||
mm.qr_code qrCode,
|
||||
mm.ma_id maId,
|
||||
IF( pmi.ma_code IS NOT NULL, 1, pcd.check_num ) checkNum
|
||||
IF(pmi.ma_code IS NOT NULL, 1, pcd.check_num ) checkNum,
|
||||
IF(pmi.ma_code IS NOT NULL AND pmi.status = 1,
|
||||
1,
|
||||
IF(pmi.ma_code IS NOT NULL AND pmi.status != 1,
|
||||
0,
|
||||
IFNULL(pcd.input_num, 0)
|
||||
)
|
||||
) AS inputNum
|
||||
FROM
|
||||
purchase_check_details pcd
|
||||
LEFT JOIN purchase_macode_info pmi ON pmi.task_id = pcd.task_id
|
||||
|
|
@ -437,7 +444,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
mm.qr_code qrCode,
|
||||
mm.ma_id maId,
|
||||
IF
|
||||
( pmi.ma_code IS NOT NULL, 1, pcd.check_num ) checkNum
|
||||
( pmi.ma_code IS NOT NULL, 1, pcd.check_num ) checkNum,
|
||||
IF(pmi.ma_code IS NOT NULL AND pmi.status = 1,
|
||||
1,
|
||||
IF(pmi.ma_code IS NOT NULL AND pmi.status != 1,
|
||||
0,
|
||||
IFNULL(pcd.input_num, 0)
|
||||
)
|
||||
) AS inputNum
|
||||
FROM
|
||||
purchase_check_details pcd
|
||||
LEFT JOIN purchase_check_info pci on pci.task_id=pcd.task_id
|
||||
|
|
@ -570,7 +584,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<update id="updateTypeByTypeId">
|
||||
update ma_type set num = #{num} where type_id = #{typeId}
|
||||
update ma_type
|
||||
set num = ifnull( num, 0 ) + #{inputNum}
|
||||
where type_id = #{typeId}
|
||||
</update>
|
||||
|
||||
<update id="updateMaMachine">
|
||||
|
|
|
|||
Loading…
Reference in New Issue