@ -35,10 +35,12 @@ import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign;
import com.yxt.anrui.portal.api.sysuser.SysUserFeign ;
import com.yxt.anrui.portal.api.sysuser.SysUserVo ;
import com.yxt.anrui.scm.api.scmfile.ScmFile ;
import com.yxt.anrui.scm.api.scmvehiclepatrolinspection.AppScmVehiclePatrolinspectionDetailedsVo ;
import com.yxt.anrui.scm.api.scmvehiclepatrolinspection.AppScmVehiclePatrolinspectionPageVo ;
import com.yxt.anrui.scm.api.scmvehiclepatrolinspection.ScmVehiclePatrolinspection ;
import com.yxt.anrui.scm.api.scmvehiclepatrolinspectionsheet.* ;
import com.yxt.anrui.scm.api.scmvehpatrolinspectionmonth.ScmVehPatrolinspectionmonthVo ;
import com.yxt.anrui.scm.api.scmvehpatrolinspectionmonth.VehPatrolinspectionmonthVo ;
import com.yxt.anrui.scm.api.scmvehpatrolinspectionmonth.VehRecordsQuery ;
import com.yxt.anrui.scm.api.scmwarehouse.ScmWarehouse ;
import com.yxt.anrui.scm.biz.scmfile.ScmFileService ;
@ -423,32 +425,21 @@ public class ScmVehiclePatrolinspectionsheetService extends MybatisBaseService<S
* 应巡检展示的是当前记录表中减去标识为盘盈的记录 、 未巡检展示的是待巡检
* /
ResultBean rb = ResultBean . fireFail ( ) ;
String s1 = "" ;
String type1 = "06" ; //巡检相关照片
String oneKey = "001" ;
String oneValue = "问题未解决" ;
String orgPath = dto . getOrgPath ( ) ;
String useOrgSid = "" ;
if ( StringUtils . isBlank ( orgPath ) ) {
useOrgSid = sysStaffOrgFeign . getPathSidByUserSid ( dto . getUserSid ( ) ) . getData ( ) ;
} else {
useOrgSid = sysStaffOrgFeign . getOrgSidByPath ( orgPath ) . getData ( ) ;
}
String vinNo = dto . getVinNo ( ) ;
VehRecordsQuery vehRecordsQuery = new VehRecordsQuery ( ) ;
vehRecordsQuery . setOrgPath ( orgPath ) ;
vehRecordsQuery . setUserSid ( dto . getUserSid ( ) ) ;
ScmVehiclePatrolinspectionsheet scmVehiclePatrolinspectionsheet = new ScmVehiclePatrolinspectionsheet ( ) ;
SysUserVo sysUserVo = sysUserFeign . fetchBySid ( dto . getUserSid ( ) ) . getData ( ) ;
ScmVehPatrolinspectionmonthVo scmVehPatrolinspectionmonthVo = null ;
//查询是否有月度巡检记录
List < ScmVehPatrolinspectionmonthVo > monthVoList = scmVehPatrolinspectionmonthService . selectListAll ( ) ;
ScmVehPatrolinspectionmonthVo scmVehPatrolinspectionmonthVo = null ;
if ( monthVoList . size ( ) > 0 ) { // 有 根据生成巡检月度报告 判断 是否已生成报告
scmVehPatrolinspectionmonthVo = monthVoList . get ( 0 ) ;
if ( scmVehPatrolinspectionmonthVo . getState ( ) = = 0 ) {
// 否 继续走新增
scmVehPatrolinspectionmonthVo = monthVoList . get ( 0 ) ;
// AppScmVehiclePatrolinspectionDetailedsVo patrolinspectionVo = scmVehiclePatrolinspectionService.selectByMainSidAndVinNo(monthVoList.get(0).getSid(), vinNo);
addPatrolinspectionsheet ( dto , scmVehPatrolinspectionmonthVo ) ;
} else if ( scmVehPatrolinspectionmonthVo . getState ( ) = = 1 ) {
// 是 先生成月度巡检 和 巡检记录
@ -456,48 +447,97 @@ public class ScmVehiclePatrolinspectionsheetService extends MybatisBaseService<S
monthVoList = scmVehPatrolinspectionmonthService . selectListAll ( ) ;
if ( monthVoList . size ( ) > 0 ) {
scmVehPatrolinspectionmonthVo = monthVoList . get ( 0 ) ;
addPatrolinspectionsheet ( dto , scmVehPatrolinspectionmonthVo ) ;
} else {
rb . setMsg ( "暂无需要巡检车辆" ) ;
}
}
} else { // 否 先生成月度巡检 和 巡检记录
scmVehPatrolinspectionmonthService . getInspectionRecords ( vehRecordsQuery ) ;
monthVoList = scmVehPatrolinspectionmonthService . selectListAll ( ) ;
if ( monthVoList . size ( ) > 0 ) {
scmVehPatrolinspectionmonthVo = monthVoList . get ( 0 ) ;
addPatrolinspectionsheet ( dto , scmVehPatrolinspectionmonthVo ) ;
} else {
rb . setMsg ( "暂无需要巡检车辆" ) ;
}
}
List < AppScmVehiclePatrolinspectionPageVo > list = scmVehiclePatrolinspectionService . selectByVinNo ( dto . getVinNo ( ) , useOrgSid ) ;
if ( list . size ( ) > 0 ) {
String id = list . get ( 0 ) . getId ( ) ;
String mainSid = list . get ( 0 ) . getSid ( ) ;
scmVehiclePatrolinspectionService . deleteByVinNo ( dto . getVinNo ( ) , id ) ;
int count = baseMapper . selectByMainSidNum ( mainSid ) ;
if ( count > 0 ) {
baseMapper . deleteByMainSid ( mainSid ) ;
}
return rb . success ( ) . setMsg ( "添加成功" ) ;
}
public void addPatrolinspectionsheet ( ScmVehiclePatrolinspectionsheetDto dto , ScmVehPatrolinspectionmonthVo scmVehPatrolinspectionmonthVo ) {
String s1 = "" ;
String type1 = "06" ; //巡检相关照片
String oneKey = "001" ;
String oneValue = "问题未解决" ;
String useOrgSid = "" ;
String orgPath = dto . getOrgPath ( ) ;
if ( StringUtils . isBlank ( orgPath ) ) {
useOrgSid = sysStaffOrgFeign . getPathSidByUserSid ( dto . getUserSid ( ) ) . getData ( ) ;
} else {
useOrgSid = sysStaffOrgFeign . getOrgSidByPath ( orgPath ) . getData ( ) ;
}
ScmVehiclePatrolinspection scmVehiclePatrolinspection = new ScmVehiclePatrolinspection ( ) ;
scmVehiclePatrolinspection . setVinNo ( dto . getVinNo ( ) ) ;
scmVehiclePatrolinspection . setMainSid ( scmVehPatrolinspectionmonthVo . getSid ( ) ) ;
scmVehiclePatrolinspection . setLocation ( dto . getWarehouse ( ) ) ;
scmVehiclePatrolinspection . setLocationSid ( dto . getWarehouseSid ( ) ) ;
scmVehiclePatrolinspection . setPatrolInspectionState ( oneValue ) ;
scmVehiclePatrolinspection . setPatrolInspectionStateKey ( oneKey ) ;
scmVehiclePatrolinspection . setCreateOrgSid ( useOrgSid ) ;
scmVehiclePatrolinspection . setCreateBySid ( dto . getUserSid ( ) ) ;
scmVehiclePatrolinspection . setUseOrgSid ( useOrgSid ) ;
Boolean newAdd = dto . getNewAdd ( ) ;
if ( newAdd ) {
VehRecordsQuery vehRecordsQuery = new VehRecordsQuery ( ) ;
vehRecordsQuery . setOrgPath ( orgPath ) ;
vehRecordsQuery . setUserSid ( dto . getUserSid ( ) ) ;
SysUserVo sysUserVo = sysUserFeign . fetchBySid ( dto . getUserSid ( ) ) . getData ( ) ;
ScmVehiclePatrolinspectionsheet scmVehiclePatrolinspectionsheet = new ScmVehiclePatrolinspectionsheet ( ) ;
// 待巡检记录列表添加数据
ScmVehiclePatrolinspection scmVehiclePatrolinspection = scmVehiclePatrolinspectionService . getDetailedsByMainSid ( scmVehPatrolinspectionmonthVo . getSid ( ) , dto . getVinNo ( ) ) ;
if ( scmVehiclePatrolinspection = = null ) {
scmVehiclePatrolinspection = new ScmVehiclePatrolinspection ( ) ;
scmVehiclePatrolinspection . setVinNo ( dto . getVinNo ( ) ) ;
scmVehiclePatrolinspection . setMainSid ( scmVehPatrolinspectionmonthVo . getSid ( ) ) ;
scmVehiclePatrolinspection . setLocation ( dto . getWarehouse ( ) ) ;
scmVehiclePatrolinspection . setLocationSid ( dto . getWarehouseSid ( ) ) ;
scmVehiclePatrolinspection . setPatrolInspectionState ( oneValue ) ;
scmVehiclePatrolinspection . setPatrolInspectionStateKey ( oneKey ) ;
scmVehiclePatrolinspection . setCreateOrgSid ( useOrgSid ) ;
scmVehiclePatrolinspection . setCreateBySid ( dto . getUserSid ( ) ) ;
scmVehiclePatrolinspection . setUseOrgSid ( useOrgSid ) ;
scmVehiclePatrolinspection . setPushState ( dto . getPushState ( ) ) ;
scmVehiclePatrolinspection . setState ( 0 ) ;
scmVehiclePatrolinspectionService . save ( scmVehiclePatrolinspection ) ;
} else {
if ( "002" . equals ( scmVehiclePatrolinspection . getPatrolInspectionStateKey ( ) ) ) {
scmVehiclePatrolinspection = new ScmVehiclePatrolinspection ( ) ;
scmVehiclePatrolinspection . setVinNo ( dto . getVinNo ( ) ) ;
scmVehiclePatrolinspection . setMainSid ( scmVehPatrolinspectionmonthVo . getSid ( ) ) ;
scmVehiclePatrolinspection . setLocation ( dto . getWarehouse ( ) ) ;
scmVehiclePatrolinspection . setLocationSid ( dto . getWarehouseSid ( ) ) ;
scmVehiclePatrolinspection . setPatrolInspectionState ( oneValue ) ;
scmVehiclePatrolinspection . setPatrolInspectionStateKey ( oneKey ) ;
scmVehiclePatrolinspection . setCreateOrgSid ( useOrgSid ) ;
scmVehiclePatrolinspection . setCreateBySid ( dto . getUserSid ( ) ) ;
scmVehiclePatrolinspection . setUseOrgSid ( useOrgSid ) ;
scmVehiclePatrolinspection . setPushState ( dto . getPushState ( ) ) ;
scmVehiclePatrolinspection . setState ( 0 ) ;
scmVehiclePatrolinspectionService . save ( scmVehiclePatrolinspection ) ;
} else {
scmVehiclePatrolinspection . setVinNo ( dto . getVinNo ( ) ) ;
scmVehiclePatrolinspection . setMainSid ( scmVehPatrolinspectionmonthVo . getSid ( ) ) ;
scmVehiclePatrolinspection . setLocation ( dto . getWarehouse ( ) ) ;
scmVehiclePatrolinspection . setLocationSid ( dto . getWarehouseSid ( ) ) ;
scmVehiclePatrolinspection . setPatrolInspectionState ( oneValue ) ;
scmVehiclePatrolinspection . setPatrolInspectionStateKey ( oneKey ) ;
scmVehiclePatrolinspection . setCreateOrgSid ( useOrgSid ) ;
scmVehiclePatrolinspection . setCreateBySid ( dto . getUserSid ( ) ) ;
scmVehiclePatrolinspection . setUseOrgSid ( useOrgSid ) ;
scmVehiclePatrolinspection . setPushState ( dto . getPushState ( ) ) ;
scmVehiclePatrolinspection . setState ( 1 ) ;
int count = baseMapper . selectByMainSidNum ( scmVehiclePatrolinspection . getSid ( ) ) ;
if ( count > 0 ) {
baseMapper . deleteByMainSid ( scmVehiclePatrolinspection . getSid ( ) ) ;
}
scmVehiclePatrolinspectionService . updateById ( scmVehiclePatrolinspection ) ;
}
}
scmVehiclePatrolinspection . setPushState ( dto . getPushState ( ) ) ;
scmVehiclePatrolinspectionService . save ( scmVehiclePatrolinspection ) ;
// 巡检记录列表添加数据
BeanUtil . copyProperties ( dto , scmVehiclePatrolinspectionsheet , "sid" ) ;
ScmWarehouse scmWarehouse = scmWarehouseService . fetchBySid ( dto . getWarehouseSid ( ) ) ;
scmVehiclePatrolinspectionsheet . setDutyName ( scmWarehouse . getLibTubeName ( ) ) ;
@ -513,6 +553,7 @@ public class ScmVehiclePatrolinspectionsheetService extends MybatisBaseService<S
}
save ( scmVehiclePatrolinspectionsheet ) ;
//附件数据添加
scmFileService . deleteByLinkSidAndType ( scmVehiclePatrolinspectionsheet . getSid ( ) , type1 ) ;
List < String > images = dto . getImages ( ) ;
if ( images ! = null ) {
@ -530,7 +571,7 @@ public class ScmVehiclePatrolinspectionsheetService extends MybatisBaseService<S
}
}
}
// 消息推送
List < String > receiveIdList = new ArrayList < > ( ) ;
SysUserVo sysUserVos = sysUserFeign . fetchBySid ( scmWarehouse . getLibTubeSid ( ) ) . getData ( ) ;
Integer id = sysUserVos . getId ( ) ;
@ -542,7 +583,6 @@ public class ScmVehiclePatrolinspectionsheetService extends MybatisBaseService<S
appLiableListDto . setLiableSid ( scmWarehouse . getLibTubeSid ( ) ) ;
recipientSidList . add ( dto . getLiableSid ( ) ) ;
liableList . add ( appLiableListDto ) ;
// 消息推送
AppScmMessageFlowableQuery query = new AppScmMessageFlowableQuery ( ) ;
Map < String , Object > appMap = new HashMap < > ( ) ;
appMap . put ( "sid" , dto . getMainSid ( ) ) ;
@ -557,7 +597,6 @@ public class ScmVehiclePatrolinspectionsheetService extends MybatisBaseService<S
query . setName ( "供应链" ) ;
// 消息推送
messageFeign . sendMessage ( query ) ;
return rb . success ( ) . setMsg ( "添加成功" ) ;
}
// /**