|
@@ -5,11 +5,15 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.persagy.fm.common.exception.BusinessValidatorException;
|
|
|
import com.persagy.fm.sop.mapper.SopMapper;
|
|
|
+import com.persagy.fm.sop.model.SopDTO;
|
|
|
import com.persagy.fm.sop.model.dto.*;
|
|
|
import com.persagy.fm.sop.model.vo.*;
|
|
|
import com.persagy.fm.sop.service.*;
|
|
|
import com.persagy.old.cache.OrderTypeCache;
|
|
|
-import com.persagy.old.common.*;
|
|
|
+import com.persagy.old.common.CommonConst;
|
|
|
+import com.persagy.old.common.DateUtil;
|
|
|
+import com.persagy.old.common.SopConst;
|
|
|
+import com.persagy.old.common.StringUtil;
|
|
|
import com.persagy.old.dao.DBConst;
|
|
|
import com.persagy.old.dao.DBConst.Result;
|
|
|
import com.persagy.old.service.EquipModelServiceI;
|
|
@@ -55,12 +59,21 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
@Autowired
|
|
|
private SopEquipModelRelService sopEquipModelRelService;
|
|
|
|
|
|
+ /* @Autowired
|
|
|
+ private WoFlowPlanServiceI woFlowPlanService;
|
|
|
+*/
|
|
|
+ @Autowired
|
|
|
+ private SopStateMachine sopStateMachine;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SopHisService sopHisService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public JSONObject queryPublishedSopList(QuerySopListForSelVo sopListForSelVo) throws Exception {
|
|
|
String projectId = sopListForSelVo.getProjectId();
|
|
|
//1.根据update和项目id查询
|
|
|
- List<Sop> sops = queryPublishedSopsByProjectIdAndUpdatetime(sopListForSelVo, projectId);
|
|
|
+ List<Sop> sops = queryPublishedSopsByProjectIdAndUpdatetime(sopListForSelVo);
|
|
|
/*
|
|
|
//========2.移除待修订状态sop=======
|
|
|
//如果不是集团的sop的查询
|
|
@@ -102,8 +115,11 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
//将 请求体中的参数拷贝到我们里面
|
|
|
//将对象映射到数据库实体上面去
|
|
|
Sop sop = SopMapper.INSTANCE.SaveSopVoToSop(saveSopVo);
|
|
|
- sop.setSopStatus(SopConst.SOP_STATUS_PUBLISH);
|
|
|
- sop.setPublishStatus(SopConst.PUBLISH_STATUS_NORMAL);
|
|
|
+ /*sop.setSopStatus(SopConst.SOP_STATUS_PUBLISH);
|
|
|
+ sop.setPublishStatus(SopConst.PUBLISH_STATUS_NORMAL);*/
|
|
|
+ SopState sopState = sopStateMachine.newPublic();
|
|
|
+ //设置状态
|
|
|
+ setSopStatus(sop, sopState);
|
|
|
sop.setVersionCount(1);
|
|
|
sop.setVersion("V0.1");
|
|
|
sop.setVersionExplain("[\""+ CommonConst.version_explain_create+"\"]");
|
|
@@ -112,6 +128,11 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private void setSopStatus(Sop sop, SopState sopState) {
|
|
|
+ sop.setPublishStatus(sopState.getPublicStatus());
|
|
|
+ sop.setSopStatus(sopState.getSopStatus());
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public boolean verifySopForPublish(SaveSopVo saveSopVo) throws Exception {
|
|
|
String projectId = saveSopVo.getProject_id();
|
|
@@ -344,21 +365,45 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
@Override
|
|
|
public String addDraftSop(SaveSopEditVo saveSopEditVo) throws Exception {
|
|
|
Set<String> sopRefSops = this.getSopRefSops(saveSopEditVo);
|
|
|
- saveSopEditVo.setSop_id(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
+ saveSopEditVo.setSop_edit_id(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
|
//将表单提交的值拷贝过来
|
|
|
SopEdit sopEdit = SopMapper.INSTANCE.SaveSopEditVoToSopEdit(saveSopEditVo);
|
|
|
sopEdit.setRefSopIds(new ArrayList<>(sopRefSops));
|
|
|
- insertRecord(sopEdit);
|
|
|
+ if (StringUtils.isBlank(sopEdit.getSopId())) {
|
|
|
+ sopEdit.setSopId(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
+ }
|
|
|
+ //sop类型 1 通用 2 项目专用
|
|
|
+ if(CommonConst.group_sop_id.equals(saveSopEditVo.getProject_id())) {
|
|
|
+ sopEdit.setSopType(SopConst.SOP_TYPE_GROUP);
|
|
|
+ }else {
|
|
|
+ sopEdit.setSopType(SopConst.SOP_TYPE_PROJECT);
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(sopEdit.getSopStatus())) {
|
|
|
+ //sop状态 0 草稿 1 已发布 2 已作废
|
|
|
+ //则是新建的
|
|
|
+ SopState sopState = sopStateMachine.saveDraft();
|
|
|
+ setEditSopStatus(sopEdit, sopState);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ SopState sopState = sopStateMachine.public2Draft();
|
|
|
+ setEditSopStatus(sopEdit,sopState);
|
|
|
+ }
|
|
|
+ sopEdit.insert();
|
|
|
return sopEdit.getSopId();
|
|
|
}
|
|
|
|
|
|
+ private void setEditSopStatus(SopEdit sopEdit, SopState sopState) {
|
|
|
+ sopEdit.setSopStatus(sopState.getSopStatus());
|
|
|
+ sopEdit.setPublishStatus(sopState.getPublicStatus());
|
|
|
+ }
|
|
|
+
|
|
|
public boolean insertRecord(SopEdit sopEdit) throws Exception {
|
|
|
if (StringUtils.isBlank(sopEdit.getSopId())) {
|
|
|
sopEdit.setSopId(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
}
|
|
|
//sop类型 1 通用 2 项目专用
|
|
|
- sopEdit.setSopType("1");
|
|
|
+ sopEdit.setSopType(SopConst.SOP_TYPE_GROUP);
|
|
|
|
|
|
if(StringUtils.isBlank(sopEdit.getSopStatus())) {
|
|
|
//sop状态 0 草稿 1 已发布 2 已作废
|
|
@@ -411,7 +456,8 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
update.setRefSopIds(new ArrayList<>(sopRefSops));
|
|
|
if("1".equals(saveSopVo.getSop_status())) {
|
|
|
//将状态更新为3 publish_status
|
|
|
- update.setPublishStatus("3");
|
|
|
+ SopState sopState = sopStateMachine.public2Draft();
|
|
|
+ setEditSopStatus(update,sopState);
|
|
|
}
|
|
|
|
|
|
if(sopEdit != null) {
|
|
@@ -430,10 +476,10 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
//插入编辑状态sop
|
|
|
this.insertRecord(data);
|
|
|
}
|
|
|
- //根据sopid 更新sop的状态为3
|
|
|
Sop sop = new Sop();
|
|
|
sop.setSopId(saveSopVo.getSop_id());
|
|
|
- sop.setPublishStatus("3");
|
|
|
+ SopState sopState = sopStateMachine.public2Draft();
|
|
|
+ setSopStatus(sop,sopState);
|
|
|
return sop.updateById();
|
|
|
}
|
|
|
|
|
@@ -448,7 +494,7 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
flag = false;
|
|
|
}
|
|
|
//1.根据update和项目id查询
|
|
|
- List<Sop> sops = queryPublishedSopsByProjectIdAndUpdatetime(sopListForSelVo, projectId);
|
|
|
+ List<Sop> sops = queryPublishedSopsByProjectIdAndUpdatetime(sopListForSelVo);
|
|
|
//2筛选sop
|
|
|
|
|
|
/*
|
|
@@ -498,6 +544,253 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
return item;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean publishSop(SaveSopVo saveSopVo) throws Exception {
|
|
|
+ //验证必填项
|
|
|
+ //根据id查询sop
|
|
|
+ String sop_id = saveSopVo.getSop_id();
|
|
|
+ Sop querySop = new Sop();
|
|
|
+ Sop oldSop = querySop.selectById(sop_id);
|
|
|
+
|
|
|
+ //转化为his sop 并填充必要的参数
|
|
|
+ SopHis sopHis = new SopHis();
|
|
|
+
|
|
|
+ org.springframework.beans.BeanUtils.copyProperties(oldSop, sopHis);
|
|
|
+ //获取sop的版本信息
|
|
|
+ Integer versionCount = oldSop.getVersionCount();
|
|
|
+ Map<String, SopHis.RefedSopBean> stringProfileMap = proccessSopIdRefProfile(oldSop.getRefSopIds());
|
|
|
+ //在每一步上追加该信息
|
|
|
+ proccessSopItem(sopHis, stringProfileMap, null);
|
|
|
+ //在refed中添加信息
|
|
|
+ sopHis.setRefedSops(getSopProfileOfRefCurrentSop(sopHis.getSopId()));
|
|
|
+
|
|
|
+ //将历史版本落库
|
|
|
+ sopHisService.save(sopHis);
|
|
|
+
|
|
|
+ //删除草稿
|
|
|
+ sopEditService.removeById(saveSopVo.getSop_id());
|
|
|
+
|
|
|
+
|
|
|
+ //更新sop
|
|
|
+ Sop sop = SopMapper.INSTANCE.SaveSopVoToSop(saveSopVo);
|
|
|
+
|
|
|
+ Set<String> sopRefSops = this.getSopRefSops(saveSopVo);
|
|
|
+
|
|
|
+ sop.setRefSopIds(new ArrayList<>(sopRefSops));
|
|
|
+
|
|
|
+ //首先更新相关的对象关系表
|
|
|
+ updateSopRelation(saveSopVo);
|
|
|
+
|
|
|
+ sop.setVersionExplain("[\"修订标准操作\"]");
|
|
|
+
|
|
|
+ return updateRecordByKeyAndUpVersion(sop);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public boolean updateRecordByKeyAndUpVersion(Sop sopUpdate) throws Exception {
|
|
|
+ Sop sop = new Sop();
|
|
|
+ Sop sop1 = sop.selectById(sop.getSopId());
|
|
|
+ Integer versionCount1 = sop1.getVersionCount();
|
|
|
+ int count = versionCount1 + 1;
|
|
|
+ sopUpdate.setVersion("V" + (double) count / 10);
|
|
|
+ sopUpdate.setVersionCount(count);
|
|
|
+ sopUpdate.updateById();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private boolean updateSopRelation(SaveSopVo saveSopVo) throws Exception{
|
|
|
+
|
|
|
+ //添加sop与对象关系-sop_obj_rel
|
|
|
+ List<SaveSopVo.FitObjsBean> sopRelObjs = getSopRelObjs(saveSopVo);
|
|
|
+
|
|
|
+ //查询数据库中的关联信息
|
|
|
+ //删除所有
|
|
|
+ sopObjRelService.deleteBySopId(saveSopVo.getSop_id());
|
|
|
+ if(CollectionUtils.isNotEmpty(sopRelObjs)) {
|
|
|
+ for (SaveSopVo.FitObjsBean sopRelObj : sopRelObjs) {
|
|
|
+ SopObjRel sopObjRel = new SopObjRel();
|
|
|
+ sopObjRel.setSopId(saveSopVo.getSop_id());
|
|
|
+ sopObjRel.setObjId(sopRelObj.getObj_id());
|
|
|
+ sopObjRel.setObjType(sopRelObj.getObj_type());
|
|
|
+ sopObjRel.setValid(true);
|
|
|
+
|
|
|
+ sopObjRel.insert();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sopEquipModelRelService.deleteBySopId(saveSopVo.getSop_id());
|
|
|
+
|
|
|
+
|
|
|
+ //添加sop与设备型号关系-sop_equip_model_rel
|
|
|
+ List<String> equip_model_ids = saveSopVo.getEquip_model_ids();
|
|
|
+ distinctCollection(equip_model_ids);
|
|
|
+ if(CollectionUtils.isNotEmpty(equip_model_ids)) {
|
|
|
+ for (String equip_model_id : equip_model_ids) {
|
|
|
+ SopEquipModelRel sopEquipModelRel = new SopEquipModelRel();
|
|
|
+ sopEquipModelRel.setEquipModelId(equip_model_id);
|
|
|
+ sopEquipModelRel.setSopId(saveSopVo.getSop_id());
|
|
|
+ sopEquipModelRel.setValid(true);
|
|
|
+ sopEquipModelRel.insert();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除所有
|
|
|
+
|
|
|
+ sopOrderTypeRelService.deleteBySopId(saveSopVo.getSop_id());
|
|
|
+
|
|
|
+
|
|
|
+ //添加sop与工单类型关系-sop_order_type_rel
|
|
|
+ List<String> order_types = saveSopVo.getOrder_type();
|
|
|
+ distinctCollection(order_types);
|
|
|
+ if(CollectionUtils.isNotEmpty(order_types)) {
|
|
|
+ for (String order_type : order_types) {
|
|
|
+ SopOrderTypeRel sopOrderTypeRel = new SopOrderTypeRel();
|
|
|
+ sopOrderTypeRel.setOrderType(order_type);
|
|
|
+ sopOrderTypeRel.setProjectId(saveSopVo.getProject_id());
|
|
|
+ sopOrderTypeRel.setValid(true);
|
|
|
+ sopOrderTypeRel.setSopId(saveSopVo.getSop_id());
|
|
|
+ sopOrderTypeRel.insert();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //添加sop与自定义标签关系-sop_label_rel
|
|
|
+
|
|
|
+
|
|
|
+ sopLabelRelService.deleteBySopId(saveSopVo.getSop_id());
|
|
|
+ List<String> labels = saveSopVo.getLabels();
|
|
|
+ distinctCollection(labels);
|
|
|
+ if(CollectionUtils.isNotEmpty(labels)) {
|
|
|
+ for (String label : labels) {
|
|
|
+ SopLabelRel sopLabelRel = new SopLabelRel();
|
|
|
+ sopLabelRel.setLabel(label);
|
|
|
+ sopLabelRel.setSopId(saveSopVo.getSop_id());
|
|
|
+ sopLabelRel.setValid(true);
|
|
|
+ sopLabelRel.insert();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sopSopRelService.deleteBySopId(saveSopVo.getSop_id());
|
|
|
+ //添加sop与sop关系-sop_sop_rel
|
|
|
+ Set<String> sopRefSops = getSopRefSops(saveSopVo);
|
|
|
+ if(CollectionUtils.isNotEmpty(sopRefSops)) {
|
|
|
+ for (String sopRefSop : sopRefSops) {
|
|
|
+ SopSopRel sopSopRel = new SopSopRel();
|
|
|
+ sopSopRel.setProjectId(saveSopVo.getProject_id());
|
|
|
+ sopSopRel.setRelSopId(sopRefSop);
|
|
|
+ sopSopRel.setSopId(saveSopVo.getSop_id());
|
|
|
+ sopSopRel.setValid(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理引用当前sop的所有sop简介
|
|
|
+ * @param sopId
|
|
|
+ * @param sopId
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public List< SopHis.RefedSopBean> getSopProfileOfRefCurrentSop( String sopId) throws Exception{
|
|
|
+ //查询引用该sop的sopid
|
|
|
+ QueryWrapper<SopSopRel> sopSopRelQueryWrapper = new QueryWrapper<>();
|
|
|
+ sopSopRelQueryWrapper.eq("rel_sop_id",sopId);
|
|
|
+ List<SopSopRel> list = sopSopRelService.list(sopSopRelQueryWrapper);
|
|
|
+ List<String> refSopIds = new ArrayList<String>();
|
|
|
+ for (SopSopRel sopSopRel : list) {
|
|
|
+ refSopIds.add(sopSopRel.getSopId());
|
|
|
+ }
|
|
|
+
|
|
|
+ return new ArrayList<>(proccessSopIdRefProfile(refSopIds).values());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理sop详情 补充引用sop简介,添加内容对象变化标识
|
|
|
+ * @param sop
|
|
|
+ * @param refSopProfile
|
|
|
+ * @Param changedObjIds objId //对象变化数据key:objId value:{"objId":objId, "objName":objName, "objType":objType}
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void proccessSopItem(SopHis sop, Map<String, SopHis.RefedSopBean> refSopProfile, Set<String> changedObjIds){
|
|
|
+ if(CollectionUtils.isNotEmpty(changedObjIds)) {
|
|
|
+ List<SopHis.FitObjsBean> fitObjs = sop.getFitObjs();
|
|
|
+ if(CollectionUtils.isNotEmpty(fitObjs)) {
|
|
|
+ for (SopHis.FitObjsBean fitObj : fitObjs) {
|
|
|
+ String obj_id = fitObj.getObj_id();
|
|
|
+ if(changedObjIds.contains(obj_id)) {
|
|
|
+ fitObj.setIs_revise(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //處理步驟
|
|
|
+ List<SopStepsBean> steps = sop.getSteps();
|
|
|
+ for (SopStepsBean step : steps) {
|
|
|
+ Boolean from_sop = step.isFrom_sop();
|
|
|
+ if(BooleanUtils.isTrue(from_sop)) {
|
|
|
+ //将引用的简洁填充上去
|
|
|
+ String sop_id = step.getSop_id();
|
|
|
+ SopHis.RefedSopBean profile = refSopProfile.get(sop_id);
|
|
|
+ if(profile != null) {
|
|
|
+ step.setProfile(profile);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ List<SopStepsBean.StepContentBean> step_content = step.getStep_content();
|
|
|
+ if(CollectionUtils.isNotEmpty(step_content)) {
|
|
|
+ for (SopStepsBean.StepContentBean stepContentBean : step_content) {
|
|
|
+ Boolean from_sop1 = stepContentBean.isFrom_sop();
|
|
|
+ if(BooleanUtils.isTrue(from_sop1)) {
|
|
|
+ String sop_id = stepContentBean.getSop_id();
|
|
|
+ SopHis.RefedSopBean profile = refSopProfile.get(sop_id);
|
|
|
+ if(profile != null) {
|
|
|
+ stepContentBean.setProfile(profile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理引用的sop id与简介(sop_name,version,step_count,status_explain,update_time)
|
|
|
+ * @Param userId 调用者
|
|
|
+ * @param refSopIds 被引用sopId集合
|
|
|
+ * @return map key:sopId value:sop对象
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public Map<String, SopHis.RefedSopBean> proccessSopIdRefProfile(List<String> refSopIds) throws Exception {
|
|
|
+ List<Sop> sops = sopService.listByIds(refSopIds);
|
|
|
+ Map<String, SopHis.RefedSopBean> sopId_Profile = new HashMap<>();
|
|
|
+ for (Sop sopItem : sops) {
|
|
|
+ SopHis.RefedSopBean profile = new SopHis.RefedSopBean();
|
|
|
+ profile.setRef_sop_id(sopItem.getSopId());
|
|
|
+ profile.setRef_sop_name(sopItem.getSopName());
|
|
|
+ profile.setVersion(sopItem.getVersion());
|
|
|
+ profile.setStep_count(sopItem.getSteps().size());
|
|
|
+ profile.setStauts_explain(getSopStatus(sopItem));
|
|
|
+ profile.setUpdate_time(DateUtil.transferDateFormat(sopItem.getUpdateTime(), CommonConst.date_format_save, CommonConst.date_format_show));
|
|
|
+ sopId_Profile.put(sopItem.getSopId(), profile);
|
|
|
+ }
|
|
|
+ return sopId_Profile;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
private Map<String, Object> getSopListCriteria(List<Sop> sops, List<SopInfoVo> sopInfoVos) throws Exception {
|
|
|
//根据业务数据抽取条件
|
|
@@ -515,6 +808,8 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
return criteria;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private List<Sop> filterSopByFitScope(QuerySopListForSelVo sopListForSelVo, List<Sop> sops) throws Exception {
|
|
|
JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(sopListForSelVo));
|
|
|
|
|
@@ -532,10 +827,8 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
//1.根据适用返回查询sopid
|
|
|
//1.1根据设备型号查询
|
|
|
if(!StringUtil.isEmptyList(param, "equip_model_ids")){
|
|
|
- QueryWrapper<SopEquipModelRel> sopEquipModelRelQueryWrapper = new QueryWrapper<>();
|
|
|
- sopEquipModelRelQueryWrapper.in("equip_model_id",sopListForSelVo.getEquip_model_ids());
|
|
|
- List<SopEquipModelRel> list = sopEquipModelRelService.list(sopEquipModelRelQueryWrapper);
|
|
|
|
|
|
+ List<SopEquipModelRel> list = sopEquipModelRelService.selectByEquipModelIds(sopListForSelVo.getEquip_model_ids());
|
|
|
Set<String> tmp = new HashSet<>();
|
|
|
for (SopEquipModelRel sopEquipModelRel : list) {
|
|
|
tmp.add(sopEquipModelRel.getSopId());
|
|
@@ -544,9 +837,7 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
}
|
|
|
//1.2根据自定义标签查询
|
|
|
if( !StringUtil.isEmptyList(param, "labels")){
|
|
|
- QueryWrapper<SopLabelRel> query = new QueryWrapper<>();
|
|
|
- query.in("label",sopListForSelVo.getLabels());
|
|
|
- List<SopLabelRel> list = sopLabelRelService.list(query);
|
|
|
+ List<SopLabelRel> list = sopLabelRelService.selectByLabels(sopListForSelVo.getLabels());
|
|
|
Set<String> tmp = new HashSet<>();
|
|
|
for (SopLabelRel sopLabelRel : list) {
|
|
|
tmp.add(sopLabelRel.getSopId());
|
|
@@ -555,22 +846,18 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
}
|
|
|
//1.3根据工单类型查询
|
|
|
if(!StringUtil.isEmptyList(param, "order_type")){
|
|
|
- QueryWrapper<SopOrderTypeRel> query = new QueryWrapper<>();
|
|
|
- query.in("order_type",sopListForSelVo.getOrder_type());
|
|
|
- List<SopOrderTypeRel> list = sopOrderTypeRelService.list(query);
|
|
|
+ List<SopOrderTypeRel> sopOrderTypeRels = sopOrderTypeRelService.selectByOrderTypes(sopListForSelVo.getOrder_type());
|
|
|
Set<String> tmp = new HashSet<>();
|
|
|
- for (SopOrderTypeRel sopOrderTypeRel : list) {
|
|
|
+ for (SopOrderTypeRel sopOrderTypeRel : sopOrderTypeRels) {
|
|
|
tmp.add(sopOrderTypeRel.getSopId());
|
|
|
}
|
|
|
sopId.retainAll(tmp);
|
|
|
}
|
|
|
//1.4根据适用对象查询
|
|
|
if( !StringUtil.isEmptyList(param, "fit_obj_ids")){
|
|
|
- QueryWrapper<SopObjRel> query = new QueryWrapper<>();
|
|
|
- query.in("obj_id",sopListForSelVo.getFit_obj_ids());
|
|
|
- List<SopObjRel> list = sopObjRelService.list(query);
|
|
|
+ List<SopObjRel> sopObjRels = sopObjRelService.selectByObjectIds(sopListForSelVo.getFit_obj_ids());
|
|
|
Set<String> tmp = new HashSet<>();
|
|
|
- for (SopObjRel sopObjRel : list) {
|
|
|
+ for (SopObjRel sopObjRel : sopObjRels) {
|
|
|
tmp.add(sopObjRel.getSopId());
|
|
|
}
|
|
|
sopId.retainAll(tmp);
|
|
@@ -722,6 +1009,116 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public JSONObject queryEditingSopList(QueryHistoryListVo queryHistoryListVo) throws Exception {
|
|
|
+ String sop_name = queryHistoryListVo.getSop_name();
|
|
|
+
|
|
|
+ //根据sop_status valid projectid 查询
|
|
|
+ QueryWrapper<SopEdit> query = new QueryWrapper<>();
|
|
|
+ query.eq("sop_status", SopConst.SOP_STATUS_DRAFT)
|
|
|
+ .eq("project_id",queryHistoryListVo.getProjectId())
|
|
|
+ .like("sop_name",sop_name)
|
|
|
+ .orderByDesc(DBConst.TABLE_FIELD_UPDATE_TIME);
|
|
|
+
|
|
|
+ List<SopEdit> list = sopEditService.list(query);
|
|
|
+ List<SopDTO> sopDTOS = new ArrayList<>();
|
|
|
+ //转化为业务数据
|
|
|
+ for (SopEdit sopEdit : list) {
|
|
|
+ SopDTO sopDTO = new SopDTO();
|
|
|
+ BeanUtils.copyProperties(sopEdit,sopDTO);
|
|
|
+ sopDTOS.add(sopDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.filterRemind(sopDTOS, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject queryDestroyedSopList(QueryHistoryListVo queryHistoryListVo) throws Exception {
|
|
|
+
|
|
|
+ String sop_name = queryHistoryListVo.getSop_name();
|
|
|
+
|
|
|
+ //根据sop_status valid projectid 查询
|
|
|
+ QueryWrapper<Sop> query = new QueryWrapper<>();
|
|
|
+ query.eq("sop_status", SopConst.SOP_STATUS_DESTROYED)
|
|
|
+ .eq("project_id",queryHistoryListVo.getProjectId())
|
|
|
+ .like("sop_name",sop_name)
|
|
|
+ .orderByDesc(DBConst.TABLE_FIELD_UPDATE_TIME);
|
|
|
+
|
|
|
+ List<Sop> list = sopService.list(query);
|
|
|
+ return this.filterRemind((List)list, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * Description: 条件过滤
|
|
|
+ * @param sops
|
|
|
+ * @param destoryFlag
|
|
|
+ * @return
|
|
|
+ * @throws Exception JSONObject
|
|
|
+ * @author yuecaipu
|
|
|
+ * @since 2018年5月2日: 下午2:11:59
|
|
|
+ * Update By yuecaipu 2018年5月2日: 下午2:11:59
|
|
|
+ */
|
|
|
+ public JSONObject filterRemind(List<SopDTO> sops, boolean destoryFlag) throws Exception {
|
|
|
+ JSONObject sopJson = new JSONObject();
|
|
|
+ JSONArray editSopArray = new JSONArray();
|
|
|
+ for (SopDTO sop : sops) {
|
|
|
+ JSONArray scopes = new JSONArray();
|
|
|
+
|
|
|
+ List<String> orderTypes = sop.getOrderType();
|
|
|
+
|
|
|
+ for (String orderType : orderTypes) {
|
|
|
+ String dictName ="tset";//= woFlowPlanService.getNameById(orderType);
|
|
|
+ //String dictName = DictionaryCache.getNameByTypeCode(DBConst.DICT_WORK_ORDER_TYPE, tempArray.getString(j), projectId);
|
|
|
+ if(dictName != null)
|
|
|
+ scopes.add(dictName);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Sop.FitObjsBean> fitObjs = sop.getFitObjs();
|
|
|
+ for (Sop.FitObjsBean fitObj : fitObjs) {
|
|
|
+ scopes.add(fitObj.getObj_id());
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("equip_model_ids", sop.getEquipModelIds());
|
|
|
+
|
|
|
+ String resultStr = equipModelService.queryBathchMergeRecordByequipModelIds(param.toJSONString(), "equip_model_ids", "equip_model_id");
|
|
|
+ JSONObject resultObj = JSONObject.parseObject(resultStr);
|
|
|
+ JSONArray resultContent = resultObj.getJSONArray(DBConst.Result.CONTENT);
|
|
|
+ if (Result.SUCCESS.equals(resultObj.getString(Result.RESULT)) && resultContent.size()>0) {
|
|
|
+ for (int j = 0; j < resultContent.size(); j++) {
|
|
|
+ JSONObject content = resultContent.getJSONObject(j);
|
|
|
+ scopes.add(content.getString("equip_model_name"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> labels = sop.getLabels();
|
|
|
+ if(labels != null) {
|
|
|
+ scopes.addAll(labels);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject editSop = new JSONObject();
|
|
|
+ editSop.put("sop_id", sop.getProjectId());
|
|
|
+ editSop.put("sop_name", sop.getSopName());
|
|
|
+ editSop.put("version", sop.getVersion());
|
|
|
+ if(!destoryFlag) {
|
|
|
+ editSop.put("sop_status", sop.getSopStatus());
|
|
|
+ }
|
|
|
+ editSop.put("scopes", scopes);
|
|
|
+ editSop.put("update_time", DateUtil.transferDateFormat(sop.getUpdateTime(), CommonConst.date_format_save, CommonConst.date_format_show));
|
|
|
+ editSop.put("operator",sop.getOperator());
|
|
|
+ editSopArray.add(editSop);
|
|
|
+ }
|
|
|
+ sopJson.put("Content", editSopArray);
|
|
|
+ sopJson.put("Count", editSopArray.size());
|
|
|
+ return sopJson;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String queryDestroyedSopList(JSONObject jsonObject) throws Exception {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* Description: 获取到sop中所有设备型号
|
|
@@ -880,9 +1277,7 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
if(CollectionUtils.isEmpty(signCodes)) {
|
|
|
return sops;
|
|
|
}
|
|
|
-// if (signCodes.size() > 1) {
|
|
|
-// return sops;
|
|
|
-// }
|
|
|
+
|
|
|
if (signCodes.contains("public")) {
|
|
|
for (Sop object : sops) {
|
|
|
if (SopConst.SOP_TYPE_GROUP.equals(object.getSopType())) {
|
|
@@ -906,6 +1301,7 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return resultSops;
|
|
|
}
|
|
|
|
|
@@ -913,6 +1309,7 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
|
|
|
|
|
|
public boolean isContainsClassObj(Sop sop) throws Exception {
|
|
|
+
|
|
|
List<SopStepsBean> steps = sop.getSteps();
|
|
|
for (SopStepsBean step : steps) {
|
|
|
Boolean from_sop = step.isFrom_sop();
|
|
@@ -1005,7 +1402,7 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
|
|
|
|
|
|
|
|
|
- private List<Sop> queryPublishedSopsByProjectIdAndUpdatetime(QuerySopListForSelVo sopListForSelVo,String projectId) throws Exception {
|
|
|
+ private List<Sop> queryPublishedSopsByProjectIdAndUpdatetime(QuerySopListForSelVo sopListForSelVo) throws Exception {
|
|
|
String sop_name = sopListForSelVo.getSop_name();
|
|
|
/*
|
|
|
//如果项目id 不是集团特有的id的话进入
|
|
@@ -1015,22 +1412,19 @@ public class GroupSopServiceImpl implements GroupSopService {
|
|
|
//设置为group_sop_id
|
|
|
projectIds.add(CommonConst.group_sop_id);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- */
|
|
|
- //查询条件为 projectIds valid sop_status SOP_STATUS_PUBLISH,
|
|
|
- // 大于等于 小于等于 不包含待修订
|
|
|
+ }*/
|
|
|
|
|
|
QueryWrapper<Sop> query = new QueryWrapper();
|
|
|
- query.eq("project_id",projectId)
|
|
|
+ query.eq("project_id",sopListForSelVo.getProjectId())
|
|
|
.eq("valid",true)
|
|
|
.eq("sop_status", SopConst.SOP_STATUS_PUBLISH)
|
|
|
.ge("update_time",sopListForSelVo.getUpdate_time_from())
|
|
|
.le("update_time",sopListForSelVo.getUpdate_time_to())
|
|
|
- .ne("publish_status",SopConst.PUBLISH_STATUS_REVISE)
|
|
|
+ //.ne("publish_status",SopConst.PUBLISH_STATUS_REVISE)
|
|
|
.like("sop_name",sop_name).orderByDesc("update_time");
|
|
|
|
|
|
|
|
|
+
|
|
|
return sopService.list(query);
|
|
|
}
|
|
|
|