Browse Source

2026-09-08

项目信息增加oa流程
master
fengyuan_yang 2 weeks ago
parent
commit
4d02ec012f
  1. 2
      src/main/java/com/spring/modules/part/mapper/PartInformationMapper.java
  2. 96
      src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java
  3. 8
      src/main/java/com/spring/modules/part/vo/PartInformationVo.java
  4. 26
      src/main/java/com/spring/modules/project/entity/PlmProjectPart.java
  5. 26
      src/main/resources/mapper/part/PartInformationMapper.xml

2
src/main/java/com/spring/modules/part/mapper/PartInformationMapper.java

@ -283,7 +283,7 @@ public interface PartInformationMapper extends BaseMapper<PartInformationEntity>
* @date 2024/9/25 16:19
* @version 1.0
*/
void updateProjectPartBuNo(PartInformationEntity data);
void updateProjectPartBuNo(PartInformationVo data);
IPage<PartInformationEntity> queryPartByPartNo(@Param("page")Page<PartInformationEntity> page, @Param("params") PartInformationVo part);

96
src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java

@ -108,6 +108,7 @@ import static com.spring.modules.part.task.PartRelatedTask.convertToSQLString;
public class PartInformationServiceImpl extends ServiceImpl<PartInformationMapper, PartInformationEntity> implements PartInformationService {
private static final int DRAWING_NO_SYNC_PART_PREFIX_LENGTH = 8;
private static final List<String> PROJECT_PART_PRODUCT_CATEGORIES = Arrays.asList("Label", "Diecut", "Decoration", "Material");
@Autowired
private ProcedureDao procedureDao;
@ -742,6 +743,7 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
data.setBaseNo(data.getPartNo().substring(0, a));
data.setRevNo(data.getPartNo().substring(a));
data.setVirtualPartNo(data.getPartNo());
validateProjectPartRequiredFields(data.getApplicationDesc(), data.getProductCategory(), null);
partInformationMapper.saveProjectPart(data);
// 新增客户料号信息
partInformationMapper.saveCustomerPartInfo(data);
@ -1247,10 +1249,8 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
partInformationMapper.update(data, updateInformationWrapper);
syncDrawingNoByPartPrefix(data);
recordChangeRemark(data.getSite(), data.getPartNo(), data.getUpdateBy(), "用户编辑物料(项目页面)");
// 判断是否需要修改项目物料的BU
if (StringUtils.hasText(data.getBuNo())) {
partInformationMapper.updateProjectPartBuNo(data);
}
validateProjectPartRequiredFields(data.getApplicationDesc(), data.getProductCategory(), null);
partInformationMapper.updateProjectPartBuNo(data);
if (StringUtils.hasText(data.getCustomerPartNo())) {
// 检查是否存在客户料号
List<PartInformationVo> customerPartNos = partInformationMapper.getProjectCustomerPartNo(data);
@ -2900,6 +2900,7 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
a.setCreateBy(data.getCreateBy());
return a;
}).collect(Collectors.toList());
validateProjectPartRequiredFields(partList);
partInformationMapper.addProjectPart(partList);
String site = resolveProjectPartSite(data, partList);
resetCompletedProjectIfTemporaryPartAdded(site, data.getProjectId(), data.getCreateBy(), containsTemporaryPart(site, partList));
@ -2926,6 +2927,7 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
a.setVirtualPartNo(a.getFinalPartNo() == null ? a.getPlmPartNo() : a.getFinalPartNo());
return a;
}).collect(Collectors.toList());
validateProjectPartRequiredFields(partList);
partInformationMapper.addProjectPart(partList);
String site = resolveProjectPartSite(data, partList);
resetCompletedProjectIfTemporaryPartAdded(site, data.getProjectId(), data.getCreateBy(), containsTemporaryPart(site, partList));
@ -4421,6 +4423,15 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
task.setProductGroupId4(getCellValueAsString(row.getCell(4)));
task.setUmId(getCellValueAsString(row.getCell(5)));
task.setCodeNo(getCellValueAsString(row.getCell(6)));
task.setApplicationDesc(getCellValueAsString(row.getCell(7)));
if (!StringUtils.hasText(task.getApplicationDesc())) {
throw new RuntimeException("第" + (j + 1) + "行应用描述不能为空");
}
String productCategory = getCellValueAsString(row.getCell(8));
if (!StringUtils.hasText(productCategory)) {
throw new RuntimeException("第" + (j + 1) + "行产品类别不能为空");
}
task.setProductCategory(parseProjectPartProductCategory(productCategory, j + 1));
task.setUomForWeightNet("kg");
task.setUomForVolumeNet("m3");
task.setActive("Y");
@ -5503,6 +5514,9 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
List<Integer> repeatPartNoRows = new ArrayList<>();
List<Integer> wrongBuNoRows = new ArrayList<>();
List<Integer> wrongIfsPartNoRows = new ArrayList<>();
List<Integer> wrongProductCategoryRows = new ArrayList<>();
List<Integer> emptyApplicationDescRows = new ArrayList<>();
List<Integer> emptyProductCategoryRows = new ArrayList<>();
List<PlmProjectPartData> partList = new ArrayList<>();
BuData buData = new BuData();
buData.setSite(data.getOrderRef1());
@ -5553,6 +5567,19 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
}
}
part.setCustomerPartNo(getStringCellValue(row, 2));
part.setApplicationDesc(getStringCellValue(row, 3));
part.setProductCategory(getStringCellValue(row, 4));
if (!StringUtils.hasText(part.getApplicationDesc())) {
flag = false;
emptyApplicationDescRows.add(j + 1);
}
if (!StringUtils.hasText(part.getProductCategory())) {
flag = false;
emptyProductCategoryRows.add(j + 1);
} else if (!isValidProjectPartProductCategory(part.getProductCategory())) {
flag = false;
wrongProductCategoryRows.add(j + 1);
}
part.setSite(data.getOrderRef1());
part.setProjectId(data.getOrderRef2());
part.setCustomerNo(data.getOrderRef3());
@ -5583,6 +5610,8 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
vo.setBuNo(part.getBuNo());
vo.setBuDesc(buMap.get(part.getBuNo()));
vo.setCustomerPartNo(part.getCustomerPartNo());
vo.setApplicationDesc(part.getApplicationDesc());
vo.setProductCategory(StringUtils.hasText(part.getProductCategory()) ? part.getProductCategory().trim() : null);
list1.add(vo);
}
if (flag){
@ -5604,17 +5633,19 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
exceptionList.add(wrongBuNoRowsStr);
}
if (!wrongIfsPartNoRows.isEmpty()){
/* String wrongIfsPartNosStr = null;
if ("N".equals(searchType)){
// Inventory Part
wrongIfsPartNosStr = "IFS物料编码在Inventory Part中不存在: 第"+ wrongIfsPartNoRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行";
} else {
// Project Part
wrongIfsPartNosStr = "IFS物料编码在Project Part中不存在: 第"+ wrongIfsPartNoRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行";
}*/
String wrongIfsPartNosStr = "IFS物料编码不存在或不可导入: 第"+ wrongIfsPartNoRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行";
exceptionList.add(wrongIfsPartNosStr);
}
if (!emptyApplicationDescRows.isEmpty()){
exceptionList.add("应用描述不能为空: 第" + emptyApplicationDescRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行");
}
if (!emptyProductCategoryRows.isEmpty()){
exceptionList.add("产品类别不能为空: 第" + emptyProductCategoryRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行");
}
if (!wrongProductCategoryRows.isEmpty()){
String wrongProductCategoryRowsStr = "产品类别无效(仅支持 Label/Diecut/Decoration/Material): 第" + wrongProductCategoryRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行";
exceptionList.add(wrongProductCategoryRowsStr);
}
list.setRecords(exceptionList);
return new PageUtils(list);
}
@ -5713,6 +5744,47 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe
projectDao.resetCompletedProjectToDraft(site, projectId, updateBy);
}
private boolean isValidProjectPartProductCategory(String value) {
return StringUtils.hasText(value) && PROJECT_PART_PRODUCT_CATEGORIES.contains(value.trim());
}
private void validateProjectPartRequiredFields(List<PartInformationVo> partList) {
if (partList == null || partList.isEmpty()) {
return;
}
for (int i = 0; i < partList.size(); i++) {
PartInformationVo part = partList.get(i);
String partNo = part == null ? null : (StringUtils.hasText(part.getPartNo()) ? part.getPartNo() : part.getPlmPartNo());
String prefix = StringUtils.hasText(partNo) ? "物料[" + partNo + "]:" : "第" + (i + 1) + "条物料:";
validateProjectPartRequiredFields(part == null ? null : part.getApplicationDesc(),
part == null ? null : part.getProductCategory(), prefix);
}
}
private void validateProjectPartRequiredFields(String applicationDesc, String productCategory, String prefix) {
String p = StringUtils.hasText(prefix) ? prefix : "";
if (!StringUtils.hasText(applicationDesc)) {
throw new RuntimeException(p + "应用描述不能为空");
}
if (!StringUtils.hasText(productCategory)) {
throw new RuntimeException(p + "产品类别不能为空");
}
if (!isValidProjectPartProductCategory(productCategory)) {
throw new RuntimeException(p + "产品类别无效,仅支持 Label/Diecut/Decoration/Material");
}
}
private String parseProjectPartProductCategory(String value, int excelRowNumber) {
if (!StringUtils.hasText(value)) {
return null;
}
String trimmed = value.trim();
if (!PROJECT_PART_PRODUCT_CATEGORIES.contains(trimmed)) {
throw new RuntimeException("第" + excelRowNumber + "行产品类别无效,仅支持 Label/Diecut/Decoration/Material");
}
return trimmed;
}
}

8
src/main/java/com/spring/modules/part/vo/PartInformationVo.java

@ -181,4 +181,12 @@ public class PartInformationVo extends PartInformationEntity {
private Boolean planningInfoFlag;
private Boolean partItemInfoFlag;
private String partNo;
/**
* 应用描述项目物料
*/
private String applicationDesc;
/**
* 产品类别 Label/Diecut/Decoration/Material
*/
private String productCategory;
}

26
src/main/java/com/spring/modules/project/entity/PlmProjectPart.java

@ -309,5 +309,31 @@ public class PlmProjectPart extends QueryPage {
public void setBuDesc(String buDesc) {
this.buDesc = buDesc;
}
/**
* 应用描述
*/
private String applicationDesc;
/**
* 产品类别 Label/Diecut/Decoration/Material
*/
private String productCategory;
public String getApplicationDesc() {
return applicationDesc;
}
public void setApplicationDesc(String applicationDesc) {
this.applicationDesc = applicationDesc;
}
public String getProductCategory() {
return productCategory;
}
public void setProductCategory(String productCategory) {
this.productCategory = productCategory;
}
}

26
src/main/resources/mapper/part/PartInformationMapper.xml

@ -1117,9 +1117,9 @@
<!-- 新增项目物料 -->
<insert id="saveProjectPart" parameterType="com.spring.modules.part.vo.PartInformationVo">
insert into plm_project_part
(site, project_id, test_part_no, base_no, rev_no, part_no_source, bu_no, virtual_part_no)
(site, project_id, test_part_no, base_no, rev_no, part_no_source, bu_no, virtual_part_no, application_desc, product_category)
values
(#{site}, #{projectId}, #{partNo}, #{baseNo}, #{revNo}, #{partNoSource}, #{buNo}, #{virtualPartNo})
(#{site}, #{projectId}, #{partNo}, #{baseNo}, #{revNo}, #{partNoSource}, #{buNo}, #{virtualPartNo}, #{applicationDesc}, #{productCategory})
</insert>
<!-- 修改项目物料finalPart -->
@ -1362,7 +1362,9 @@
a.ifs_part_no,
a.show_in_query_flag,
a.temporary_part_flag,
a.drawing_no
a.drawing_no,
b.application_desc as applicationDesc,
b.product_category as productCategory
FROM part as a
LEFT JOIN plm_project_part as b on a.site = b.site and (a.part_no = b.test_part_no or a.part_no = b.final_part_no)
LEFT JOIN plm_project_info as c on b.site = c.site and b.project_id = c.project_id
@ -1499,10 +1501,10 @@
<!-- 新增项目物料 -->
<insert id="addProjectPart">
insert into plm_project_part
(site, project_id, test_part_no, create_date, create_by, part_no_source, bu_no, final_part_no, virtual_part_no)
(site, project_id, test_part_no, create_date, create_by, part_no_source, bu_no, final_part_no, virtual_part_no, application_desc, product_category)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.projectId}, #{item.partNo}, getDate(), #{item.createBy}, #{item.partNoSource}, #{item.buNo}, #{item.finalPartNo}, #{item.virtualPartNo})
(#{item.site}, #{item.projectId}, #{item.partNo}, getDate(), #{item.createBy}, #{item.partNoSource}, #{item.buNo}, #{item.finalPartNo}, #{item.virtualPartNo}, #{item.applicationDesc}, #{item.productCategory})
</foreach>
</insert>
@ -2070,11 +2072,17 @@
and show_in_query_flag = 'Y'
</select>
<!-- 单独的方法 修改项目物料的BU相关信息 -->
<update id="updateProjectPartBuNo" parameterType="PartInformationEntity">
<!-- 单独的方法 修改项目物料的BU、应用描述、产品类别 -->
<update id="updateProjectPartBuNo" parameterType="com.spring.modules.part.vo.PartInformationVo">
UPDATE plm_project_part
SET bu_no = #{buNo}
WHERE site = #{site} AND project_id = #{projectId} AND test_part_no = #{partNo}
SET bu_no = #{buNo},
application_desc = #{applicationDesc},
product_category = #{productCategory},
update_date = getDate(),
update_by = #{updateBy}
WHERE site = #{site}
AND project_id = #{projectId}
AND (test_part_no = #{partNo} OR final_part_no = #{partNo})
</update>
<!-- 修改项目物料的客户料号相关信息 -->

Loading…
Cancel
Save