查询工位停机类型和原因

tags/yfai-mes-ext-v1.0
gsz 12 months ago
parent a10c96d993
commit 3f2441aea8

@ -1,7 +1,10 @@
package cn.estsh.i3plus.ext.mes.api.base; package cn.estsh.i3plus.ext.mes.api.base;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeReasonType; import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeReasonType;
import java.util.List;
/** /**
* @Description : * @Description :
* @Reference : * @Reference :
@ -10,4 +13,12 @@ import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeReasonType;
* @Modify: * @Modify:
**/ **/
public interface IMesBasDowntimeReasonTypeService extends IBaseMesService<MesDowntimeReasonType> { public interface IMesBasDowntimeReasonTypeService extends IBaseMesService<MesDowntimeReasonType> {
/**
*
* @param downtimeReasonType
* @param pager
* @return
*/
List<MesDowntimeReasonType> findMesDowntimeTypeReason(MesDowntimeReasonType downtimeReasonType, Pager pager);
} }

@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
* @Description : * @Description :
* @Reference : * @Reference :
* @Author : gsz * @Author : gsz
* @CreateDate : 2024-05-17 14:16 * @CreateDate : 2024-05-17 14:16
@ -15,4 +15,5 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesDowntimeReason") @RequestMapping(MesCommonConstant.MES_YANFEN + "/mesDowntimeReason")
public class MesBasDowntimeReasonController extends BaseMesController<MesDowntimeReason>{ public class MesBasDowntimeReasonController extends BaseMesController<MesDowntimeReason>{
} }

@ -1,9 +1,19 @@
package cn.estsh.i3plus.ext.mes.apiservice.controller.base; package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
import cn.estsh.i3plus.ext.mes.api.base.IMesBasDowntimeReasonTypeService;
import cn.estsh.i3plus.ext.mes.apiservice.config.AuthUtilExt;
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeReasonType; import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeReasonType;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* @Description : * @Description :
@ -15,4 +25,23 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesDowntimeReasonType") @RequestMapping(MesCommonConstant.MES_YANFEN + "/mesDowntimeReasonType")
public class MesBasDowntimeReasonTypeController extends BaseMesController<MesDowntimeReasonType>{ public class MesBasDowntimeReasonTypeController extends BaseMesController<MesDowntimeReasonType>{
@Autowired
private IMesBasDowntimeReasonTypeService downtimeReasonTypeService;
@GetMapping(value = "/find-downtime-type-reason")
@ApiOperation(value = "查询设备停机类型和原因")
public ResultBean findMesDowntimeTypeReason(MesDowntimeReasonType mesDowntimeReasontype, Pager pager) {
try {
mesDowntimeReasontype.setOrganizeCode(AuthUtilExt.getOrganizeCode());
//查询汇总工单数量
List<MesDowntimeReasonType> mesDowntimeReasonTypes = downtimeReasonTypeService.findMesDowntimeTypeReason(mesDowntimeReasontype,pager);
return ResultBean.success("查询成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(mesDowntimeReasonTypes);
} catch (ImppBusiException e) {
return ResultBean.fail(e).build();
} catch (Exception e) {
return ResultBean.fail(e);
}
}
} }

@ -3,13 +3,24 @@ package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.api.base.IMesBasDowntimeReasonTypeService; import cn.estsh.i3plus.ext.mes.api.base.IMesBasDowntimeReasonTypeService;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum; import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeReason;
import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeReasonType; import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeReasonType;
import cn.estsh.i3plus.pojo.mes.repository.IMesBasDowntimeReasonRepository;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ValidatorBean; import cn.estsh.impp.framework.boot.util.ValidatorBean;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
@ -22,17 +33,20 @@ import org.springframework.stereotype.Service;
@Service @Service
@Slf4j @Slf4j
public class MesBasDowntimeReasonTypeServiceImpl extends BaseMesService<MesDowntimeReasonType> implements IMesBasDowntimeReasonTypeService { public class MesBasDowntimeReasonTypeServiceImpl extends BaseMesService<MesDowntimeReasonType> implements IMesBasDowntimeReasonTypeService {
@Autowired
private IMesBasDowntimeReasonRepository downtimeReasonRDao;
@Override @Override
protected void setPackQueryBean(MesDowntimeReasonType bean, DdlPackBean packBean) { protected void setPackQueryBean(MesDowntimeReasonType bean, DdlPackBean packBean) {
DdlPreparedPack.getStringEqualPack(bean.getReasonTypeCode(), "reasonTypeCode", packBean); DdlPreparedPack.getStringEqualPack(bean.getReasonTypeCode(), "reasonTypeCode", packBean);
DdlPreparedPack.getStringEqualPack(bean.getReasonTypeName(), "reasonTypeName", packBean); DdlPreparedPack.getStringEqualPack(bean.getReasonTypeName(), "reasonTypeName", packBean);
} }
@Override @Override
protected void onInsertBean(MesDowntimeReasonType item) { protected void onInsertBean(MesDowntimeReasonType item) {
// 数据校验 // 数据校验
ValidatorBean.checkNotNull(item.getOrganizeCode(), "工厂号不能为空"); ValidatorBean.checkNotNull(item.getOrganizeCode(), "工厂号不能为空");
ValidatorBean.checkNotNull(item.getReasonTypeCode(), "reasonTypeCode不能为空" ); ValidatorBean.checkNotNull(item.getReasonTypeCode(), "reasonTypeCode不能为空");
ValidatorBean.checkNotNull(item.getReasonTypeName(), "reasonTypeName不能为空"); ValidatorBean.checkNotNull(item.getReasonTypeName(), "reasonTypeName不能为空");
//唯一性校验 //唯一性校验
@ -49,4 +63,34 @@ public class MesBasDowntimeReasonTypeServiceImpl extends BaseMesService<MesDownt
} }
} }
/**
*
*
* @param downtimeReasonType
* @param pager
* @return
*/
@Override
public List<MesDowntimeReasonType> findMesDowntimeTypeReason(MesDowntimeReasonType downtimeReasonType, Pager pager) {
ListPager<MesDowntimeReasonType> downtimeReasonTypeListPager = this.queryPager(downtimeReasonType, pager);
List<MesDowntimeReasonType> downtimeReasonTypeList = downtimeReasonTypeListPager.getObjectList();
if (!CollectionUtils.isEmpty(downtimeReasonTypeList)) {
//查对应原因
List<MesDowntimeReason> mesDowntimeReasonList = downtimeReasonRDao.findByProperty(
new String[]{"organizeCode", "isDeleted", "isValid"},
new Object[]{downtimeReasonType.getOrganizeCode(),
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue()});
Map<String, List<MesDowntimeReason>> reasonMap = mesDowntimeReasonList.stream().collect(Collectors.groupingBy(MesDowntimeReason::getReasonTypeCode));
for (MesDowntimeReasonType mesDowntimeReasonType : downtimeReasonTypeList) {
if (!StringUtil.isEmpty(reasonMap.get(mesDowntimeReasonType.getReasonTypeCode()))) {
mesDowntimeReasonType.setDowntimeReasonList(reasonMap.get(mesDowntimeReasonType.getReasonTypeCode()));
}
}
}
return downtimeReasonTypeList;
}
} }

Loading…
Cancel
Save