@ -25,6 +25,7 @@ import com.foreverwin.mesnac.meapi.dto.WorkCenterLinkDTO;
import com.foreverwin.mesnac.meapi.model.Router ;
import com.foreverwin.mesnac.meapi.model.Sfc ;
import com.foreverwin.mesnac.meapi.model.ShopOrder ;
import com.foreverwin.mesnac.meapi.model.UserGroup ;
import com.foreverwin.mesnac.meapi.service.* ;
import com.foreverwin.mesnac.meapi.util.StringUtils ;
import com.foreverwin.modular.core.exception.BaseException ;
@ -36,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.web.multipart.MultipartFile ;
import sun.awt.geom.AreaOp ;
import javax.servlet.http.HttpServletRequest ;
import java.io.IOException ;
@ -67,6 +69,8 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
@Autowired
private ShopOrderService shopOrderService ;
@Autowired
private UserGroupService userGroupService ;
@Autowired
private SfcDispatchMapper sfcDispatchMapper ;
@Autowired
private UserResourceService userResourceService ;
@ -86,7 +90,38 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
@Override
public List < SfcDispatchDto > findSfcDispatchList ( SfcDispatchDto sfcDispatchDto ) {
return sfcDispatchMapper . findSfcDispatchList ( sfcDispatchDto ) ;
List < SfcDispatchDto > list = sfcDispatchMapper . findSfcDispatchList ( sfcDispatchDto ) ;
if ( list = = null | | list . size ( ) < = 0 ) {
return list ;
}
//查询用户对应用户组
String site = CommonMethods . getSite ( ) ;
String user = CommonMethods . getUser ( ) ;
String userBo = HandleEnum . USER . getHandle ( site , user ) ;
List < UserGroup > userGroupList = userGroupService . getUserGroupListByUserBo ( userBo ) ;
String role = "ADMINISTRATOR" ;
if ( userGroupList ! = null & & userGroupList . size ( ) > 0 ) {
for ( UserGroup userGroupModel : userGroupList ) {
String userGroup = userGroupModel . getUserGroup ( ) ;
if ( Constants . USER_GROUP_ADMINISTRATOR . equals ( userGroup ) ) {
role = Constants . USER_GROUP_ADMINISTRATOR ;
break ;
} else if ( Constants . USER_GROUP_CJDD . equals ( userGroup ) ) {
role = Constants . USER_GROUP_CJDD ;
break ;
} else if ( Constants . USER_GROUP_ZJH . equals ( userGroup ) ) {
role = Constants . USER_GROUP_ZJH ;
break ;
}
}
}
//赋值用户组
for ( SfcDispatchDto sfcDispatch : list ) {
sfcDispatch . setRole ( role ) ;
}
return list ;
}
@Override
@ -360,6 +395,10 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
message . append ( "派工单[" + dispatchNo + "]的派工状态不是新建,不允许保存" ) ;
continue ;
}
//时间
sfcDispatchDto . setEarliestStartDate ( sfcDispatchDto . getPlannedStartDate ( ) ) ;
sfcDispatchDto . setLatestEndDate ( sfcDispatchDto . getPlannedCompDate ( ) ) ;
}
//派工导入
@ -444,7 +483,7 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
continue ;
}
//派工人员为多个
//派工人员为多个 (只要一个匹配)
String [ ] employeeArray = new String [ 1 ] ;
if ( ! employees . contains ( "," ) ) {
employeeArray [ 0 ] = employees ;
@ -452,7 +491,7 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
employeeArray = employees . split ( "," ) ;
}
Boolean isMatch = false ;
for ( int m = 0 ; m < employeeArray . length ; m + + ) {
String employee = employeeArray [ m ] ;
List < UserResource > singleUserResourceList = usMap . get ( employee ) ;
@ -464,7 +503,6 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
}
Boolean isMatch = false ;
for ( int i = 0 ; i < singleUserResourceList . size ( ) ; i + + ) {
UserResource userResource = singleUserResourceList . get ( i ) ;
if ( resource . equals ( userResource . getResrce ( ) ) ) {
@ -472,12 +510,16 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
break ;
}
}
if ( ! isMatch ) {
flag = false ;
message . append ( seq + + % 3 = = 0 ? "\n" : "| |" ) ;
message . append ( "派工单[" + dispatchNo + "]分配的操作员[" + employee + "]与资源[" + resource + "]不匹配" ) ;
continue ;
}
if ( isMatch ) { break ; }
}
if ( ! isMatch ) {
flag = false ;
message . append ( seq + + % 3 = = 0 ? "\n" : "| |" ) ;
message . append ( "派工单[" + dispatchNo + "]分配的操作员与资源[" + resource + "]都不匹配" ) ;
continue ;
}
}
@ -532,7 +574,7 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
}
shopOrderReleaseService . sfcDispatch ( site , user , workCenter, shopOrderModel, sfcModel , routerList ) ;
shopOrderReleaseService . sfcDispatch ( site , user , shopOrderModel, sfcModel , routerList ) ;
}
@Override