Leon 4 years ago
commit 86e05c1728

@ -76,5 +76,10 @@
<artifactId>commons-net</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
</dependencies>
</project>

@ -44,6 +44,7 @@ public interface AbnormalBillService extends IService<AbnormalBill> {
/**
*
*
* @param abnormalBill
* @param abnormalBillDispose
*/
@ -124,8 +125,13 @@ public interface AbnormalBillService extends IService<AbnormalBill> {
// void deleteFileInDatabase(String ftpPath,String fileName);
/**
*
*
*/
boolean anomalyReportSendMessage(AbnormalBill abnormalBill);
boolean anomalyCreatedAndSendMessage(AbnormalBill abnormalBill,AbnormalBillDispose abnormalBillDispose);
/**
*
*/
String formatMessage(AbnormalBill abnormalBill,String messageType, String site);
}

@ -0,0 +1,15 @@
package com.foreverwin.mesnac.anomaly.service;
/**
* @Description TODO
* @Author zhaojiawei
* @Since 2021-07-22
*/
public interface AnomalyJobService {
/**
*
* @param site
*/
void anomalyJobProcess(String site);
}

@ -7,8 +7,10 @@ import com.foreverwin.mesnac.anomaly.dto.AbnormalBillDisposeDto;
import com.foreverwin.mesnac.anomaly.dto.AbnormalBillDto;
import com.foreverwin.mesnac.anomaly.mapper.AbnormalBillDisposeMapper;
import com.foreverwin.mesnac.anomaly.mapper.AbnormalBillMapper;
import com.foreverwin.mesnac.anomaly.mapper.AbnormalMessageMapper;
import com.foreverwin.mesnac.anomaly.model.*;
import com.foreverwin.mesnac.anomaly.service.*;
import com.foreverwin.mesnac.anomaly.util.ActiveMQUtil;
import com.foreverwin.mesnac.common.constant.Constants;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.helper.NextNumberHelper;
@ -119,6 +121,15 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
private UserGroupMapper userGroupMapper;
@Autowired
private ActiveMQUtil activeMQUtil;
@Autowired
private AbnormalMessageMapper abnormalMessageMapper;
@Autowired
private AbnormalMessageService abnormalMessageService;
@Override
public IPage<AbnormalBill> selectPage(FrontPage<AbnormalBill> frontPage, AbnormalBill abnormalBill) {
QueryWrapper<AbnormalBill> queryWrapper = new QueryWrapper<>();
@ -142,6 +153,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
String message = this.generateAbnormalBill(abnormalBill, abnormalBillDispose, dutyCauseType, dutyType);
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
//发送消息
this.anomalyCreatedAndSendMessage(abnormalBill,null);
return message;
}
@ -196,6 +209,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
//发送消息
this.anomalyCreatedAndSendMessage(abnormalBill,null);
return message;
}
@ -203,21 +218,21 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Override
public String anomalyReportDevice(AbnormalBill abnormalBill,AbnormalBillDispose abnormalBillDispose) {
String message = this.generateAbnormalBill(abnormalBill, abnormalBillDispose, null, null);
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
//判断设备异常是否有为处理完成的sfc
if(!StringUtil.isBlank(abnormalBill.getSfc()) ){
List<String> status = new ArrayList<>();
status.add(Constants.PROGRAM_CONFIRM);
status.add(Constants.CANCEL);
status.add(Constants.SHUT_DOWN);
List<AbnormalBill> abnormalBillList = abnormalBillMapper.findCountBySfc(abnormalBill.getSite(), abnormalBill.getType(), abnormalBill.getSfc(), status);
if(abnormalBillList.size() > 1 && !"更新成功".equals(message)){
throw BusinessException.build("设备异常有未处理完成的sfc");
}else if(abnormalBillList.size() > 1 ){
if(abnormalBillList.size() >= 1 ){
throw BusinessException.build("设备异常有未处理完成的sfc");
}
}
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
this.saveOrUpdate(abnormalBill);
//发送消息
this.anomalyCreatedAndSendMessage(abnormalBill,null);
return message;
}
@ -311,6 +326,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalBill.setResponseDateTime(now);
abnormalBill.setStatus(Constants.RESPONSE);
this.saveOrUpdate(abnormalBill);
//发送消息
this.anomalyCreatedAndSendMessage(abnormalBillMapper.selectById(abnormalBill.getHandle()),null);
}
@Override
@ -354,9 +371,12 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalBillDispose.setResolveDateTime(now);
abnormalBillDispose.setResolveUser(user);
abnormalBill.setStatus(Constants.PROGRAM_CONFIRM);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
this.saveOrUpdate(abnormalBill);
this.anomalyCreatedAndSendMessage(abnormalBillMapper.selectById(abnormalBill.getHandle()),abnormalBillDispose);
}
@Override
@ -378,6 +398,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
nwaUserService.checkUserGroup(abnormalBillDispose.getDutySendUserGroup());
this.saveOrUpdate(abnormalBill);
this.anomalyCreatedAndSendMessage(abnormalBillMapper.selectById(abnormalBill.getHandle()),abnormalBillDispose);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
}
@ -399,43 +420,56 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalBill.setStatus(Constants.SHUT_DOWN);
abnormalBillDispose.setClosedUser(user);
abnormalBillDispose.setClosedDateTime(now);
this.anomalyCreatedAndSendMessage(abnormalBill,abnormalBillDispose);
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
}
@Override
public String generateAbnormalBill(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose,List<String> dutyCauseType,List<String> dutyType) {
String site = CommonMethods.getSite();
String message = null;
//返回的消息
String message = "保存成功";
LocalDateTime currentTime = LocalDateTime.now();
String user = CommonMethods.getUser();
//如果前台传过来的异常单为空的话,则抛出一个异常
if(StringUtil.isBlank(abnormalBill.getAbnormalNo())) {
throw BusinessException.build("异常单号不存在");
}
//设置异常单的handle
abnormalBill.setHandle(HandleEnum.Z_ABNORMAL_BILL.getHandle(site,abnormalBill.getAbnormalNo()));
//更新的时候,判断该异常单的状态是否为新建
AbnormalBill abnormalBill1 = abnormalBillMapper.selectById(abnormalBill.getHandle());
if(abnormalBill1 != null){
if(!"N".equals(abnormalBill1.getStatus()) && StringUtil.isBlank(abnormalBillDispose.getClosedUser())){
throw BusinessException.build("该异常单已经被人处理,不能进行更新");
}
message = "更新成功";
}else{
message = "保存成功";
if(abnormalBillMapper.selectById(abnormalBill.getHandle()) != null &&
!Constants.SHUT_DOWN.equals(abnormalBill.getStatus())){
throw BusinessException.build("该异常单已经提交,请清空后提交");
}
abnormalBillDispose.setClosedUser(null);
/**
*
*/
//更新的时候,判断该异常单的状态是否为新建,如果为新建,则可以修改,否则就不能进行修改
// AbnormalBill abnormalBill1 = abnormalBillMapper.selectById(abnormalBill.getHandle());
// if(abnormalBill1 != null){
// if(!"N".equals(abnormalBill1.getStatus()) && StringUtil.isBlank(abnormalBillDispose.getClosedUser())){
// throw BusinessException.build("该异常单已经被人处理,不能进行更新");
// }
// message = "更新成功";
// }else{
// message = "保存成功";
// }
// abnormalBillDispose.setClosedUser(null);
//设置异常单详细表的handle和abnormalBillBo
abnormalBillDispose.setAbnormalBillBo(abnormalBill.getHandle());
abnormalBillDispose.setHandle(HandleEnum.Z_ABNORMAL_BILL_DISPOSE.getHandle(site,abnormalBill.getAbnormalNo()));
//设置责任划分填报人和填报时间
if(StringUtil.isBlank(abnormalBillDispose.getDutyUser())){
abnormalBillDispose.setDutyUser(user);
abnormalBillDispose.setDutyDateTime(currentTime);
}
ArrayList<AbnormalCause> causeTypes = new ArrayList<>();
abnormalBillDispose.setDutyUser(user);
abnormalBillDispose.setDutyDateTime(currentTime);
//判断原因分类是否为空,如果不为空把它放进Z_ABNORMAL_CAUSE表里面
ArrayList<AbnormalCause> causeTypes = new ArrayList<>();
if(dutyCauseType != null && dutyCauseType.size() >= 1){
for(String cause:dutyCauseType){
AbnormalCause abnormalCause = new AbnormalCause();
@ -458,9 +492,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
causeTypes.add(abnormalCause);
}
}
/**
*
*/
//判断工序编码是否传递错误
if(!StringUtil.isBlank(abnormalBill.getOperation())){
QueryWrapper<Operation> operationQueryWrapper = new QueryWrapper<Operation>();
operationQueryWrapper.eq("OPERATION",abnormalBill.getOperation())
@ -471,9 +504,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
}
/**
*
*/
//判断设备传递的不良代码是否有误
if(!StringUtil.isBlank(abnormalBill.getNcCode()) && Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
List<String> ncCodes = Arrays.asList(abnormalBill.getNcCode().split(","));
Integer length = ncCodeMapper.checkNcCode(ncCodes,site,"FAILURE");
@ -528,6 +559,10 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
if(StringUtil.isBlank(abnormalBill.getSfc()) && !Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())) {
throw BusinessException.build("产品条码不能为空");
}
//异常提报的时候,提报用户不可以为空
if(StringUtil.isBlank(abnormalBill.getReportSendUserGroup()) ) {
throw BusinessException.build("提报用户组不能为空");
}
// }else if(!StringUtil.isBlank(abnormalBill.getSfc()) && Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
// AbnormalBill abnormalBill2 = new AbnormalBill();
// abnormalBill2.setType(abnormalBill.getType());
@ -568,7 +603,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
throw BusinessException.build("问题数量或不良品数量必须为一个正整数");
}
//判断输入的用户组是否正确,并返回对应的用户
//判断输入的责任划分用户组是否正确,并返回对应的用户
nwaUserService.checkUserGroup(abnormalBillDispose.getDutySendUserGroup());
//插入原因分类和责任分类
if(dutyTypes.size() > 0){
@ -582,10 +617,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
this.fileUpload(abnormalBill);
}
this.anomalyReportSendMessage(abnormalBill);
// this.anomalyCreatedAndSendMessage(abnormalBill,null);
return message;
}
@ -604,6 +636,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
abnormalBill.setCancelUser(CommonMethods.getUser());
abnormalBill.setCancelDateTime(now);
this.anomalyCreatedAndSendMessage(abnormalBill,null);
this.saveOrUpdate(abnormalBill);
return true;
}
@ -678,9 +711,11 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
if(!Constants.RESPONSE.equals(abnormalBill.getStatus())){
throw BusinessException.build("该异常单的状态必须是响应中才能转维修");
}
if(StringUtil.isBlank(abnormalBillDispose.getAbnormalMethod())){
throw BusinessException.build("转维修时方案分类必须填写");
}
abnormalBill.setHandle(HandleEnum.Z_ABNORMAL_BILL.getHandle(site,abnormalBill.getAbnormalNo()));
abnormalBill.setStatus(Constants.SHUT_DOWN);
abnormalBillDispose.setResolveUser(user);
@ -739,18 +774,19 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
if(!HandleEnum.SHOP_ORDER.getHandle(site,shopOrder).equals(sfc1.getShopOrderBo())){
throw new BaseException("工单传递有误");
}
// Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(site, resource));
// if(resrce == null){
// throw new BaseException("资源传递有误");
// }
}
this.anomalyReportDevice(abnormalBill,abnormalBillDispose);
}
/**
*
* @param abnormalBill
* @param abnormalBillDispose
* @return
*/
@Override
public boolean anomalyReportSendMessage(AbnormalBill abnormalBill){
//得到异常提报用户组下面的用户
List<NwaUser> sendUsersList = nwaUserService.checkUserGroup(abnormalBill.getReportSendUserGroup());
public boolean anomalyCreatedAndSendMessage(AbnormalBill abnormalBill,AbnormalBillDispose abnormalBillDispose){
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
String locale = LocaleContextHolder.getLocale().getLanguage();
@ -770,37 +806,123 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
case "Z"://质量异常
abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_QUALITY);
break;
case "Q":
case "Q"://其他异常
abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_OTHER);
break;
case "S":
case "S"://设备异常
abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_RESOURCE);
break;
}
//设置发送的用户组
abnormalMessage.setSendUserGroup(abnormalBill.getReportSendUserGroup());
//设置发送用户,响应时设置
// StringBuilder sendUser = new StringBuilder();
// for (int i = 0; i < sendUsersList.size(); i++) {
// if(i == (sendUsersList.size() - 1)){
// sendUser.append(sendUsersList.get(i));
// }else{
// sendUser.append(sendUsersList.get(i)).append(",");
// }
// }
// abnormalMessage.setSendUser(sendUser.toString());
switch (abnormalBill.getStatus()){
case Constants.NEW://新建
abnormalMessage.setSendUserGroup(abnormalBill.getReportSendUserGroup());
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
break;
case Constants.RESPONSE://响应中,设置响应超时的用户的发送的用户组为提报时要升级的用户组
QueryWrapper<AbnormalMessage> wrapper = new QueryWrapper<>();
AbnormalMessage abnormalMessage1 = new AbnormalMessage();
abnormalMessage1.setSite(site);
abnormalMessage1.setAbnormalBillBo(abnormalBill.getHandle());
abnormalMessage1.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
wrapper.setEntity(abnormalMessage1);
AbnormalMessage _abnormalMessage = abnormalMessageMapper.selectOne(wrapper);
abnormalMessage.setUpUserGroup(_abnormalMessage.getUpUserGroup());
abnormalMessage.setGrade(_abnormalMessage.getGrade());
abnormalMessage.setUpDateTime(_abnormalMessage.getUpDateTime());
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_RESPONSE);
break;
case Constants.CORRECTION_CONFIRM://纠纷确认
abnormalMessage.setSendUserGroup(abnormalBillDispose.getDutySendUserGroup());
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_CORRECTION_CONFIRM);
break;
case Constants.PROGRAM_CONFIRM://方案确认
abnormalMessage.setSendUser(abnormalBillDispose.getResolveSendUser());
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_PROGRAM_CONFIRM);
break;
case Constants.CANCEL://取消
abnormalMessage.setSendUserGroup(abnormalBill.getCancelSendUserGroup());
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_CANCEL);
break;
case Constants.SHUT_DOWN:
break;
}
String message = this.formatMessage(abnormalBill, abnormalMessage.getMessageType(), site);
//得到消息触发的时间
abnormalMessage.setResponseDateTime(now);
//得到要发送的消息
abnormalMessage.setContent(message);
//得到升级的用户组
//新建有、响应没有、纠防确认有、方案确认没有、取消没有、关闭没有
if(Constants.NEW.equals(abnormalBill.getStatus()) || Constants.CORRECTION_CONFIRM.equals(abnormalBill.getStatus())){
abnormalMessage.setUpUserGroup(abnormalMessage.getSendUserGroup()+"_UP");
//得到升级的时间和等级
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(site, abnormalMessage.getSendUserGroup());
abnormalMessage.setUpDateTime(abnormalMessage.getResponseDateTime().plusMinutes(Integer.parseInt(customFieldByGroup.getMessageNoticeTime())));
abnormalMessage.setGrade(customFieldByGroup.getMessageNoticeLevel());
//得到升级的消息类型
abnormalMessage.setUpMessageType(abnormalMessage.getMessageType());
}
//得到异常节点
//abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
//设置状态新建是Y响应为N纠防确认是N方案确认是Y
if(Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getAbnormalNode()) ||
Constants.ABNORMAL_MESSAGE_CORRECTION_CONFIRM.equals(abnormalMessage.getAbnormalNode())){
abnormalMessage.setStatus("N");
}else{
abnormalMessage.setStatus("Y");
}
abnormalMessage.setCreatedUser(user);
abnormalMessage.setCreatedDateTime(now);
abnormalMessage.setModifiedUser(user);
abnormalMessage.setModifiedDateTime(now);
//判断,如果是方案确认,则发送用户,否则,除了节点是响应之外,则发送用户
if(Constants.ABNORMAL_MESSAGE_PROGRAM_CONFIRM.equals(abnormalMessage.getAbnormalNode())){
String sendUsers = abnormalMessage.getSendUser().replace(',', '|');
activeMQUtil.wechatSendMessage(sendUsers,abnormalMessage.getContent());
}else if(!Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getAbnormalNode())){
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(abnormalMessage.getSendUserGroup());
StringBuilder sendUsers = new StringBuilder();
for (int i = 0; i < nwaUsers.size(); i++) {
if(i == (nwaUsers.size() - 1)){
sendUsers.append(nwaUsers.get(i));
}else{
sendUsers.append(nwaUsers.get(i)).append("|");
}
}
activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent());
}
abnormalMessageService.saveOrUpdate(abnormalMessage);
return true;
}
@Override
public String formatMessage(AbnormalBill abnormalBill,String messageType, String site) {
//找到消息内容
String locale = LocaleContextHolder.getLocale().getLanguage();
MessageType messageTypeEntity = new MessageType();
messageTypeEntity.setSite(site);
messageTypeEntity.setMessageType(abnormalMessage.getMessageType());
messageTypeEntity.setMessageType(messageType);
QueryWrapper<MessageType> messageTypeQueryWrapper = new QueryWrapper<MessageType>();
messageTypeQueryWrapper.setEntity(messageTypeEntity);
MessageType messageType = messageTypeMapper.selectOne(messageTypeQueryWrapper);
MessageType sendMessageType = messageTypeMapper.selectOne(messageTypeQueryWrapper);
if(messageType == null){
throw new BaseException("异常提报时找不到要发送的消息类型");
}
//格式化消息
String body = messageType.getBody();
String body = sendMessageType.getBody();
//替换消息类型中的参数
Map<String, String> messageMap = new HashMap<>();
//根据车间找到对应车间的描述
@ -813,49 +935,19 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
Item _item = itemMapper.selectById(locale, abnormalBill.getItemBo());
String item = _item.getItem() + "/" + _item.getDescription();
messageMap.put("WORKCENTER",workCenter.getDescription());
messageMap.put("WORKCENTER_LIN",line.getDescription());
messageMap.put("PROJECT",projectNo.getItemNumber());
if(workCenter != null){
messageMap.put("WORKCENTER",workCenter.getDescription());
}
if(line != null){
messageMap.put("WORKCENTER_LIN",line.getDescription());
}
if(projectNo != null){
messageMap.put("PROJECT",projectNo.getItemNumber());
}
messageMap.put("SHOPORDER",abnormalBill.getWorkCenter());
messageMap.put("ITEM",item);
String message = StringUtils.format(body, messageMap);
//得到要发送的消息
abnormalMessage.setContent(message);
//得到升级的用户组
// List<String> _upSendUserGroups = Arrays.asList(abnormalMessage.getSendUserGroup().split(","));
// for(int i = 0; i < _upSendUserGroups.size(); i++){
// _upSendUserGroups.set(i,_upSendUserGroups.get(i)+"_UP");
// }
// List<UserGroup> upSendUserGroups = userGroupMapper.getUserGroupListByGroups(site, _upSendUserGroups);
// if(upSendUserGroups != null && upSendUserGroups.size() > 0){
// abnormalMessage.setUpUserGroup(upSendUserGroups.get(0).getUserGroup());
// }
//得到升级的用户组
abnormalMessage.setUpUserGroup(abnormalMessage.getSendUserGroup()+"_UP");
//得到升级的消息类型
abnormalMessage.setUpMessageType(abnormalMessage.getMessageType());
//得到消息触发的时间
abnormalMessage.setResponseDateTime(now);
//得到升级的时间和等级
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(site, abnormalMessage.getSendUserGroup());
abnormalMessage.setUpDateTime(abnormalMessage.getResponseDateTime().plusMinutes(Integer.parseInt(customFieldByGroup.getMessageNoticeTime())));
abnormalMessage.setGrade(customFieldByGroup.getMessageNoticeLevel());
//得到异常节点
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
//设置状态
if(Constants.ABNORMAL_MESSAGE_REPORT.equals(abnormalMessage.getAbnormalNode())){
abnormalMessage.setStatus("Y");
}else{
abnormalMessage.setStatus("N");
}
abnormalMessage.setCreatedUser(user);
abnormalMessage.setCreatedDateTime(now);
abnormalMessage.setModifiedUser(user);
abnormalMessage.setModifiedDateTime(now);
return false;
//格式化之后的消息
return StringUtils.format(body, messageMap);
}

@ -0,0 +1,122 @@
package com.foreverwin.mesnac.anomaly.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.foreverwin.mesnac.anomaly.mapper.AbnormalBillMapper;
import com.foreverwin.mesnac.anomaly.mapper.AbnormalMessageMapper;
import com.foreverwin.mesnac.anomaly.model.AbnormalBill;
import com.foreverwin.mesnac.anomaly.model.AbnormalMessage;
import com.foreverwin.mesnac.anomaly.service.AbnormalBillService;
import com.foreverwin.mesnac.anomaly.service.AbnormalMessageService;
import com.foreverwin.mesnac.anomaly.service.AnomalyJobService;
import com.foreverwin.mesnac.anomaly.util.ActiveMQUtil;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.meapi.model.NwaUser;
import com.foreverwin.mesnac.meapi.service.NwaUserService;
import com.foreverwin.modular.core.util.CommonMethods;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
/**
* @Description TODO
* @Author zhaojiawei
* @Since 2021-07-22
*/
public class AnomalyJobServiceImpl implements AnomalyJobService {
@Autowired
private AbnormalMessageService abnormalMessageService;
@Autowired
private AbnormalMessageMapper abnormalMessageMapper;
@Autowired
private AbnormalBillMapper abnormalBillMapper;
@Autowired
private AbnormalBillService abnormalBillService;
@Autowired
private ActiveMQUtil activeMQUtil;
@Autowired
private NwaUserService nwaUserService;
@Override
public void anomalyJobProcess(String site) {
LocalDateTime now = LocalDateTime.now();
String user = CommonMethods.getUser();
//找到状态为N并且升级时间大于当前时间
QueryWrapper<AbnormalMessage> abnormalMessageQueryWrapper = new QueryWrapper<>();
abnormalMessageQueryWrapper.eq("STATUS","N");
abnormalMessageQueryWrapper.gt("UP_DATE_TIME",now);
List<AbnormalMessage> abnormalMessages = abnormalMessageMapper.selectList(abnormalMessageQueryWrapper);
for(AbnormalMessage _abnormalMessage : abnormalMessages){
String uuid = UUID.randomUUID().toString();
AbnormalMessage abnormalMessage = new AbnormalMessage();
//设置abnormalMessage的handle
abnormalMessage.setHandle(uuid);
//设置abnormalMessage的site
abnormalMessage.setSite(_abnormalMessage.getSite());
//设置abnormalMessage的异常单Bo
abnormalMessage.setAbnormalBillBo(_abnormalMessage.getAbnormalBillBo());
//设置abnormalMessage的type
abnormalMessage.setType(_abnormalMessage.getType());
//设置abnormalMessage的message_type
abnormalMessage.setMessageType(_abnormalMessage.getUpMessageType());
//设置发送用户组和升级用户组
if(!StringUtil.isBlank(_abnormalMessage.getUpUserGroup())){
//当前发送用户组就等于升级用户组,升级用户组就等于空
abnormalMessage.setSendUserGroup(abnormalMessage.getUpUserGroup());
abnormalMessage.setUpUserGroup(null);
}
//设置发送用户和升级用户
if(!StringUtil.isBlank(abnormalMessage.getUpUser())){
//当前发送用户就等于升级用户,升级用户就等于空
abnormalMessage.setSendUser(abnormalMessage.getUpUser());
abnormalMessage.setUpUser(null);
}
AbnormalBill abnormalBill = abnormalBillMapper.selectById(abnormalMessage.getAbnormalBillBo());
String message = abnormalBillService.formatMessage(abnormalBill,abnormalMessage.getMessageType(),site);
abnormalMessage.setContent(message);
//设置UP_DATE_TIME、UP_MESSAGE_TYPE、GRADE、RESPONSE_DATE_TIME、ABNORMAL_NODE、STATUS
abnormalMessage.setUpMessageType(null);
abnormalMessage.setUpDateTime(null);
abnormalMessage.setGrade(abnormalMessage.getGrade() + 1);
abnormalMessage.setResponseDateTime(now);
abnormalMessage.setAbnormalNode(_abnormalMessage.getAbnormalNode());
abnormalMessage.setStatus("Y");
//设置时间
abnormalMessage.setCreatedUser(user);
abnormalMessage.setCreatedDateTime(now);
abnormalMessage.setModifiedUser(user);
abnormalMessage.setModifiedDateTime(now);
// if(Constants.ABNORMAL_MESSAGE_PROGRAM_CONFIRM.equals(abnormalMessage.getAbnormalNode())){
// String sendUsers = abnormalMessage.getSendUser().replace(',', '|');
// activeMQUtil.wechatSendMessage(sendUsers,abnormalMessage.getContent());
// }else if(!Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getAbnormalNode())){
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(abnormalMessage.getSendUserGroup());
StringBuilder sendUsers = new StringBuilder();
for (int i = 0; i < nwaUsers.size(); i++) {
if(i == (nwaUsers.size() - 1)){
sendUsers.append(nwaUsers.get(i));
}else{
sendUsers.append(nwaUsers.get(i)).append("|");
}
}
activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent());
// }
abnormalMessageService.saveOrUpdate(abnormalMessage);
}
}
}

@ -0,0 +1,64 @@
package com.foreverwin.mesnac.anomaly.util;
import com.foreverwin.modular.core.exception.BaseException;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import javax.jms.*;
/**
* @Description TODO
* @Author zhaojiawei
* @Since 2021-07-21
*/
@Component
@ConditionalOnProperty(prefix = "activeMq", value = {"enabled"}, matchIfMissing = true)
public class ActiveMQUtil {
@Value("${activeMq.sendWeChatMessage}")
private String weChatUrl;
@Value("${activeMq.queue}")
private String queue;
public void wechatSendMessage(String user, String text) {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(weChatUrl);
Connection connection = null;
Session session = null;
MessageProducer producer = null;
try{
connection = factory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(this.queue);
producer = session.createProducer(destination);
JSONObject jsonObject = new JSONObject();
//jsonObject.put("TO_USER", user);
jsonObject.put("TO_USER", "@all");
jsonObject.put("CONTENT",text);
String sendMessage = jsonObject.toString();
TextMessage textMessage = session.createTextMessage(sendMessage);
producer.send(textMessage);
}catch (Exception e){
throw new BaseException("发送消息失败"+e.getMessage());
}finally {
try {
if (producer != null) {
producer.close();
}
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
}catch (Exception e){
e.printStackTrace();
}
}
}
}

@ -87,6 +87,9 @@ public enum HandleEnum {
/**设备检验任务**/
RESOURCE_INSPECT_TASK("ResourceInspectTaskBo","ResourceInspectTaskBo:{0},{1}"),
/**设备检验任务**/
SPLIT_SFC("SplitSfcBo","SplitSfcBo:{0},{1}"),
/**设备检验任务**/
RESOURCE_REPAIR_TASK("ResourceRepairTaskBo","ResourceRepairTaskBo:{0},{1}"),

@ -218,9 +218,9 @@ public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper,
task.setOperation(operation);
task.setStepId(stepId);
task.setResrce((String) paramMap.get("RESRCE"));
task.setCreateUser((String) paramMap.get("CREATE_USER"));
task.setCreateUser(CommonMethods.getUser());
task.setCreatedDateTime(LocalDateTime.now());
task.setModifyUser((String) paramMap.get("CREATE_USER"));
task.setModifyUser(CommonMethods.getUser());
task.setModifiedDateTime(LocalDateTime.now());
task.setSfcDispatchBo((String) paramMap.get("SFC_DISPATCH_DETAIL_BO"));
task.setSfc(sfc);

@ -72,4 +72,6 @@ ftp:
port: 21
username: zjw
password: zhaojiawei
activeMq:
sendWeChatMessage: tcp://localhost:61616?wireFormat.maxInactivityDuration=0
queue: send.weChat.notice

@ -17,8 +17,17 @@ public class SfcDto extends Sfc {
private String stepId;
private String plannedStartDate;
private String plannedCompDate;
//工作令号
private String workOrder;
public String getWorkOrder() {
return workOrder;
}
public void setWorkOrder(String workOrder) {
this.workOrder = workOrder;
}
public String getStepId() {
return stepId;
}
@ -123,11 +132,4 @@ public class SfcDto extends Sfc {
this.plannedCompDate = plannedCompDate;
}
public String getWorkOrder() {
return workOrder;
}
public void setWorkOrder(String workOrder) {
this.workOrder = workOrder;
}
}

@ -13,6 +13,7 @@ import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import com.sap.me.productdefinition.OperationBOHandle;
import org.eclipse.jetty.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -63,7 +64,9 @@ public class NcGroupServiceImpl extends ServiceImpl<NcGroupMapper, NcGroup> impl
public List<NcGroup> findNgGroupByOperationBo(Operation operation) {
String site = CommonMethods.getSite();
operation.setSite(site);
operation.setHandle("OperationBO"+site+","+operation.getOperation()+",#");
if(StringUtil.isBlank(operation.getOperation())){
operation.setHandle("OperationBO"+site+","+operation.getOperation()+",#");
}
return ncGroupMapper.findNgGroupByOperationBo(operation);
}

@ -0,0 +1,136 @@
package com.foreverwin.mesnac.production.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.production.model.SplitSfc;
import com.foreverwin.mesnac.production.service.SplitSfcService;
import com.foreverwin.modular.core.util.FrontPage;
import com.foreverwin.modular.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*
* @author Philip
* @since 2021-07-20
*/
@RestController
@RequestMapping("/Z-SPLIT-SFC")
public class SplitSfcController {
@Autowired
public SplitSfcService splitSfcService;
@ResponseBody
@GetMapping("/getSfcData")
public R getSfcData(String sfc){
SfcDto result;
result = splitSfcService.getSfcData(sfc);
return R.ok(result);
}
@ResponseBody
@GetMapping("/splitSfc")
public R getSfcData(SfcDto sfcDto){
return R.ok( splitSfcService.splitSfc(sfcDto));
}
/**
* id
*
* @param id
* @return
*/
@ResponseBody
@GetMapping("/{id:.+}")
public R getSplitSfcById(@PathVariable String id) {
return R.ok( splitSfcService.getById(id));
}
/**
*
*
* @return
*/
@ResponseBody
@GetMapping("")
public R getSplitSfcList(SplitSfc splitSfc){
List<SplitSfc> result;
QueryWrapper<SplitSfc> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(splitSfc);
result = splitSfcService.list(queryWrapper);
return R.ok(result);
}
/**
*
*
* @param frontPage
* @return
*/
@ResponseBody
@GetMapping("/page")
public R page(FrontPage<SplitSfc> frontPage, SplitSfc splitSfc){
IPage result;
QueryWrapper<SplitSfc> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(splitSfc);
if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) {
//TODO modify global query
queryWrapper.lambda().and(wrapper -> wrapper
.like(SplitSfc::getHandle, frontPage.getGlobalQuery())
.or().like(SplitSfc::getSite, frontPage.getGlobalQuery())
.or().like(SplitSfc::getSfc, frontPage.getGlobalQuery())
.or().like(SplitSfc::getSplitSfc, frontPage.getGlobalQuery())
.or().like(SplitSfc::getRouter, frontPage.getGlobalQuery())
.or().like(SplitSfc::getCreateUser, frontPage.getGlobalQuery())
);
}
result = splitSfcService.page(frontPage.getPagePlus(), queryWrapper);
return R.ok(result);
}
/**
*
* @param splitSfc
* @return null
*/
@PostMapping
public R save(@RequestBody SplitSfc splitSfc) {
return R.ok(splitSfcService.save(splitSfc));
}
/**
*
* @param splitSfc
* @return null
*/
@PutMapping
public R updateById(@RequestBody SplitSfc splitSfc) {
return R.ok(splitSfcService.updateById(splitSfc));
}
/**
* id
* @param id ID
* @return 0 1
*/
@ResponseBody
@RequestMapping(method = RequestMethod.DELETE, value = "/{id:.+}")
public R removeById(@PathVariable("id") String id){
return R.ok(splitSfcService.removeById(id));
}
/**
*
* @param ids ID
* @return 0 1
*/
@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/delete-batch")
public R removeByIds(List<String> ids){
return R.ok(splitSfcService.removeByIds(ids));
}
}

@ -0,0 +1,33 @@
package com.foreverwin.mesnac.production.dto;
import com.foreverwin.mesnac.production.model.SplitSfc;
public class SplitSfcDto extends SplitSfc {
private String ncCode;
private String routerBo;
private String ncQty;
public String getNcCode() {
return ncCode;
}
public void setNcCode(String ncCode) {
this.ncCode = ncCode;
}
public String getRouterBo() {
return routerBo;
}
public void setRouterBo(String routerBo) {
this.routerBo = routerBo;
}
public String getNcQty() {
return ncQty;
}
public void setNcQty(String ncQty) {
this.ncQty = ncQty;
}
}

@ -69,7 +69,7 @@ public interface SfcCrossMapper extends BaseMapper {
List<SfcDto> getSfcListByResrce(@Param("site") String site, @Param("resrce") String resrce,@Param("locale") String locale);
Integer resourceCheck(@Param("resrceBO")String resrceBO, @Param("dateTime")LocalDateTime dateTime);
SfcDto getInfoBySfc(@Param("sfc")Sfc sfc);
Integer resourceCheck(@Param("site")String site,@Param("resrce")String resrce, @Param("dateTime")LocalDateTime dateTime);
}

@ -0,0 +1,24 @@
package com.foreverwin.mesnac.production.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.production.dto.SplitSfcDto;
import com.foreverwin.mesnac.production.model.SplitSfc;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper
* </p>
*
* @author Philip
* @since 2021-07-20
*/
@Repository
public interface SplitSfcMapper extends BaseMapper<SplitSfc> {
SfcDto getSfcData(@Param("handle") String handle);
SplitSfcDto getAbnormalQty(@Param("site")String site, @Param("sfc")String sfc, @Param("operation") String operation);
}

@ -0,0 +1,169 @@
package com.foreverwin.mesnac.production.model;
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 com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author Philip
* @since 2021-07-20
*/
@TableName("Z_SPLIT_SFC")
public class SplitSfc extends Model<SplitSfc> {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "HANDLE", type = IdType.INPUT)
private String handle;
/**
*
*/
@TableField("SITE")
private String site;
/**
*
*/
@TableField("SFC")
private String sfc;
/**
*
*/
@TableField("SPLIT_SFC")
private String splitSfc;
/**
*
*/
@TableField("SPLIT_QTY")
private BigDecimal splitQty;
/**
* 线
*/
@TableField("ROUTER")
private String router;
/**
*
*/
@TableField("CREATE_USER")
private String createUser;
/**
*
*/
@TableField("CREATED_DATE_TIME")
private LocalDateTime createdDateTime;
public String getHandle() {
return handle;
}
public void setHandle(String handle) {
this.handle = handle;
}
public String getSite() {
return site;
}
public void setSite(String site) {
this.site = site;
}
public String getSfc() {
return sfc;
}
public void setSfc(String sfc) {
this.sfc = sfc;
}
public String getSplitSfc() {
return splitSfc;
}
public void setSplitSfc(String splitSfc) {
this.splitSfc = splitSfc;
}
public BigDecimal getSplitQty() {
return splitQty;
}
public void setSplitQty(BigDecimal splitQty) {
this.splitQty = splitQty;
}
public String getRouter() {
return router;
}
public void setRouter(String router) {
this.router = router;
}
public String getCreateUser() {
return createUser;
}
public void setCreateUser(String createUser) {
this.createUser = createUser;
}
public LocalDateTime getCreatedDateTime() {
return createdDateTime;
}
public void setCreatedDateTime(LocalDateTime createdDateTime) {
this.createdDateTime = createdDateTime;
}
public static final String HANDLE = "HANDLE";
public static final String SITE = "SITE";
public static final String SFC = "SFC";
public static final String SPLIT_SFC = "SPLIT_SFC";
public static final String SPLIT_QTY = "SPLIT_QTY";
public static final String ROUTER = "ROUTER";
public static final String CREATE_USER = "CREATE_USER";
public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME";
@Override
protected Serializable pkVal() {
return this.handle;
}
@Override
public String toString() {
return "SplitSfc{" +
"handle = " + handle +
", site = " + site +
", sfc = " + sfc +
", splitSfc = " + splitSfc +
", splitQty = " + splitQty +
", router = " + router +
", createUser = " + createUser +
", createdDateTime = " + createdDateTime +
"}";
}
}

@ -0,0 +1,33 @@
package com.foreverwin.mesnac.production.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.production.model.SplitSfc;
import com.foreverwin.modular.core.util.FrontPage;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author Philip
* @since 2021-07-20
*/
public interface SplitSfcService extends IService<SplitSfc> {
/**
*
* @param frontPage
* @return
*/
IPage<SplitSfc> selectPage(FrontPage<SplitSfc> frontPage, SplitSfc splitSfc);
List<SplitSfc> selectList(SplitSfc splitSfc);
SfcDto getSfcData(String sfc);
SplitSfc splitSfc(SfcDto sfcDto);
}

@ -173,7 +173,7 @@ public class PodTemplateServiceImpl implements PodTemplateService {
throw new BaseException("资源不能为空");
}
//是否设备点检
sfcCrossService.resourceCheck(HandleEnum.RESOURCE.getHandle(site,resrce));
sfcCrossService.resourceCheck(resrce);
sfcDtoList.forEach(sfcDto -> {
String operation = sfcDto.getOperation();
Operation currentRevisionRef = operationService.getCurrentRevisionRef(site, operation);

@ -77,10 +77,11 @@ public class SfcCrossServiceImpl implements SfcCrossService {
}
@Override
public void resourceCheck(String resrceBO) {
public void resourceCheck(String resrce) {
LocalDateTime now = LocalDateTime.now();
String site = CommonMethods.getSite();
LocalDateTime dateTime = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 0, 0, 0);
Integer integer = sfcCrossMapper.resourceCheck(resrceBO, dateTime);
Integer integer = sfcCrossMapper.resourceCheck(site,resrce, dateTime);
if (integer<1){
throw new BaseException("当前设备点检未完成");
}

@ -0,0 +1,166 @@
package com.foreverwin.mesnac.production.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.util.ExceptionUtil;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.production.dto.SplitSfcDto;
import com.foreverwin.mesnac.production.mapper.SplitSfcMapper;
import com.foreverwin.mesnac.production.model.SplitSfc;
import com.foreverwin.mesnac.production.service.SplitSfcService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.meext.MEServices;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import com.sap.me.nonconformance.*;
import com.sap.me.production.SplitSerializeServiceInterface;
import com.sap.me.production.SplitSfcDetail;
import com.sap.me.production.SplitSfcRequest;
import com.sap.me.production.SplitSfcResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author Philip
* @since 2021-07-20
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class SplitSfcServiceImpl extends ServiceImpl<SplitSfcMapper, SplitSfc> implements SplitSfcService {
@Autowired
private SplitSfcMapper splitSfcMapper;
@Override
public IPage<SplitSfc> selectPage(FrontPage<SplitSfc> frontPage, SplitSfc splitSfc) {
QueryWrapper<SplitSfc> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(splitSfc);
return super.page(frontPage.getPagePlus(), queryWrapper);
}
@Override
public List<SplitSfc> selectList(SplitSfc splitSfc) {
QueryWrapper<SplitSfc> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(splitSfc);
return super.list(queryWrapper);
}
@Override
public SfcDto getSfcData(String sfc) {
String site = CommonMethods.getSite();
String handle = HandleEnum.SFC.getHandle(site, sfc);
//根据sfc找工单等信息
SfcDto sfcData = splitSfcMapper.getSfcData(handle);
if (sfcData==null){
throw new BaseException("未找到产品条码信息");
}
String operation = sfcData.getOperation();
//查询质量异常记录数量
SplitSfcDto sfcDto=splitSfcMapper.getAbnormalQty(site,sfc,operation);
if (sfcDto==null){
throw new BaseException("未找到方案确认的质量异常");
}
sfcData.setQty(Double.valueOf(sfcDto.getNcQty()));
return sfcData;
}
@Override
public SplitSfc splitSfc(SfcDto sfcDto){
String site = CommonMethods.getSite();
String sfc = sfcDto.getSfc();
String handle = HandleEnum.SFC.getHandle(site, sfc);
BigDecimal splitQty = new BigDecimal(sfcDto.getQty());
//根据sfc找工单等信息
SfcDto sfcData = splitSfcMapper.getSfcData(handle);
String operation = sfcData.getOperation();
if (sfcData==null){
throw new BaseException("未找到产品条码信息");
}
//查询质量异常记录数量 处置工艺路线及不良代码
SplitSfcDto splitSfcDto=splitSfcMapper.getAbnormalQty(site,sfc,operation);
String routerBo = splitSfcDto.getRouterBo();
String ncCode = splitSfcDto.getNcCode();
if (StringUtil.isBlank(routerBo)){
throw new BaseException("异常处置未选择处置工艺路线");
}
if (StringUtil.isBlank(ncCode)){
throw new BaseException("异常处置未选择不良代码");
}
BigDecimal sfcQty = new BigDecimal(sfcData.getQty());
if (new BigDecimal(splitSfcDto.getNcQty()).compareTo(sfcQty)>=0){
throw new BaseException("质量异常数量不小于于产品条码的数量,不能拆分");
}
if (splitQty.compareTo(new BigDecimal(splitSfcDto.getNcQty()))>0){
throw new BaseException("拆分数量大于质量异常数量的数量,不能拆分");
}
String[] splitNcCode = ncCode.split(",");
SplitSfcRequest splitSfcRequest=new SplitSfcRequest();
try {
SplitSerializeServiceInterface splitService = MEServices.create("com.sap.me.production", "SplitSerializeService",site);
NCProductionServiceInterface ncProductionService = MEServices.create("com.sap.me.nonconformance", "NCProductionService",site);
//拆sfc
List<SplitSfcDetail> newList=new ArrayList<>();
SplitSfcDetail splitDetail=new SplitSfcDetail();
splitDetail.setQuantity(splitQty);
newList.add(splitDetail);
splitSfcRequest.setNewSfcList(newList);
splitSfcRequest.setSfcRef(HandleEnum.SFC.getHandle(site,sfc));
Collection<SplitSfcResponse> splitSfcResponses = splitService.splitSfc(splitSfcRequest);
SplitSfcResponse splitSfcResponse = splitSfcResponses.iterator().next();
String newSfcRef = splitSfcResponse.getNewSfcRef();
//记录不合格
CreateNCRequest createNCRequest=new CreateNCRequest();
createNCRequest.setQty(splitQty);
createNCRequest.setSfcRef(newSfcRef);
ProductionContext productionContext=new ProductionContext();
StepIdentifier stepIdentifier=new StepIdentifier();
stepIdentifier.setStepId(sfcData.getStepId());
stepIdentifier.setOperationId(sfcData.getOperation());
productionContext.setStepIdentifier(stepIdentifier);
createNCRequest.setProdCtx(productionContext);
createNCRequest.setNcCodeRef(HandleEnum.NC_CODE.getHandle(site,splitNcCode[0]));
ncProductionService.createNC(createNCRequest);
//不合格处置特殊工艺路线
DispositionMultipleSfcsRequest dispositionSfcsRequest=new DispositionMultipleSfcsRequest();
List<String> sfcs=new ArrayList<>();
sfcs.add(newSfcRef);
dispositionSfcsRequest.setSfcs(sfcs);
dispositionSfcsRequest.setBypassStepValidation(true);
DispositionSelection dispositionSelection=new DispositionSelection();
dispositionSelection.setRouterRef(routerBo);
dispositionSfcsRequest.setDispositionSelection(dispositionSelection);
ncProductionService.dispositionMultipleSfcs(dispositionSfcsRequest);
SplitSfc splitSfc=new SplitSfc();
String newSfc = StringUtil.trimHandle(newSfcRef);
splitSfc.setHandle(HandleEnum.SPLIT_SFC.getHandle(site,newSfc));
splitSfc.setSite(site);
splitSfc.setSfc(sfc);
splitSfc.setSplitSfc(newSfc);
splitSfc.setSplitQty(splitQty);
splitSfc.setRouter(StringUtil.trimHandle(routerBo));
splitSfc.setCreateUser(CommonMethods.getUser());
splitSfc.setCreatedDateTime(LocalDateTime.now());
save(splitSfc);
return splitSfc;
} catch (Exception e) {
ExceptionUtil.throwException(e);
}
return null;
}
}

@ -160,7 +160,7 @@ WHERE sfc.site = #{site} and
</select>
<select id="resourceCheck" resultType="java.lang.Integer">
SELECT count(HANDLE) FROM Z_RESOURCE_INSPECT_TASK zrit WHERE RESOURCE_BO=#{resrceBO} AND CATEGORY='DM' AND STATUS='COMPLETE' AND "RESULT"='OK' AND CREATED_DATE_TIME>=#{dateTime}
SELECT count(HANDLE) FROM Z_RESOURCE_INSPECT_TASK zrit WHERE site=#{site} and RESRCE=#{resrce} AND CATEGORY='DM' AND STATUS='COMPLETE' AND "RESULT"='OK' AND CREATED_DATE_TIME>=#{dateTime}
</select>
<select id="getInfoBySfc" resultType="com.foreverwin.mesnac.meapi.dto.SfcDto">

@ -0,0 +1,385 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.foreverwin.mesnac.production.mapper.SplitSfcMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.foreverwin.mesnac.production.model.SplitSfc">
<id column="HANDLE" property="handle" />
<result column="SITE" property="site" />
<result column="SFC" property="sfc" />
<result column="SPLIT_SFC" property="splitSfc" />
<result column="SPLIT_QTY" property="splitQty" />
<result column="ROUTER" property="router" />
<result column="CREATE_USER" property="createUser" />
<result column="CREATED_DATE_TIME" property="createdDateTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
HANDLE, SITE, SFC, SPLIT_SFC, SPLIT_QTY, ROUTER, CREATE_USER, CREATED_DATE_TIME
</sql>
<!-- BaseMapper标准查询/修改/删除 -->
<select id="selectById" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include> FROM Z_SPLIT_SFC WHERE HANDLE=#{handle}
</select>
<select id="selectByMap" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
FROM Z_SPLIT_SFC
<if test="cm!=null and !cm.isEmpty">
<where>
<foreach collection="cm.keys" item="k" separator="AND">
<if test="cm[k] != null">
${k} = #{cm[${k}]}
</if>
</foreach>
</where>
</if>
</select>
<select id="selectBatchIds" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
FROM Z_SPLIT_SFC WHERE HANDLE IN (
<foreach item="item" index="index" collection="coll" separator=",">#{item}
</foreach>)
</select>
<select id="selectOne" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include> FROM Z_SPLIT_SFC
<where>
<if test="ew.entity.handle!=null">
HANDLE=#{ew.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
<if test="ew.entity.splitSfc!=null"> AND SPLIT_SFC=#{ew.entity.splitSfc}</if>
<if test="ew.entity.splitQty!=null"> AND SPLIT_QTY=#{ew.entity.splitQty}</if>
<if test="ew.entity.router!=null"> AND ROUTER=#{ew.entity.router}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
</where>
</select>
<select id="selectCount" resultType="Integer">
SELECT COUNT(1) FROM Z_SPLIT_SFC
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
<if test="ew.entity.splitSfc!=null"> AND SPLIT_SFC=#{ew.entity.splitSfc}</if>
<if test="ew.entity.splitQty!=null"> AND SPLIT_QTY=#{ew.entity.splitQty}</if>
<if test="ew.entity.router!=null"> AND ROUTER=#{ew.entity.router}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectList" resultMap="BaseResultMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SPLIT_SFC
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
<if test="ew.entity.splitSfc!=null"> AND SPLIT_SFC=#{ew.entity.splitSfc}</if>
<if test="ew.entity.splitQty!=null"> AND SPLIT_QTY=#{ew.entity.splitQty}</if>
<if test="ew.entity.router!=null"> AND ROUTER=#{ew.entity.router}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectMaps" resultType="HashMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SPLIT_SFC
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
<if test="ew.entity.splitSfc!=null"> AND SPLIT_SFC=#{ew.entity.splitSfc}</if>
<if test="ew.entity.splitQty!=null"> AND SPLIT_QTY=#{ew.entity.splitQty}</if>
<if test="ew.entity.router!=null"> AND ROUTER=#{ew.entity.router}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectObjs" resultType="Object">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SPLIT_SFC
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
<if test="ew.entity.splitSfc!=null"> AND SPLIT_SFC=#{ew.entity.splitSfc}</if>
<if test="ew.entity.splitQty!=null"> AND SPLIT_QTY=#{ew.entity.splitQty}</if>
<if test="ew.entity.router!=null"> AND ROUTER=#{ew.entity.router}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectPage" resultMap="BaseResultMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SPLIT_SFC
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
<if test="ew.entity.splitSfc!=null"> AND SPLIT_SFC=#{ew.entity.splitSfc}</if>
<if test="ew.entity.splitQty!=null"> AND SPLIT_QTY=#{ew.entity.splitQty}</if>
<if test="ew.entity.router!=null"> AND ROUTER=#{ew.entity.router}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<select id="selectMapsPage" resultType="HashMap">
SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SPLIT_SFC
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
<if test="ew.entity.splitSfc!=null"> AND SPLIT_SFC=#{ew.entity.splitSfc}</if>
<if test="ew.entity.splitQty!=null"> AND SPLIT_QTY=#{ew.entity.splitQty}</if>
<if test="ew.entity.router!=null"> AND ROUTER=#{ew.entity.router}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</select>
<insert id="insert" parameterType="com.foreverwin.mesnac.production.model.SplitSfc">
INSERT INTO Z_SPLIT_SFC
<trim prefix="(" suffix=")" suffixOverrides=",">
HANDLE,
<if test="site!=null">SITE,</if>
<if test="sfc!=null">SFC,</if>
<if test="splitSfc!=null">SPLIT_SFC,</if>
<if test="splitQty!=null">SPLIT_QTY,</if>
<if test="router!=null">ROUTER,</if>
<if test="createUser!=null">CREATE_USER,</if>
<if test="createdDateTime!=null">CREATED_DATE_TIME,</if>
</trim> VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
#{handle},
<if test="site!=null">#{site},</if>
<if test="sfc!=null">#{sfc},</if>
<if test="splitSfc!=null">#{splitSfc},</if>
<if test="splitQty!=null">#{splitQty},</if>
<if test="router!=null">#{router},</if>
<if test="createUser!=null">#{createUser},</if>
<if test="createdDateTime!=null">#{createdDateTime},</if>
</trim>
</insert>
<insert id="insertAllColumn" parameterType="com.foreverwin.mesnac.production.model.SplitSfc">
INSERT INTO Z_SPLIT_SFC
<trim prefix="(" suffix=")" suffixOverrides=",">
<include refid="Base_Column_List"></include>
</trim> VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
#{handle},
#{site},
#{sfc},
#{splitSfc},
#{splitQty},
#{router},
#{createUser},
#{createdDateTime},
</trim>
</insert>
<update id="updateById">
UPDATE Z_SPLIT_SFC <trim prefix="SET" suffixOverrides=",">
<if test="et.site!=null">SITE=#{et.site},</if>
<if test="et.sfc!=null">SFC=#{et.sfc},</if>
<if test="et.splitSfc!=null">SPLIT_SFC=#{et.splitSfc},</if>
<if test="et.splitQty!=null">SPLIT_QTY=#{et.splitQty},</if>
<if test="et.router!=null">ROUTER=#{et.router},</if>
<if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
<if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
</trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
</update>
<update id="updateAllColumnById">
UPDATE Z_SPLIT_SFC <trim prefix="SET" suffixOverrides=",">
SITE=#{et.site},
SFC=#{et.sfc},
SPLIT_SFC=#{et.splitSfc},
SPLIT_QTY=#{et.splitQty},
ROUTER=#{et.router},
CREATE_USER=#{et.createUser},
CREATED_DATE_TIME=#{et.createdDateTime},
</trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if>
</update>
<update id="update">
UPDATE Z_SPLIT_SFC <trim prefix="SET" suffixOverrides=",">
<if test="et.site!=null">SITE=#{et.site},</if>
<if test="et.sfc!=null">SFC=#{et.sfc},</if>
<if test="et.splitSfc!=null">SPLIT_SFC=#{et.splitSfc},</if>
<if test="et.splitQty!=null">SPLIT_QTY=#{et.splitQty},</if>
<if test="et.router!=null">ROUTER=#{et.router},</if>
<if test="et.createUser!=null">CREATE_USER=#{et.createUser},</if>
<if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if>
</trim>
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
HANDLE=#{ew.entity.handle}
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
<if test="ew.entity.splitSfc!=null"> AND SPLIT_SFC=#{ew.entity.splitSfc}</if>
<if test="ew.entity.splitQty!=null"> AND SPLIT_QTY=#{ew.entity.splitQty}</if>
<if test="ew.entity.router!=null"> AND ROUTER=#{ew.entity.router}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</update>
<delete id="deleteById">
DELETE FROM Z_SPLIT_SFC WHERE HANDLE=#{handle}
</delete>
<delete id="deleteByMap">
DELETE FROM Z_SPLIT_SFC
<if test="cm!=null and !cm.isEmpty">
<where>
<foreach collection="cm.keys" item="k" separator="AND">
<if test="cm[k] != null">
${k} = #{cm[${k}]}
</if>
</foreach>
</where>
</if>
</delete>
<delete id="delete">
DELETE FROM Z_SPLIT_SFC
<where>
<if test="ew!=null">
<if test="ew.entity!=null">
<if test="ew.entity.handle!=null">
HANDLE=#{ew.entity.handle}
</if>
<if test="ew.entity.site!=null"> AND SITE=#{ew.entity.site}</if>
<if test="ew.entity.sfc!=null"> AND SFC=#{ew.entity.sfc}</if>
<if test="ew.entity.splitSfc!=null"> AND SPLIT_SFC=#{ew.entity.splitSfc}</if>
<if test="ew.entity.splitQty!=null"> AND SPLIT_QTY=#{ew.entity.splitQty}</if>
<if test="ew.entity.router!=null"> AND ROUTER=#{ew.entity.router}</if>
<if test="ew.entity.createUser!=null"> AND CREATE_USER=#{ew.entity.createUser}</if>
<if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
</if>
</delete>
<delete id="deleteBatchIds">
DELETE FROM Z_SPLIT_SFC WHERE HANDLE IN (
<foreach item="item" index="index" collection="coll" separator=",">#{item}
</foreach>)
</delete>
<!-- BaseMapper标准查询/修改/删除 -->
<select id="getSfcData" resultType="com.foreverwin.mesnac.meapi.dto.SfcDto">
SELECT SO.SHOP_ORDER,cf.VALUE WORK_ORDER,OP.OPERATION,ss.STEP_ID,s.qty FROM SFC S
JOIN SHOP_ORDER SO ON so.HANDLE=S.SHOP_ORDER_BO
LEFT JOIN CUSTOM_FIELDS CF ON cf.HANDLE=s.SHOP_ORDER_BO AND CF."ATTRIBUTE"='WORK_ORDER'
JOIN SFC_ROUTING SR ON s.HANDLE=sr.SFC_BO
JOIN SFC_ROUTER SR2 ON SR.HANDLE =SR2.SFC_ROUTING_BO AND SR2.IN_USE = 'true'
JOIN SFC_STEP SS ON SR2.HANDLE =SS.SFC_ROUTER_BO AND (SS.QTY_IN_QUEUE>0 or SS.QTY_IN_WORK>0)
JOIN OPERATION OP ON 'OperationBO:'|| OP.SITE ||','|| OP.OPERATION||',#'=SS.OPERATION_BO
WHERE S.HANDLE=#{handle}
</select>
<select id="getAbnormalQty" resultType="com.foreverwin.mesnac.production.dto.SplitSfcDto">
SELECT zab.NC_QTY,zsbd.ROUTER_BO,zab.NC_CODE FROM Z_ABNORMAL_BILL zab
JOIN Z_ABNORMAL_BILL_DISPOSE zsbd ON zab.HANDLE=ZSBD.ABNORMAL_BILL_BO
WHERE ZAB.SFC=#{sfc} AND zab.SITE=#{site} AND ZAB.OPERATION=#{operation} AND zab.STATUS='F' AND zab."TYPE"='Z'
</select>
</mapper>

@ -38,5 +38,9 @@
<groupId>com.foreverwin.modular</groupId>
<artifactId>modular-melib</artifactId>
</dependency>
<dependency>
<groupId>com.foreverwin.mesnac</groupId>
<artifactId>anomaly</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,43 @@
package com.foreverwin.mesnac.quartz.job;
import com.foreverwin.mesnac.anomaly.service.AnomalyJobService;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.modular.core.exception.BaseException;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Description TODO
* @Author zhaojiawei
* @Since 2021-07-22
*/
@DisallowConcurrentExecution
public class AnomalyJob implements Job {
private static final String SITE_UPPERCASE = "SITE";
private static final String SITE_LOWERCASE = "site";
@Autowired
private AnomalyJobService anomalyJobService;
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
//获取站点,若站点为空则抛出异常
String site = getSite(context);
if (StringUtil.isBlank(site)) {
throw new BaseException("anomaly.quartz.task.not.site", null);
}
anomalyJobService.anomalyJobProcess(site);
}
private String getSite(JobExecutionContext context) {
String site = context.getJobDetail().getJobDataMap().getString(SITE_LOWERCASE);
if (StringUtil.isBlank(site)) {
site = context.getJobDetail().getJobDataMap().getString(SITE_UPPERCASE);
}
return site;
}
}
Loading…
Cancel
Save