新购入库
This commit is contained in:
parent
1d47b4aea4
commit
246b482bc2
|
|
@ -61,5 +61,25 @@ public class MaterialConstants {
|
|||
|
||||
public static final String FOUR_CONSTANT = "4";
|
||||
|
||||
/**
|
||||
* 已全部入库
|
||||
*/
|
||||
public static final Integer INVENTORY = 4;
|
||||
|
||||
/**
|
||||
* 部分已入库
|
||||
*/
|
||||
public static final Integer PARTIALLY_WAREHOUSED = 9;
|
||||
|
||||
/**
|
||||
* 入库审核中
|
||||
*/
|
||||
public static final Integer INBOUND_AUDIT = 5;
|
||||
|
||||
/**
|
||||
* 入库审核未通过
|
||||
*/
|
||||
public static final Integer PURCHASE_STORAGE_NO_PASSED = 7;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
package com.bonus.material.purchase.controller;
|
||||
|
||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||
import com.bonus.material.purchase.dto.PurchaseDto;
|
||||
import com.bonus.material.purchase.service.IPurchaseStorageService;
|
||||
import com.bonus.material.purchase.vo.PurchaseVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2024/10/21 13:51
|
||||
*/
|
||||
@Api(tags = "新购验收入库接口")
|
||||
@RestController
|
||||
@RequestMapping("/purchase/storage")
|
||||
public class PurchaseStorageController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private IPurchaseStorageService purchaseStorageService;
|
||||
|
||||
|
||||
/**
|
||||
* 一级分页查询
|
||||
*/
|
||||
@ApiOperation(value = "查询新购验收入库详细列表")
|
||||
@RequiresPermissions("purchase:storage:list")
|
||||
@GetMapping(value = "/list")
|
||||
public TableDataInfo getList(PurchaseDto dto) {
|
||||
startPage();
|
||||
List<PurchaseVo> list = purchaseStorageService.selectAll(dto);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新购验收入库详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取新购验收入库详细信息")
|
||||
@RequiresPermissions("purchase:storage:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(purchaseStorageService.selectPurchaseCheckInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新购入库二级明细列表
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取新购入库二级明细列表")
|
||||
@RequiresPermissions("purchase:storage:details")
|
||||
@GetMapping("/details")
|
||||
public TableDataInfo getDetails(PurchaseDto dto) {
|
||||
startPage();
|
||||
List<PurchaseVo> list = purchaseStorageService.getDetails(dto);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库或批量入库
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "入库或批量入库操作")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("purchase:storage:warehouse")
|
||||
@PostMapping
|
||||
public AjaxResult warehouse(@RequestBody PurchaseDto dto) {
|
||||
return purchaseStorageService.warehouse(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回或批量驳回
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "入库或批量入库操作")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("purchase:storage:reject")
|
||||
@PostMapping
|
||||
public AjaxResult reject(@RequestBody PurchaseDto dto) {
|
||||
return purchaseStorageService.reject(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出新购验收入库详细列表
|
||||
*/
|
||||
@ApiOperation(value = "导出新购验收入库详细列表")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("purchase:storage:export")
|
||||
@SysLog(title = "新购验收入库任务", businessType = OperaType.EXPORT, module = "仓储管理->导出新购验收入库任务")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PurchaseDto dto) {
|
||||
List<PurchaseVo> list = purchaseStorageService.selectAll(dto);
|
||||
ExcelUtil<PurchaseVo> util = new ExcelUtil<PurchaseVo>(PurchaseVo.class);
|
||||
util.exportExcel(response, list, "新购验收入库任务数据");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.bonus.material.purchase.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2024/10/21 13:58
|
||||
*/
|
||||
@Data
|
||||
public class PurchaseDto {
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "类型id")
|
||||
private Integer typeId;
|
||||
|
||||
@ApiModelProperty(value="供应商id")
|
||||
private Integer supplierId;
|
||||
|
||||
@ApiModelProperty(value="入库数量")
|
||||
private Integer inputNum;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
@ApiModelProperty(value = "关键字")
|
||||
private String keyWord;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期")
|
||||
private String productDate;
|
||||
|
||||
@ApiModelProperty(value = "二级明细id")
|
||||
private String purchaseId;
|
||||
|
||||
@ApiModelProperty(value = "id列表")
|
||||
private List<Integer> taskIds;
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package com.bonus.material.purchase.mapper;
|
||||
|
||||
import com.bonus.material.purchase.dto.PurchaseDto;
|
||||
import com.bonus.material.purchase.vo.PurchaseVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 新购验收入库Mapper接口
|
||||
* @Author ma_sh
|
||||
* @create 2024/10/21 13:55
|
||||
*/
|
||||
public interface PurchaseStorageMapper {
|
||||
|
||||
/**
|
||||
* 查询新购验收入库列表
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<PurchaseVo> selectAll(PurchaseDto dto);
|
||||
|
||||
/**
|
||||
* 根据id查询详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<PurchaseVo> selectPurchaseCheckInfoById(Long id);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<PurchaseVo> getDetails(PurchaseDto dto);
|
||||
|
||||
/**
|
||||
* 更新入库数量
|
||||
* @param purchaseId
|
||||
* @param bindNum
|
||||
* @return
|
||||
*/
|
||||
int updateNum(@Param("id") String purchaseId, @Param("purchaseNum") Integer bindNum);
|
||||
|
||||
/**
|
||||
* 更新状态
|
||||
* @param updatedStatus
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int updateStatusById(@Param("updatedStatus") Integer updatedStatus, @Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 新增机具入库记录
|
||||
* @param detail
|
||||
* @return
|
||||
*/
|
||||
int insertMachine(PurchaseVo detail);
|
||||
|
||||
/**
|
||||
* 更新库存数量
|
||||
* @param inputNum
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
int updateStorageNum(@Param("inputNum") Integer inputNum, @Param("typeId") Integer typeId);
|
||||
|
||||
/**
|
||||
* 查询详情单子状态
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
List<PurchaseVo> select(String taskId);
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.bonus.material.purchase.service;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.purchase.dto.PurchaseDto;
|
||||
import com.bonus.material.purchase.vo.PurchaseVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 新购入库服务层
|
||||
* @Author ma_sh
|
||||
* @create 2024/10/21 13:53
|
||||
*/
|
||||
public interface IPurchaseStorageService {
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<PurchaseVo> selectAll(PurchaseDto dto);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<PurchaseVo> selectPurchaseCheckInfoById(Long id);
|
||||
|
||||
/**
|
||||
* 查询二级明细
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<PurchaseVo> getDetails(PurchaseDto dto);
|
||||
|
||||
/**
|
||||
* 入库或批量入库
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
AjaxResult warehouse(PurchaseDto dto);
|
||||
|
||||
/**
|
||||
* 驳回或批量驳回
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
AjaxResult reject(PurchaseDto dto);
|
||||
}
|
||||
|
|
@ -0,0 +1,288 @@
|
|||
package com.bonus.material.purchase.service.impl;
|
||||
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.common.biz.constant.MaterialConstants;
|
||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.ma.mapper.MachineMapper;
|
||||
import com.bonus.material.purchase.dto.PurchaseDto;
|
||||
import com.bonus.material.purchase.mapper.PurchaseStorageMapper;
|
||||
import com.bonus.material.purchase.service.IPurchaseStorageService;
|
||||
import com.bonus.material.purchase.vo.PurchaseVo;
|
||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.bonus.common.biz.constant.MaterialConstants.ONE_CONSTANT;
|
||||
import static com.bonus.common.biz.constant.MaterialConstants.ZERO_CONSTANT;
|
||||
|
||||
/**
|
||||
* 新购入库实现层
|
||||
* @Author ma_sh
|
||||
* @create 2024/10/21 13:53
|
||||
*/
|
||||
@Service
|
||||
public class IPurchaseStorageServiceImpl implements IPurchaseStorageService {
|
||||
|
||||
@Resource
|
||||
private PurchaseStorageMapper purchaseStorageMapper;
|
||||
|
||||
@Resource
|
||||
private MachineMapper machineMapper;
|
||||
|
||||
@Resource
|
||||
private TmTaskMapper tmTaskMapper;
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PurchaseVo> selectAll(PurchaseDto dto) {
|
||||
List<PurchaseVo> list = purchaseStorageMapper.selectAll(dto);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PurchaseVo> selectPurchaseCheckInfoById(Long id) {
|
||||
return purchaseStorageMapper.selectPurchaseCheckInfoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询二级明细详情
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PurchaseVo> getDetails(PurchaseDto dto) {
|
||||
return purchaseStorageMapper.getDetails(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库或批量入库
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult warehouse(PurchaseDto dto) {
|
||||
if (dto.getId() != null) {
|
||||
//外层入库
|
||||
return processByTaskIds(dto);
|
||||
} else if (dto.getPurchaseId() != null) {
|
||||
//内层入库
|
||||
return processByPurchaseIds(dto);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回或批量驳回
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult reject(PurchaseDto dto) {
|
||||
if (dto.getId() != null) {
|
||||
//外层驳回
|
||||
return rejectByTaskIds(dto);
|
||||
} else if (dto.getPurchaseId() != null) {
|
||||
//内层驳回
|
||||
return rejectByPurchaseIds(dto);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 内层驳回
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult rejectByPurchaseIds(PurchaseDto purchaseDto) {
|
||||
purchaseDto.setStatus(MaterialConstants.PURCHASE_STORAGE_NO_PASSED);
|
||||
int result = 0;
|
||||
try {
|
||||
List<PurchaseVo> details = purchaseStorageMapper.getDetails(purchaseDto);
|
||||
if (CollectionUtils.isNotEmpty(details)) {
|
||||
result += updateRejectAndStatus(Integer.parseInt(purchaseDto.getPurchaseId()));
|
||||
List<PurchaseVo> statusList = purchaseStorageMapper.select(details.get(0).getId().toString());
|
||||
result += updateTaskStatus(statusList);
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("驳回成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新驳回状态和状态
|
||||
* @param purchaseId
|
||||
* @return
|
||||
*/
|
||||
private int updateRejectAndStatus(int purchaseId) {
|
||||
return purchaseStorageMapper.updateStatusById(MaterialConstants.PURCHASE_STORAGE_NO_PASSED, purchaseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 外层驳回
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult rejectByTaskIds(PurchaseDto dto) {
|
||||
List<Integer> taskIdList = parseIds(dto.getId());
|
||||
int result = 0;
|
||||
try {
|
||||
for (Integer taskId : taskIdList) {
|
||||
dto.setId(String.valueOf(taskId));
|
||||
List<PurchaseVo> details;
|
||||
details = purchaseStorageMapper.getDetails(dto);
|
||||
result += updateDetailsAndStatus(details);
|
||||
details = purchaseStorageMapper.getDetails(dto);
|
||||
result += updateTaskStatus(details);
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("驳回成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 内层入库
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult processByPurchaseIds(PurchaseDto purchaseDto) {
|
||||
purchaseDto.setStatus(MaterialConstants.INVENTORY);
|
||||
int result = 0;
|
||||
try {
|
||||
List<PurchaseVo> details = purchaseStorageMapper.getDetails(purchaseDto);
|
||||
if (CollectionUtils.isNotEmpty(details)) {
|
||||
result += updatePurchaseInfoAndDetails(details.get(0), Integer.parseInt(purchaseDto.getPurchaseId()));
|
||||
List<PurchaseVo> statusList = purchaseStorageMapper.select(details.get(0).getId().toString());
|
||||
result += updateTaskStatus(statusList);
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("入库成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新采购单和采购明细
|
||||
* @param detail
|
||||
* @param purchaseId
|
||||
* @return
|
||||
*/
|
||||
private int updatePurchaseInfoAndDetails(PurchaseVo detail, int purchaseId) {
|
||||
int result = purchaseStorageMapper.updateStatusById(MaterialConstants.INVENTORY, purchaseId);
|
||||
if (ZERO_CONSTANT.equals(detail.getManageType())) {
|
||||
result += purchaseStorageMapper.insertMachine(detail);
|
||||
} else if (ONE_CONSTANT.equals(detail.getManageType())) {
|
||||
result += purchaseStorageMapper.updateStorageNum(detail.getBindNum(), detail.getTypeId());
|
||||
}
|
||||
return result + purchaseStorageMapper.updateNum(detail.getPurchaseId(), detail.getBindNum());
|
||||
}
|
||||
|
||||
/**
|
||||
* 外层入库
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult processByTaskIds(PurchaseDto dto) {
|
||||
List<Integer> taskIdList = parseIds(dto.getId());
|
||||
int result = 0;
|
||||
try {
|
||||
for (Integer taskId : taskIdList) {
|
||||
dto.setId(String.valueOf(taskId));
|
||||
List<PurchaseVo> details;
|
||||
details = purchaseStorageMapper.getDetails(dto);
|
||||
for (PurchaseVo purchaseVo : details) {
|
||||
result += purchaseStorageMapper.updateStatusById(MaterialConstants.PURCHASE_STORAGE_NO_PASSED, Integer.parseInt(purchaseVo.getPurchaseId()));
|
||||
}
|
||||
details = purchaseStorageMapper.getDetails(dto);
|
||||
result += updateTaskStatus(details);
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("入库成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新采购单和采购明细状态
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
private int updateDetailsAndStatus(List<PurchaseVo> details) {
|
||||
return details.stream()
|
||||
.mapToInt(detail -> {
|
||||
int result = purchaseStorageMapper.updateNum(detail.getPurchaseId(), detail.getBindNum());
|
||||
result += purchaseStorageMapper.updateStatusById(MaterialConstants.INVENTORY, Integer.parseInt(detail.getPurchaseId()));
|
||||
if (ZERO_CONSTANT.equals(detail.getManageType())) {
|
||||
result += purchaseStorageMapper.insertMachine(detail);
|
||||
} else if (ONE_CONSTANT.equals(detail.getManageType())) {
|
||||
result += purchaseStorageMapper.updateStorageNum(detail.getBindNum(), detail.getTypeId());
|
||||
}
|
||||
return result;
|
||||
}).sum();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务状态
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
private int updateTaskStatus(List<PurchaseVo> details) {
|
||||
Map<Integer, List<Integer>> groupedByIdStatus = details.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
PurchaseVo::getId,
|
||||
Collectors.mapping(PurchaseVo::getStatus, Collectors.toList())
|
||||
));
|
||||
|
||||
return groupedByIdStatus.entrySet().stream()
|
||||
.mapToInt(entry -> {
|
||||
Integer id = entry.getKey();
|
||||
List<Integer> statusList = entry.getValue();
|
||||
if (statusList.contains(MaterialConstants.INBOUND_AUDIT) || statusList.contains(MaterialConstants.PURCHASE_STORAGE_NO_PASSED)) {
|
||||
return tmTaskMapper.updateStatusById(MaterialConstants.PARTIALLY_WAREHOUSED, id);
|
||||
} else if (!statusList.contains(MaterialConstants.INBOUND_AUDIT) && !statusList.contains(MaterialConstants.PURCHASE_STORAGE_NO_PASSED)
|
||||
&& !statusList.contains(MaterialConstants.PARTIALLY_WAREHOUSED) && statusList.contains(MaterialConstants.INVENTORY)) {
|
||||
return tmTaskMapper.updateStatusById(MaterialConstants.INVENTORY, id);
|
||||
}
|
||||
return 0;
|
||||
}).sum();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串转换为Integer集合
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
private List<Integer> parseIds(String ids) {
|
||||
return Arrays.stream(ids.split(","))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package com.bonus.material.purchase.vo;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2024/10/21 13:47
|
||||
*/
|
||||
@Data
|
||||
public class PurchaseVo {
|
||||
|
||||
@ApiModelProperty(value="任务id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "二级明细id")
|
||||
private String purchaseId;
|
||||
|
||||
@ApiModelProperty(value="typeId")
|
||||
private Integer typeId;
|
||||
|
||||
@ApiModelProperty("物资名称")
|
||||
private String materialName;
|
||||
|
||||
@ApiModelProperty("规格型号")
|
||||
private String materialModel;
|
||||
|
||||
@ApiModelProperty(value="单位")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value="供应商名称")
|
||||
private String supplierName;
|
||||
|
||||
@ApiModelProperty(value="出厂日期")
|
||||
@JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date productDate;
|
||||
|
||||
@ApiModelProperty(value="到货时间")
|
||||
@JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
|
||||
@Excel(name = "到货时间")
|
||||
private Date arrivalTime;
|
||||
|
||||
@ApiModelProperty(value="采购单号")
|
||||
@Excel(name = "采购单号")
|
||||
private String purchaseCode;
|
||||
|
||||
@ApiModelProperty(value="采购物资")
|
||||
@Excel(name = "采购物资")
|
||||
private String purchaseMaterial;
|
||||
|
||||
@ApiModelProperty(value="采购数量")
|
||||
@Excel(name = "采购数量")
|
||||
private Integer purchaseNum;
|
||||
|
||||
@ApiModelProperty(value="验收数量")
|
||||
private Integer checkNum;
|
||||
|
||||
@ApiModelProperty(value="绑定数量")
|
||||
private Integer bindNum;
|
||||
|
||||
@ApiModelProperty(value="采购价格(元含税)")
|
||||
private Integer purchasePrice;
|
||||
|
||||
@ApiModelProperty(value="采购价格(元不含税)")
|
||||
private Integer notaxPrice;
|
||||
|
||||
@ApiModelProperty(value="税率")
|
||||
private Integer taxRate;
|
||||
|
||||
@ApiModelProperty(value="创建人")
|
||||
@Excel(name = "创建人")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty(value="创建时间")
|
||||
@Excel(name = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty(value="状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value="状态名称")
|
||||
@Excel(name = "状态")
|
||||
private String statusName;
|
||||
|
||||
@ApiModelProperty(value="备注")
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "管理类型0是编码1计数")
|
||||
private String manageType;
|
||||
|
||||
@ApiModelProperty(value = "采购人")
|
||||
private String purchaserName;
|
||||
}
|
||||
|
|
@ -66,4 +66,12 @@ public interface TmTaskMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
int deleteTmTaskByTaskIds(Long[] taskIds);
|
||||
|
||||
/**
|
||||
* 更新任务状态
|
||||
* @param updatedStatus
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int updateStatusById(@Param("updatedStatus") Integer updatedStatus, @Param("id") Integer id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,141 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.material.purchase.mapper.PurchaseStorageMapper">
|
||||
|
||||
<insert id="insertMachine">
|
||||
|
||||
</insert>
|
||||
|
||||
<update id="updateNum">
|
||||
UPDATE purchase_check_details
|
||||
SET input_num = #{purchaseNum}
|
||||
WHERE
|
||||
id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateStatusById">
|
||||
UPDATE purchase_check_details
|
||||
SET `status` = #{updatedStatus}
|
||||
WHERE
|
||||
id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateStorageNum">
|
||||
UPDATE ma_type
|
||||
SET storage_num = #{inputNum} + IFNULL(storage_num, 0)
|
||||
WHERE
|
||||
type_id = #{typeId}
|
||||
</update>
|
||||
|
||||
<select id="selectAll" resultType="com.bonus.material.purchase.vo.PurchaseVo">
|
||||
SELECT
|
||||
pci.task_id as id,
|
||||
pci.arrival_time as arrivalTime,
|
||||
tt.`code` as purchaseCode,
|
||||
GROUP_CONCAT( mt.type_name ) AS purchaseMaterial,
|
||||
SUM( pcd.check_num ) AS purchaseNum,
|
||||
pci.purchaser as purchaserName,
|
||||
pci.create_by as createBy,
|
||||
pci.create_time as createTime,
|
||||
tt.task_status as STATUS,
|
||||
pci.remark as remark
|
||||
FROM
|
||||
purchase_check_info pci
|
||||
LEFT JOIN purchase_check_details pcd ON pcd.task_id = pci.task_id
|
||||
LEFT JOIN tm_task tt ON pci.task_id = tt.task_id
|
||||
LEFT JOIN ma_type mt ON pcd.type_id = mt.type_id
|
||||
where 1 = 1
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
<![CDATA[ AND DATE_FORMAT( pci.arrival_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND (
|
||||
tt.`code` LIKE CONCAT('%',#{keyWord},'%')
|
||||
OR pci.remark LIKE CONCAT('%',#{keyWord},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND pcd.`status` = #{status}
|
||||
</if>
|
||||
GROUP BY
|
||||
pci.task_id
|
||||
ORDER BY
|
||||
pci.arrival_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectPurchaseCheckInfoById" resultType="com.bonus.material.purchase.vo.PurchaseVo">
|
||||
SELECT
|
||||
pci.task_id as id,
|
||||
mt1.type_name AS materialName,
|
||||
mt.type_name AS materialModel,
|
||||
pcd.check_num AS purchaseNum,
|
||||
pcd.check_num AS checkNum,
|
||||
pcd.bind_num AS bindNum,
|
||||
mt.unit_name AS unitName,
|
||||
pcd.type_id as typeId,
|
||||
ms.supplier AS supplierName,
|
||||
pcd.production_time AS productDate,
|
||||
mt.manage_type as manageType,
|
||||
pcd.`status` as STATUS
|
||||
FROM
|
||||
purchase_check_info pci
|
||||
LEFT JOIN tm_task tt ON pci.task_id = tt.task_id
|
||||
LEFT JOIN purchase_check_details pcd ON pci.task_id = pcd.task_id
|
||||
LEFT JOIN ma_type mt ON pcd.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
LEFT JOIN ma_supplier_info ms ON pcd.supplier_id = ms.supplier_id
|
||||
where pci.task_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getDetails" resultType="com.bonus.material.purchase.vo.PurchaseVo">
|
||||
SELECT
|
||||
pcd.id AS purchaseId,
|
||||
pcd.task_id AS id,
|
||||
mt1.type_name AS materialName,
|
||||
mt.type_name AS materialModel,
|
||||
pcd.check_num AS purchaseNum,
|
||||
pcd.check_num AS checkNum,
|
||||
pcd.bind_num AS bindNum,
|
||||
pcd.type_id as typeId,
|
||||
mt.unit_name AS unitName,
|
||||
ms.supplier AS supplierName,
|
||||
pcd.production_time AS productDate,
|
||||
mt.manage_type AS manageType,
|
||||
pcd.`status` AS STATUS
|
||||
FROM
|
||||
purchase_check_details pcd
|
||||
LEFT JOIN tm_task tt ON pcd.task_id = tt.task_id
|
||||
LEFT JOIN purchase_check_info pci ON pci.task_id = pcd.task_id
|
||||
LEFT JOIN ma_type mt ON pcd.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
LEFT JOIN ma_supplier_info ms ON pcd.supplier_id = ms.supplier_id
|
||||
where 1 = 1
|
||||
<if test="typeId != null and typeId != ''">
|
||||
AND mt.id = #{typeId}
|
||||
</if>
|
||||
<if test="supplierId != null and supplierId != ''">
|
||||
AND ms.supplier_id = #{supplierId}
|
||||
</if>
|
||||
<if test="productDate != null and productDate != ''">
|
||||
<![CDATA[ AND DATE_FORMAT( pcd.production_time, '%Y-%m-%d' ) = #{productDate} ]]>
|
||||
</if>
|
||||
<if test="id != null and id != ''">
|
||||
AND pcd.task_id = #{id}
|
||||
</if>
|
||||
<if test="purchaseId != null and purchaseId != ''">
|
||||
AND pcd.id = #{purchaseId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="select" resultType="com.bonus.material.purchase.vo.PurchaseVo">
|
||||
SELECT
|
||||
pcd.task_id as id,
|
||||
pcd.status as STATUS
|
||||
FROM
|
||||
purchase_check_details pcd
|
||||
where pcd.task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -85,6 +85,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where task_id = #{taskId}
|
||||
</update>
|
||||
|
||||
<update id="updateStatusById">
|
||||
update tm_task set status = #{updatedStatus} where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteTmTaskByTaskId" parameterType="Long">
|
||||
delete from tm_task where task_id = #{taskId}
|
||||
</delete>
|
||||
|
|
|
|||
Loading…
Reference in New Issue