优化成本计算逻辑进行中

This commit is contained in:
bgy
2024-09-14 18:35:25 +08:00
parent 734414f3ba
commit 1eb6e5915e
2 changed files with 57 additions and 24 deletions
@@ -110,15 +110,7 @@ public class StandardCostService {
//1.查询出所有满足物料编号的物料(BOM物料) //1.查询出所有满足物料编号的物料(BOM物料)
String sql = flowTaskInfoVO.getSqlString(); String sql = flowTaskInfoVO.getSqlString();
log.info("传递过来的SQL语句:" + sql); log.info("传递过来的SQL语句:" + sql);
//TODO 查询最顶部的BOM物料编号下所有的物料并进行层级排序
List<AppSceneCostMaterialBom> list = standardCostService.costMaterialBomService.queryAllBomInfoBytopMaterialCode(topMaterialCode);
log.info("Full EmptyTask list: {}", list);
//2.把查询的结果存放在临时表里(表命名规则:前缀_流程id_组件code)
for (int i = 0; list != null && i < list.size(); i++) {
AppSceneCostMaterialBom material = list.get(i);
AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(material.getMaterialCode()).parentMarterialNo(material.getParentMaterialCode()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).num(material.getNumber()).build();
standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue);
}
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -478,7 +470,7 @@ public class StandardCostService {
//获取最上层的物料号 //获取最上层的物料号
String topMaterialCode = flowTaskInfoVO.getTopMaterialCode(); String topMaterialCode = flowTaskInfoVO.getTopMaterialCode();
//获取任务类型 //获取任务类型
String taskType = parameters.getTaksType(); String taskType = parameters.getTaskType();
//获取任务代码 //获取任务代码
String taskCode = flowTaskInfoVO.getTaskCode(); String taskCode = flowTaskInfoVO.getTaskCode();
//获取流程id //获取流程id
@@ -1,19 +1,23 @@
package com.zzsmart.qomo.kn.cost.manage.service.impl; package com.zzsmart.qomo.kn.cost.manage.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsmart.qomo.dao.entity.FlowDefinition; import com.zzsmart.qomo.dao.entity.FlowInstance;
import com.zzsmart.qomo.dao.entity.FlowInstanceParameter;
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostPartMissingInfo; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostPartMissingInfo;
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardVersion; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardVersion;
import com.zzsmart.qomo.kn.cost.manage.enums.CostCountStatusEnum; import com.zzsmart.qomo.kn.cost.manage.enums.CostCountStatusEnum;
import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper; import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper;
import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostPartMissingInfoMapper; import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostPartMissingInfoMapper;
import com.zzsmart.qomo.kn.cost.manage.plugin.StandardCostService;
import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService; import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostStandardVersionService; import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostStandardVersionService;
import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO; import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO;
import com.zzsmart.qomo.service.IDataFlowDefinitionService;
import com.zzsmart.qomo.service.IDataFlowInstanceService; import com.zzsmart.qomo.service.IDataFlowInstanceService;
import com.zzsmart.qomo.service.IFlowInstanceParameterService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -34,7 +38,11 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
@Autowired @Autowired
private IDataFlowInstanceService flowInstanceService; private IDataFlowInstanceService flowInstanceService;
@Autowired @Autowired
private IFlowInstanceParameterService flowInstanceParameterService;
@Autowired
private AppSceneCostPartMissingInfoMapper costPartMissingInfoMapper; private AppSceneCostPartMissingInfoMapper costPartMissingInfoMapper;
@Autowired
StandardCostService standardCostService;
/** /**
* 查看关键缺失部件 * 查看关键缺失部件
@@ -77,7 +85,7 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
AppSceneCostCount appSceneCostCount = getById(id); AppSceneCostCount appSceneCostCount = getById(id);
if (appSceneCostCount != null) { if (appSceneCostCount != null) {
//执行标准成本计算 //执行标准成本计算
executeStandardCost(id, appSceneCostCount.getFlowDefinitionId()); executeStandardCost(id, appSceneCostCount.getFlowDefinitionId(), appSceneCostCount.getMaterialNo());
} }
} }
return null; return null;
@@ -89,9 +97,23 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
* @param id * @param id
* @param flowDefinitionId * @param flowDefinitionId
*/ */
private void executeStandardCost(Integer id, Integer flowDefinitionId) { private void executeStandardCost(Integer id, Integer flowDefinitionId, String meterialNo) {
//TODO 执行标准成本计算(参数传递) boolean isSuccess = false;
flowInstanceService.execute(flowDefinitionId, null, null); JSONObject parameter = new JSONObject();
parameter.put("materialNo", meterialNo);
String parameters = JSON.toJSONString(parameter);
//执行标准成本计算(参数传递)
FlowInstance flowInstance = ((IDataFlowInstanceService) flowInstanceService).execute(flowDefinitionId, (String) null, (String) null);
if (flowInstance != null) {
FlowInstanceParameter flowInstanceParameter = new FlowInstanceParameter();
flowInstanceParameter.setFlowInstanceId(flowInstance.getId());
flowInstanceParameter.setParameters(parameters);
boolean save = flowInstanceParameterService.save(flowInstanceParameter);
if (save) {
isSuccess = true;
}
}
// flowInstanceService.execute(flowDefinitionId, null, null);
} }
/** /**
@@ -108,15 +130,34 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
if (save) { if (save) {
AppSceneCostCount appSceneCostCount1 = AppSceneCostCount.builder().materialNo(appSceneCostCount.getMaterialNo()).drawingNo(appSceneCostCount.getDrawingNo()).stage(appSceneCostCount.getStage()).flowDefinitionId(appSceneCostCount.getFlowDefinitionId()).year(appSceneCostCount.getYear()).costVersion(costStandardVersion.getVersion()).status(CostCountStatusEnum.Executing.getValue()).createTime(new Date()).build(); AppSceneCostCount appSceneCostCount1 = AppSceneCostCount.builder().materialNo(appSceneCostCount.getMaterialNo()).drawingNo(appSceneCostCount.getDrawingNo()).stage(appSceneCostCount.getStage()).flowDefinitionId(appSceneCostCount.getFlowDefinitionId()).year(appSceneCostCount.getYear()).costVersion(costStandardVersion.getVersion()).status(CostCountStatusEnum.Executing.getValue()).createTime(new Date()).build();
boolean flag = save(appSceneCostCount1); boolean flag = save(appSceneCostCount1);
if (flag) { //方案一:模型组件运行
//发送更新成本计算状态的队列消息(队列名:updateCostCountStatus) // if (flag) {
// //发送更新成本计算状态的队列消息(队列名:updateCostCountStatus)
//
// //执行标准成本计算
// executeStandardCost(appSceneCostCount1.getId(), appSceneCostCount1.getFlowDefinitionId(), appSceneCostCount.getMaterialNo());
// //TODO 新增部件缺失信息记录
// AppSceneCostPartMissingInfo costPartMissingInfo = AppSceneCostPartMissingInfo.builder().costStandardId(appSceneCostCount1.getId().toString()).materialNumber(appSceneCostCount1.getMaterialNo()).versionNumber(appSceneCostCount1.getCostVersion()).missingInfo("电源线;绝缘层涂料").build();
// costPartMissingInfoMapper.insert(costPartMissingInfo);
// }
//执行标准成本计算 // 方案二:直接执行标准成本计算
executeStandardCost(appSceneCostCount1.getId(), appSceneCostCount1.getFlowDefinitionId()); countStandardCost(appSceneCostCount1);
//TODO 新增部件缺失信息记录
AppSceneCostPartMissingInfo costPartMissingInfo = AppSceneCostPartMissingInfo.builder().costStandardId(appSceneCostCount1.getId().toString()).materialNumber(appSceneCostCount1.getMaterialNo()).versionNumber(appSceneCostCount1.getCostVersion()).missingInfo("电源线;绝缘层涂料").build();
costPartMissingInfoMapper.insert(costPartMissingInfo);
}
} }
} }
/**
* 执行标准成本计算
*
* @param appSceneCostCount1
*/
private void countStandardCost(AppSceneCostCount appSceneCostCount1) {
//0.获取物料下所有的子物料
//1.物料成本计算
//2.人工成本计算
//3.制造计算(各种费用)
//4.标准成本本计算
}
} }