Merge remote-tracking branch 'origin/master'

This commit is contained in:
syruan 2024-08-22 16:19:10 +08:00
commit 29fc0b28b7
9 changed files with 100 additions and 99 deletions

View File

@ -98,4 +98,13 @@ public class BaseTreeController {
return R.ok(bmProNature); return R.ok(bmProNature);
} }
/**
* 获取新购状态
*/
@RequestMapping("/getStatus")
public R<Object> getStatus(){
R<List<Object>> bmProNature = remoteDictService.getDictData("purchase_status");
return R.ok(bmProNature);
}
} }

View File

@ -59,7 +59,7 @@ public class BpmPurchaseAcceptController extends BaseController {
*/ */
@ApiOperation("单个或批量验收合格") @ApiOperation("单个或批量验收合格")
@PostMapping ("/approve") @PostMapping ("/approve")
public AjaxResult updateTask(PurchaseDto purchaseDto) public AjaxResult updateTask(@RequestBody PurchaseDto purchaseDto)
{ {
return purchaseAcceptService.updateTask(purchaseDto); return purchaseAcceptService.updateTask(purchaseDto);
} }
@ -71,21 +71,21 @@ public class BpmPurchaseAcceptController extends BaseController {
*/ */
@ApiOperation("二级页面不合格") @ApiOperation("二级页面不合格")
@PostMapping ("/reject") @PostMapping ("/reject")
public AjaxResult updateDetails(PurchaseDto purchaseDto) public AjaxResult updateDetails(@RequestBody PurchaseDto purchaseDto)
{ {
return purchaseAcceptService.updateDetails(purchaseDto); return purchaseAcceptService.updateDetails(purchaseDto);
} }
/** /**
* 导出新购验列表 * 导出新购验列表
*/ */
@ApiOperation(value = "导出新购验列表") @ApiOperation(value = "导出新购验列表")
@RequiresPermissions("purchase:purchaseDto:export") @RequiresPermissions("purchase:purchaseDto:export")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, PurchaseDto purchaseDto) public void export(HttpServletResponse response, PurchaseDto purchaseDto)
{ {
List<PurchaseAcceptVo> list = purchaseAcceptService.selectAll(purchaseDto); List<PurchaseAcceptVo> list = purchaseAcceptService.selectAll(purchaseDto);
ExcelUtil<PurchaseAcceptVo> util = new ExcelUtil<>(PurchaseAcceptVo.class); ExcelUtil<PurchaseAcceptVo> util = new ExcelUtil<>(PurchaseAcceptVo.class);
util.exportExcel(response, list, "新购验列表"); util.exportExcel(response, list, "新购验列表");
} }
} }

View File

@ -15,7 +15,7 @@ import java.util.List;
public class PurchaseDto { public class PurchaseDto {
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private Integer id; private String id;
@ApiModelProperty(value = "类型id") @ApiModelProperty(value = "类型id")
private Integer typeId; private Integer typeId;

View File

@ -33,27 +33,12 @@ public interface BpmPurchaseAcceptMapper {
*/ */
List<Integer> selectStatus(PurchaseDto purchaseDto); 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 * @param idList
* @return * @return
*/ */
List<PurchaseAcceptVo> select(@Param("array") String[] split); List<PurchaseAcceptVo> select(@Param("array") List<String> idList);
/** /**
* 更新采购数量 * 更新采购数量
@ -61,5 +46,6 @@ public interface BpmPurchaseAcceptMapper {
* @param purchaseNum * @param purchaseNum
* @return * @return
*/ */
int updateCheckNum(@Param("id") Integer id, @Param("purchaseNum") Integer purchaseNum); int updateCheckNum(@Param("id") String id, @Param("purchaseNum") Integer purchaseNum);
} }

View File

@ -124,5 +124,5 @@ public interface BpmPurchaseInfoMapper {
*/ */
int updateByPrimaryKey(BpmPurchaseInfo record); int updateByPrimaryKey(BpmPurchaseInfo record);
int updateStatusById(@Param("updatedStatus") Byte updatedStatus, @Param("id") Integer id); int updateStatusById(@Param("updatedStatus") Integer updatedStatus, @Param("id") Integer id);
} }

View File

@ -4,14 +4,17 @@ import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.purchase.dto.PurchaseDto; import com.bonus.purchase.dto.PurchaseDto;
import com.bonus.purchase.mapper.BpmPurchaseAcceptMapper; import com.bonus.purchase.mapper.BpmPurchaseAcceptMapper;
import com.bonus.purchase.mapper.BpmPurchaseInfoMapper;
import com.bonus.purchase.service.BpmPurchaseAcceptService; import com.bonus.purchase.service.BpmPurchaseAcceptService;
import com.bonus.purchase.utils.Constants; import com.bonus.purchase.utils.Constants;
import com.bonus.purchase.vo.PurchaseAcceptVo; import com.bonus.purchase.vo.PurchaseAcceptVo;
import com.bonus.task.mapper.BpmTaskMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -26,6 +29,12 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
@Resource @Resource
private BpmPurchaseAcceptMapper mapper; private BpmPurchaseAcceptMapper mapper;
@Resource
private BpmTaskMapper bpmTaskMapper;
@Resource
private BpmPurchaseInfoMapper bpmPurchaseInfoMapper;
/** /**
* 查询采购单 * 查询采购单
* @param purchaseDto * @param purchaseDto
@ -55,13 +64,12 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult updateTask(PurchaseDto purchaseDto) { public AjaxResult updateTask(PurchaseDto purchaseDto) {
//只有任务状态为待验收时方可批量验收合格 //只有任务状态为待验收时方可批量验收合格
if (purchaseDto.getTaskId() != null) { if (purchaseDto.getId() != null) {
String[] split = purchaseDto.getTaskId().split(","); String[] split = purchaseDto.getId().split(",");
ArrayList<Integer> list = new ArrayList<>(); ArrayList<Integer> taskIdList = new ArrayList<>();
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
list.add(Integer.parseInt(split[i])); taskIdList.add(Integer.parseInt(split[i]));
} }
purchaseDto.setTaskIds(list);
List<Integer> statusList = mapper.selectStatus(purchaseDto); List<Integer> statusList = mapper.selectStatus(purchaseDto);
if (CollectionUtils.isNotEmpty(statusList)) { if (CollectionUtils.isNotEmpty(statusList)) {
for (Integer status : statusList) { for (Integer status : statusList) {
@ -70,42 +78,68 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
} }
} }
} }
purchaseDto.setStatus(Constants.PURCHASE_ACCEPTED); int result = 0;
int result;
try { try {
result = mapper.updateTask(purchaseDto);
//根据任务id查询详情表 //根据任务id查询详情表
List<Integer> taskIds = purchaseDto.getTaskIds(); for (Integer taskId : taskIdList) {
for (Integer taskId : taskIds) { purchaseDto.setId(String.valueOf(taskId));
purchaseDto.setId(taskId);
List<PurchaseAcceptVo> details = mapper.getDetails(purchaseDto); List<PurchaseAcceptVo> details = mapper.getDetails(purchaseDto);
//根据查询的采购数量更新验收数量 //根据查询的采购数量更新验收数量
for (PurchaseAcceptVo purchaseVo : details) { for (PurchaseAcceptVo purchaseVo : details) {
result = mapper.updateCheckNum(purchaseVo.getId(), purchaseVo.getPurchaseNum()); result += mapper.updateCheckNum(purchaseVo.getPurchaseId(), purchaseVo.getPurchaseNum());
if ("0".equals(purchaseVo.getManageType())) {
result += bpmPurchaseInfoMapper.updateStatusById(Constants.PENDING_BINDING, Integer.parseInt(purchaseVo.getPurchaseId()));
} else if ("1".equals(purchaseVo.getManageType())) {
result += bpmPurchaseInfoMapper.updateStatusById(Constants.PENDING_INVENTORY, Integer.parseInt(purchaseVo.getPurchaseId()));
}
}
// 提取 PurchaseId
List<String> idList = details.stream().map(PurchaseAcceptVo::getPurchaseId).collect(Collectors.toList());
//根据详情id查询详情状态更新任务表状态
List<PurchaseAcceptVo> idStatusList = mapper.select(idList);
// 使用流 API id 分组并提取 status
Map<Integer, List<Integer>> groupedByIdStatus = idStatusList.stream()
.collect(Collectors.groupingBy(
PurchaseAcceptVo::getId,
Collectors.mapping(PurchaseAcceptVo::getStatus, Collectors.toList())
));
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
Integer id = entry.getKey();
List<Integer> statusList1 = entry.getValue();
if (statusList1.contains(Constants.PENDING_BINDING)) {
//如果详情状态包含待绑定则外部任务状态为待绑定
result += bpmTaskMapper.updateStatusById(Constants.PENDING_BINDING, id);
} else if (!statusList1.contains(Constants.PENDING_BINDING) && statusList1.contains(Constants.PENDING_INVENTORY)) {
result += bpmTaskMapper.updateStatusById(Constants.PENDING_INVENTORY, id);
}
}
if (result > 0) {
return AjaxResult.success("批量验收合格成功");
} }
}
if (result > 0) {
return AjaxResult.success("操作成功");
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} else if (purchaseDto.getPurchaseId() != null) { } else if (purchaseDto.getPurchaseId() != null) {
String[] split = purchaseDto.getPurchaseId().split(","); String[] split = purchaseDto.getPurchaseId().split(",");
purchaseDto.setStatus(Constants.PURCHASE_ACCEPTED); purchaseDto.setStatus(Constants.PENDING_BINDING);
int result; int result = 0;
try { try {
result = mapper.updateDetails(split, purchaseDto.getStatus());
//根据采购单id查询详情id //根据采购单id查询详情id
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
purchaseDto.setPurchaseId(split[i]); purchaseDto.setPurchaseId(split[i]);
List<PurchaseAcceptVo> details = mapper.getDetails(purchaseDto); List<PurchaseAcceptVo> details = mapper.getDetails(purchaseDto);
for (PurchaseAcceptVo purchaseVo : details) { if (CollectionUtils.isNotEmpty(details)) {
result = mapper.updateCheckNum(purchaseVo.getId(), purchaseVo.getPurchaseNum()); if ("0".equals(details.get(0).getManageType())) {
bpmPurchaseInfoMapper.updateStatusById(Constants.PENDING_BINDING, Integer.parseInt(split[i]));
} else if ("1".equals(details.get(0).getManageType())) {
bpmPurchaseInfoMapper.updateStatusById(Constants.PENDING_INVENTORY, Integer.parseInt(split[i]));
}
} }
result = mapper.updateCheckNum(details.get(0).getPurchaseId(), details.get(0).getPurchaseNum());
} }
//根据详情id查询详情状态更新任务表状态 //根据详情id查询详情状态更新任务表状态
List<PurchaseAcceptVo> statusList = mapper.select(split); List<PurchaseAcceptVo> statusList = mapper.select(Arrays.asList(split));
// 使用流 API id 分组并提取 status // 使用流 API id 分组并提取 status
Map<Integer, List<Integer>> groupedByIdStatus = statusList.stream() Map<Integer, List<Integer>> groupedByIdStatus = statusList.stream()
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
@ -114,24 +148,16 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
)); ));
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) { for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
Integer id = entry.getKey(); Integer id = entry.getKey();
ArrayList<Integer> list = new ArrayList<>();
List<Integer> statusList1 = entry.getValue(); List<Integer> statusList1 = entry.getValue();
if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_ACCEPTED) if (statusList1.contains(Constants.PENDING_BINDING)) {
&& !statusList1.contains(Constants.PURCHASE_NO_PASSED)) { //如果详情状态包含待绑定则外部任务状态为待绑定
//如果不包含47和49则更新任务状态为48 全部通过 result += bpmTaskMapper.updateStatusById(Constants.PENDING_BINDING, id);
list.add(id); } else if (!statusList1.contains(Constants.PENDING_BINDING) && statusList1.contains(Constants.PENDING_INVENTORY)) {
purchaseDto.setTaskIds(list); result += bpmTaskMapper.updateStatusById(Constants.PENDING_INVENTORY, id);
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) { if (result > 0) {
return AjaxResult.success("操作成功"); return AjaxResult.success("批量验收合格成功");
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -150,12 +176,13 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
public AjaxResult updateDetails(PurchaseDto purchaseDto) { public AjaxResult updateDetails(PurchaseDto purchaseDto) {
if (purchaseDto.getPurchaseId() != null) { if (purchaseDto.getPurchaseId() != null) {
String[] split = purchaseDto.getPurchaseId().split(","); String[] split = purchaseDto.getPurchaseId().split(",");
purchaseDto.setStatus(Constants.PURCHASE_NO_PASSED); // 将字符串数组转换为 List<Integer>
int result; List<Integer> idList = Arrays.stream(split).map(Integer::parseInt).collect(Collectors.toList());
int result = 0;
try { try {
result = mapper.updateDetails(split, purchaseDto.getStatus()); result += bpmPurchaseInfoMapper.updateStatusByTaskIdIn(Constants.PURCHASE_NO_PASSED, idList);
//根据详情id查询详情状态更新任务表状态 //根据详情id查询详情状态更新任务表状态
List<PurchaseAcceptVo> statusList = mapper.select(split); List<PurchaseAcceptVo> statusList = mapper.select(Arrays.asList(split));
// 使用流 API id 分组并提取 status // 使用流 API id 分组并提取 status
Map<Integer, List<Integer>> groupedByIdStatus = statusList.stream() Map<Integer, List<Integer>> groupedByIdStatus = statusList.stream()
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
@ -164,20 +191,13 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
)); ));
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) { for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
Integer id = entry.getKey(); Integer id = entry.getKey();
ArrayList<Integer> list = new ArrayList<>();
List<Integer> statusList1 = entry.getValue(); List<Integer> statusList1 = entry.getValue();
if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_ACCEPTED) if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_ACCEPTED)
&& !statusList1.contains(Constants.PURCHASE_NO_PASSED)) { && !statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
//如果不包含47和49则更新任务状态为48 全部通过 //如果不包含47和49则更新任务状态为48 全部通过
list.add(id); result += bpmTaskMapper.updateStatusById(Constants.PURCHASE_ACCEPTED, 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)) { } else if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
list.add(id); result += bpmTaskMapper.updateStatusById(Constants.PURCHASE_NO_PASSED, id);
purchaseDto.setTaskIds(list);
purchaseDto.setStatus(Constants.PURCHASE_NO_PASSED);
result = mapper.updateTask(purchaseDto);
} }
} }
if (result > 0) { if (result > 0) {

View File

@ -221,7 +221,7 @@ public class BpmPurchaseInfoService{
return bpmPurchaseInfoMapper.updateIsActiveById(id); return bpmPurchaseInfoMapper.updateIsActiveById(id);
} }
public int updateStatusByIdIn(Byte updatedStatus,Integer id){ public int updateStatusByIdIn(Integer updatedStatus,Integer id){
return bpmPurchaseInfoMapper.updateStatusById(updatedStatus,id); return bpmPurchaseInfoMapper.updateStatusById(updatedStatus,id);
} }

View File

@ -60,8 +60,7 @@ public class PurchaseAcceptVo {
private Integer notaxPrice; private Integer notaxPrice;
@ApiModelProperty(value="税率") @ApiModelProperty(value="税率")
@Excel(name = "税率") private String taxRate;
private Integer taxRate;
@ApiModelProperty(value="操作人") @ApiModelProperty(value="操作人")
@Excel(name = "操作人") @Excel(name = "操作人")
@ -81,4 +80,11 @@ public class PurchaseAcceptVo {
@ApiModelProperty(value="备注") @ApiModelProperty(value="备注")
@Excel(name = "备注") @Excel(name = "备注")
private String remark; private String remark;
@ApiModelProperty(value = "二级明细id")
private String purchaseId;
@ApiModelProperty(value = "管理类型0是编码1计数")
private String manageType;
} }

View File

@ -3,25 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.purchase.mapper.BpmPurchaseAcceptMapper"> <mapper namespace="com.bonus.purchase.mapper.BpmPurchaseAcceptMapper">
<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 id="updateCheckNum">
UPDATE bpm_purchase_info bp UPDATE bpm_purchase_info bp
SET bp.check_num = #{purchaseNum} SET bp.check_num = #{purchaseNum}
@ -38,7 +20,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SUM( bp.purchase_num ) AS purchaseNum, SUM( bp.purchase_num ) AS purchaseNum,
SUM( bp.purchase_price ) AS purchasePrice, SUM( bp.purchase_price ) AS purchasePrice,
SUM( bp.notax_price ) AS notaxPrice, SUM( bp.notax_price ) AS notaxPrice,
CONCAT(bp.tax_rate, '%') AS taxRate,
su.nick_name AS createBy, su.nick_name AS createBy,
bt.create_time AS createTime, bt.create_time AS createTime,
bt.`status` AS STATUS, bt.`status` AS STATUS,
@ -78,11 +59,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.id AS purchaseId, bp.id AS purchaseId,
mt1.`name` AS materialName, mt1.`name` AS materialName,
mt.`name` AS materialModel, mt.`name` AS materialModel,
mt.manage_type AS manageType,
sda.dict_label AS unitName, sda.dict_label AS unitName,
bp.purchase_price AS purchasePrice, bp.purchase_price AS purchasePrice,
bp.notax_price AS notaxPrice, bp.notax_price AS notaxPrice,
bp.purchase_num AS purchaseNum, bp.purchase_num AS purchaseNum,
bs.`name` AS supplierName, bs.`name` AS supplierName,
CONCAT(bp.tax_rate, '%') AS taxRate,
bp.product_date AS productDate, bp.product_date AS productDate,
bp.`status` AS STATUS, bp.`status` AS STATUS,
sda1.dict_label AS statusName sda1.dict_label AS statusName
@ -97,10 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE WHERE
bp.is_active = '1' bp.is_active = '1'
<if test="typeId != null and typeId != ''"> <if test="typeId != null and typeId != ''">
AND ( AND mt.id = #{typeId}
mt1.id = #{typeId}
OR mt.id = #{typeId}
)
</if> </if>
<if test="supplierId != null and supplierId != ''"> <if test="supplierId != null and supplierId != ''">
AND bs.id = #{supplierId} AND bs.id = #{supplierId}