工艺模块,相关接口
This commit is contained in:
parent
44eadc098c
commit
085ee1403c
@ -24,8 +24,10 @@ import com.ruoyi.system.domain.BomDetails;
|
||||
import com.ruoyi.system.domain.MaterialProperties;
|
||||
import com.ruoyi.system.domain.bo.BomDetailsBo;
|
||||
import com.ruoyi.system.domain.vo.BomDetailsVo;
|
||||
import com.ruoyi.system.runner.JdUtil;
|
||||
import com.ruoyi.system.service.IBomDetailsService;
|
||||
import com.ruoyi.system.service.IMaterialPropertiesService;
|
||||
import com.ruoyi.system.service.IProcessRouteService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
@ -60,9 +62,13 @@ import static org.aspectj.bridge.MessageUtil.fail;
|
||||
public class BomDetailsController extends BaseController {
|
||||
|
||||
private final IBomDetailsService iBomDetailsService;
|
||||
|
||||
private final IMaterialPropertiesService iMaterialPropertiesService ;
|
||||
|
||||
private final IProcessRouteService iProcessRouteService;
|
||||
private static final Logger log = LoggerFactory.getLogger(BomDetailsController.class);
|
||||
|
||||
|
||||
/**
|
||||
* 查询bom明细列表
|
||||
*/
|
||||
@ -353,27 +359,29 @@ public class BomDetailsController extends BaseController {
|
||||
@Log(title = "非标金蝶物料清单更新")
|
||||
@SaCheckPermission("system:details:updateMaterial")
|
||||
@PostMapping("/updateFBMaterial")
|
||||
public List<BomDetails> updateFBMaterial(@RequestBody List<String> bomDetail) {
|
||||
public R updateFBMaterial(@RequestBody List<Map<String, String>> bomDetailParams) {
|
||||
List<BomDetails> bomDetailsList = new ArrayList<>();
|
||||
for (String fnumber : bomDetail) {
|
||||
List<BomDetails> bomDetails = iBomDetailsService.selectByFNumber(fnumber);
|
||||
System.out.println(fnumber);
|
||||
|
||||
// 遍历前端传来的数据
|
||||
for (Map<String, String> param : bomDetailParams) {
|
||||
String fnumber = param.get("fnumber"); // 物料编码
|
||||
String totalWeight = param.get("totalWeight"); // 生产令号
|
||||
|
||||
// 根据物料编码和生产令号查询
|
||||
List<BomDetails> bomDetails = iBomDetailsService.selectByFNumberAndTotalWeight(fnumber, totalWeight);
|
||||
|
||||
System.out.println("处理物料编码:" + fnumber + ", 生产令号:" + totalWeight);
|
||||
|
||||
if (bomDetails != null && !bomDetails.isEmpty()) {
|
||||
//物料清单保存方法
|
||||
FBloadBillOfMaterialsPreservation(bomDetails);
|
||||
// 物料清单保存方法
|
||||
FBloadBillOfMaterialsPreservation(bomDetails);
|
||||
bomDetailsList.addAll(bomDetails);
|
||||
}
|
||||
}
|
||||
return bomDetailsList;
|
||||
|
||||
return R.ok("成功",bomDetailsList);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
非标物料清单保存方法
|
||||
*/
|
||||
|
||||
|
||||
/*s
|
||||
物料清单保存方法
|
||||
*/
|
||||
@ -494,7 +502,7 @@ public class BomDetailsController extends BaseController {
|
||||
}
|
||||
|
||||
//FBOM物料清单保存
|
||||
public static void FBloadBillOfMaterialsPreservation(List<BomDetails> bomlist) {
|
||||
public void FBloadBillOfMaterialsPreservation(List<BomDetails> bomlist) {
|
||||
|
||||
BomDetails bomDetails1 = bomlist.get(0);
|
||||
int verification = isMaterialVerification(bomDetails1.getFNumber(), bomDetails1.getFName());
|
||||
@ -564,15 +572,18 @@ public class BomDetailsController extends BaseController {
|
||||
// 添加FTreeEntity字段
|
||||
fTreeEntityItem.addProperty("FReplaceGroup", 1);
|
||||
|
||||
// 检查备注是否为空
|
||||
if (details.getRemarks() != null) {
|
||||
// 添加供应类型
|
||||
if (details.getRemarks().equals("采购")) {
|
||||
if (details.getPartNumber() != null){
|
||||
if (iProcessRouteService.isAnTuDingGou(details.getPartNumber())) {
|
||||
fTreeEntityItem.addProperty("FSupplyType", "C");
|
||||
} else if (details.getRemarks().equals("伊特")) {
|
||||
|
||||
fTreeEntityItem.addProperty("FSupplyType", "C");
|
||||
|
||||
} else{
|
||||
fTreeEntityItem.addProperty("FSupplyType", " ");
|
||||
}
|
||||
}
|
||||
|
||||
fTreeEntityItem.addProperty("FMATERIALTYPE", "1");
|
||||
// 创建FMATERIALIDCHILD对象,并加入FTreeEntity
|
||||
JsonObject fMaterialIdChild = new JsonObject();
|
||||
|
||||
@ -78,30 +78,15 @@ public class MaterialBomController extends BaseController {
|
||||
List<MaterialBomVo> list =iMaterialBomService.getMaterialInfo(bo.getRouteDescription(),bo.getMaterialCode());
|
||||
return R.ok(list);
|
||||
}
|
||||
/* *//**
|
||||
* 新增bomaterial
|
||||
*//*
|
||||
|
||||
@SaCheckPermission("system:bom:add")
|
||||
@Log(title = "bomaterial", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody MaterialBomBo bo) {
|
||||
return toAjax(iMaterialBomService.insertByBo(bo));
|
||||
}*/
|
||||
/**
|
||||
* 新增bomaterial
|
||||
*/
|
||||
@SaCheckPermission("system:bom:add")
|
||||
@Log(title = "bomaterial", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> addMaterialBom(@Validated(AddGroup.class) @RequestBody ProcessRoute bo) {
|
||||
if (bo.getMaterialCode().equals("")|| bo.getMaterialName().equals("")){
|
||||
return R.fail("物料名称和物料代码不能为空");
|
||||
}
|
||||
return toAjax( iMaterialBomService.addMaterialBom(bo));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改bomaterial
|
||||
*/
|
||||
|
||||
@ -117,17 +117,7 @@ public class ProcessRouteController extends BaseController {
|
||||
ProcessRouteVo child = new ProcessRouteVo();
|
||||
child.setId(processRouteVo.getId());
|
||||
child.setParentId(parentId);
|
||||
/* child.setMaterialCode(materialCode);
|
||||
child.setMaterialName(materialName);*/
|
||||
/* child.setMaterialCode(processRouteVo.getMaterialCode());
|
||||
child.setMaterialName(processRouteVo.getMaterialName());
|
||||
child.setMaterial(processRouteVo.getMaterial());
|
||||
child.setDiscWeight(processRouteVo.getDiscWeight());
|
||||
child.setRawMaterialCode(processRouteVo.getRawMaterialCode());
|
||||
child.setRawMaterialName(processRouteVo.getRawMaterialName());
|
||||
child.setDiscUsage(processRouteVo.getDiscUsage());
|
||||
child.setBomUnit(processRouteVo.getBomUnit());
|
||||
child.setBomMaterial(processRouteVo.getBomMaterial());*/
|
||||
|
||||
child.setProcessNo(processRouteVo.getProcessNo());
|
||||
child.setWorkCenter(processRouteVo.getWorkCenter());
|
||||
child.setProcessName(processRouteVo.getProcessName());
|
||||
@ -331,18 +321,16 @@ public class ProcessRouteController extends BaseController {
|
||||
|
||||
return ResponseEntity.ok(iProcessRouteService.getProcessMaterialList(materialCode,materialName,productionOrderNo));
|
||||
}
|
||||
@Log(title = "明细导入", businessType = BusinessType.IMPORT)
|
||||
@Log(title = "导入时间", businessType = BusinessType.IMPORT)
|
||||
@SaCheckPermission("system:route:importDataTime")
|
||||
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@PostMapping(value = "/importDataTime", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importDataTime(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
log.info("读取文件名: " + originalFilename);
|
||||
ExcelResult<ProcessRouteVo> result = ExcelUtil.importExcelSheet6(file.getInputStream(), ProcessRouteVo.class, true);
|
||||
List<ProcessRouteVo> list = result.getList();
|
||||
for (ProcessRouteVo processRouteVo : list) {
|
||||
String materialCode = processRouteVo.getMaterialCode();
|
||||
}
|
||||
return null;
|
||||
List<ProcessRoute> list1 = iProcessRouteService.importDataTime(list);
|
||||
return R.ok("更新成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ public class MaterialBom extends BaseEntity {
|
||||
/**
|
||||
* 用量
|
||||
*/
|
||||
private BigDecimal quantity;
|
||||
private Double quantity;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
@ -57,4 +57,8 @@ public class MaterialBom extends BaseEntity {
|
||||
* 父级物料名称
|
||||
*/
|
||||
private String parentMaterialName;
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
private Double stock;
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public class MaterialBomBo extends BaseEntity {
|
||||
* 用量
|
||||
*/
|
||||
@NotNull(message = "用量不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private BigDecimal quantity;
|
||||
private Double quantity;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
@ -59,7 +59,6 @@ public class MaterialBomBo extends BaseEntity {
|
||||
/**
|
||||
* 材质
|
||||
*/
|
||||
@NotBlank(message = "材质不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String materialType;
|
||||
|
||||
/**
|
||||
@ -73,5 +72,9 @@ public class MaterialBomBo extends BaseEntity {
|
||||
*/
|
||||
@NotBlank(message = "父级物料名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String parentMaterialName;
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
private Double stock;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
package com.ruoyi.system.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BomUpdateRequest {
|
||||
private String fnumber;
|
||||
private String totalWeight;
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
package com.ruoyi.system.domain.dto;
|
||||
|
||||
public class MaterialUpdateDTO {
|
||||
}
|
||||
@ -48,7 +48,7 @@ public class MaterialBomVo {
|
||||
* 用量
|
||||
*/
|
||||
@ExcelProperty(value = "用量")
|
||||
private BigDecimal quantity;
|
||||
private Double quantity;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
@ -74,4 +74,11 @@ public class MaterialBomVo {
|
||||
*/
|
||||
@ExcelProperty(value = "父级物料名称")
|
||||
private String parentMaterialName;
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
@ExcelProperty(value = "库存")
|
||||
private Double stock;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -20,14 +20,40 @@ public interface ProcessRouteMapper extends BaseMapperPlus<ProcessRouteMapper, P
|
||||
@Update("UPDATE process_route SET process_no = process_no + 10 WHERE process_no >= #{processNo} AND material_code = #{materialCode} AND AND route_description = #{routeDescription} ")
|
||||
void updateProcessNoAfterInsert(@Param("processNo") Long processNo, @Param("materialCode") String materialCode,@Param("route_description") String routeDescription);
|
||||
|
||||
// 更新所有比删除序号大的工艺路线
|
||||
@Update("UPDATE process_route SET process_no = process_no - 10 WHERE process_no > #{processNo} AND material_code = #{materialCode} AND route_description = #{routeDescription}")
|
||||
void updateProcessNoAfterDelete(@Param("processNo") Long processNo, @Param("materialCode") String materialCode,@Param("route_description") String routeDescription);
|
||||
|
||||
|
||||
// 查询工艺序号是否已经存在,根据 materialCode
|
||||
@Select("SELECT COUNT(1) FROM process_route WHERE process_no = #{processNo} AND material_code = #{materialCode} AND route_description = #{routeDescription}")
|
||||
boolean existsByProcessNoAndMaterialCode(@Param("processNo") Long processNo, @Param("materialCode") String materialCode,@Param("route_description") String routeDescription);
|
||||
@Select("SELECT * FROM process_route WHERE route_description = #{routeDescription} AND material_code = #{materialCode} AND material_name = #{materialName}")
|
||||
List<ProcessRoute> selectRouteByLinAndMaterialCode(String routeDescription, String materialCode, String materialName);
|
||||
|
||||
// 检查工序号是否存在(排除自身)
|
||||
@Select("SELECT COUNT(1) FROM process_route WHERE process_no = #{processNo} " +
|
||||
"AND material_code = #{materialCode} " +
|
||||
"AND route_description = #{routeDescription} " +
|
||||
"AND id != #{id}")
|
||||
boolean existsByProcessNoAndMaterialCodeExcludeSelf(
|
||||
@Param("processNo") Long processNo,
|
||||
@Param("materialCode") String materialCode,
|
||||
@Param("routeDescription") String routeDescription,
|
||||
@Param("id") Long id);
|
||||
|
||||
// 更新序号范围(向下调整)
|
||||
@Update("UPDATE process_route SET process_no = process_no - 10 " +
|
||||
"WHERE process_no > #{startNo} AND process_no <= #{endNo} " +
|
||||
"AND material_code = #{materialCode} " +
|
||||
"AND route_description = #{routeDescription}")
|
||||
void updateProcessNoForRangeDown(
|
||||
@Param("startNo") Long startNo,
|
||||
@Param("endNo") Long endNo,
|
||||
@Param("materialCode") String materialCode,
|
||||
@Param("routeDescription") String routeDescription);
|
||||
|
||||
// 更新序号范围(向上调整)
|
||||
@Update("UPDATE process_route SET process_no = process_no + 10 " +
|
||||
"WHERE process_no >= #{startNo} AND process_no < #{endNo} " +
|
||||
"AND material_code = #{materialCode} " +
|
||||
"AND route_description = #{routeDescription}")
|
||||
void updateProcessNoForRangeUp(
|
||||
@Param("startNo") Long startNo,
|
||||
@Param("endNo") Long endNo,
|
||||
@Param("materialCode") String materialCode,
|
||||
@Param("routeDescription") String routeDescription);
|
||||
}
|
||||
|
||||
@ -14,6 +14,8 @@ import com.ruoyi.system.domain.vo.ProductionRouteTwoVo;
|
||||
import com.ruoyi.system.jdmain.rouplan.Model;
|
||||
import com.ruoyi.system.mapper.ImProductionPlanProMapper;
|
||||
import com.ruoyi.system.service.IImProductionPlanProService;
|
||||
import com.ruoyi.system.service.IProcessRouteService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
@ -28,6 +30,7 @@ public class JdUtil {
|
||||
private ImProductionPlanProMapper imProductionPlanProMapper;
|
||||
@Resource
|
||||
private IImProductionPlanProService imProductionPlanProService;
|
||||
|
||||
//入库状态
|
||||
public static JsonArray storageProduce(String number, String FMaterialIdCode) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
@ -432,5 +435,6 @@ public class JdUtil {
|
||||
// 转换为 List<Model> 格式
|
||||
return null;
|
||||
}
|
||||
//查询物料是否为按图订制
|
||||
|
||||
}
|
||||
|
||||
@ -54,4 +54,6 @@ public interface IBomDetailsService {
|
||||
List<BomDetails> selectByFNumber1(String fNumber,String partNumber,String partName);
|
||||
|
||||
BomDetails selectBOMFNumber(String fnumbers);
|
||||
|
||||
List<BomDetails> selectByFNumberAndTotalWeight(String fnumber, String totalWeight);
|
||||
}
|
||||
|
||||
@ -88,4 +88,8 @@ public interface IProcessRouteService {
|
||||
List<MaterialBom> getProcessMaterialList(String materialCode,String materialName, String productionOrderNo);
|
||||
|
||||
List<ProcessRoute> deleteRoute(ProcessRoute processRoute);
|
||||
|
||||
List<ProcessRoute> importDataTime(List<ProcessRouteVo> list);
|
||||
|
||||
boolean isAnTuDingGou(String materialCode);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class BomDetailsServiceImpl implements IBomDetailsService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFNumber()), BomDetails::getFNumber, bo.getFNumber());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterial()), BomDetails::getMaterial, bo.getMaterial());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUnitWeight()), BomDetails::getUnitWeight, bo.getUnitWeight());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getTotalWeight()), BomDetails::getTotalWeight, bo.getTotalWeight());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getTotalWeight()), BomDetails::getTotalWeight, bo.getTotalWeight());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRemarks()), BomDetails::getRemarks, bo.getRemarks());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getFName()), BomDetails::getFName, bo.getFName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStats()), BomDetails::getStats, bo.getStats());
|
||||
@ -181,6 +181,19 @@ public class BomDetailsServiceImpl implements IBomDetailsService {
|
||||
return baseMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fnumber
|
||||
* @param totalWeight
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<BomDetails> selectByFNumberAndTotalWeight(String fnumber, String totalWeight) {
|
||||
LambdaQueryWrapper<BomDetails> bomDetailsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
bomDetailsLambdaQueryWrapper.eq(BomDetails::getTotalWeight,totalWeight)
|
||||
.eq(BomDetails::getFNumber,fnumber);
|
||||
return baseMapper.selectList(bomDetailsLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
public int loadMaterialPreservation(BomDetails bomDetails1) {
|
||||
K3CloudApi client = new K3CloudApi();
|
||||
// 创建一个空的JsonObject
|
||||
|
||||
@ -6,9 +6,16 @@ import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.system.domain.BomDetails;
|
||||
import com.ruoyi.system.domain.ProcessRoute;
|
||||
import com.ruoyi.system.mapper.BomDetailsMapper;
|
||||
import com.ruoyi.system.mapper.ProcessRouteMapper;
|
||||
import com.ruoyi.system.service.IProcessRouteService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.domain.bo.MaterialBomBo;
|
||||
import com.ruoyi.system.domain.vo.MaterialBomVo;
|
||||
@ -32,7 +39,10 @@ import java.util.Collection;
|
||||
public class MaterialBomServiceImpl implements IMaterialBomService {
|
||||
|
||||
private final MaterialBomMapper baseMapper;
|
||||
private final BomDetailsMapper bomDetailsMapper;
|
||||
|
||||
private final ProcessRouteMapper processRouteMapper;
|
||||
private static final Logger logger = LoggerFactory.getLogger(IMaterialBomService.class);
|
||||
/**
|
||||
* 查询bomaterial
|
||||
*/
|
||||
@ -71,6 +81,7 @@ public class MaterialBomServiceImpl implements IMaterialBomService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialType()), MaterialBom::getMaterialType, bo.getMaterialType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getParentMaterialCode()), MaterialBom::getParentMaterialCode, bo.getParentMaterialCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getParentMaterialName()), MaterialBom::getParentMaterialName, bo.getParentMaterialName());
|
||||
lqw.eq(bo.getStock() != null, MaterialBom::getStock, bo.getStock());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@ -79,15 +90,70 @@ public class MaterialBomServiceImpl implements IMaterialBomService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(MaterialBomBo bo) {
|
||||
MaterialBom add = BeanUtil.toBean(bo, MaterialBom.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
try {
|
||||
// 1. 转换 BO 到实体类
|
||||
MaterialBom add = BeanUtil.toBean(bo, MaterialBom.class);
|
||||
|
||||
// 2. 查找对应的工艺路线
|
||||
LambdaQueryWrapper<ProcessRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessRoute::getRouteDescription, bo.getProjectNumber())
|
||||
.eq(ProcessRoute::getProcessNo, "10") // 使用父级物料编码
|
||||
.eq(ProcessRoute::getMaterialCode, bo.getParentMaterialCode()) // 使用父级物料编码
|
||||
.eq(ProcessRoute::getMaterialName, bo.getParentMaterialName()); // 使用父级物料名称
|
||||
|
||||
ProcessRoute processRoute = processRouteMapper.selectOne(wrapper);
|
||||
|
||||
// 3. 如果找到对应的工艺路线,更新相关字段
|
||||
if (processRoute != null) {
|
||||
processRoute.setId(processRoute.getId());
|
||||
// 更新原材料相关信息
|
||||
processRoute.setRawMaterialCode(bo.getMaterialCode()); // BOM物料编码
|
||||
processRoute.setRawMaterialName(bo.getMaterialName()); // BOM物料名称
|
||||
processRoute.setDiscUsage(bo.getQuantity()); // 用量
|
||||
processRoute.setBomUnit(bo.getUnit()); // 单位
|
||||
processRoute.setBomMaterial(bo.getMaterialType());
|
||||
// 更新工艺路线
|
||||
int updateResult = processRouteMapper.updateById(processRoute);
|
||||
if (updateResult <= 0) {
|
||||
throw new ServiceException("更新工艺路线失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 验证并保存 BOM 材料
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
|
||||
// 5. 如果保存成功,设置返回的 ID
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
Boolean b = insertByBoToBom(bo);
|
||||
return flag;
|
||||
} catch (Exception e) {
|
||||
logger.error("新增BOM材料失败", e);
|
||||
throw new ServiceException("新增BOM材料失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
public Boolean insertByBoToBom(MaterialBomBo bo){
|
||||
//在BOM详情中添加原材料BOM
|
||||
BomDetails bomDetails = new BomDetails();
|
||||
bomDetails.setTotalWeight(bo.getProjectNumber());
|
||||
bomDetails.setFNumber(bo.getParentMaterialCode());
|
||||
bomDetails.setFName(bo.getParentMaterialName());
|
||||
bomDetails.setPartNumber(bo.getMaterialCode());
|
||||
bomDetails.setName(bo.getMaterialName());
|
||||
bomDetails.setName(bo.getMaterialName());
|
||||
bomDetails.setDenominator(1.0);
|
||||
bomDetails.setQuantity(bo.getQuantity());
|
||||
bomDetails.setStats("外购");
|
||||
bomDetails.setMaterial(bo.getMaterialType());
|
||||
int flag = bomDetailsMapper.insert(bomDetails);
|
||||
if (flag>0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 修改bomaterial
|
||||
*/
|
||||
@ -103,6 +169,19 @@ public class MaterialBomServiceImpl implements IMaterialBomService {
|
||||
*/
|
||||
private void validEntityBeforeSave(MaterialBom entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
// 添加必要的数据验证逻辑
|
||||
if (StringUtils.isEmpty(entity.getMaterialCode())) {
|
||||
throw new ServiceException("物料编码不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getMaterialName())) {
|
||||
throw new ServiceException("物料名称不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getProjectNumber())) {
|
||||
throw new ServiceException("项目令号不能为空");
|
||||
}
|
||||
if (entity.getQuantity() == null ) {
|
||||
throw new ServiceException("用量必须大于0");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +201,7 @@ public class MaterialBomServiceImpl implements IMaterialBomService {
|
||||
materialBomBo.setProjectNumber(bo.getProcessDescription());
|
||||
materialBomBo.setParentMaterialCode(bo.getMaterialCode());
|
||||
materialBomBo.setParentMaterialName(bo.getMaterialName());
|
||||
materialBomBo.setQuantity(BigDecimal.valueOf(bo.getDiscUsage()));
|
||||
materialBomBo.setQuantity(bo.getDiscUsage());
|
||||
materialBomBo.setUnit(bo.getBomUnit());
|
||||
materialBomBo.setMaterialType(bo.getBomMaterial());
|
||||
materialBomBo.setMaterialCode(bo.getRawMaterialCode());
|
||||
|
||||
@ -66,10 +66,11 @@ public class ProcessOrderProServiceImpl implements IProcessOrderProService {
|
||||
private LambdaQueryWrapper<ProcessOrderPro> buildQueryWrapper(ProcessOrderProBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ProcessOrderPro> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getProductionOrderNo()), ProcessOrderPro::getProductionOrderNo, bo.getProductionOrderNo());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProductionOrderNo()), ProcessOrderPro::getProductionOrderNo, bo.getProductionOrderNo());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProductionName()), ProcessOrderPro::getProductionName, bo.getProductionName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDrawingNo()), ProcessOrderPro::getDrawingNo, bo.getDrawingNo());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDrawingName()), ProcessOrderPro::getDrawingName, bo.getDrawingName());
|
||||
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.poi.excel.cell.CellSetter;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -22,6 +23,7 @@ import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.controller.ProcessRouteController;
|
||||
import com.ruoyi.system.domain.*;
|
||||
import com.ruoyi.system.domain.bo.BomDetailsBo;
|
||||
import com.ruoyi.system.domain.bo.MaterialBomBo;
|
||||
import com.ruoyi.system.domain.bo.ProcessRouteBo;
|
||||
import com.ruoyi.system.domain.dto.*;
|
||||
import com.ruoyi.system.domain.vo.*;
|
||||
@ -36,11 +38,13 @@ import com.ruoyi.system.service.IBomDetailsService;
|
||||
import com.ruoyi.system.service.IMaterialPropertiesService;
|
||||
import com.ruoyi.system.service.IProcessRouteService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.aspectj.bridge.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@ -110,7 +114,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
private LambdaQueryWrapper<ProcessRoute> buildQueryWrapper(ProcessRouteBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ProcessRoute> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRouteDescription()), ProcessRoute::getRouteDescription, bo.getRouteDescription());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getRouteDescription()), ProcessRoute::getRouteDescription, bo.getRouteDescription());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterialCode()), ProcessRoute::getMaterialCode, bo.getMaterialCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getMaterialName()), ProcessRoute::getMaterialName, bo.getMaterialName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getBomUnit()), ProcessRoute::getBomUnit, bo.getBomUnit());
|
||||
@ -164,18 +168,37 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ProcessRouteBo bo) {
|
||||
// 直接更新整条记录
|
||||
ProcessRoute update = BeanUtil.toBean(bo, ProcessRoute.class);
|
||||
// 1. 检查指定 materialCode 下的 processNo 是否已存在
|
||||
if (baseMapper.existsByProcessNoAndMaterialCode(update.getProcessNo(), update.getMaterialCode(), update.getProcessDescription())) {
|
||||
throw new ServiceException("该物料编码的工艺序号已存在,请选择其他序号");
|
||||
|
||||
// 1. 检查记录是否存在
|
||||
ProcessRoute oldRoute = baseMapper.selectById(update.getId());
|
||||
if (oldRoute == null) {
|
||||
throw new ServiceException("要修改的工艺路线不存在");
|
||||
}
|
||||
// 2. 更新所有比新序号大的工艺路线,将它们的 processNo 增加步长(10)
|
||||
baseMapper.updateProcessNoAfterInsert(update.getProcessNo(), update.getMaterialCode(), update.getProcessDescription());
|
||||
update.setRouteDescription(oldRoute.getRouteDescription());
|
||||
update.setMaterialCode(oldRoute.getMaterialCode());
|
||||
update.setMaterialName(oldRoute.getMaterialName());
|
||||
update.setMaterial(oldRoute.getMaterial());
|
||||
update.setDiscWeight(oldRoute.getDiscWeight());
|
||||
|
||||
// 3. 插入新的工艺路线
|
||||
return baseMapper.insert(update) > 0;
|
||||
// 2. 如果工序号变化了,才需要检查工序号
|
||||
if (!oldRoute.getProcessNo().equals(update.getProcessNo())) {
|
||||
// 检查新工序号是否已存在(排除当前记录)
|
||||
LambdaQueryWrapper<ProcessRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessRoute::getProcessNo, update.getProcessNo())
|
||||
.eq(ProcessRoute::getMaterialCode, update.getMaterialCode())
|
||||
.eq(ProcessRoute::getRouteDescription, update.getRouteDescription())
|
||||
.ne(ProcessRoute::getId, update.getId());
|
||||
|
||||
if (baseMapper.selectCount(wrapper) > 0) {
|
||||
throw new ServiceException("该物料编码的工艺序号已存在,请选择其他序号");
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 直接更新全部字段
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
@ -233,164 +256,11 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public boolean saveData(List<ProcessRouteVo> routeVoList, List<ProductionOrderVo> productionOrderVos) {
|
||||
List<ProcessRoute> processRoutes = BeanUtil.copyToList(routeVoList, ProcessRoute.class);
|
||||
List<ProductionOrder> productionOrder = BeanUtil.copyToList(productionOrderVos, ProductionOrder.class);
|
||||
if (processRoutes != null){
|
||||
log.info("保存到总装BOM:{}", processRoutes);
|
||||
boolean b = productionOrderMapper.insertBatch(productionOrder);
|
||||
}
|
||||
//將材料bom 對應到processRoute 更新到材料BOM表中
|
||||
//装配bom父级
|
||||
String zFnumber = null;
|
||||
String zFname = null;
|
||||
String zFlinghao = null;
|
||||
String proMaterials = null;
|
||||
for (ProcessRoute processRoute : processRoutes) {
|
||||
if (processRoute.getRawMaterialCode()!=null && processRoute.getRawMaterialName()!=null){
|
||||
MaterialBom materialBom = new MaterialBom();
|
||||
materialBom.setProjectNumber(processRoute.getProcessDescription());
|
||||
materialBom.setParentMaterialCode(processRoute.getMaterialCode());
|
||||
materialBom.setParentMaterialName(processRoute.getMaterialName());
|
||||
materialBom.setMaterialCode(processRoute.getRawMaterialCode());
|
||||
materialBom.setMaterialName(processRoute.getRawMaterialName());
|
||||
materialBom.setUnit(processRoute.getBomUnit());
|
||||
materialBom.setMaterialType(processRoute.getBomMaterial());
|
||||
materialBom.setQuantity(BigDecimal.valueOf(processRoute.getDiscUsage()));
|
||||
|
||||
}
|
||||
//同步到材料bom表
|
||||
baseMapper.insert(processRoute);
|
||||
}
|
||||
|
||||
List<BomDetails> materialsToAdd = new ArrayList<>();
|
||||
List<BomDetailsVo> bomDetailsVos = new ArrayList<>();
|
||||
|
||||
for (ProcessRoute processRoute : processRoutes) {
|
||||
if (processRoute.getRawMaterialCode()!= null){
|
||||
//封装bomdetils 的对象.
|
||||
zFlinghao = processRoute.getProcessDescription();
|
||||
BomDetailsVo bomDetails = new BomDetailsVo();
|
||||
bomDetails.setTotalWeight(processRoute.getRouteDescription());//生产令号
|
||||
bomDetails.setFNumber(processRoute.getMaterialCode());
|
||||
bomDetails.setFName(processRoute.getMaterialName());
|
||||
bomDetails.setPartNumber(processRoute.getRawMaterialCode());
|
||||
bomDetails.setName(processRoute.getRawMaterialName());
|
||||
if (processRoute.getMaterial().equals("总装部件")){
|
||||
proMaterials = processRoute.getMaterial();
|
||||
zFnumber = processRoute.getMaterialCode();
|
||||
zFname = processRoute.getMaterialName();
|
||||
}
|
||||
if (proMaterials != null && proMaterials.equals("总装部件")) {
|
||||
log.info("开始新增装配bom");
|
||||
BomDetailsVo bomDetails1 = null;
|
||||
for (ProductionOrderVo productionOrderVo : productionOrderVos) {
|
||||
bomDetails1 = new BomDetailsVo();
|
||||
bomDetails1.setTotalWeight(zFlinghao);
|
||||
bomDetails1.setFNumber(zFnumber);
|
||||
bomDetails1.setFName(zFname);
|
||||
bomDetails1.setPartdiagramCode(productionOrderVo.getProductionOrderNo());
|
||||
bomDetails1.setPartdiagramName(productionOrderVo.getParentPart());
|
||||
bomDetails1.setPartNumber(productionOrderVo.getDrawingNo());
|
||||
bomDetails1.setName(productionOrderVo.getDrawingName());
|
||||
bomDetails1.setQuantity(Double.valueOf(productionOrderVo.getQuantity()));
|
||||
bomDetails1.setMaterial(productionOrderVo.getMaterial());
|
||||
if (productionOrderVo.getDrawingNo().startsWith("009") || productionOrderVo.getDrawingNo().startsWith("AA") || productionOrderVo.getDrawingNo().startsWith("AB") || productionOrderVo.getDrawingNo().startsWith("AC") ||
|
||||
productionOrderVo.getDrawingNo().contains("(M)") || productionOrderVo.getDrawingName().equals("按图定制") || productionOrderVo.getDrawingName().startsWith(" ") || productionOrderVo.getRemark().contains("外购件")) {
|
||||
bomDetails1.setStats("外购");
|
||||
} else {
|
||||
bomDetails1.setStats("自制");
|
||||
}
|
||||
}
|
||||
bomDetailsVos.add(bomDetails1);
|
||||
}
|
||||
|
||||
if (processRoute.getBomUnit()!= null){
|
||||
if (processRoute.getBomUnit().equals("mm")){
|
||||
bomDetails.setQuantity(processRoute.getDiscUsage()/1000);//转换成m
|
||||
}else{
|
||||
bomDetails.setQuantity(processRoute.getDiscUsage());
|
||||
}
|
||||
}
|
||||
|
||||
if (processRoute.getRawMaterialCode().startsWith("009")||processRoute.getRawMaterialCode().startsWith("AA")||processRoute.getRawMaterialCode().startsWith("AB")||
|
||||
processRoute.getRawMaterialCode().startsWith("AC")||processRoute.getRawMaterialCode().startsWith("015")||processRoute.getRawMaterialCode().contains("(M)")||processRoute.getProcessName().equals("按图定制")
|
||||
){
|
||||
bomDetails.setStats("外购");
|
||||
}else{
|
||||
bomDetails.setStats("自制");
|
||||
}
|
||||
bomDetails.setMaterial(processRoute.getBomMaterial());
|
||||
bomDetails.setDenominator(1.0);//分母
|
||||
Date xuEndTime = processRoute.getXuEndTime();
|
||||
Date xuStartTime = processRoute.getXuStartTime();
|
||||
bomDetailsVos.add(bomDetails);
|
||||
|
||||
}else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (BomDetailsVo bomDetailsvo : bomDetailsVos) {
|
||||
BomDetails bomDetails = BeanUtil.toBean(bomDetailsvo, BomDetails.class);
|
||||
// 验证物料是否存在
|
||||
if (bomDetails.getFNumber() != null && bomDetails.getFName() != null && bomDetails.getPartNumber() != null && bomDetails.getName() != null) {
|
||||
int verification = isMaterialVerification(bomDetails.getPartNumber(), bomDetails.getName());
|
||||
if (verification == 1) {
|
||||
bomDetails.setUnitWeight("是");
|
||||
} else {
|
||||
if (bomDetails.getStats() == null || bomDetails.getStats().equals("外购") || bomDetails.getFName().startsWith("009") || bomDetails.getFName().startsWith("AA")
|
||||
|| bomDetails.getFName().startsWith("AB") || bomDetails.getFName().startsWith("AC")|| bomDetails.getFName().startsWith("015")) {
|
||||
materialsToAdd.add(bomDetails);
|
||||
} else if (bomDetails.getStats().equals("自制")) {
|
||||
materialsToAdd.add(bomDetails);
|
||||
} else if (bomDetails.getStats().equals("委外")) {
|
||||
materialsToAdd.add(bomDetails);
|
||||
}
|
||||
bomDetails.setUnitWeight("否");
|
||||
}
|
||||
}
|
||||
|
||||
// 保存当前记录
|
||||
BomDetailsVo bean = BeanUtil.toBean(bomDetails, BomDetailsVo.class);
|
||||
|
||||
iBomDetailsService.insertByVo(bean);
|
||||
}
|
||||
|
||||
ArrayList<BomDetails> bomDetails = new ArrayList<>();
|
||||
// 统一新增不存在的物料
|
||||
for (BomDetails material : materialsToAdd) {
|
||||
//替换属性编码(金蝶)
|
||||
if (material == null) {
|
||||
continue; // 如果 material 为空,则跳过当前循环
|
||||
}
|
||||
|
||||
String state = determineState(material);
|
||||
log.info("开始新增不存在的物料==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
int result = loadMaterialPreservation(material, state);
|
||||
if (result == 1) {
|
||||
log.info("新增物料成功==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
material.setUnitWeight("新增成功");
|
||||
bomDetails.add(material);
|
||||
} else {
|
||||
log.error("新增物料失败==> 物料图号: " + material.getPartNumber() + " 物料名称: " + material.getName());
|
||||
material.setUnitWeight("新增成功");
|
||||
bomDetails.add(material);
|
||||
}
|
||||
BomDetailsBo bean = BeanUtil.toBean(bomDetails, BomDetailsBo.class);
|
||||
iBomDetailsService.updateByBo(bean);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return baseMapper.insertBatch(processRoutes);
|
||||
|
||||
}*/
|
||||
|
||||
public boolean saveData(List<ProcessRouteVo> routeVoList, List<ProductionOrderVo> productionOrderVos) {
|
||||
// 将 ProcessRouteVo 转换为 ProcessRoute
|
||||
List<ProcessRoute> processRoutes = BeanUtil.copyToList(routeVoList, ProcessRoute.class);
|
||||
//firstBatchQuantity
|
||||
|
||||
// 1. 处理材料 BOM
|
||||
processMaterialBom(processRoutes);
|
||||
@ -401,10 +271,72 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
// 3. 保存 BOM 详情
|
||||
saveBomDetails(bomDetailsVos);
|
||||
List<ProcessRoute> routeArrayList = new ArrayList<>();
|
||||
// 4. 批量插入 ProcessRoute 数据
|
||||
for (ProcessRoute processRoute : processRoutes) {
|
||||
if (processRoute.getProcessNo() != null || processRoute.getProcessName() != null) {
|
||||
routeArrayList.add(processRoute);
|
||||
boolean allEmpty = processRoutes.stream()
|
||||
.allMatch(route -> route.getProcessNo() == null && route.getProcessName() == null);
|
||||
|
||||
if (allEmpty && !processRoutes.isEmpty()) {
|
||||
// 1. 找出Excel中重复出现的组焊件物料编码
|
||||
List<String> duplicateWeldingMaterials = processRoutes.stream()
|
||||
.filter(route -> "组焊件".equals(route.getMaterial()))
|
||||
.map(ProcessRoute::getMaterialCode)
|
||||
.collect(Collectors.groupingBy(code -> code, Collectors.counting()))
|
||||
.entrySet().stream()
|
||||
.filter(entry -> entry.getValue() > 1)
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 用于记录已处理的重复组焊件
|
||||
Set<String> processedWeldingMaterials = new HashSet<>();
|
||||
|
||||
for (ProcessRoute processRoute : processRoutes) {
|
||||
// 判断是否是重复的组焊件
|
||||
boolean isDuplicateWelding = "组焊件".equals(processRoute.getMaterial())
|
||||
&& duplicateWeldingMaterials.contains(processRoute.getMaterialCode());
|
||||
|
||||
// 如果是重复的组焊件且已处理过,则跳过
|
||||
if (isDuplicateWelding && processedWeldingMaterials.contains(processRoute.getMaterialCode())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 生成4个默认工序
|
||||
for (int i = 0; i <2; i++) {
|
||||
ProcessRoute defaultRoute = new ProcessRoute();
|
||||
BeanUtil.copyProperties(processRoute, defaultRoute);
|
||||
|
||||
// 设置工序号 (10, 20, 30, 40)
|
||||
defaultRoute.setProcessNo((long) ((i + 1) * 10));
|
||||
|
||||
// 清空工序相关信息
|
||||
defaultRoute.setWorkCenter(null);
|
||||
defaultRoute.setProcessName(null);
|
||||
defaultRoute.setProcessDescription(null);
|
||||
defaultRoute.setProcessControl(null);
|
||||
defaultRoute.setActivityDuration(null);
|
||||
defaultRoute.setActivityUnit(null);
|
||||
|
||||
// 设置创建时间和更新时间
|
||||
defaultRoute.setCreateTime(new Date());
|
||||
defaultRoute.setUpdateTime(new Date());
|
||||
|
||||
routeArrayList.add(defaultRoute);
|
||||
}
|
||||
|
||||
// 如果是重复的组焊件,标记为已处理
|
||||
if (isDuplicateWelding) {
|
||||
processedWeldingMaterials.add(processRoute.getMaterialCode());
|
||||
log.info("为重复出现的组焊件物料 {} 生成了默认工序", processRoute.getMaterialCode());
|
||||
} else {
|
||||
log.info("为物料 {} 生成了默认工序", processRoute.getMaterialCode());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 处理非空工序的情况
|
||||
for (ProcessRoute processRoute : processRoutes) {
|
||||
if (processRoute.getProcessNo() != null || processRoute.getProcessName() != null) {
|
||||
processRoute.setCreateTime(new Date());
|
||||
processRoute.setUpdateTime(new Date());
|
||||
routeArrayList.add(processRoute);
|
||||
}
|
||||
}
|
||||
}
|
||||
return baseMapper.insertBatch(routeArrayList);
|
||||
@ -418,7 +350,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
String parentMaterialName = processRoute.getMaterialName();
|
||||
String unit = processRoute.getBomUnit();
|
||||
String materialType = processRoute.getBomMaterial();
|
||||
BigDecimal quantity = processRoute.getDiscUsage() != null ? BigDecimal.valueOf(processRoute.getDiscUsage()) : BigDecimal.ZERO;
|
||||
Double quantity = processRoute.getDiscUsage() != null ? processRoute.getDiscUsage() : 0;
|
||||
if (projectNumber == null || parentMaterialCode == null || parentMaterialName == null || unit == null || materialType == null) {
|
||||
// 处理空值情况,例如记录日志或抛出异常
|
||||
log.error("必填字段为空: {}", processRoute);
|
||||
@ -448,7 +380,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
for (ProcessRoute processRoute : processRoutes) {
|
||||
if (processRoute != null) {
|
||||
String zFlinghao = processRoute.getRouteDescription();
|
||||
if ("总装部件".equals(processRoute.getMaterial())&& !hasProcessedAssemblyPart) {
|
||||
if ("总装部件".equals(processRoute.getMaterial()) && !hasProcessedAssemblyPart) {
|
||||
String zFnumber = processRoute.getMaterialCode();
|
||||
String zFname = processRoute.getMaterialName();
|
||||
// 将装配 BOM 详情填充进 BOM 详情列表
|
||||
@ -477,32 +409,31 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
// 处理单位换算
|
||||
if ("mm".equals(processRoute.getBomUnit())) {
|
||||
bomDetails.setQuantity(processRoute.getDiscUsage() / 1000.0); // 转换为米
|
||||
} else {
|
||||
} else if ("根".equals(processRoute.getBomUnit())){
|
||||
bomDetails.setDenominator(processRoute.getDiscUsage());
|
||||
bomDetails.setQuantity(1.0);
|
||||
}else {
|
||||
bomDetails.setQuantity(processRoute.getDiscUsage());
|
||||
bomDetails.setDenominator(1.0);
|
||||
}
|
||||
|
||||
//处理原来材料分数格式
|
||||
if ("根".equals(processRoute.getBomUnit())) {
|
||||
bomDetails.setDenominator(processRoute.getDiscUsage());
|
||||
bomDetails.setQuantity(1.0);
|
||||
}
|
||||
|
||||
// 根据 RawMaterialCode 判断是否外购
|
||||
if (isOutsourced(processRoute.getMaterialCode())) {
|
||||
if (isOutsourced(processRoute.getRawMaterialCode())) {
|
||||
bomDetails.setStats("外购");
|
||||
} else {
|
||||
bomDetails.setStats("自制");
|
||||
}
|
||||
|
||||
bomDetails.setMaterial(processRoute.getBomMaterial());
|
||||
bomDetails.setDenominator(1.0);
|
||||
|
||||
return bomDetails;
|
||||
}
|
||||
|
||||
private void createAssemblyBomDetails(String zFlinghao, String zFnumber, String zFname, List<ProductionOrderVo> productionOrderVos) {
|
||||
ArrayList<BomDetailsVo> bomDetailsVos = new ArrayList<>();
|
||||
for (ProductionOrderVo productionOrderVo : productionOrderVos) {
|
||||
if (productionOrderVo !=null){
|
||||
if (productionOrderVo != null) {
|
||||
BomDetailsVo bomDetails = new BomDetailsVo();
|
||||
bomDetails.setTotalWeight(zFlinghao);
|
||||
bomDetails.setFNumber(zFnumber);
|
||||
@ -513,15 +444,16 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
bomDetails.setName(productionOrderVo.getDrawingName());
|
||||
bomDetails.setQuantity(Double.valueOf(productionOrderVo.getQuantity()));
|
||||
bomDetails.setMaterial(productionOrderVo.getMaterial());
|
||||
bomDetails.setRemarks(productionOrderVo.getRemark());
|
||||
// 判断外购或自制
|
||||
String drawingNo = productionOrderVo.getDrawingNo();
|
||||
String remark = productionOrderVo.getRemark();
|
||||
if (drawingNo != null ){
|
||||
if ((isOutsourced(drawingNo) || (remark != null && remark.contains("外购件")) || drawingNo.startsWith(" "))||drawingNo.startsWith("009")) {
|
||||
bomDetails.setStats("外购");
|
||||
} else {
|
||||
bomDetails.setStats("自制");
|
||||
}
|
||||
if (drawingNo != null) {
|
||||
if ((isOutsourced(drawingNo) || (remark != null && remark.contains("外购件")) || drawingNo.startsWith(" ")) || drawingNo.startsWith("009")) {
|
||||
bomDetails.setStats("外购");
|
||||
} else {
|
||||
bomDetails.setStats("自制");
|
||||
}
|
||||
}
|
||||
|
||||
// iBomDetailsService.insertByVo(bomDetails);
|
||||
@ -728,7 +660,8 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
}
|
||||
|
||||
private boolean isOutsourced(String code) {
|
||||
return code.startsWith("009") || code.startsWith("AA") || code.startsWith("AB(") || code.startsWith("AC(") || code.startsWith("015") || code.contains("(M)") || code.startsWith("BC(");
|
||||
return code.startsWith("009") || code.startsWith("AA") || code.startsWith("AB(") ||
|
||||
code.startsWith("AC(") || code.startsWith("015") || code.contains("(M)") || code.startsWith("BC(");
|
||||
}
|
||||
|
||||
//保存到 BomDetails 表中
|
||||
@ -780,8 +713,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
materialsToAdd.add(bomDetails);
|
||||
}
|
||||
|
||||
// 保存 BomDetails 记录
|
||||
// iBomDetailsService.insertByVo(BeanUtil.toBean(bomDetails, BomDetailsVo.class));
|
||||
|
||||
}
|
||||
|
||||
// 新增不存在的物料
|
||||
@ -981,7 +913,6 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 检查 plannedProcessList 是否为 null,避免空指针异常
|
||||
if (plannedProcessList != null && !plannedProcessList.isEmpty()) {
|
||||
plannedProcesses.addAll(plannedProcessList); // 将非空列表添加到最终列表中
|
||||
@ -1227,6 +1158,7 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
route.setActivityDuration(vo.getActivityDuration());
|
||||
route.setActivityUnit("分");
|
||||
routeArrayList.add(route);
|
||||
|
||||
}
|
||||
if (baseMapper.insertBatch(routeArrayList)) {
|
||||
return R.ok();
|
||||
@ -1239,27 +1171,24 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
* 查询材料bom
|
||||
*/
|
||||
@Override
|
||||
public List<MaterialBom> getProcessMaterialList(ProcessRoute processRoute) {
|
||||
if (processRoute == null) {
|
||||
public List<MaterialBom> getProcessMaterialList(String materialCode, String materialName, String productionOrderNo) {
|
||||
if (materialCode == null) {
|
||||
logger.error("做工艺的物料不存在");
|
||||
throw new IllegalArgumentException("做工艺的物料不能为空");
|
||||
}
|
||||
|
||||
String materialCode = processRoute.getMaterialCode();
|
||||
String materialName = processRoute.getMaterialName();
|
||||
if (materialCode == null || materialName == null) {
|
||||
logger.error("MaterialCode or MaterialName is null");
|
||||
throw new IllegalArgumentException("MaterialCode and MaterialName cannot be null");
|
||||
}
|
||||
|
||||
|
||||
QueryWrapper<MaterialBom> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("parent_material_code", processRoute.getMaterialCode());
|
||||
wrapper.eq("parent_material_name", processRoute.getMaterialName());
|
||||
wrapper.eq("parent_material_code", materialCode);
|
||||
wrapper.eq("project_number", productionOrderNo);
|
||||
wrapper.eq("parent_material_name", materialName);
|
||||
|
||||
return materialBomMapper.selectList(wrapper);
|
||||
}
|
||||
//是否是按图定制的物料
|
||||
public Boolean insertByBoToBom(MaterialBomBo bo){
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 删除工序
|
||||
*/
|
||||
@ -1289,7 +1218,149 @@ public class ProcessRouteServiceImpl implements IProcessRouteService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入更新时间
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
|
||||
public List<ProcessRoute> importDataTime1(List<ProcessRouteVo> list) {
|
||||
if (!list.isEmpty()){
|
||||
for (ProcessRouteVo processRouteVo : list) {
|
||||
LambdaQueryWrapper<ProcessRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessRoute::getRouteDescription,processRouteVo.getRouteDescription());
|
||||
List<ProcessRoute> processRoutes = baseMapper.selectList(wrapper);
|
||||
for (ProcessRoute processRoute : processRoutes) {
|
||||
if (processRouteVo.getMaterialCode().equals(processRoute.getMaterialCode())){
|
||||
processRoute.setXuStartTime(processRouteVo.getXuStartTime());
|
||||
processRoute.setXuEndTime(processRouteVo.getXuEndTime());
|
||||
}
|
||||
baseMapper.updateById(processRoute);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入更新时间
|
||||
* @param list 工艺路线列表
|
||||
* @return 更新后的工艺路线列表
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<ProcessRoute> importDataTime(List<ProcessRouteVo> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
try {
|
||||
// 1. 收集所有需要查询的令号
|
||||
Set<String> routeDescriptions = list.stream()
|
||||
.map(ProcessRouteVo::getRouteDescription)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (CollUtil.isEmpty(routeDescriptions)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 2. 批量查询所有相关的工艺路线
|
||||
LambdaQueryWrapper<ProcessRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(ProcessRoute::getRouteDescription, routeDescriptions);
|
||||
List<ProcessRoute> allProcessRoutes = baseMapper.selectList(wrapper);
|
||||
|
||||
if (CollUtil.isEmpty(allProcessRoutes)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 3. 建立复合键映射关系,用于快速查找
|
||||
Map<String, List<ProcessRoute>> routeMap = allProcessRoutes.stream()
|
||||
.collect(Collectors.groupingBy(route ->
|
||||
generateKey(route.getRouteDescription(),
|
||||
route.getMaterialCode(),
|
||||
route.getProcessNo(),
|
||||
route.getMaterialName(),
|
||||
route.getProcessName(),
|
||||
route.getProcessControl(),
|
||||
route.getActivityDuration())
|
||||
));
|
||||
|
||||
// 4. 批量更新数据
|
||||
List<ProcessRoute> updatedRoutes = new ArrayList<>();
|
||||
for (ProcessRouteVo vo : list) {
|
||||
String key = generateKey(vo.getRouteDescription(),
|
||||
vo.getMaterialCode(),
|
||||
vo.getProcessNo(),
|
||||
vo.getMaterialName(),
|
||||
vo.getProcessName(),
|
||||
vo.getProcessControl(),
|
||||
vo.getActivityDuration());
|
||||
|
||||
List<ProcessRoute> matchingRoutes = routeMap.get(key);
|
||||
if (CollUtil.isNotEmpty(matchingRoutes)) {
|
||||
for (ProcessRoute route : matchingRoutes) {
|
||||
// 更新时间
|
||||
route.setXuStartTime(vo.getXuStartTime());
|
||||
route.setXuEndTime(vo.getXuEndTime());
|
||||
route.setUpdateTime(new Date());
|
||||
updatedRoutes.add(route);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 批量更新到数据库
|
||||
if (!updatedRoutes.isEmpty()) {
|
||||
for (List<ProcessRoute> batch : ListUtils.partition(updatedRoutes, 500)) {
|
||||
baseMapper.updateBatchById(batch);
|
||||
}
|
||||
}
|
||||
|
||||
return updatedRoutes;
|
||||
} catch (Exception e) {
|
||||
log.error("批量更新工艺路线时间失败", e);
|
||||
throw new ServiceException("批量更新工艺路线时间失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是按图订购
|
||||
* @param materialCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isAnTuDingGou(String materialCode) {
|
||||
LambdaQueryWrapper<ProcessRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessRoute::getMaterialCode, materialCode);
|
||||
wrapper.eq(ProcessRoute::getProcessName, "按图订制");
|
||||
//查询数量
|
||||
Long count = baseMapper.selectCount(wrapper);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成复合键
|
||||
* 用于匹配所有需要的字段
|
||||
*/
|
||||
private String generateKey(String routeDescription,
|
||||
String materialCode,
|
||||
Long processNo,
|
||||
String materialName,
|
||||
String processName,
|
||||
String processControl,
|
||||
Double activityDuration) {
|
||||
return String.format("%s:%s:%s:%s:%s:%s:%s",
|
||||
StringUtils.defaultString(routeDescription, ""),
|
||||
StringUtils.defaultString(materialCode, ""),
|
||||
processNo == null ? "" : processNo.toString(),
|
||||
StringUtils.defaultString(materialName, ""),
|
||||
StringUtils.defaultString(processName, ""),
|
||||
StringUtils.defaultString(processControl, ""),
|
||||
activityDuration == null?"" : activityDuration.toString());
|
||||
}
|
||||
/**
|
||||
* 获取计划订单编号,然后获取计划订单详情 单据内码 行内码
|
||||
*/
|
||||
|
||||
@ -182,7 +182,7 @@ public class ProductionRouteTwoServiceImpl implements IProductionRouteTwoService
|
||||
productionRouteTwo.setFworkcenteridFname(plannedProcess.getFWorkCenterName()); // 工作中心
|
||||
productionRouteTwo.setFprocessidFname(plannedProcess.getFProcessName()); // 工艺名称
|
||||
productionRouteTwo.setFOptCtrlCodeidFname(plannedProcess.getFOptCtrlCodeIFName());
|
||||
productionRouteTwo.setActivityLengh(Long.valueOf(String.valueOf(plannedProcess.getFActivity1BaseQty())));
|
||||
productionRouteTwo.setActivityLengh(plannedProcess.getFActivity1BaseQty().longValue());
|
||||
// 填充物料相关数据
|
||||
productionRouteTwo.setFMaterialid2ChildFnumber(materialUsageDTO.getMaterialCode()); // 物料编码
|
||||
productionRouteTwo.setFMaterialName1(materialUsageDTO.getMaterialName()); // 物料名称
|
||||
|
||||
@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="parentMaterialCode" column="parent_material_code"/>
|
||||
<result property="parentMaterialName" column="parent_material_name"/>
|
||||
<result property="stock" column="stock"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user