@ -67,6 +67,7 @@ import org.springblade.desk.quality.pojo.request.InspectionTaskStartNew;
import org.springblade.desk.quality.pojo.vo.* ;
import org.springblade.desk.quality.service.* ;
import org.springblade.desk.quality.wrapper.InspectionTaskListWrapper ;
import org.springblade.erpdata.feign.IErpDataCheckerSealClient ;
import org.springblade.scheduling.pojo.entity.WorkPlanEntity ;
import org.springblade.system.feign.IDictClient ;
import org.springblade.system.feign.IUserClient ;
@ -77,6 +78,8 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.time.LocalDateTime ;
import java.time.format.DateTimeFormatter ;
import java.util.* ;
@ -154,6 +157,10 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
private AuditFileMapper auditFileMapper ;
@Resource
private ITeamSetService teamSetService ;
@Resource
private IWorkPlanItemDetailService workPlanItemDetailService ;
@Resource
private final IErpDataCheckerSealClient erpDataCheckerSealClient ;
@Override
@ -661,20 +668,20 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
}
if ( moduleList . get ( 0 ) ) {
// 头记录
JSONObject modelJson = buildModelOne ( wo , yo , dsPart ) ;
jsonObj . put ( "modelOne" , modelJson ) ;
JSONObject modelOne = buildModelOne ( wo , yo , dsPart ) ;
jsonObj . put ( "modelOne" , modelOne ) ;
}
// 检验记录
if ( moduleList . get ( 1 ) ) {
JSONObject modelJson1 = new JSONObject ( ) ;
JSONObject modelThree = new JSONObject ( ) ;
List < JSONObject > checkList = this . getCheckListNotNG ( woId , wpList , true ) ;
modelJson1 . put ( "checkList" , checkList ) ;
jsonObj . put ( "modelThree" , modelJson1 ) ;
modelThree . put ( "checkList" , checkList ) ;
jsonObj . put ( "modelThree" , modelThree ) ;
}
List < JSONObject > modelTwoList = this . buildModelTwo ( wo , yo , dsPart , wpList , planList ) ;
jsonObj . put ( "modelTwo" , modelTwoList ) ;
List < JSONObject > modelTwo = this . buildModelTwo ( wo , yo , dsPart , wpList , planList ) ;
jsonObj . put ( "modelTwo" , modelTwo ) ;
if ( moduleList . get ( 2 ) ) {
// 镀后入库记录
@ -708,12 +715,19 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
partJson . put ( "material" , dsPart . getMaterial ( ) ) ;
partJson . put ( "cruxMemo" , dsPart . getKeyInfo ( ) ) ;
partJson . put ( "memo" , dsPart . getRemarks ( ) ) ;
partJson . put ( "area" , dsPart . getArea ( ) ) ;
if ( dsPart . getArea ( ) ! = null ) {
partJson . put ( "area" , roundToSixDecimalPlaces ( dsPart . getArea ( ) ) ) ;
}
}
if ( yo ! = null ) {
yoJson . put ( "productType" , yo . getProductType ( ) ) ;
yoJson . put ( "prodIdent" , yo . getProductIdent ( ) ) ;
yoJson . put ( "poQty" , yo . getYpQty ( ) ) ;
yoJson . put ( "poArea" , yo . getYpArea ( ) ) ;
if ( yo . getYpArea ( ) ! = null ) {
yoJson . put ( "poArea" , roundToSixDecimalPlaces ( yo . getYpArea ( ) ) ) ;
}
yoJson . put ( "primaryCraft" , yo . getPrimaryCraft ( ) ) ;
}
if ( wo ! = null ) {
@ -725,6 +739,19 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
return modelJson ;
}
/ * *
* double保留6为小数 , 四舍五入
* @param num
* @return
* /
private double roundToSixDecimalPlaces ( Double num ) {
// 防止double精度问题,先转为BigDecimal
BigDecimal bigDecimal = new BigDecimal ( Double . toString ( num ) ) ;
// 设置保留6位小数,四舍五入模式
bigDecimal = bigDecimal . setScale ( 6 , RoundingMode . HALF_UP ) ;
return bigDecimal . doubleValue ( ) ;
}
/ * *
* 构建modelTwo
*
@ -795,8 +822,8 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
List < FeiBaSetEntity > basList = feiBaSetService . listByIds ( bas ) ;
List < EquipmentEntity > cardList = mesEquipmentCardService . listByIds ( cards ) ;
// 设备编号
String gj = StringUtils . join ( rackList . stream ( ) . filter ( j - > j . getRsTyp e ( ) ! = null ) . map ( j - > j . getRsTyp e ( ) ) . collect ( Collectors . toList ( ) ) , "'、'" ) ;
String fb = StringUtils . join ( basList . stream ( ) . filter ( j - > j . getFsTyp e ( ) ! = null ) . map ( j - > j . getFsTyp e ( ) ) . collect ( Collectors . toList ( ) ) , "、" ) ;
String gj = StringUtils . join ( rackList . stream ( ) . filter ( j - > j . getRsCod e ( ) ! = null ) . map ( j - > j . getRsCod e ( ) ) . collect ( Collectors . toList ( ) ) , "'、'" ) ;
String fb = StringUtils . join ( basList . stream ( ) . filter ( j - > j . getFsCod e ( ) ! = null ) . map ( j - > j . getFsCod e ( ) ) . collect ( Collectors . toList ( ) ) , "、" ) ;
String eq = StringUtils . join ( cardList . stream ( ) . filter ( j - > j . getDeviceCode ( ) ! = null ) . map ( j - > j . getDeviceCode ( ) ) . collect ( Collectors . toList ( ) ) , "、" ) ;
modelTwo . put ( "gjCode" , gj ) ;
modelTwo . put ( "fbCode" , fb ) ;
@ -832,7 +859,7 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
// 如果是荧光检测工序,需要返回报工人签章图片
if ( "荧光检测" . equals ( prWorkPlan . getPpsName ( ) ) ) {
if ( makeRec ! = null ) {
String checkManByNewErpMes = workPlanMapper . getCheckManByNewErpMes ( makeRec . getWorkerAccount ( ) ) ;
String checkManByNewErpMes = erpDataCheckerSealClient . getCheckManByNewErpMes ( makeRec . getWorkerName ( ) ) ;
modelTwo . put ( "workerImgUrl" , checkManByNewErpMes ) ;
}
}
@ -926,10 +953,10 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
BsProcessSetEntity process = processSetService . getById ( workPlan . getPpsId ( ) ) ;
if ( "喷砂" . equals ( process . getName ( ) ) | | "涂色标" . equals ( process . getName ( ) ) ) {
dsRbFilePreserveList = workPlanMapper . getDataByWcIdAndPpsId ( null ,
workPlan . getPpsId ( ) , Boolean . TRUE ) ;
workPlan . getPpsId ( ) , "0" ) ;
} else {
dsRbFilePreserveList = workPlanMapper . getDataByWcIdAndPpsId ( bsCenterTeam . getWcId ( ) ,
workPlan . getPpsId ( ) , Boolean . TRUE ) ;
workPlan . getPpsId ( ) , "0" ) ;
}
}
@ -987,36 +1014,121 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
private List < JSONObject > getCheckListNotNG ( Long woId , List < WorkPlanExpandVO > wpList , Boolean eleOrPrint ) {
List < JSONObject > checkList = new ArrayList < > ( ) ;
//组装检测项集合
Map < String , JSONObject > ccMap = new LinkedHashMap < > ( ) ;
JSONObject cc ;
List < WorkPlanItemVO > piLst = workPlanItemService . listByWoIdNotNG ( woId ) ;
Map < Long , WorkPlanExpandVO > workPlanMap = wpList . stream ( )
. collect ( Collectors . toMap (
WorkPlanExpandVO : : getId ,
Function . identity ( )
) ) ;
Map < String , List < JSONObject > > piMap = new LinkedHashMap < > ( ) ;
List < JSONObject > lst ;
if ( CollectionUtils . isNotEmpty ( piLst ) ) {
for ( WorkPlanItemVO pi : piLst ) {
lst = piMap . get ( pi . getItemCode ( ) ) ;
WorkPlanExpandVO workPlan = workPlanMap . get ( pi . getWpId ( ) ) ;
String testOrder = workPlan . getOrders ( ) + "-" + pi . getItemCode ( ) ;
JSONObject checkDetail = new JSONObject ( ) ;
checkDetail . put ( "testOrders" , testOrder ) ;
checkDetail . put ( "checkName" , pi . getCheckUserRealName ( ) ) ;
if ( StringUtils . isNotEmpty ( pi . getCheckUserAccount ( ) ) ) {
String checkManByNewErp = workPlanMapper . getCheckManByNewErpMes ( pi . getCheckUserAccount ( ) ) ;
if ( eleOrPrint ) {
checkDetail . put ( "imgUrl" , checkManByNewErp ) ;
if ( CollectionUtils . isEmpty ( lst ) ) {
lst = new ArrayList < > ( ) ;
piMap . put ( testOrder , lst ) ;
cc = new JSONObject ( ) ;
cc . put ( "testOrders" , testOrder ) ;
if ( pi . getCheckQty ( ) ! = null & & pi . getCheckQty ( ) > 0 ) {
cc . put ( "checkQty" , pi . getCheckQty ( ) ) ;
}
if ( pi . getTestQty ( ) ! = null & & pi . getTestQty ( ) > 0 ) {
cc . put ( "testQty" , pi . getTestQty ( ) ) ;
} else {
if ( checkManByNewErp ! = null & & checkManByNewErp . indexOf ( "base64," ) > 0 ) {
String checkManByNewErpSubString = checkManByNewErp . substring ( checkManByNewErp . indexOf ( "base64," ) + 7 ) ;
checkDetail . put ( "imgUrl" , checkManByNewErpSubString ) ;
cc . put ( "testQty" , "" ) ;
}
cc . put ( "checkResult" , WorkPlanItem . checkResultMap . get ( pi . getCheckResult ( ) ) ) ;
if ( StringUtils . isNotEmpty ( pi . getCheckUserRealName ( ) ) ) {
String checkManByNewErp = null ;
try {
checkManByNewErp = erpDataCheckerSealClient . getCheckManByNewErpMes ( pi . getCheckUserRealName ( ) ) ;
} catch ( Exception e ) {
// DB Link 等异常降级,避免阻塞 PDF 生成
}
cc . put ( "checkName" , pi . getCheckUserRealName ( ) ) ;
if ( eleOrPrint ) {
cc . put ( "imgUrl" , checkManByNewErp ) ;
} else {
if ( checkManByNewErp ! = null & & checkManByNewErp . indexOf ( "base64," ) > 0 ) {
String checkManByNewErpSubString = checkManByNewErp . substring ( checkManByNewErp . indexOf ( "base64," ) + 7 ) ;
cc . put ( "imgUrl" , checkManByNewErpSubString ) ;
}
}
if ( pi . getCheckDate ( ) ! = null ) {
cc . put ( "checkDate" , pi . getCheckDate ( ) . toLocalDate ( ) . toString ( ) ) ;
} else {
cc . put ( "checkDate" , "" ) ;
}
}
ccMap . put ( testOrder , cc ) ;
}
if ( "厚度检测" . equals ( pi . getItemName ( ) ) ) {
for ( int i = 0 ; i < 3 ; i + + ) {
lst . add ( this . buildCCC ( pi . getItemName ( ) , pi . getStandardName ( ) , pi . getCheckValue ( ) , pi . getId ( ) , null , pi . getCreateTime ( ) ) ) ;
}
}
lst . add ( this . buildCCC ( pi . getItemName ( ) , pi . getStandardName ( ) , pi . getCheckValue ( ) , pi . getId ( ) , null , pi . getCreateTime ( ) ) ) ;
List < WorkPlanItemDetailVO > idLst ;
for ( Map . Entry < String , JSONObject > entry : ccMap . entrySet ( ) ) {
cc = ccMap . get ( entry . getKey ( ) ) ;
if ( cc ! = null ) {
lst = piMap . get ( cc . get ( "testOrders" ) ) ;
lst = lst . stream ( ) . collect ( Collectors . collectingAndThen ( Collectors . toCollection ( ( )
- > new TreeSet < > ( Comparator . comparing ( i - > ( Date ) i . get ( "createTime" ) ) ) ) , ArrayList : : new ) ) ;
if ( lst ! = null & & lst . size ( ) > 0 ) {
for ( JSONObject ccc : lst ) {
idLst = workPlanItemDetailService . listVOByWorkPlanItemId ( ( Long ) ccc . get ( "wpiId" ) ) ;
if ( idLst ! = null & & idLst . size ( ) > 0 ) {
lst = new ArrayList < > ( ) ;
for ( WorkPlanItemDetailVO itemDetail : idLst ) {
if ( "厚度检测" . equals ( ccc . get ( "testName" ) ) ) {
cc . put ( "deviceCode" , itemDetail . getGaugeValue8 ( ) ) ;
lst . add ( this . buildCCC ( ( String ) ccc . get ( "testName" ) , ( String ) ccc . get ( "trialStandard" ) , itemDetail . getGaugeValueNotNUll ( ) , null , itemDetail . getGaugeValue8 ( ) , ( Date ) ccc . get ( "createTime" ) ) ) ;
} else if ( itemDetail . getMtId ( ) ! = null ) {
lst . add ( this . buildCCC ( ( String ) ccc . get ( "testName" ) , itemDetail . getRuleSize ( ) ,
itemDetail . getGaugeValue1 ( ) , ( Long ) ccc . get ( "wpiId" ) , itemDetail . getTools ( ) , ( Date ) ccc . get ( "createTime" ) ) ) ;
cc . put ( "deviceCode" , itemDetail . getTools ( ) ) ;
if ( cc . get ( "trialStandard" ) ! = null ) {
cc . put ( "trialStandard" , ( String ) cc . get ( "trialStandard" ) + ';' + itemDetail . getRuleSize ( ) ) ;
} else {
cc . put ( "trialStandard" , itemDetail . getRuleSize ( ) ) ;
}
if ( cc . get ( "checkResult" ) ! = null ) {
cc . put ( "checkResult" , cc . get ( "checkResult" ) ) ;
} else {
cc . put ( "checkResult" , itemDetail . getGaugeValue1 ( ) ) ;
}
}
}
}
cc . put ( "cccList" , lst ) ;
checkList . add ( cc ) ;
break ;
}
}
}
}
checkList . add ( checkDetail ) ;
}
}
return checkList ;
}
private JSONObject buildCCC ( String testName , String trialStandard , String checkValue , Long wpiId , String tools , Date createTime ) {
JSONObject ccc = new JSONObject ( ) ;
ccc . put ( "testName" , testName ) ;
ccc . put ( "trialStandard" , trialStandard ) ;
ccc . put ( "checkValue" , checkValue ) ;
ccc . put ( "wpiId" , wpiId ) ;
ccc . put ( "emTools" , tools ) ;
ccc . put ( "createTime" , createTime ) ;
return ccc ;
}
public void getNewProcess ( List < WorkPlan > wpList , JSONObject jsonObj , List < Boolean > modelFlag ) {
if ( wpList = = null | | wpList . size ( ) = = 0 ) {
return ;
@ -1246,10 +1358,10 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
BsProcessSetEntity process = processSetService . getById ( workPlan . getPpsId ( ) ) ;
if ( "喷砂" . equals ( process . getName ( ) ) | | "涂色标" . equals ( process . getName ( ) ) ) {
dsRbFilePreserveList = workPlanMapper . getDataByWcIdAndPpsId ( null ,
workPlan . getPpsId ( ) , Boolean . TRUE ) ;
workPlan . getPpsId ( ) , "0" ) ;
} else {
dsRbFilePreserveList = workPlanMapper . getDataByWcIdAndPpsId ( bsCenterTeam . getWcId ( ) ,
workPlan . getPpsId ( ) , Boolean . TRUE ) ;
workPlan . getPpsId ( ) , "0" ) ;
}
}
@ -2125,12 +2237,12 @@ public class InspectionTaskServiceImpl extends BaseServiceImpl<InspectionTaskMap
if ( pi . getCheckUserId ( ) ! = null ) {
R < User > user = userClient . userInfoById ( pi . getCheckUserId ( ) ) ;
String userName = user . getData ( ) . getAccount ( ) ;
String userName = user . getData ( ) . getRealName ( ) ;
if ( null ! = user & & user . getData ( ) ! = null ) {
cc . setCheckName ( user . getData ( ) . getRealName ( ) ) ;
}
//zxh 20250212 从nerp获取检验员印章
String checkManByNewErp = workPlanMapper . getCheckManByNewErpMes ( userName ) ;
String checkManByNewErp = erpDataCheckerSealClient . getCheckManByNewErpMes ( userName ) ;
if ( eleOrPrint ) {