| | |
| | | Map<Id,List<String>> pro2Map = new Map<Id,List<String>>(); |
| | | //存放注册证上最前的维护日,一类证优先,否则二类证。 |
| | | Map<Id,Date> prSteMap = new Map<Id,Date>();//存一类维护日 |
| | | Map<Id,Date> prSte1Map = new Map<Id,Date>();//存二类维护日 |
| | | //Map<Id,Date> prSte1Map = new Map<Id,Date>();//存二类维护日 |
| | | if (pro2List.size()>0) { |
| | | for (Product_Register_Link__c prl: pro2List) { |
| | | //有医疗器械分类就增加,没有就放进去 |
| | |
| | | prSteMap.put(prl.Product2__r.Id,null); |
| | | } |
| | | } |
| | | //和上面一样 |
| | | /*//和上面一样 |
| | | if ((prl.Product_Register__r.MedPrdClass__c == '2' || prl.Product_Register__r.MedPrdClass__c == '3') && prl.Product_Register__r.Stelsedag__c <> null && |
| | | (newMap.get(prl.Product2__r.Id).demoteer_Sap__c <= prl.Product_Register__r.ValidTo__c && newMap.get(prl.Product2__r.Id).demoteer_Sap__c >= prl.Product_Register__r.ValidFrom__c)) { |
| | | System.debug(prSte1Map.containsKey(prl.Product2__r.Id)); |
| | |
| | | if (!prSte1Map.containsKey(prl.Product2__r.Id) || prSte1Map.get(prl.Product2__r.Id) == null) { |
| | | prSte1Map.put(prl.Product2__r.Id,null); |
| | | } |
| | | } |
| | | }*/ |
| | | } |
| | | } |
| | | |
| | |
| | | Map<Id,String> prlMap = new Map<Id,String>(); |
| | | Map<Id,String> prl1Map = new Map<Id,String>(); |
| | | Map<Id,String> prl2Map = new Map<Id,String>(); |
| | | Map<Id,String> prl3Map = new Map<Id,String>(); |
| | | System.debug('pro2Map='+pro2Map); |
| | | System.debug('prSteMap='+prSteMap); |
| | | System.debug('prSte1Map='+prSte1Map); |
| | | /*System.debug('prSte1Map='+prSte1Map);*/ |
| | | Date stedate; |
| | | |
| | | //通过上面的循环,把关系表过获取的数据读出来,传给map,一共分为3个map,要注意 |
| | | if (pro2Map.size()>0) { |
| | | for (Product_Register_Link__c pr: pro2List) { |
| | | //保证id在上面的map里存在,但是这一步有没有好像没啥区别,又没错误,索性不删掉 |
| | | if (pro2Map.containsKey(pr.Product2__r.Id) && (prSteMap.containsKey(pr.Product2__r.Id) || prSte1Map.containsKey(pr.Product2__r.Id))) { |
| | | //&& (prSteMap.containsKey(pr.Product2__r.Id)) || prSte1Map.containsKey(pr.Product2__r.Id) |
| | | if (pro2Map.containsKey(pr.Product2__r.Id)) { |
| | | //取得是产品的生产日期在注册证的有效期内的注册证上面的维护日,一类优先,其次二类 |
| | | stedate = prSteMap.get(pr.Product2__r.Id)==null?(prSte1Map.get(pr.Product2__r.Id)==null?null:prSte1Map.get(pr.Product2__r.Id)):prSteMap.get(pr.Product2__r.Id); |
| | | if (stedate <> null) { |
| | | //保证产品上的生产日有值 |
| | | if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <> null) { |
| | | //注册证维护日有值 |
| | | if (pr.Product_Register__r.Stelsedag__c <> null) { |
| | | //入库日小于等于维护日 |
| | | if (newMap.get(pr.Product2__r.Id).Diedatvanink__c == null || newMap.get(pr.Product2__r.Id).Diedatvanink__c <= stedate) { |
| | | if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c |
| | | && pr.Product_Register__r.MedPrdClass__c == '2' || pr.Product_Register__r.MedPrdClass__c == '3') { |
| | | System.debug('2'); |
| | | /*stedate = prSteMap.get(pr.Product2__r.Id)==null?(prSte1Map.get(pr.Product2__r.Id)==null?null:prSte1Map.get(pr.Product2__r.Id)):prSteMap.get(pr.Product2__r.Id);*/ |
| | | stedate = prSteMap.get(pr.Product2__r.Id); |
| | | //保证产品上的生产日有值 |
| | | if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <> null) { |
| | | //注册证维护日有值 |
| | | if (stedate <> null) { |
| | | //入库日小于等于维护日 |
| | | if (newMap.get(pr.Product2__r.Id).Diedatvanink__c == null || newMap.get(pr.Product2__r.Id).Diedatvanink__c <= stedate) { |
| | | if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c |
| | | && (pr.Product_Register__r.MedPrdClass__c == '2' || pr.Product_Register__r.MedPrdClass__c == '3')) { |
| | | System.debug('2'); |
| | | if (prlMap.get(pr.Product2__r.Id) == null || !prlMap.containsKey(pr.Product2__r.Id)) { |
| | | prlMap.put(pr.Product2__r.Id, '二类'); |
| | | }else { |
| | | String Lins = prlMap.get(pr.Product2__r.Id); |
| | | Lins += '二类'; |
| | | prlMap.put(pr.Product2__r.Id, Lins); |
| | | } |
| | | }else if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c |
| | | && pr.Product_Register__r.MedPrdClass__c == '1') { |
| | | System.debug('1'); |
| | | if (prlMap.get(pr.Product2__r.Id) == null || !prlMap.containsKey(pr.Product2__r.Id)) { |
| | | prlMap.put(pr.Product2__r.Id, '二类'); |
| | | prlMap.put(pr.Product2__r.Id, '一类'); |
| | | }else { |
| | | String Lins = prlMap.get(pr.Product2__r.Id); |
| | | Lins += '二类'; |
| | | Lins += '一类'; |
| | | prlMap.put(pr.Product2__r.Id, Lins); |
| | | } |
| | | }else if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c |
| | | && (pr.Product_Register__r.MedPrdClass__c == '1')) { |
| | | System.debug('1'); |
| | | if (prlMap.get(pr.Product2__r.Id) == null || !prlMap.containsKey(pr.Product2__r.Id)) { |
| | | prlMap.put(pr.Product2__r.Id, '一类'); |
| | | }else { |
| | | String Lins = prlMap.get(pr.Product2__r.Id); |
| | | Lins += '一类'; |
| | | prlMap.put(pr.Product2__r.Id, Lins); |
| | | } |
| | | } |
| | | //入库日大于维护日 |
| | | }else if (newMap.get(pr.Product2__r.Id).Diedatvanink__c <> null && newMap.get(pr.Product2__r.Id).Diedatvanink__c > stedate) { |
| | | if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c |
| | | && pr.Product_Register__r.MedPrdClass__c == '1') { |
| | | if (prl1Map.get(pr.Product2__r.Id) == null || !prl1Map.containsKey(pr.Product2__r.Id)) { |
| | | prl1Map.put(pr.Product2__r.Id, '一类'); |
| | | }else { |
| | | String Lins = prl1Map.get(pr.Product2__r.Id); |
| | | Lins += '一类'; |
| | | prl1Map.put(pr.Product2__r.Id, Lins); |
| | | } |
| | | //入库日大于维护日 |
| | | }else if (newMap.get(pr.Product2__r.Id).Diedatvanink__c <> null && newMap.get(pr.Product2__r.Id).Diedatvanink__c > stedate) { |
| | | if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c |
| | | && pr.Product_Register__r.MedPrdClass__c == '1') { |
| | | if (prl1Map.get(pr.Product2__r.Id) == null || !prl1Map.containsKey(pr.Product2__r.Id)) { |
| | | prl1Map.put(pr.Product2__r.Id, '一类'); |
| | | }else { |
| | | String Lins = prl1Map.get(pr.Product2__r.Id); |
| | | Lins += '一类'; |
| | | prl1Map.put(pr.Product2__r.Id, Lins); |
| | | } |
| | | }else if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c |
| | | && pr.Product_Register__r.MedPrdClass__c == '2' || pr.Product_Register__r.MedPrdClass__c == '3') { |
| | | if (prl1Map.get(pr.Product2__r.Id) == null || !prl1Map.containsKey(pr.Product2__r.Id)) { |
| | | prl1Map.put(pr.Product2__r.Id, '二类'); |
| | | }else { |
| | | String Lins = prl1Map.get(pr.Product2__r.Id); |
| | | Lins += '二类'; |
| | | prl1Map.put(pr.Product2__r.Id, Lins); |
| | | } |
| | | }else if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c |
| | | && pr.Product_Register__r.MedPrdClass__c == '2' || pr.Product_Register__r.MedPrdClass__c == '3') { |
| | | if (prl1Map.get(pr.Product2__r.Id) == null || !prl1Map.containsKey(pr.Product2__r.Id)) { |
| | | prl1Map.put(pr.Product2__r.Id, '二类'); |
| | | }else { |
| | | String Lins = prl1Map.get(pr.Product2__r.Id); |
| | | Lins += '二类'; |
| | | prl1Map.put(pr.Product2__r.Id, Lins); |
| | | } |
| | | } |
| | | }else { |
| | | //维护日空,这个map置空 |
| | | prl2Map.put(pr.Product2__r.Id, '空'); |
| | | } |
| | | }else if (stedate == null && newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c |
| | | && (pr.Product_Register__r.MedPrdClass__c == '2' || pr.Product_Register__r.MedPrdClass__c == '3')) { |
| | | prl3Map.put(pr.Product2__r.Id, '二类'); |
| | | }else { |
| | | //维护日空,也没有二类证,这个map置空 |
| | | prl2Map.put(pr.Product2__r.Id, '空'); |
| | | } |
| | | }else { |
| | | //前面map无值,这个map置空 |
| | | prl2Map.put(pr.Product2__r.Id, '空'); |
| | | } |
| | | } |
| | | } |
| | |
| | | }else if (prl1Map.get(pr2.Id).contains('二类') && !prl1Map.get(pr2.Id).contains('一类')) { |
| | | pr2.Level_Category__c = '二类'; |
| | | } |
| | | }else if (prl3Map.containsKey(pr2.Id)) { |
| | | pr2.Level_Category__c = '二类'; |
| | | }else if (prl2Map.containsKey(pr2.Id)) { |
| | | //为了避免麻烦与后续修改,统一非监管了。 |
| | | pr2.Level_Category__c = '非监管'; |