package org.jeecg.modules.tms.service.impl;
|
|
|
import cn.hutool.core.util.StrUtil;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.apache.shiro.SecurityUtils;
|
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.exception.JeecgBootException;
|
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness;
|
import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI;
|
import org.jeecg.modules.flowable.apithird.service.FlowCommonService;
|
import org.jeecg.modules.flowable.service.IFlowDefinitionService;
|
import org.jeecg.modules.flowable.service.IFlowTaskService;
|
import org.jeecg.modules.system.entity.SysUser;
|
import org.jeecg.modules.system.service.ISysUserService;
|
import org.jeecg.modules.tms.entity.BaseTools;
|
import org.jeecg.modules.tms.entity.ToolsStocktakingBound;
|
import org.jeecg.modules.tms.entity.ToolsStocktakingBoundDetail;
|
import org.jeecg.modules.tms.enums.OutBillStatus;
|
import org.jeecg.modules.tms.mapper.ToolsStocktakingBoundDetailMapper;
|
import org.jeecg.modules.tms.mapper.ToolsStocktakingBoundMapper;
|
import org.jeecg.modules.tms.service.IToolsStocktakingBoundService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
import java.io.Serializable;
|
import java.util.*;
|
|
/**
|
* @Description: 盘点单表
|
* @Author: jeecg-boot
|
* @Date: 2025-05-16
|
* @Version: V1.0
|
*/
|
|
@Service("IToolsStocktakingBoundService")
|
public class ToolsStocktakingBoundServiceImpl extends ServiceImpl<ToolsStocktakingBoundMapper, ToolsStocktakingBound> implements IToolsStocktakingBoundService, FlowCallBackServiceI {
|
|
|
@Autowired
|
private ISysUserService systemUserService;
|
@Autowired
|
private ToolsStocktakingBoundMapper toolsStocktakingBoundMapper;
|
@Autowired
|
private ToolsStocktakingBoundDetailMapper toolsStocktakingBoundDetailMapper;
|
@Resource
|
private FlowCommonService flowCommonService;
|
@Resource
|
private IFlowDefinitionService flowDefinitionService;
|
@Autowired
|
private IFlowTaskService flowTaskService;
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void saveMain(ToolsStocktakingBound toolsStocktakingBound, List<ToolsStocktakingBoundDetail> toolsStocktakingBoundDetailList) {
|
toolsStocktakingBoundMapper.insert(toolsStocktakingBound);
|
if (toolsStocktakingBoundDetailList != null && toolsStocktakingBoundDetailList.size() > 0) {
|
for (ToolsStocktakingBoundDetail entity : toolsStocktakingBoundDetailList) {
|
//外键设置
|
entity.setGoodsShelvesId(toolsStocktakingBound.getId());
|
toolsStocktakingBoundDetailMapper.insert(entity);
|
}
|
}
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void updateMain(ToolsStocktakingBound toolsStocktakingBound, List<ToolsStocktakingBoundDetail> toolsStocktakingBoundDetailList) {
|
toolsStocktakingBoundMapper.updateById(toolsStocktakingBound);
|
|
//1.先删除子表数据
|
toolsStocktakingBoundDetailMapper.deleteByMainId(toolsStocktakingBound.getId());
|
|
//2.子表数据重新插入
|
if (toolsStocktakingBoundDetailList != null && toolsStocktakingBoundDetailList.size() > 0) {
|
for (ToolsStocktakingBoundDetail entity : toolsStocktakingBoundDetailList) {
|
//外键设置
|
entity.setGoodsShelvesId(toolsStocktakingBound.getId());
|
toolsStocktakingBoundDetailMapper.insert(entity);
|
}
|
}
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void delMain(String id) {
|
toolsStocktakingBoundDetailMapper.deleteByMainId(id);
|
toolsStocktakingBoundMapper.deleteById(id);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void delBatchMain(Collection<? extends Serializable> idList) {
|
for (Serializable id : idList) {
|
toolsStocktakingBoundDetailMapper.deleteByMainId(id.toString());
|
toolsStocktakingBoundMapper.deleteById(id);
|
}
|
}
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public boolean submintOrder(String id) {
|
|
ToolsStocktakingBound toolsStocktakingBound = this.getById(id);
|
if (toolsStocktakingBound == null) {
|
return false;
|
} else {
|
toolsStocktakingBound.setReviewer(toolsStocktakingBound.getReviewer());
|
//修改状态
|
// toolsStocktakingBound.setApprovalStatus(OutBillStatus.SUBMITTED.getValue());
|
flowCommonService.initActBusiness("盘点单号:" + toolsStocktakingBound.getOrderCode() + ";盘点名称: " + toolsStocktakingBound.getStocktakingName() + ";进行盘点",
|
toolsStocktakingBound.getId(), "IToolsStocktakingBoundService", "tools_stocktaking_bound", null);
|
Map<String, Object> variables = new HashMap<>();
|
variables.put("dataId", toolsStocktakingBound.getId());
|
if (StrUtil.isEmpty(toolsStocktakingBound.getReviewer())) {
|
variables.put("organization", "新增工具盘点单默认启动流程");
|
variables.put("comment", "新增工具盘点单默认启动流程");
|
} else {
|
variables.put("organization", toolsStocktakingBound.getRemark());
|
variables.put("comment", toolsStocktakingBound.getRemark());
|
}
|
variables.put("proofreading", true);
|
List<String> usernames = new ArrayList<>();
|
usernames.add(toolsStocktakingBound.getReviewer());
|
variables.put("NextAssignee", usernames);
|
Result result = flowDefinitionService.startProcessInstanceByKey("tools_stocktaking_bound", variables);
|
if (result != null) {
|
toolsStocktakingBound.setInventoryTime(new Date());
|
toolsStocktakingBound.setApprovalStatus(OutBillStatus.SUBMITTED.getValue());
|
//保存工单
|
toolsStocktakingBoundMapper.updateById(toolsStocktakingBound);
|
return result.isSuccess();
|
}
|
return true;
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
public void afterFlowHandle(FlowMyBusiness business) {
|
business.getTaskNameId();//接下来审批的节点
|
business.getValues();//前端传进来的参数
|
business.getActStatus();
|
}
|
|
@Override
|
public Object getBusinessDataById(String dataId) {
|
return this.getById(dataId);
|
}
|
|
@Override
|
public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) {
|
return null;
|
}
|
|
@Override
|
public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) {
|
Object object = values.get("NextAssignee");
|
return (List<String>) object;
|
}
|
}
|