Browse Source

2026-05-26

RoHs优化
master
fengyuan_yang 3 weeks ago
parent
commit
07c50359f3
  1. 48
      src/main/java/com/spring/modules/quote/service/impl/QuoteServiceImpl.java
  2. 8
      src/main/java/com/spring/modules/rohs/entity/RohsMaterialEntity.java
  3. 3
      src/main/java/com/spring/modules/rohs/mapper/RohsMapper.java
  4. 15
      src/main/java/com/spring/modules/rohs/service/impl/RohsServiceImpl.java
  5. 41
      src/main/resources/mapper/rohs/RohsMapper.xml

48
src/main/java/com/spring/modules/quote/service/impl/QuoteServiceImpl.java

@ -472,8 +472,8 @@ public class QuoteServiceImpl extends ServiceImpl<QuoteMapper, Quote> implements
if ("plm_quote".equals(nodeDetail.getPlmTable()) && quoteInfo != null) {
// 判断是否为金额类型
if ("C".equals(nodeDetail.getFieldType())) {
BigDecimal v = (BigDecimal) getPropertyValue(quoteInfo, nodeDetail.getPlmField());
fieldValue = v == null ? "0" : v.toString();
Object value = getPropertyValue(quoteInfo, nodeDetail.getPlmField());
fieldValue = toNumericFlowValue(value, nodeDetail.getPlmTable(), nodeDetail.getPlmField());
} else {
Object value = getPropertyValue(quoteInfo, nodeDetail.getPlmField());
fieldValue = value == null ? "" : value.toString();
@ -483,8 +483,8 @@ public class QuoteServiceImpl extends ServiceImpl<QuoteMapper, Quote> implements
else if ("plm_quote_detail".equals(nodeDetail.getPlmTable()) && defaultQuoteDetail != null) {
// 判断是否为金额类型
if ("C".equals(nodeDetail.getFieldType())) {
BigDecimal v = (BigDecimal) getPropertyValue(defaultQuoteDetail, nodeDetail.getPlmField());
fieldValue = v == null ? "0" : v.toString();
Object value = getPropertyValue(defaultQuoteDetail, nodeDetail.getPlmField());
fieldValue = toNumericFlowValue(value, nodeDetail.getPlmTable(), nodeDetail.getPlmField());
} else {
Object value = getPropertyValue(defaultQuoteDetail, nodeDetail.getPlmField());
fieldValue = value == null ? "" : value.toString();
@ -740,8 +740,8 @@ public class QuoteServiceImpl extends ServiceImpl<QuoteMapper, Quote> implements
if ("plm_quote".equals(nodeDetail.getPlmTable()) && quoteInfo != null) {
// 判断是否为金额类型
if ("C".equals(nodeDetail.getFieldType())) {
BigDecimal v = (BigDecimal) getPropertyValue(quoteInfo, nodeDetail.getPlmField());
fieldValue = v == null ? "0" : v.toString();
Object value = getPropertyValue(quoteInfo, nodeDetail.getPlmField());
fieldValue = toNumericFlowValue(value, nodeDetail.getPlmTable(), nodeDetail.getPlmField());
} else {
Object value = getPropertyValue(quoteInfo, nodeDetail.getPlmField());
fieldValue = value == null ? "" : value.toString();
@ -751,8 +751,8 @@ public class QuoteServiceImpl extends ServiceImpl<QuoteMapper, Quote> implements
else if ("plm_quote_detail".equals(nodeDetail.getPlmTable()) && defaultQuoteDetail != null) {
// 判断是否为金额类型
if ("C".equals(nodeDetail.getFieldType())) {
BigDecimal v = (BigDecimal) getPropertyValue(defaultQuoteDetail, nodeDetail.getPlmField());
fieldValue = v == null ? "0" : v.toString();
Object value = getPropertyValue(defaultQuoteDetail, nodeDetail.getPlmField());
fieldValue = toNumericFlowValue(value, nodeDetail.getPlmTable(), nodeDetail.getPlmField());
} else {
Object value = getPropertyValue(defaultQuoteDetail, nodeDetail.getPlmField());
fieldValue = value == null ? "" : value.toString();
@ -777,6 +777,38 @@ public class QuoteServiceImpl extends ServiceImpl<QuoteMapper, Quote> implements
return mainData;
}
/**
* OA流程字段值转换金额字段(C)统一按数值字符串输出
* 兼容 BigDecimal / Number / String避免直接强转导致 ClassCastException
*/
private String toNumericFlowValue(Object value, String plmTable, String plmField) {
if (value == null) {
return "0";
}
if (value instanceof BigDecimal) {
return ((BigDecimal) value).toString();
}
if (value instanceof Number) {
return new BigDecimal(value.toString()).toString();
}
if (value instanceof String) {
String strValue = ((String) value).trim();
if (!StringUtils.hasText(strValue)) {
return "0";
}
try {
return new BigDecimal(strValue).toString();
} catch (NumberFormatException ex) {
throw new RuntimeException(String.format(
"流程字段配置异常:[%s.%s] 被配置为金额(C),但值[%s]不是数字",
plmTable, plmField, strValue));
}
}
throw new RuntimeException(String.format(
"流程字段配置异常:[%s.%s] 被配置为金额(C),但值类型[%s]不支持",
plmTable, plmField, value.getClass().getSimpleName()));
}
/**
* 获取默认报价行的条目明细QuoteDetail
* @param quoteId 报价单ID

8
src/main/java/com/spring/modules/rohs/entity/RohsMaterialEntity.java

@ -1,6 +1,7 @@
package com.spring.modules.rohs.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@ -30,11 +31,8 @@ public class RohsMaterialEntity implements Serializable {
private String finalPartNo;
private String customerPartNo;
private String partDesc;
private String partSpec;
private String remark;
@TableField(exist = false)
private String partStatus;
}

3
src/main/java/com/spring/modules/rohs/mapper/RohsMapper.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.spring.modules.change.vo.ProcessFormVo;
import com.spring.modules.rohs.entity.RohsEntity;
import com.spring.modules.rohs.entity.RohsMaterialEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;
@ -22,4 +23,6 @@ public interface RohsMapper extends BaseMapper<RohsEntity> {
RohsEntity getDetailWithNames(@Param("site") String site, @Param("referenceNo") String referenceNo);
IPage<Map<String, Object>> queryProjectMaterialPage(IPage<?> page, @Param("params") Map<String, Object> params);
List<RohsMaterialEntity> queryMaterialList(@Param("site") String site, @Param("referenceNo") String referenceNo);
}

15
src/main/java/com/spring/modules/rohs/service/impl/RohsServiceImpl.java

@ -353,10 +353,9 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
@Override
public PageUtils queryProjectMaterialPage(Map<String, Object> params) {
params.put("testPartNo", toLikeParam((String) params.get("testPartNo")));
params.put("partDesc", toLikeParam((String) params.get("partDesc")));
params.put("finalPartNo", toLikeParam((String) params.get("finalPartNo")));
params.put("customerPartNo", toLikeParam((String) params.get("customerPartNo")));
params.put("partDesc", toLikeParam((String) params.get("partDesc")));
params.put("partStatus", toLikeParam((String) params.get("partStatus")));
IPage<Map<String, Object>> page = this.baseMapper.queryProjectMaterialPage(
new Query<Map<String, Object>>().getPage(params),
@ -370,12 +369,7 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
if (StringUtils.isBlank(site) || StringUtils.isBlank(referenceNo)) {
return Collections.emptyList();
}
QueryWrapper<RohsMaterialEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("site", site)
.eq("reference_no", referenceNo)
.orderByAsc("line_no")
.orderByAsc("id");
return rohsMaterialService.list(queryWrapper);
return this.baseMapper.queryMaterialList(site, referenceNo);
}
@Override
@ -413,10 +407,7 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
entity.setProjectId(StringUtils.isNotBlank(material.getProjectId()) ? material.getProjectId() : rohs.getProjectId());
entity.setTestPartNo(uniqueKey);
entity.setFinalPartNo(material.getFinalPartNo());
entity.setCustomerPartNo(material.getCustomerPartNo());
entity.setPartDesc(material.getPartDesc());
entity.setPartSpec(material.getPartSpec());
entity.setRemark(material.getRemark());
saveList.add(entity);
}

41
src/main/resources/mapper/rohs/RohsMapper.xml

@ -75,6 +75,18 @@
<result column="commGroup3Desc" property="commGroup3Desc" />
</resultMap>
<resultMap id="MaterialResultMap" type="com.spring.modules.rohs.entity.RohsMaterialEntity">
<id column="id" property="id" />
<result column="site" property="site" />
<result column="reference_no" property="referenceNo" />
<result column="line_no" property="lineNo" />
<result column="project_id" property="projectId" />
<result column="test_part_no" property="testPartNo" />
<result column="final_part_no" property="finalPartNo" />
<result column="part_desc" property="partDesc" />
<result column="part_status" property="partStatus" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
a.site, a.reference_no, a.applicant, a.application_date, a.process, a.pm, a.planned_mass_production_date, a.color, a.vendor_code, a.vendor_material_code, a.material_classify, a.other_material_classify, a.material_use_for, a.end_customer, a.project_id, a.is_macallan_material, a.need_create_number, a.npd_engineer, a.material_validity_time, a.material_validity_comments, a.need_deviation, a.technical_plan, a.wm_required_spec, a.is_fiber_material, a.material_thickness, a.buyer, a.expect_report_time, a.qualification_documents_needed, a.test_report_including_items, a.remark, a.status, a.sgs_report_number, a.expired_date, a.fiber_information, a.hsf_standard, a.hsf_approver, a.related_people, a.valid_until_value, a.valid_until, a.is_meet_rohs_requirement, a.is_ah_grade, a.hsf_supplier_classification, a.material_desc, a.npd_remark, a.is_same_material_diff_size, a.ifs_part_no, a.comm_group1, a.comm_group2, a.comm_group3, a.create_date, a.create_by, a.update_date, a.update_by, a.step_id, a.reject_flag, a.reject_step_id
@ -149,14 +161,12 @@
a.project_id as projectId,
a.test_part_no as testPartNo,
a.final_part_no as finalPartNo,
c.customer_part_no as customerPartNo,
a.part_desc as partDesc,
a.part_spec as partSpec,
d.part_status as partStatus,
b.final_customer_id as finalCustomerId,
b.customer_id as customerId
from view_Project_Part as a
left join plm_project_info as b on a.site = b.site and a.project_id = b.project_id
left join plm_customer_part_info as c on b.site = c.site and b.customer_id = c.customer_no and a.test_part_no = c.part_no
left join part as d on a.site = d.site and a.test_part_no = d.part_no
where a.site = #{params.site}
and d.status = 'Y'
@ -166,19 +176,34 @@
<if test="params.endCustomer != null and params.endCustomer != ''">
and (b.final_customer_id = #{params.endCustomer} or b.customer_id = #{params.endCustomer})
</if>
<if test="params.testPartNo != null and params.testPartNo != ''">
and a.test_part_no like #{params.testPartNo}
</if>
<if test="params.partDesc != null and params.partDesc != ''">
and a.part_desc like #{params.partDesc}
</if>
<if test="params.finalPartNo != null and params.finalPartNo != ''">
and a.final_part_no like #{params.finalPartNo}
</if>
<if test="params.customerPartNo != null and params.customerPartNo != ''">
and c.customer_part_no like #{params.customerPartNo}
<if test="params.partStatus != null and params.partStatus != ''">
and d.part_status like #{params.partStatus}
</if>
order by a.project_id, a.test_part_no
</select>
<select id="queryMaterialList" resultMap="MaterialResultMap">
select
m.id,
m.site,
m.reference_no,
m.line_no,
m.project_id,
m.test_part_no,
m.final_part_no,
m.part_desc,
p.part_status
from plm_rohs_material m
left join part p on m.site = p.site and m.test_part_no = p.part_no
where m.site = #{site}
and m.reference_no = #{referenceNo}
order by m.line_no, m.id
</select>
</mapper>
Loading…
Cancel
Save