异常代码优化提交

master
赵嘉伟 4 years ago
parent 06ce7d10a0
commit 7ff2eebadf

@ -185,13 +185,12 @@ public class AbnormalBillController {
/**
*
* @param messageType
* @param type
* @return
*/
@GetMapping("/init")
public R init(String messageType,String type){
return R.ok(abnormalBillService.init(messageType,type));
public R init(String type){
return R.ok(abnormalBillService.init(type));
}

@ -57,7 +57,7 @@ public interface AbnormalBillService extends IService<AbnormalBill> {
/**
*
*/
HashMap<String,Object> init(String messageType, String type);
HashMap<String,Object> init( String type);
/**
*
* @param abnormalBillDto

@ -12,19 +12,23 @@ import com.foreverwin.mesnac.anomaly.model.*;
import com.foreverwin.mesnac.anomaly.service.*;
import com.foreverwin.mesnac.common.constant.Constants;
import com.foreverwin.mesnac.common.dto.ScrapDto;
import com.foreverwin.mesnac.common.dto.UsrDto;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.helper.NextNumberHelper;
import com.foreverwin.mesnac.common.mapper.MessageMapper;
import com.foreverwin.mesnac.common.model.Message;
import com.foreverwin.mesnac.common.service.AnomalyService;
import com.foreverwin.mesnac.common.service.MessageService;
import com.foreverwin.mesnac.common.service.UserService;
import com.foreverwin.mesnac.common.util.ActiveMQUtil;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.meapi.mapper.*;
import com.foreverwin.mesnac.meapi.model.*;
import com.foreverwin.mesnac.meapi.service.*;
import com.foreverwin.mesnac.meapi.service.DataFieldListService;
import com.foreverwin.mesnac.meapi.service.NwaUserService;
import com.foreverwin.mesnac.meapi.service.RouterService;
import com.foreverwin.mesnac.meapi.service.WorkCenterService;
import com.foreverwin.mesnac.meapi.util.StringUtils;
import com.foreverwin.mesnac.production.mapper.SfcScrapMapper;
import com.foreverwin.mesnac.quality.service.SelfReportService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.exception.BusinessException;
@ -57,9 +61,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
private NextNumberHelper nextNumberHelper;
@Autowired
private NcGroupMapper ncGroupMapper;
@Autowired
private AbnormalBillDisposeService abnormalBillDisposeService;
@ -69,9 +70,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
private NwaUserService nwaUserService;
@Autowired
private NcCodeService ncCodeService;
@Autowired
private AbnormalNcCodeService abnormalNcCodeService;
@ -87,8 +85,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
private ShopOrderMapper shopOrderMapper;
@Autowired
private NwaUserMapper nwaUserMapper;
@Autowired
private RouterService routerService;
@ -111,18 +107,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
private OperationMapper operationMapper;
@Autowired
private MessageTypeService messageTypeService;
@Autowired
private MessageTypeMapper messageTypeMapper;
@Autowired
private WorkCenterMapper workCenterMapper;
@Autowired
private ItemMapper itemMapper;
@Autowired
private UserGroupMapper userGroupMapper;
@ -139,10 +126,10 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
private SelfReportService selfReportService;
@Autowired
private SfcScrapMapper sfcScrapMapper;
private AbnormalPlanService abnormalPlanService;
@Autowired
private AbnormalPlanService abnormalPlanService;
private UserService userService;
@Override
@ -184,8 +171,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
String message = this.generateAbnormalBill(abnormalBill, abnormalBillDispose, dutyCauseType, dutyType);
//获取当前时间
LocalDateTime now = LocalDateTime.now();
//生成不良代码和不良代码组,并把它放到hashMap里面ncCode是存放在异常单里面的ncCode
//生成不良代码和不良代码组,并把它放到hashMap里面ncCode是存放在异常单里面的ncCode
List<String> ncCode = new ArrayList<>();
List<String> ncGroup = new ArrayList<>();
StringBuilder ncCodes = new StringBuilder();
@ -202,7 +190,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//设置异常单BO
abnormalNcCode.setAbnormalBillBo(abnormalBill.getHandle());
List<AbnormalNcCode> abnormalNcCodes1 = abnormalNcCodeService.selectList(abnormalNcCode);
if(abnormalNcCodes1.size() != 0){
if(abnormalNcCodes1.size() > 0){
QueryWrapper<AbnormalNcCode> abnormalNcCodeQueryWrapper = new QueryWrapper<>();
abnormalNcCodeQueryWrapper.setEntity(abnormalNcCode);
abnormalNcCodeService.remove(abnormalNcCodeQueryWrapper);
@ -224,7 +212,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalNcCodeService.saveOrUpdateBatch(abnormalNcCodes);
abnormalBill.setNcCode(ncCodes.substring(0,ncCodes.length() - 1));
}
//判断是否是用户自报
//判断是否是用户自报,如果是自报的话,调用孙豪的方法
if(!StringUtil.isBlank(abnormalBill.getInspector()) && Constants.NEW.equals(abnormalBill.getStatus())){
abnormalBill.setObjectBo(HandleEnum.SELF_REPORT.getHandle(abnormalBill.getSite(),abnormalBill.getObjectBo()));
selfReportService.updateState(abnormalBill.getObjectBo(),Constants.STATE_CONFIRM);
@ -233,6 +223,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
//发送消息
if(Constants.NEW.equals(abnormalBill.getStatus())){
this.anomalyCreatedAndSendMessage(abnormalBill,null);
@ -259,53 +251,58 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
this.saveOrUpdate(abnormalBill);
//发送消息
this.anomalyCreatedAndSendMessage(abnormalBill,null);
if(Constants.NEW.equals(abnormalBill.getStatus())){
this.anomalyCreatedAndSendMessage(abnormalBill,null);
}
return message;
}
@Override
public HashMap<String, Object> init(String messageType, String type) {
public HashMap<String, Object> init( String type) {
HashMap<String, Object> hashMap = new HashMap<>();
String site = CommonMethods.getSite();
//消息类型
// if("Z".equals(type)){
// List<NcCode> category = ncCodeService.findNcByCategory(messageType,null);
// hashMap.put("ncByNG",category);
// }
//工作中心
WorkCenter workCenter = new WorkCenter();
workCenter.setWcCategory("LEVEL4");
workCenter.setSite(site);
List<WorkCenter> workCenterList = workCenterService.selectList(workCenter);
hashMap.put("workCenter",workCenterList);
//原因分类
DataField ncCode = new DataField();
ncCode.setSite(site);
ncCode.setDataField("REASON_CATEGORY");
List<DataField> ncCodeList = dataFieldListService.findDataFieldListById(ncCode);
hashMap.put("causeType",ncCodeList);
//责任部门
DataField dataField = new DataField();
dataField.setSite(site);
dataField.setDataField("RESPONSIBILITY_DEPARTMENT");
List<DataField> dutyDepartList = dataFieldListService.findDataFieldListById(dataField);
hashMap.put("dutyDepart",dutyDepartList);
//责任分类
dataField.setDataField("RESPONSIBILITY_TYPE");
List<DataField> dutyTypeList = dataFieldListService.findDataFieldListById(dataField);
hashMap.put("dutyType",dutyTypeList);
//当前登录用户的fullName
NwaUser nwaUser = new NwaUser();
nwaUser.setSite(site);
nwaUser.setUserName(CommonMethods.getUser());
List<NwaUser> nwaUsers = nwaUserService.selectList(nwaUser);
if(nwaUsers != null && nwaUsers.size() > 0){
hashMap.put("currentUser",nwaUsers.get(0).getFullName());
List<UsrDto> list = userService.findList(CommonMethods.getUser());
if(list != null && list.size() > 0){
hashMap.put("currentUser",list.get(0).getFullName());
}
//初始化异常单号
if(!StringUtil.isBlank(type)){
hashMap.put("abnormalNo",this.getNextNumber(type));
}
return hashMap;
}
@ -470,6 +467,15 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//return 返回的消息
String message = "提报成功";
//设置消息类型
if(Constants.ABNORMAL_QUALITY.equals(abnormalBill.getType())){
abnormalBill.setMessageType(Constants.ABNORMAL_MESSAGE_QUALITY);
}else if(Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
abnormalBill.setMessageType(Constants.ABNORMAL_MESSAGE_RESOURCE);
}else if(Constants.ABNORMAL_OTHER.equals(abnormalBill.getType())){
abnormalBill.setMessageType(Constants.ABNORMAL_MESSAGE_OTHER);
}
//如果前台传过来的异常单为空的话,则抛出一个异常
if(StringUtil.isBlank(abnormalBill.getAbnormalNo())) {
@ -539,7 +545,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
//判断工序编是否传递错误
//判断工序编是否传递错误
if(!StringUtil.isBlank(abnormalBill.getOperation())){
QueryWrapper<Operation> operationQueryWrapper = new QueryWrapper<Operation>();
operationQueryWrapper.eq("OPERATION",abnormalBill.getOperation())
@ -554,7 +560,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");
Integer length = ncCodeMapper.checkNcCode(ncCodes,site);
if(ncCodes.size() != length){
throw BusinessException.build("不良代码传递有误");
}
@ -876,7 +882,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
public boolean anomalyCreatedAndSendMessage(AbnormalBill abnormalBill,AbnormalBillDispose abnormalBillDispose){
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
String locale = LocaleContextHolder.getLocale().getLanguage();
LocalDateTime now = LocalDateTime.now();
Message abnormalMessage = new Message();
//发送消息的主键
@ -888,25 +893,33 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalMessage.setObjectBo(abnormalBill.getHandle());
//异常类型
abnormalMessage.setType(abnormalBill.getType());
//根据异常的类型找到消息的类型
switch (abnormalMessage.getType()){
case "Z"://质量异常
abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_QUALITY);
break;
case "Q"://其他异常
abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_OTHER);
break;
case "S"://设备异常
abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_RESOURCE);
break;
}
abnormalMessage.setMessageType(abnormalBill.getMessageType());
// //根据异常的类型找到消息的类型
// switch (abnormalMessage.getType()){
// case "Z"://质量异常
// abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_QUALITY);
// break;
// case "Q"://其他异常
// abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_OTHER);
// break;
// case "S"://设备异常
// abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_RESOURCE);
// break;
// }
//设置发送的用户组
switch (abnormalBill.getStatus()){
case Constants.NEW://新建
//新建
case Constants.NEW:
abnormalMessage.setSendUserGroup(abnormalBill.getReportSendUserGroup());
abnormalMessage.setNode(Constants.ABNORMAL_MESSAGE_REPORT);
break;
case Constants.RESPONSE://响应中,设置响应超时的用户的发送的用户组为提报时要升级的用户组
//响应中,设置响应超时的用户的发送的用户组为提报时要升级的用户组
case Constants.RESPONSE:
QueryWrapper<Message> wrapper = new QueryWrapper<>();
Message abnormalMessage1 = new Message();
abnormalMessage1.setSite(site);
@ -920,39 +933,47 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalMessage.setUpDateTime(_abnormalMessage.getUpDateTime());
abnormalMessage.setNode(Constants.ABNORMAL_MESSAGE_RESPONSE);
break;
case Constants.CORRECTION_CONFIRM://纠纷确认
abnormalMessage.setSendUserGroup(abnormalBillDispose.getDutySendUserGroup());
abnormalMessage.setNode(Constants.ABNORMAL_MESSAGE_CORRECTION_CONFIRM);
break;
case Constants.PROGRAM_CONFIRM://方案确认
abnormalMessage.setSendUser(abnormalBillDispose.getResolveSendUserGroup());
abnormalMessage.setNode(Constants.ABNORMAL_MESSAGE_PROGRAM_CONFIRM);
break;
case Constants.CANCEL://取消
abnormalMessage.setSendUserGroup(abnormalBill.getCancelSendUserGroup());
abnormalMessage.setNode(Constants.ABNORMAL_MESSAGE_CANCEL);
//异常取消的时候要关闭当前异常单下所有的异常信息
UpdateWrapper<Message> messageTypeUpdateWrapper = new UpdateWrapper<>();
// messageTypeUpdateWrapper.eq("SITE",site);
// messageTypeUpdateWrapper.eq("ABNORMAL_BILL_BO",abnormalMessage.getAbnormalBillBo());
Message abnormalMessage2 = new Message();
// abnormalMessage2.setAbnormalBillBo(abnormalMessage.getAbnormalBillBo());
abnormalMessage2.setStatus("Y");
messageTypeUpdateWrapper.eq("STATUS","N");
messageTypeUpdateWrapper.eq("OBJECT_BO",abnormalMessage.getObjectBo());
messageService.update(abnormalMessage2,messageTypeUpdateWrapper);
break;
default:
abnormalMessage.setSendUser(abnormalBillDispose.getResolveSendUserGroup());
abnormalMessage.setNode(Constants.ABNORMAL_MESSAGE_CANCEL);
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())){
@ -972,12 +993,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
//得到异常节点
//abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
//设置状态新建是Y响应为N纠防确认是N方案确认是Y
//设置状态新建是Y响应为N纠防确认是N方案确认是Y取消是Y
if(Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getNode()) ||
Constants.ABNORMAL_MESSAGE_CORRECTION_CONFIRM.equals(abnormalMessage.getNode())){
abnormalMessage.setStatus("N");
@ -990,11 +1006,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalMessage.setModifiedDateTime(now);
//判断,如果是方案确认,则发送用户,否则,除了节点是响应之外,则发送用户组
if(Constants.ABNORMAL_MESSAGE_PROGRAM_CONFIRM.equals(abnormalMessage.getNode())){
String sendUsers = abnormalMessage.getSendUser().replace(',', '|');
activeMQUtil.wechatSendMessage(sendUsers,abnormalMessage.getContent());
}else if(!Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getNode())){
//发送消息
if(!Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getNode())){
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup());
StringBuilder sendUsers = new StringBuilder();
for (int i = 0; i < nwaUsers.size(); i++) {

@ -71,12 +71,13 @@ public class ShopOrderController {
/**
* handle
* @param handle
* @param shopOrder
* @param plannedItemBo
* @return
*/
@GetMapping("/findById")
public R findById(String handle,String plannedItemBo){
return R.ok(shopOrderService.findById(handle,plannedItemBo));
public R findById(String shopOrder,String plannedItemBo){
return R.ok(shopOrderService.findById(shopOrder,plannedItemBo));
}
/**

@ -41,7 +41,7 @@ public interface NcCodeMapper extends BaseMapper<NcCode> {
*
* @return
*/
Integer checkNcCode(@Param("NcCodeList")List<String> ncCodes,@Param("site")String site,@Param("category")String category);
Integer checkNcCode(@Param("NcCodeList")List<String> ncCodes,@Param("site")String site);
List<NcCode> findNcCodeByNcGroup(@Param("ncGroup")NcGroup ncGroup);

@ -17,7 +17,7 @@ import org.springframework.stereotype.Repository;
@Repository
public interface ShopOrderMapper extends BaseMapper<ShopOrder> {
ShopOrder findById(@Param("handle")String handle,@Param("status501")String status501,@Param("plannedItemBo")String plannedItemBo);
ShopOrder findById(@Param("site")String site,@Param("shopOrder")String shopOrder,@Param("status501")String status501,@Param("plannedItemBo")String plannedItemBo);
ShopOrderDto findByShopOrderBo(@Param("handle")String handle);
}

@ -29,10 +29,10 @@ public interface ShopOrderService extends IService<ShopOrder> {
/**
* handle
* @param handle
* @param shopOrder
* @return
*/
ShopOrder findById(String handle,String plannedItemBo);
ShopOrder findById(String shopOrder,String plannedItemBo);
ShopOrderDto findByShopOrderBo(String handle);

@ -47,20 +47,20 @@ public class ShopOrderServiceImpl extends ServiceImpl<ShopOrderMapper, ShopOrder
}
@Override
public ShopOrder findById(String handle,String plannedItemBo) {
public ShopOrder findById(String shopOrder,String plannedItemBo) {
String site = CommonMethods.getSite();
String status501 = new StatusBOHandle(site,"501").getValue();
return shopOrderMapper.findById(handle,status501,plannedItemBo);
return shopOrderMapper.findById(site,shopOrder,status501,plannedItemBo);
}
@Override
public ShopOrderDto findByShopOrderBo(String shopOrder) {
String site = CommonMethods.getSite();
String handle = null;
if(!StringUtil.isBlank(shopOrder)){
handle = "ShopOrderBO:"+site+","+shopOrder;
String handle = "ShopOrderBO:"+site+","+shopOrder;
return shopOrderMapper.findByShopOrderBo(handle);
}
return shopOrderMapper.findByShopOrderBo(handle);
return null;
}

@ -387,18 +387,18 @@
</select>
<select id="checkNcCode" resultType="integer">
SELECT count(*)
FROM NC_CODE
WHERE NC_CODE IN
SELECT count(NC.HANDLE)
FROM NC_CODE NC
LEFT JOIN NC_GROUP_MEMBER NGM ON NGM.NC_CODE_OR_GROUP_GBO = NC.HANDLE
LEFT JOIN NC_GROUP NG ON NG.HANDLE = NGM.NC_GROUP_BO
WHERE NC.NC_CODE IN
<foreach collection="NcCodeList" index="index" item="item" separator="," open="(" close=")">
UPPER(#{item})
</foreach>
<if test="site != null and site != ''">
AND SITE = #{site}
</if>
<if test="category != null and category != ''">
AND NC_CATEGORY = #{category}
AND NC.SITE = #{site}
</if>
AND NG.NC_GROUP LIKE 'E\_%' ESCAPE '\'
</select>
<select id="findNcCodeByNcGroup" resultMap="BaseResultMap">

@ -997,9 +997,9 @@
SELECT <include refid="Base_Column_List"></include>
FROM SHOP_ORDER
<where>
STATUS_BO = #{status501}
<if test="handle != null and handle != ''">
AND HANDLE = #{handle}
STATUS_BO = #{status501} AND SITE = #{site}
<if test="shopOrder != null and shopOrder != ''">
AND SHOP_ORDER = #{shopOrder}
</if>
<if test="plannedItemBo!= null and plannedItemBo != ''">
AND PLANNED_ITEM_BO = #{plannedItemBo}

Loading…
Cancel
Save