入库联调
This commit is contained in:
parent
20d547eede
commit
9ccc563fec
|
|
@ -70,6 +70,15 @@ public class PurchaseStorageController extends BaseController {
|
|||
return purchaseStorageService.warehouse(dto);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "查询待绑定编号机具详情")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("purchase:storage:list")
|
||||
@PostMapping("/getMachineById")
|
||||
public AjaxResult getMachineById(@RequestBody PurchaseDto dto) {
|
||||
return purchaseStorageService.getMachineById(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回或批量驳回
|
||||
* @param dto
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ public class PurchaseCheckDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "规格名称")
|
||||
private String typeName;
|
||||
|
||||
@ApiModelProperty(value = "机具编号")
|
||||
private String maCode;
|
||||
|
||||
@ApiModelProperty(value = "物资单位名称")
|
||||
private String unitName;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
public class PurchaseDto {
|
||||
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
private String taskId;
|
||||
|
||||
|
|
@ -45,7 +47,7 @@ public class PurchaseDto {
|
|||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期")
|
||||
private String productDate;
|
||||
private Date productDate;
|
||||
|
||||
@ApiModelProperty(value = "二级明细id")
|
||||
private String purchaseId;
|
||||
|
|
@ -74,6 +76,9 @@ public class PurchaseDto {
|
|||
@ApiModelProperty(value = "提交绑定数据集合")
|
||||
private List<PurchaseDto> dtoList;
|
||||
|
||||
@ApiModelProperty(value = "提交入库数据集合")
|
||||
private List<PurchaseDto> inPutList;
|
||||
|
||||
/** 是否是固定资产编号(0 否,1 是) */
|
||||
@ApiModelProperty(value = "是否是固定资产编号(0 否,1 是)")
|
||||
private String fixCode;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.material.purchase.mapper;
|
||||
|
||||
import com.bonus.material.purchase.domain.PurchaseCheckDetails;
|
||||
import com.bonus.material.purchase.domain.dto.PurchaseDto;
|
||||
import com.bonus.material.purchase.domain.vo.PurchaseVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -95,4 +96,6 @@ public interface PurchaseBindMapper {
|
|||
* @return
|
||||
*/
|
||||
List<PurchaseVo> getDetailById(PurchaseDto purchaseDto);
|
||||
|
||||
List<PurchaseCheckDetails> getMachineById(PurchaseDto dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ public interface PurchaseStorageMapper {
|
|||
|
||||
/**
|
||||
* 新增机具入库记录
|
||||
* @param detail
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
int insertMachine(PurchaseVo detail);
|
||||
int insertMachine(PurchaseDto dto);
|
||||
|
||||
/**
|
||||
* 更新库存数量
|
||||
|
|
|
|||
|
|
@ -40,4 +40,11 @@ public interface IPurchaseStorageService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult reject(PurchaseDto dto);
|
||||
|
||||
/**
|
||||
* 查询机具信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getMachineById(PurchaseDto dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.bonus.common.core.utils.StringUtils;
|
|||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.ma.mapper.MachineMapper;
|
||||
import com.bonus.material.purchase.config.RemoteConfig;
|
||||
import com.bonus.material.purchase.domain.PurchaseCheckDetails;
|
||||
import com.bonus.material.purchase.domain.dto.PurchaseDto;
|
||||
import com.bonus.material.purchase.mapper.PurchaseBindMapper;
|
||||
import com.bonus.material.purchase.mapper.PurchaseStorageMapper;
|
||||
|
|
@ -91,14 +92,12 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult warehouse(PurchaseDto dto) {
|
||||
if (dto.getTaskId() != null) {
|
||||
//外层入库
|
||||
return processByTaskIds(dto);
|
||||
} else if (dto.getPurchaseId() != null) {
|
||||
//内层入库
|
||||
return processByPurchaseIds(dto);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
/*if (dto.getTaskId() != null) {
|
||||
//外层入库
|
||||
return processByTaskIds(dto);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -119,6 +118,17 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService {
|
|||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询机具详情
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getMachineById(PurchaseDto dto) {
|
||||
List<PurchaseCheckDetails> list = purchaseBindMapper.getMachineById(dto);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 内层驳回
|
||||
* @param purchaseDto
|
||||
|
|
@ -195,13 +205,36 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService {
|
|||
purchaseDto.setStatus(PurchaseTaskStatusEnum.IN_STORE.getStatus());
|
||||
int result = 0;
|
||||
try {
|
||||
//判断为数量还是编码入库
|
||||
if (CollectionUtils.isEmpty(purchaseDto.getInPutList())) {
|
||||
//数量入库
|
||||
List<PurchaseVo> details = purchaseBindMapper.getDetails(purchaseDto);
|
||||
List<PurchaseVo> purchaseVoList = purchaseBindMapper.getDetailById(purchaseDto);
|
||||
if (CollectionUtils.isNotEmpty(details)) {
|
||||
result += updatePurchaseInfoAndDetails(purchaseVoList, details.get(0), Integer.parseInt(purchaseDto.getPurchaseId()));
|
||||
List<PurchaseVo> statusList = purchaseStorageMapper.select(details.get(0).getTaskId().toString());
|
||||
result += updateTaskStatus(statusList);
|
||||
result += updatePurchaseInfoAndDetails(details.get(0), Integer.parseInt(purchaseDto.getPurchaseId()));
|
||||
} else {
|
||||
//编码入库
|
||||
List<PurchaseVo> purchaseVoList = purchaseBindMapper.selectPurchaseCheckInfoById(purchaseDto);
|
||||
for (PurchaseDto dto : purchaseDto.getInPutList()) {
|
||||
if (CollectionUtils.isNotEmpty(purchaseVoList)) {
|
||||
for (PurchaseVo purchaseVo : purchaseVoList) {
|
||||
if (purchaseVo.getMaCode().equals(dto.getMaCode())) {
|
||||
dto.setOutFacCode(purchaseVo.getOutFacCode() == null ? "" : purchaseVo.getOutFacCode());
|
||||
dto.setProductDate(purchaseVo.getProductDate() == null ? null : purchaseVo.getProductDate());
|
||||
}
|
||||
}
|
||||
}
|
||||
dto.setTypeId(purchaseDto.getTypeId());
|
||||
result += purchaseStorageMapper.insertMachine(dto);
|
||||
result += purchaseStorageMapper.updateNum(purchaseDto.getPurchaseId(), purchaseDto.getInPutList().size());
|
||||
List<PurchaseCheckDetails> list = purchaseBindMapper.getMachineById(dto);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
result += purchaseStorageMapper.updateStatusById(PurchaseTaskStatusEnum.TASK_IN_PROGRESS.getStatus(), Integer.parseInt(purchaseDto.getPurchaseId()));
|
||||
} else {
|
||||
result += purchaseStorageMapper.updateStatusById(PurchaseTaskStatusEnum.IN_STORE.getStatus(), Integer.parseInt(purchaseDto.getPurchaseId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
List<PurchaseVo> statusList = purchaseStorageMapper.select(purchaseDto.getTaskId());
|
||||
result += updateTaskStatus(statusList);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("入库成功");
|
||||
}
|
||||
|
|
@ -217,16 +250,10 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService {
|
|||
* @param purchaseId
|
||||
* @return
|
||||
*/
|
||||
private int updatePurchaseInfoAndDetails(List<PurchaseVo> details, PurchaseVo detail, int purchaseId) {
|
||||
int result = purchaseStorageMapper.updateStatusById(PurchaseTaskStatusEnum.IN_STORE.getStatus(), purchaseId);
|
||||
if (MaTypeManageTypeEnum.CODE_DEVICE.getTypeId().equals(Integer.valueOf(detail.getManageType()))) {
|
||||
for (PurchaseVo purchaseVo : details) {
|
||||
result += purchaseStorageMapper.insertMachine(purchaseVo);
|
||||
}
|
||||
} else if (MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId().equals(Integer.valueOf(detail.getManageType()))) {
|
||||
private int updatePurchaseInfoAndDetails(PurchaseVo detail, int purchaseId) {
|
||||
int result = purchaseStorageMapper.updateNum(detail.getPurchaseId(), detail.getCheckNum());
|
||||
result += purchaseStorageMapper.updateStorageNum(detail.getCheckNum(), detail.getTypeId());
|
||||
}
|
||||
return result + purchaseStorageMapper.updateNum(detail.getPurchaseId(), detail.getBindNum());
|
||||
return result + purchaseStorageMapper.updateStatusById(PurchaseTaskStatusEnum.IN_STORE.getStatus(), purchaseId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -266,7 +293,8 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService {
|
|||
int result = purchaseStorageMapper.updateNum(detail.getPurchaseId(), detail.getBindNum());
|
||||
result += purchaseStorageMapper.updateStatusById(PurchaseTaskStatusEnum.IN_STORE.getStatus(), Integer.parseInt(detail.getPurchaseId()));
|
||||
if (MaTypeManageTypeEnum.CODE_DEVICE.getTypeId().equals(Integer.valueOf(detail.getManageType()))) {
|
||||
result += purchaseStorageMapper.insertMachine(detail);
|
||||
//根据类型id获取设备详情信息
|
||||
//result += purchaseStorageMapper.insertMachine(detail);
|
||||
} else if (MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId().equals(Integer.valueOf(detail.getManageType()))) {
|
||||
result += purchaseStorageMapper.updateStorageNum(detail.getBindNum(), detail.getTypeId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN purchase_macode_info pm on pcd.task_id = pm.task_id and pm.type_id = pcd.type_id
|
||||
where 1 = 1
|
||||
<if test="typeId != null and typeId != ''">
|
||||
AND mt.id = #{typeId}
|
||||
AND mt.type_id = #{typeId}
|
||||
</if>
|
||||
<if test="supplierId != null and supplierId != ''">
|
||||
AND ms.supplier_id = #{supplierId}
|
||||
|
|
@ -319,4 +319,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getMachineById" resultType="com.bonus.material.purchase.domain.PurchaseCheckDetails">
|
||||
SELECT
|
||||
pmi.id as id,
|
||||
pmi.task_id as taskId,
|
||||
pmi.type_id as typeId,
|
||||
pmi.ma_code as maCode
|
||||
FROM
|
||||
purchase_macode_info pmi
|
||||
LEFT JOIN ma_machine mm ON pmi.ma_code = mm.ma_code
|
||||
AND mm.type_id = #{typeId}
|
||||
WHERE
|
||||
pmi.task_id = #{taskId}
|
||||
AND pmi.type_id = #{typeId}
|
||||
AND mm.ma_code IS NULL
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<update id="updateNum">
|
||||
UPDATE purchase_check_details
|
||||
SET input_num = #{bindNum},
|
||||
SET input_num = COALESCE(input_num, 0) + #{bindNum},
|
||||
input_time = now()
|
||||
WHERE
|
||||
id = #{id}
|
||||
|
|
|
|||
Loading…
Reference in New Issue