Merge remote-tracking branch 'origin/master'
# Conflicts: # bonus-modules/bonus-purchase/src/main/java/com/bonus/purchase/service/PurchaseAcceptService.java # bonus-modules/bonus-purchase/src/main/java/com/bonus/purchase/service/impl/PurchaseAcceptServiceImpl.java
This commit is contained in:
commit
8c9e230bbf
|
|
@ -2,6 +2,7 @@ package com.bonus.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.security.annotation.RequiresPermissions;
|
||||
import com.bonus.purchase.dto.PurchaseDto;
|
||||
|
|
@ -20,7 +21,7 @@ import java.util.List;
|
|||
* @create 2024/8/19 16:13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/purchase/arrival")
|
||||
@RequestMapping("/acceptance")
|
||||
public class PurchaseAcceptController extends BaseController {
|
||||
|
||||
@Resource
|
||||
|
|
@ -51,6 +52,30 @@ public class PurchaseAcceptController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个或批量验收合格
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("单个或批量验收合格")
|
||||
@PostMapping ("/approve")
|
||||
public AjaxResult updateTask(PurchaseDto purchaseDto)
|
||||
{
|
||||
return purchaseAcceptService.updateTask(purchaseDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 二级页面验收不合格
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("二级页面不合格")
|
||||
@PostMapping ("/reject")
|
||||
public AjaxResult updateDetails(PurchaseDto purchaseDto)
|
||||
{
|
||||
return purchaseAcceptService.updateDetails(purchaseDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出新购验证列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ package com.bonus.purchase.dto;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 新购模块查询传参类
|
||||
* @Author ma_sh
|
||||
* @create 2024/8/19 17:50
|
||||
*/
|
||||
|
|
@ -29,8 +32,17 @@ public class PurchaseDto {
|
|||
private String keyWord;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private String status;
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期")
|
||||
private String productDate;
|
||||
|
||||
@ApiModelProperty(value = "id集合")
|
||||
private List<Integer> taskIds;
|
||||
|
||||
@ApiModelProperty(value = "任务id集合")
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty(value = "二级明细id")
|
||||
private String purchaseId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.purchase.mapper;
|
|||
|
||||
import com.bonus.purchase.dto.PurchaseDto;
|
||||
import com.bonus.purchase.vo.PurchaseVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -24,4 +25,41 @@ public interface PurchaseAcceptMapper {
|
|||
* @return
|
||||
*/
|
||||
List<PurchaseVo> getDetails(PurchaseDto purchaseDto);
|
||||
|
||||
/**
|
||||
* 查询状态
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
List<Integer> selectStatus(PurchaseDto purchaseDto);
|
||||
|
||||
/**
|
||||
* 更新任务状态
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
int updateTask(@Param("purchaseDto") PurchaseDto purchaseDto);
|
||||
|
||||
/**
|
||||
* 审批合格或不合格
|
||||
* @param split
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
int updateDetails(@Param("array") String[] split, @Param("status") Integer status);
|
||||
|
||||
/**
|
||||
* 查询状态
|
||||
* @param split
|
||||
* @return
|
||||
*/
|
||||
List<PurchaseVo> select(@Param("array") String[] split);
|
||||
|
||||
/**
|
||||
* 更新采购数量
|
||||
* @param id
|
||||
* @param purchaseNum
|
||||
* @return
|
||||
*/
|
||||
int updateCheckNum(@Param("id") Integer id, @Param("purchaseNum") Integer purchaseNum);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.purchase.service;
|
||||
|
||||
import com.bonus.purchase.dto.PurchaseDto;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.purchase.domain.PurchaseDto;
|
||||
import com.bonus.purchase.vo.PurchaseVo;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -24,4 +25,18 @@ public interface PurchaseAcceptService {
|
|||
* @return
|
||||
*/
|
||||
List<PurchaseVo> getDetails(PurchaseDto purchaseDto);
|
||||
|
||||
/**
|
||||
* 批量验收合格
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
AjaxResult updateTask(PurchaseDto purchaseDto);
|
||||
|
||||
/**
|
||||
* 批量审批
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
AjaxResult updateDetails(PurchaseDto purchaseDto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,20 @@
|
|||
package com.bonus.purchase.service.impl;
|
||||
|
||||
import com.bonus.purchase.dto.PurchaseDto;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.purchase.domain.PurchaseDto;
|
||||
import com.bonus.purchase.mapper.PurchaseAcceptMapper;
|
||||
import com.bonus.purchase.service.PurchaseAcceptService;
|
||||
import com.bonus.purchase.utils.Constants;
|
||||
import com.bonus.purchase.vo.PurchaseVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
|
|
@ -38,4 +45,148 @@ public class PurchaseAcceptServiceImpl implements PurchaseAcceptService {
|
|||
public List<PurchaseVo> getDetails(PurchaseDto purchaseDto) {
|
||||
return mapper.getDetails(purchaseDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量验收合格
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult updateTask(PurchaseDto purchaseDto) {
|
||||
//只有任务状态为待验收时,方可批量验收合格
|
||||
if (purchaseDto.getTaskId() != null) {
|
||||
String[] split = purchaseDto.getTaskId().split(",");
|
||||
ArrayList<Integer> list = new ArrayList<>();
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
list.add(Integer.parseInt(split[i]));
|
||||
}
|
||||
purchaseDto.setTaskIds(list);
|
||||
List<Integer> statusList = mapper.selectStatus(purchaseDto);
|
||||
if (CollectionUtils.isNotEmpty(statusList)) {
|
||||
for (Integer status : statusList) {
|
||||
if (!status.equals(Constants.PENDING_ACCEPTANCE)) {
|
||||
return AjaxResult.warn("存在非待验收任务,无法批量验收合格");
|
||||
}
|
||||
}
|
||||
}
|
||||
purchaseDto.setStatus(Constants.PURCHASE_ACCEPTED);
|
||||
int result;
|
||||
try {
|
||||
result = mapper.updateTask(purchaseDto);
|
||||
//根据任务id查询详情表
|
||||
List<Integer> taskIds = purchaseDto.getTaskIds();
|
||||
for (Integer taskId : taskIds) {
|
||||
purchaseDto.setId(taskId);
|
||||
List<PurchaseVo> details = mapper.getDetails(purchaseDto);
|
||||
//根据查询的采购数量,更新验收数量
|
||||
for (PurchaseVo purchaseVo : details) {
|
||||
result = mapper.updateCheckNum(purchaseVo.getId(), purchaseVo.getPurchaseNum());
|
||||
}
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else if (purchaseDto.getPurchaseId() != null) {
|
||||
String[] split = purchaseDto.getPurchaseId().split(",");
|
||||
purchaseDto.setStatus(Constants.PURCHASE_ACCEPTED);
|
||||
int result;
|
||||
try {
|
||||
result = mapper.updateDetails(split, purchaseDto.getStatus());
|
||||
//根据采购单id查询详情id
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
purchaseDto.setPurchaseId(split[i]);
|
||||
List<PurchaseVo> details = mapper.getDetails(purchaseDto);
|
||||
for (PurchaseVo purchaseVo : details) {
|
||||
result = mapper.updateCheckNum(purchaseVo.getId(), purchaseVo.getPurchaseNum());
|
||||
}
|
||||
}
|
||||
//根据详情id查询详情状态,更新任务表状态
|
||||
List<PurchaseVo> statusList = mapper.select(split);
|
||||
// 使用流 API 按 id 分组,并提取 status
|
||||
Map<Integer, List<Integer>> groupedByIdStatus = statusList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
PurchaseVo::getId,
|
||||
Collectors.mapping(PurchaseVo::getStatus, Collectors.toList())
|
||||
));
|
||||
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
ArrayList<Integer> list = new ArrayList<>();
|
||||
List<Integer> statusList1 = entry.getValue();
|
||||
if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_ACCEPTED)
|
||||
&& !statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
|
||||
//如果不包含47和49,则更新任务状态为48 全部通过
|
||||
list.add(id);
|
||||
purchaseDto.setTaskIds(list);
|
||||
purchaseDto.setStatus(Constants.PURCHASE_ACCEPTED);
|
||||
result = mapper.updateTask(purchaseDto);
|
||||
} else if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
|
||||
list.add(id);
|
||||
purchaseDto.setTaskIds(list);
|
||||
purchaseDto.setStatus(Constants.PURCHASE_NO_PASSED);
|
||||
result = mapper.updateTask(purchaseDto);
|
||||
}
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 二级批量审批不合格
|
||||
* @param purchaseDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult updateDetails(PurchaseDto purchaseDto) {
|
||||
if (purchaseDto.getPurchaseId() != null) {
|
||||
String[] split = purchaseDto.getPurchaseId().split(",");
|
||||
purchaseDto.setStatus(Constants.PURCHASE_NO_PASSED);
|
||||
int result;
|
||||
try {
|
||||
result = mapper.updateDetails(split, purchaseDto.getStatus());
|
||||
//根据详情id查询详情状态,更新任务表状态
|
||||
List<PurchaseVo> statusList = mapper.select(split);
|
||||
// 使用流 API 按 id 分组,并提取 status
|
||||
Map<Integer, List<Integer>> groupedByIdStatus = statusList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
PurchaseVo::getId,
|
||||
Collectors.mapping(PurchaseVo::getStatus, Collectors.toList())
|
||||
));
|
||||
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
|
||||
Integer id = entry.getKey();
|
||||
ArrayList<Integer> list = new ArrayList<>();
|
||||
List<Integer> statusList1 = entry.getValue();
|
||||
if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_ACCEPTED)
|
||||
&& !statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
|
||||
//如果不包含47和49,则更新任务状态为48 全部通过
|
||||
list.add(id);
|
||||
purchaseDto.setTaskIds(list);
|
||||
purchaseDto.setStatus(Constants.PURCHASE_ACCEPTED);
|
||||
result = mapper.updateTask(purchaseDto);
|
||||
} else if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
|
||||
list.add(id);
|
||||
purchaseDto.setTaskIds(list);
|
||||
purchaseDto.setStatus(Constants.PURCHASE_NO_PASSED);
|
||||
result = mapper.updateTask(purchaseDto);
|
||||
}
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.purchase.utils;
|
||||
|
||||
/**
|
||||
* 常量类
|
||||
* @Author ma_sh
|
||||
* @create 2024/8/20 16:54
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
/**
|
||||
* 待验收
|
||||
*/
|
||||
public static final Integer PENDING_ACCEPTANCE = 47;
|
||||
|
||||
/**
|
||||
* 已验收
|
||||
*/
|
||||
public static final Integer PURCHASE_ACCEPTED = 48;
|
||||
|
||||
/**
|
||||
* 不通过
|
||||
*/
|
||||
public static final Integer PURCHASE_NO_PASSED = 49;
|
||||
}
|
||||
|
|
@ -3,6 +3,31 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.purchase.mapper.PurchaseAcceptMapper">
|
||||
<update id="updateTask">
|
||||
UPDATE bpm_task bt
|
||||
SET bt.`status` = #{purchaseDto.status}
|
||||
WHERE
|
||||
bt.task_id IN
|
||||
<foreach collection="purchaseDto.taskIds" item="taskId" open="(" separator="," close=")">
|
||||
#{taskId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateDetails">
|
||||
UPDATE bpm_purchase_info bp
|
||||
SET bp.`status` = #{status}
|
||||
WHERE
|
||||
bp.id IN
|
||||
<foreach item="purchaseId" collection="array" open="(" separator="," close=")">
|
||||
#{purchaseId}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updateCheckNum">
|
||||
UPDATE bpm_purchase_info bp
|
||||
SET bp.check_num = #{purchaseNum}
|
||||
WHERE
|
||||
bp.id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectAll" resultType="com.bonus.purchase.vo.PurchaseVo">
|
||||
SELECT
|
||||
|
|
@ -13,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
SUM( bp.purchase_num ) AS purchaseNum,
|
||||
SUM( bp.purchase_price ) AS purchasePrice,
|
||||
SUM( bp.notax_price ) AS notaxPrice,
|
||||
bp.tax_rate AS taxRate,
|
||||
CONCAT(bp.tax_rate, '%') AS taxRate,
|
||||
bt.creator AS createBy,
|
||||
bt.create_time AS createTime,
|
||||
bt.`status` AS STATUS,
|
||||
|
|
@ -25,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt ON bp.type_id = mt.id
|
||||
LEFT JOIN sys_dict_data sda ON sda.dict_code = bt.`status`
|
||||
WHERE
|
||||
bp.is_acvtive = '1'
|
||||
bp.is_active = '1'
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
AND bt.arrival_time BETWEEN #{startTime} AND #{endTime}
|
||||
</if>
|
||||
|
|
@ -46,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
ORDER BY
|
||||
bt.arrival_time DESC
|
||||
</select>
|
||||
|
||||
<select id="getDetails" resultType="com.bonus.purchase.vo.PurchaseVo">
|
||||
SELECT
|
||||
bp.id AS id,
|
||||
|
|
@ -68,7 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN bm_supplier bs ON bp.supplier_id = bs.id
|
||||
LEFT JOIN sys_dict_data sda1 ON sda1.dict_code = bp.`status`
|
||||
WHERE
|
||||
bp.is_acvtive = '1'
|
||||
bp.is_active = '1'
|
||||
<if test="typeId != null and typeId != ''">
|
||||
AND (
|
||||
mt1.id = #{typeId}
|
||||
|
|
@ -81,5 +107,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="productDate != null and productDate != ''">
|
||||
AND bp.product_date = #{productDate}
|
||||
</if>
|
||||
<if test="id != null and id != ''">
|
||||
AND bp.task_id = #{id}
|
||||
</if>
|
||||
<if test="purchaseId != null and purchaseId != ''">
|
||||
AND bp.id = #{purchaseId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectStatus" resultType="java.lang.Integer">
|
||||
select status from bpm_task bt
|
||||
where id in
|
||||
<foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
|
||||
#{taskId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="select" resultType="com.bonus.purchase.vo.PurchaseVo">
|
||||
select task_id as id,
|
||||
status as status
|
||||
from bpm_purchase_info bp
|
||||
where id in
|
||||
<foreach collection="array" item="taskId" open="(" separator="," close=")">
|
||||
#{taskId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue