Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierView.js =================================================================== diff -u -r23486 -r23501 --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierView.js (.../supplierView.js) (revision 23486) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierView.js (.../supplierView.js) (revision 23501) @@ -46,6 +46,35 @@ } +//更新supplier的预警状态 +function updateWarningStatus(){ + var mask = new Ext.LoadMask(Ext.getBody(), { + msg : '正在更新预警状态...' + }); + mask.show(); + + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/baseData/supplierAction!updateWarningStatus.do', + success : function(response, options) { + var result = Ext.decode(response.responseText); + var success = result.success; + showResult(result.message); + if (true != success) { + mask.hide(); + return; + } else { + grid.dwrReload(); + } + mask.hide(); + }, + failure : function(response, options) { + var result = Ext.decode(response.responseText); + showResult(result.message); + mask.hide(); + } + }); +} + function sync() { Ext.MessageBox.confirm("请确认","是否确定要同步供应商信息?",function(button, text){ if("yes" == button){ @@ -198,6 +227,11 @@ handler : function() { deleteSupplier(grid); } + }, '-', { + text : '更新预警状态', + hidden : false, + iconCls : 'btn_ext_application_go', + handler : updateWarningStatus } ]; var dwrCallParams = null; Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierForm.js =================================================================== diff -u -r23486 -r23501 --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierForm.js (.../supplierForm.js) (revision 23486) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierForm.js (.../supplierForm.js) (revision 23501) @@ -22,8 +22,6 @@ var columnWarningDaysWidth = 100; var columnCompanyNameWidth = 100; -//长期约定为2050-02-14 -var longTermValidityDate = new Date(2050,1,14); function validityDateRenderer(v){ if(v.getTime() == longTermValidityDate.getTime()){ Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplier/action/SupplierAction.java =================================================================== diff -u -r23486 -r23501 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplier/action/SupplierAction.java (.../SupplierAction.java) (revision 23486) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplier/action/SupplierAction.java (.../SupplierAction.java) (revision 23501) @@ -340,4 +340,13 @@ e.printStackTrace(); } } + + public void updateWarningStatus(){ + try{ + supplierManager.updateSupplierAndCertificateStatus(); + }catch(Exception e){ + StrutsResponseUtils.output(false, "预警状态更新失败"); + } + StrutsResponseUtils.output(true, "预警状态更新成功"); + } } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/supplier/Certificate.java =================================================================== diff -u -r23486 -r23501 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/supplier/Certificate.java (.../Certificate.java) (revision 23486) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/supplier/Certificate.java (.../Certificate.java) (revision 23501) @@ -89,6 +89,11 @@ public static final String CERTIFICATE_TYPE_QUALITYGUARANTEE = "质量保证书"; // public static final int CERTIFICATE_TYPE_QUALITYGUARANTEE_NUMBER = 7; + /** + * 证件长期有效,存储在数据库里的值(2050-02-14) + */ + public static final Date LONG_TERM_VALIDITY_DATE = new Date(2528380800000L); + public static List certificateTypes = new ArrayList(); static{ Index: ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/importbasedata/service/ImportBasedataManagerImpl.java =================================================================== diff -u -r23486 -r23501 --- ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/importbasedata/service/ImportBasedataManagerImpl.java (.../ImportBasedataManagerImpl.java) (revision 23486) +++ ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/importbasedata/service/ImportBasedataManagerImpl.java (.../ImportBasedataManagerImpl.java) (revision 23501) @@ -28,6 +28,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.hibernate.Transaction; +import org.springframework.web.context.ContextLoader; import com.forgon.Constants; import com.forgon.attachfile.service.AttachFileManager; @@ -153,6 +154,11 @@ private CertificateManager certificateManager; + private ImportBasedataManager importBasedataManager; + + //用于解析日期 + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + public void setLabelTemplateManager(LabelTemplateManager labelTemplateManager) { this.labelTemplateManager = labelTemplateManager; } @@ -246,7 +252,11 @@ public void setCertificateManager(CertificateManager certificateManager){ this.certificateManager = certificateManager; } - + + public void setImportBasedataManager(ImportBasedataManager importBasedataManager) { + this.importBasedataManager = importBasedataManager; + } + @Override public Map importBasedata(HttpServletRequest re) { List inputStreams = attachFileManager @@ -347,20 +357,15 @@ * @return */ private int importManufacturerBasedata(HSSFSheet ManufacturerSheet,Map msg, int totalCount) { - - StringBuffer sb = new StringBuffer(); if (ManufacturerSheet == null) { return totalCount; } int lastRowNum = ManufacturerSheet.getLastRowNum(); int successCount = 0, failureCount = 0; - //用于解析日期 - SimpleDateFormat sdf = Constants.SIMPLEDATEFORMAT_YYYYMMDD; //用于存放读取到的证件信息。当一条完整的supplier读取完毕,而且没有发生错误时,保存这个集合中的证件信息,然后清空。 List certificates = new ArrayList(); - Map nameToIndexMap = ExcelUtils.autoDetectSheepAndCreateColumnNameToIndexMap(ManufacturerSheet,1); int companyNameIndex = ExcelUtils.getColumnIndex(nameToIndexMap, "名称"); int contactIndex = ExcelUtils.getColumnIndex(nameToIndexMap, "联系人"); @@ -371,209 +376,262 @@ int licenseDateIndex = ExcelUtils.getColumnIndex(nameToIndexMap, "发证日期"); int validityDateIndex = ExcelUtils.getColumnIndex(nameToIndexMap, "有效期至"); int productRangeIndex = ExcelUtils.getColumnIndex(nameToIndexMap, "生产/经营范围"); + + + + Map parameters = new HashMap(); + parameters.put("totalCount", totalCount); + parameters.put("successCount", successCount); + parameters.put("failureCount", failureCount); + + parameters.put("ManufacturerSheet", ManufacturerSheet); + parameters.put("certificates", certificates); + parameters.put("sb", sb); - Supplier supplier = null; - HSSFRow row = null; - boolean hasError = false; + + parameters.put("companyNameIndex", companyNameIndex); + parameters.put("contactIndex", contactIndex); + parameters.put("cellPhoneIndex", cellPhoneIndex); + parameters.put("certificateTypeIndex", certificateTypeIndex); + parameters.put("certificateNumberIndex", certificateNumberIndex); + parameters.put("establishmentDateIndex", establishmentDateIndex); + parameters.put("licenseDateIndex", licenseDateIndex); + parameters.put("validityDateIndex", validityDateIndex); + parameters.put("productRangeIndex", productRangeIndex); + for (int i = 2; i <= lastRowNum;) { - row = ManufacturerSheet.getRow(i); + HSSFRow row = ManufacturerSheet.getRow(i); if (row == null || ParerUtils.isBlankRow(row)) { i++; continue; } int recordStartRowNum = i; int recordEndRowNum = getEndRowNumber(ManufacturerSheet, recordStartRowNum, lastRowNum, companyNameIndex); i = recordEndRowNum+1; - System.out.println("start line num : "+recordStartRowNum+"\tend line num :"+recordEndRowNum); - hasError = false; //清空错误标识 - certificates.clear(); - - //获取了一条记录(一个生产厂家信息)的开始行号和结束行号之后开始处理 - row = ManufacturerSheet.getRow(recordStartRowNum); - - //****生产厂家名称 - String companyName = ParerUtils.getCellFormatValue(row, companyNameIndex); - if(StringUtils.isBlank(companyName)){ //生产厂家名称为空,理论上不会出现此种情况。但是如果数据有误,第一行有效数据就没有名称,则会出现这种情况。 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordStartRowNum+1,companyNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); - continue; + try{ + importBasedataManager.readManufacturerAndSave_TRANS_NEW( recordStartRowNum, recordEndRowNum, parameters); + }catch(Exception e){ + e.printStackTrace(); } - supplier = supplierManager.getSupplierByName(companyName); //根据生产厂家的名字来判断唯一 - if(supplier == null){ - supplier = new Supplier(); - supplier.setCompanyName(companyName); - } + } + successCount = (int) parameters.get("successCount"); + failureCount = (int) parameters.get("failureCount"); + totalCount = (int) parameters.get("totalCount"); + sb = (StringBuffer) parameters.get("sb"); + + // 格式:成功插入数量#插入失败数量#失败行1,失败行2... + msg.put("生产厂家(且不是供货商)", + successCount + "#" + failureCount + "#" + sb.toString()); + return totalCount; + + } + + @Override + public void readManufacturerAndSave_TRANS_NEW(int recordStartRowNum, + int recordEndRowNum, Map parameters) { + + int companyNameIndex = (int) parameters.get("companyNameIndex"); + int contactIndex = (int) parameters.get("contactIndex"); + int cellPhoneIndex = (int) parameters.get("cellPhoneIndex"); + int certificateTypeIndex = (int) parameters.get("certificateTypeIndex"); + int certificateNumberIndex = (int) parameters.get("certificateNumberIndex"); + int establishmentDateIndex = (int) parameters.get("establishmentDateIndex"); + int licenseDateIndex = (int) parameters.get("licenseDateIndex"); + int validityDateIndex = (int) parameters.get("validityDateIndex"); + int productRangeIndex = (int) parameters.get("productRangeIndex"); + + @SuppressWarnings("unchecked") + List certificates = (List) parameters.get("certificates"); + + int successCount = (int) parameters.get("successCount"); + int failureCount = (int) parameters.get("failureCount"); + int totalCount = (int) parameters.get("totalCount"); + StringBuffer sb = (StringBuffer) parameters.get("sb"); + HSSFSheet ManufacturerSheet = (HSSFSheet) parameters.get("ManufacturerSheet"); + + Supplier supplier = null; + boolean hasError = false; + certificates.clear(); + + //获取了一条记录(一个生产厂家信息)的开始行号和结束行号之后开始处理 + HSSFRow row = ManufacturerSheet.getRow(recordStartRowNum); + + //****生产厂家名称 + String companyName = ParerUtils.getCellFormatValue(row, companyNameIndex); + if(StringUtils.isBlank(companyName)){ //生产厂家名称为空,理论上不会出现此种情况。但是如果数据有误,第一行有效数据就没有名称,则会出现这种情况。 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordStartRowNum+1,companyNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + parameters.put("failureCount", failureCount); + return ; + } + supplier = supplierManager.getSupplierByName(companyName); //根据生产厂家的名字来判断唯一 + if(supplier == null){ + supplier = new Supplier(); + supplier.setCompanyName(companyName); + } + + //****联系人 + String contact = ParerUtils.getCellFormatValue(row, contactIndex); + if(StringUtils.isNotBlank(contact)){ + supplier.setContact(contact); + } + + //****联系方式(没有对联系电话的格式进行约束) + String cellPhone = ParerUtils.getCellFormatValue(row, cellPhoneIndex); + if(StringUtils.isNotBlank(contact)){ + supplier.setCellPhone(cellPhone); + } + supplier.setIsManufacturer(true); + supplier.setRentTousse(Supplier.SUPPLIER_TYPE_MADECOMPANY); + + + //开始处理证件信息 + for( int recordLine = recordStartRowNum ; recordLine<=recordEndRowNum; recordLine++){ - //****联系人 - String contact = ParerUtils.getCellFormatValue(row, contactIndex); - if(StringUtils.isNotBlank(contact)){ - supplier.setContact(contact); + Certificate certificate = null; + row = ManufacturerSheet.getRow(recordLine); + String certificateType = ParerUtils.getCellFormatValue(row, certificateTypeIndex); + if(StringUtils.isBlank(certificateType)){ + continue;//忽略一条记录一开始,证件行为空的情况(正规格式下,不应该出现这种情况) } - //****联系方式(没有对联系电话的格式进行约束) - String cellPhone = ParerUtils.getCellFormatValue(row, cellPhoneIndex); - if(StringUtils.isNotBlank(contact)){ - supplier.setCellPhone(cellPhone); - } - supplier.setIsManufacturer(true); - supplier.setRentTousse(Supplier.SUPPLIER_TYPE_MADECOMPANY); + if(Certificate.CERTIFICATE_TYPE_PRODUCTIONCERTIFICATE.equals(certificateType) || //生产许可证 + Certificate.CERTIFICATE_TYPE_BUSINESSLICENSE.equals(certificateType)){ //营业执照 - - //开始处理证件信息 - for( int recordLine = recordStartRowNum ; recordLine<=recordEndRowNum; recordLine++){ - - Certificate certificate = null; - row = ManufacturerSheet.getRow(recordLine); - String certificateType = ParerUtils.getCellFormatValue(row, certificateTypeIndex); - if(StringUtils.isBlank(certificateType)){ - continue;//忽略一条记录一开始,证件行为空的情况(正规格式下,不应该出现这种情况) + if(DatabaseUtil.isPoIdValid(supplier.getId())){ + certificate = certificateManager.getUniqueCertificate(supplier.getId(), certificateType); } - - if(Certificate.CERTIFICATE_TYPE_PRODUCTIONCERTIFICATE.equals(certificateType) || //生产许可证 - Certificate.CERTIFICATE_TYPE_BUSINESSLICENSE.equals(certificateType)){ //营业执照 - - if(DatabaseUtil.isPoIdValid(supplier.getId())){ - certificate = certificateManager.getUniqueCertificate(supplier.getId(), certificateType); - } - - //****有效期至 - String validityDateString = ParerUtils.getCellFormatValue(row, validityDateIndex); - if(StringUtils.isNotBlank(validityDateString)){ - try { - Date validityDate = null; - if("长期".equals(validityDateString)){ - validityDate = new Date(2528380800000L); - }else{ - validityDate = sdf.parse(validityDateString); - } - if(certificate != null){ //找到相关证件 - if(validityDate.before(certificate.getValidityDate())){ //有效期输入值太早 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_DATE_IS_TO_EARLY); - hasError = true; - break; - // TODO 逻辑有待商榷 - }else if(validityDate.after(certificate.getValidityDate())){ //有效期输入值比现存的晚,说明是新证件 - certificate.setIsNowUsing(false); - certificate.setIsNeedWarning(false); - if(!certificates.contains(certificate)){ - certificates.add(certificate); - } - certificate = new Certificate(); - }else{ //有效期输入值与现在的一样,老证件,不做任何事 - + + //****有效期至 + String validityDateString = ParerUtils.getCellFormatValue(row, validityDateIndex); + if(StringUtils.isNotBlank(validityDateString)){ + try { + Date validityDate = null; + if("长期".equals(validityDateString)){ + validityDate = Certificate.LONG_TERM_VALIDITY_DATE; + }else{ + validityDate = sdf.parse(validityDateString); + } + if(certificate != null){ //找到相关证件 + if(validityDate.before(certificate.getValidityDate())){ //有效期输入值太早 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_DATE_IS_TO_EARLY); + hasError = true; + break; + // TODO 逻辑有待商榷 + }else if(validityDate.after(certificate.getValidityDate())){ //有效期输入值比现存的晚,说明是新证件 + certificate.setIsNowUsing(false); + certificate.setIsNeedWarning(false); + if(!certificates.contains(certificate)){ + certificates.add(certificate); } - }else{ //未找到相关证件(一种情况是,这个这个supplier是新建的,一种情况是这个supplier没有相关的有效证件) certificate = new Certificate(); + }else{ //有效期输入值与现在的一样,老证件,不做任何事 + } - certificate.setValidityDate(validityDate); - certificate.setType(certificateType); - certificate.setSupplier(supplier); - certificate.setIsNowUsing(true); - certificate.setIsNeedWarning(true); - - } catch (ParseException e) {//日期格式错误 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; + }else{ //未找到相关证件(一种情况是,这个这个supplier是新建的,一种情况是这个supplier没有相关的有效证件) + certificate = new Certificate(); } - }else{ //****有效期不能为空 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); - hasError = true; - break; - } + certificate.setValidityDate(validityDate); + certificate.setType(certificateType); + certificate.setSupplier(supplier); + certificate.setIsNowUsing(true); + certificate.setIsNeedWarning(true); - //****证件号码 - String certificateNumber = ParerUtils.getCellFormatValue(row, certificateNumberIndex); - if(StringUtils.isBlank(certificateNumber)){ + } catch (ParseException e) {//日期格式错误 failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,certificateNumberIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); hasError = true; break; } - certificate.setCertificateNumber(certificateNumber); + }else{ //****有效期不能为空 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + hasError = true; + break; + } - //****成立日期 - String establishmentDate = ParerUtils.getCellFormatValue(row, establishmentDateIndex); - if(StringUtils.isNotBlank(establishmentDate)){ - try { - certificate.setEstablishmentDate(sdf.parse(establishmentDate)); - } catch (ParseException e) {//日期格式错误 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,establishmentDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; - } - } - - //****发证日期 - String licenseDate = ParerUtils.getCellFormatValue(row, licenseDateIndex); - if(StringUtils.isNotBlank(licenseDate)){ - try { - certificate.setLicenseDate(sdf.parse(licenseDate)); - } catch (ParseException e) {//日期格式错误 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,licenseDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; - } - } - - //****生产/经营范围 - String productRange = ParerUtils.getCellFormatValue(row, productRangeIndex); - if(StringUtils.isNotBlank(productRange)){ - certificate.setProductRange(productRange); - } - if(!certificates.contains(certificate)){ - certificates.add(certificate); - } - }else{//未找到证件类型 + //****证件号码 + String certificateNumber = ParerUtils.getCellFormatValue(row, certificateNumberIndex); + if(StringUtils.isBlank(certificateNumber)){ failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,certificateTypeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_TYPE_INVALID); + failureCount, sb, recordLine+1,certificateNumberIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); hasError = true; break; } - }//证件处理结束 - - //****在处理证件的过程中,出现了错误。则整条数据(供应商)都不保存 - if(hasError){ - continue; - } - - if(supplier != null){ - boolean success = true; - try{ - saveSupplierAndCertificates_TRANS_NEW(totalCount,supplier,certificates); + certificate.setCertificateNumber(certificateNumber); + + //****成立日期 + String establishmentDate = ParerUtils.getCellFormatValue(row, establishmentDateIndex); + if(StringUtils.isNotBlank(establishmentDate)){ + try { + certificate.setEstablishmentDate(sdf.parse(establishmentDate)); + } catch (ParseException e) {//日期格式错误 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,establishmentDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); + hasError = true; + break; + } } - catch(RuntimeException e){ - if (sb.length() > 0) { - sb.append("|"); + + //****发证日期 + String licenseDate = ParerUtils.getCellFormatValue(row, licenseDateIndex); + if(StringUtils.isNotBlank(licenseDate)){ + try { + certificate.setLicenseDate(sdf.parse(licenseDate)); + } catch (ParseException e) {//日期格式错误 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,licenseDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); + hasError = true; + break; } - sb.append("第" + (recordStartRowNum+1) + "行附近,生产厂家\"" + supplier.getCompanyName() + "\"保存时出错:" + e.getMessage()); - failureCount++; - success = false; } - if(success){ - successCount++; + + //****生产/经营范围 + String productRange = ParerUtils.getCellFormatValue(row, productRangeIndex); + if(StringUtils.isNotBlank(productRange)){ + certificate.setProductRange(productRange); } + if(!certificates.contains(certificate)){ + certificates.add(certificate); + } + }else{//未找到证件类型 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,certificateTypeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_TYPE_INVALID); + hasError = true; + break; } + }//证件处理结束 + + //****在处理证件的过程中,出现了错误。则整条数据(供应商)都不保存 + if(hasError){ + parameters.put("failureCount", failureCount); + return ; } - // 格式:成功插入数量#插入失败数量#失败行1,失败行2... - msg.put("生产厂家(且不是供货商)", - successCount + "#" + failureCount + "#" + sb.toString()); - objectDao.getHibernateSession().clear(); - supplierManager.updateSupplierAndCertificateStatus(); - return totalCount; - + if(supplier != null){ + boolean success = true; + try{ + saveSupplierAndCertificates(totalCount,supplier,certificates); + } + catch(RuntimeException e){ + if (sb.length() > 0) { + sb.append("|"); + } + sb.append("第" + (recordStartRowNum+1) + "行附近,生产厂家\"" + supplier.getCompanyName() + "\"保存时出错:" + e.getMessage()); + failureCount++; + success = false; + } + if(success){ + successCount++; + } + } + parameters.put("successCount", successCount); + parameters.put("failureCount", failureCount); + parameters.put("totalCount", totalCount); } - - - /** * 导入供应商信息(必须先导入厂家信息) * @param sheet @@ -582,16 +640,12 @@ * @return */ private int importSupplierBasedata(HSSFSheet supplierSheet,Map msg, int totalCount) { - - StringBuffer sb = new StringBuffer(); if (supplierSheet == null) { return totalCount; } int lastRowNum = supplierSheet.getLastRowNum(); int successCount = 0, failureCount = 0; - //用于解析日期 - SimpleDateFormat sdf = Constants.SIMPLEDATEFORMAT_YYYYMMDD; //用于存放读取到的证件信息。当一条完整的supplier读取完毕,而且没有发生错误时,保存这个集合中的证件信息,然后清空。 List certificates = new ArrayList(); @@ -611,98 +665,341 @@ int disposableGoodsNameIndex = ExcelUtils.getColumnIndex(nameToIndexMap, "物品名称"); int disposableGoodsSpecificationIndex = ExcelUtils.getColumnIndex(nameToIndexMap, "规格"); int authorizerIndex = ExcelUtils.getColumnIndex(nameToIndexMap, "授权厂家"); + + Map parameters = new HashMap(); + parameters.put("companyNameIndex", companyNameIndex); + parameters.put("contactIndex", contactIndex); + parameters.put("cellPhoneIndex", cellPhoneIndex); + parameters.put("isManufacturerIndex", isManufacturerIndex); + parameters.put("certificateTypeIndex", certificateTypeIndex); + parameters.put("certificateNumberIndex", certificateNumberIndex); + parameters.put("authorizationProductRangeIndex", authorizationProductRangeIndex); + parameters.put("establishmentDateIndex", establishmentDateIndex); + parameters.put("licenseDateIndex", licenseDateIndex); + parameters.put("validityDateIndex", validityDateIndex); + parameters.put("productRangeIndex", productRangeIndex); + parameters.put("certificationGradeIndex", certificationGradeIndex); + parameters.put("disposableGoodsNameIndex", disposableGoodsNameIndex); + parameters.put("disposableGoodsSpecificationIndex", disposableGoodsSpecificationIndex); + parameters.put("authorizerIndex", authorizerIndex); - Supplier supplier = null; - HSSFRow row = null; - boolean hasError = false; + parameters.put("totalCount", totalCount); + parameters.put("successCount", successCount); + parameters.put("failureCount", failureCount); + + parameters.put("supplierSheet", supplierSheet); + parameters.put("certificates", certificates); + parameters.put("sb", sb); + + + for (int i = 2; i <= lastRowNum;) { - row = supplierSheet.getRow(i); + HSSFRow row = supplierSheet.getRow(i); if (row == null || ParerUtils.isBlankRow(row)) { i++; continue; } int recordStartRowNum = i; int recordEndRowNum = getEndRowNumber(supplierSheet, recordStartRowNum, lastRowNum, companyNameIndex); i = recordEndRowNum+1; - System.out.println("start line num : "+recordStartRowNum+"\tend line num :"+recordEndRowNum); - - hasError = false; //清空错误标识 - certificates.clear();//清空证件信息 - //获取了一条记录的开始行号和结束行号之后开始处理 - row = supplierSheet.getRow(recordStartRowNum); - - //****供应商名称 - String companyName = ParerUtils.getCellFormatValue(row, companyNameIndex); - if(StringUtils.isBlank(companyName)){ //供应商名称为空,理论上不会出现此种情况。但是如果数据有误,第一行有效数据就没有名称,则会出现这种情况。 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordStartRowNum+1,companyNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); - continue; + try{ + importBasedataManager.readSupplierAndSave_TRANS_NEW( recordStartRowNum, recordEndRowNum, parameters); + }catch(Exception e){ + e.printStackTrace(); } - supplier = supplierManager.getSupplierByName(companyName); //根据供应商的名字来判断唯一 - if(supplier == null){ - supplier = new Supplier(); - supplier.setCompanyName(companyName); - } + } + successCount = (int) parameters.get("successCount"); + failureCount = (int) parameters.get("failureCount"); + totalCount = (int) parameters.get("totalCount"); + sb = (StringBuffer) parameters.get("sb"); + + // 格式:成功插入数量#插入失败数量#失败行1,失败行2... + msg.put("供应商与证件管理", + successCount + "#" + failureCount + "#" + sb.toString()); + return totalCount; + + } + + @Override + public void readSupplierAndSave_TRANS_NEW(int recordStartRowNum, + int recordEndRowNum, Map parameters){ + + int companyNameIndex = (int) parameters.get("companyNameIndex"); + int contactIndex = (int) parameters.get("contactIndex"); + int cellPhoneIndex = (int) parameters.get("cellPhoneIndex"); + int isManufacturerIndex = (int) parameters.get("isManufacturerIndex"); + int certificateTypeIndex = (int) parameters.get("certificateTypeIndex"); + int certificateNumberIndex = (int) parameters.get("certificateNumberIndex"); + + int authorizationProductRangeIndex = (int) parameters.get("authorizationProductRangeIndex"); + int establishmentDateIndex = (int) parameters.get("establishmentDateIndex"); + int licenseDateIndex = (int) parameters.get("licenseDateIndex"); + int validityDateIndex = (int) parameters.get("validityDateIndex"); + int productRangeIndex = (int) parameters.get("productRangeIndex"); + int certificationGradeIndex = (int) parameters.get("certificationGradeIndex"); + int disposableGoodsNameIndex = (int) parameters.get("disposableGoodsNameIndex"); + int disposableGoodsSpecificationIndex = (int) parameters.get("disposableGoodsSpecificationIndex"); + int authorizerIndex = (int) parameters.get("authorizerIndex"); + + @SuppressWarnings("unchecked") + List certificates = (List) parameters.get("certificates"); + + int successCount = (int) parameters.get("successCount"); + int failureCount = (int) parameters.get("failureCount"); + int totalCount = (int) parameters.get("totalCount"); + StringBuffer sb = (StringBuffer) parameters.get("sb"); + HSSFSheet supplierSheet = (HSSFSheet) parameters.get("supplierSheet"); + + Supplier supplier = null; + boolean hasError = false; + certificates.clear(); + + //获取了一条记录的开始行号和结束行号之后开始处理 + HSSFRow row = supplierSheet.getRow(recordStartRowNum); + + //****供应商名称 + String companyName = ParerUtils.getCellFormatValue(row, companyNameIndex); + if(StringUtils.isBlank(companyName)){ //供应商名称为空,理论上不会出现此种情况。但是如果数据有误,第一行有效数据就没有名称,则会出现这种情况。 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordStartRowNum+1,companyNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + parameters.put("failureCount", failureCount); + return ; + } + supplier = supplierManager.getSupplierByName(companyName); //根据供应商的名字来判断唯一 + if(supplier == null){ + supplier = new Supplier(); + supplier.setCompanyName(companyName); + } + + //****联系人 + String contact = ParerUtils.getCellFormatValue(row, contactIndex); + if(StringUtils.isNotBlank(contact)){ + supplier.setContact(contact); + } + + //****联系方式(没有对联系电话的格式进行约束) + String cellPhone = ParerUtils.getCellFormatValue(row, cellPhoneIndex); + if(StringUtils.isNotBlank(contact)){ + supplier.setCellPhone(cellPhone); + } + + //****是否生产厂家 + String isManufacturer = ParerUtils.getCellFormatValue(row, isManufacturerIndex); + if(StringUtils.isBlank(isManufacturer)){ + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordStartRowNum+1,isManufacturerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + parameters.put("failureCount", failureCount); + return ; + } + if(isManufacturer.equals(Constants.STR_YES)){ + supplier.setIsManufacturer(true); + }else if(isManufacturer.equals(Constants.STR_NO)){ + supplier.setIsManufacturer(false); + }else{ + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordStartRowNum+1,isManufacturerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_NOT_DEFINED); + parameters.put("failureCount", failureCount); + return ; + } + supplier.setIsSupplier(true); //因为是供应商表格导入,所以肯定是供应商 + if(supplier.getIsManufacturer()){ + supplier.setRentTousse(Supplier.SUPPLIER_TYPE_MADECOMPANY); + }else{ + supplier.setRentTousse(Supplier.SUPPLIER_TYPE_SUPPLIER); + } + + //开始处理证件信息 + for( int recordLine = recordStartRowNum ; recordLine<=recordEndRowNum; recordLine++){ - //****联系人 - String contact = ParerUtils.getCellFormatValue(row, contactIndex); - if(StringUtils.isNotBlank(contact)){ - supplier.setContact(contact); + Certificate certificate = null; + row = supplierSheet.getRow(recordLine); + String certificateType = ParerUtils.getCellFormatValue(row, certificateTypeIndex); + if(StringUtils.isBlank(certificateType)){ + continue;//忽略一条记录一开始,证件行为空的情况(正规格式下,不应该出现这种情况) } - //****联系方式(没有对联系电话的格式进行约束) - String cellPhone = ParerUtils.getCellFormatValue(row, cellPhoneIndex); - if(StringUtils.isNotBlank(contact)){ - supplier.setCellPhone(cellPhone); - } - - //****是否生产厂家 - String isManufacturer = ParerUtils.getCellFormatValue(row, isManufacturerIndex); - if(StringUtils.isBlank(isManufacturer)){ - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordStartRowNum+1,isManufacturerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); - continue; - } - if(isManufacturer.equals(Constants.STR_YES)){ - supplier.setIsManufacturer(true); - }else if(isManufacturer.equals(Constants.STR_NO)){ - supplier.setIsManufacturer(false); - }else{ - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordStartRowNum+1,isManufacturerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_NOT_DEFINED); - continue; - } - supplier.setIsSupplier(true); //因为是供应商表格导入,所以肯定是供应商 - if(supplier.getIsManufacturer()){ - supplier.setRentTousse(Supplier.SUPPLIER_TYPE_MADECOMPANY); - }else{ - supplier.setRentTousse(Supplier.SUPPLIER_TYPE_SUPPLIER); - } - - //开始处理证件信息 - for( int recordLine = recordStartRowNum ; recordLine<=recordEndRowNum; recordLine++){ + //************************注册证的处理**************************** + if(Certificate.CERTIFICATE_TYPE_REGISTRATIONCERTIFICATE.equals(certificateType)){ - Certificate certificate = null; - row = supplierSheet.getRow(recordLine); - String certificateType = ParerUtils.getCellFormatValue(row, certificateTypeIndex); - if(StringUtils.isBlank(certificateType)){ - continue;//忽略一条记录一开始,证件行为空的情况(正规格式下,不应该出现这种情况) + //****注册证号码 + //任何一张注册证的注册证号码都是唯一的,直接用注册证号码来判定唯一 + String certificateNumber = ParerUtils.getCellFormatValue(row, certificateNumberIndex); + if(StringUtils.isBlank(certificateNumber)){//注册证号码不能为空 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,certificateNumberIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + hasError = true; + break; } + certificate = certificateManager.getRegistrationCertificate(certificateNumber); - //************************注册证的处理**************************** - if(Certificate.CERTIFICATE_TYPE_REGISTRATIONCERTIFICATE.equals(certificateType)){ + //****成立日期 + String establishmentDateString = ParerUtils.getCellFormatValue(row, establishmentDateIndex); + Date establishmentDate = null; + if(StringUtils.isNotBlank(establishmentDateString)){ + try { + establishmentDate = sdf.parse(establishmentDateString); + } catch (ParseException e) {//日期格式错误 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,establishmentDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); + hasError = true; + break; + } + } + + //****发证日期 + String licenseDateString = ParerUtils.getCellFormatValue(row, licenseDateIndex); + Date licenseDate = null; + if(StringUtils.isNotBlank(licenseDateString)){ + try { + licenseDate = sdf.parse(licenseDateString); + } catch (ParseException e) {//日期格式错误 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,licenseDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); + hasError = true; + break; + } + } + + //****有效期至 + String validityDateString = ParerUtils.getCellFormatValue(row, validityDateIndex); + Date validityDate = null; + if(StringUtils.isNotBlank(validityDateString)){ + try { + validityDate = sdf.parse(validityDateString); + } catch (ParseException e) {//日期格式错误 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); + hasError = true; + break; + } + }else{ //有效期不能为空 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); + hasError = true; + break; + } + + //****注册证类别 + String registrationCertificateGrade = ParerUtils.getCellFormatValue(row, certificationGradeIndex); + + + //****此注册证的生产厂家名字 + String registrationCertificateOwnerName = ParerUtils.getCellFormatValue(row, authorizerIndex); + if(StringUtils.isBlank(certificateNumber)){//此注册证必须有生产厂家,不能为空 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + hasError = true; + break; + } + Supplier registrationCertificateOwner = supplierManager.getSupplierByName(registrationCertificateOwnerName); + if(registrationCertificateOwner == null){ + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_SUPPLIER_IS_NOT_FOUND); + hasError = true; + break; + } + + //由于一条注册证可能对应多个一次性物品定义,所以有可能有多行数据 +// int registratonCertificateStartLine = recordLine; + int registratonCertificateEndLine = getEndRowNumber(supplierSheet, + recordLine, recordEndRowNum, certificateTypeIndex); - //****注册证号码 - //任何一张注册证的注册证号码都是唯一的,直接用注册证号码来判定唯一 - String certificateNumber = ParerUtils.getCellFormatValue(row, certificateNumberIndex); - if(StringUtils.isBlank(certificateNumber)){//注册证号码不能为空 + List disposableGoodss = new ArrayList(); + //****获取此注册证关联的所有一次性物品定义 + for(; recordLine <= registratonCertificateEndLine; recordLine++){ + row = supplierSheet.getRow(recordLine); + if (row == null || ParerUtils.isBlankRow(row)) { + continue; + } + + //****一次性物品名称 + String disposableGoodsName = ParerUtils.getCellFormatValue(row, disposableGoodsNameIndex); + if(StringUtils.isBlank(disposableGoodsName)){//一次性物品的名称不能为空 failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,certificateNumberIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + failureCount, sb, recordLine+1,disposableGoodsNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); hasError = true; break; } - certificate = certificateManager.getRegistrationCertificate(certificateNumber); + //****一次性物品规格 + String disposableGoodsSpecification = ParerUtils.getCellFormatValue(row, disposableGoodsSpecificationIndex); + DisposableGoods disposableGoods = diposableGoodsManager.get(disposableGoodsName, disposableGoodsSpecification); + if(disposableGoods == null){ + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,disposableGoodsNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_DISPOSABLEGOODS_UNDEFINED); + hasError = true; + break; + } + disposableGoodss.add(disposableGoods); + } + recordLine--; + + //在注册证所关联的一次性物品处理过程中,出现错误,或者,没有一次性物品定义绑定到该注册证,跳出当前证件循环 + if(hasError == true || disposableGoodss.isEmpty()){ + break; + } + + //对读到的数据进行保存 + if(certificate == null){ + certificate = new Certificate(); + } + certificate.setCertificateNumber(certificateNumber); + certificate.setCertificationGrade(registrationCertificateGrade); + certificate.setEstablishmentDate(establishmentDate); + certificate.setLicenseDate(licenseDate); + certificate.setType(certificateType); + certificate.setValidityDate(validityDate); + certificate.setSupplier(registrationCertificateOwner); + certificate.setIsNowUsing(true); + certificate.setIsNeedWarning(true); + mergeDisposableGoodsInRegistrationCertificate(certificate,disposableGoodss); + + if(!certificates.contains(certificate)){ + certificates.add(certificate); + } + if(!supplier.getRegistrationCertificates().contains(certificate)){ + supplier.getRegistrationCertificates().add(certificate); + } + }else + //***********************************授权证的处理********************************************** + if(Certificate.CERTIFICATE_TYPE_AUTHORIZATIONCERTIFICATE.equals(certificateType)){ + + //授权书的授权产品范围是必须的,根据这个来判断唯一(还有授权方) + String authorizationProductRange = ParerUtils.getCellFormatValue(row, authorizationProductRangeIndex); + if(StringUtils.isBlank(authorizationProductRange)){//授权产品范围不能为空 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,authorizationProductRangeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + hasError = true; + break; + } + + //****授权方的名称 + String authorizerName = ParerUtils.getCellFormatValue(row, authorizerIndex); + if(StringUtils.isBlank(authorizerName)){//授权厂家名字不能为空 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + hasError = true; + break; + } + Supplier authorizer = supplierManager.getSupplierByName(authorizerName); + if(authorizer == null){ + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_SUPPLIER_IS_NOT_FOUND); + hasError = true; + break; + } + //如果不是生产厂家则报错,授权方必须是生产厂家 + if(!authorizer.getIsManufacturer()){ + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_AUTHORIZER_IS_NOT_MANUFACTURER); + hasError = true; + break; + } + + //****授权证书号码 + String certificateNumber = ParerUtils.getCellFormatValue(row, certificateNumberIndex); + + //****成立日期 String establishmentDateString = ParerUtils.getCellFormatValue(row, establishmentDateIndex); Date establishmentDate = null; @@ -729,8 +1026,7 @@ hasError = true; break; } - } - + } //****有效期至 String validityDateString = ParerUtils.getCellFormatValue(row, validityDateIndex); Date validityDate = null; @@ -750,46 +1046,25 @@ break; } - //****注册证类别 - String registrationCertificateGrade = ParerUtils.getCellFormatValue(row, certificationGradeIndex); - - - //****此注册证的生产厂家名字 - String registrationCertificateOwnerName = ParerUtils.getCellFormatValue(row, authorizerIndex); - if(StringUtils.isBlank(certificateNumber)){//此注册证必须有生产厂家,不能为空 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); - hasError = true; - break; - } - Supplier registrationCertificateOwner = supplierManager.getSupplierByName(registrationCertificateOwnerName); - if(registrationCertificateOwner == null){ - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_SUPPLIER_IS_NOT_FOUND); - hasError = true; - break; - } - - //由于一条注册证可能对应多个一次性物品定义,所以有可能有多行数据 -// int registratonCertificateStartLine = recordLine; - int registratonCertificateEndLine = getEndRowNumber(supplierSheet, + //由于一条授权书可能对应多个一次性物品定义,所以有可能有多行数据 + int authorizationEndLine = getEndRowNumber(supplierSheet, recordLine, recordEndRowNum, certificateTypeIndex); List disposableGoodss = new ArrayList(); //****获取此注册证关联的所有一次性物品定义 - for(; recordLine <= registratonCertificateEndLine; recordLine++){ + for(; recordLine <= authorizationEndLine; recordLine++){ row = supplierSheet.getRow(recordLine); - if (row == null || ParerUtils.isBlankRow(row)) { - continue; - } - + //****一次性物品名称 String disposableGoodsName = ParerUtils.getCellFormatValue(row, disposableGoodsNameIndex); if(StringUtils.isBlank(disposableGoodsName)){//一次性物品的名称不能为空 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,disposableGoodsNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); - hasError = true; + //如果为空,则设定为是全部授权 + recordLine++; break; +// failureCount = appendFailureRowNumAndRecordFailureNum( +// failureCount, sb, recordLine+1,disposableGoodsNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); +// hasError = true; +// break; } //****一次性物品规格 @@ -801,403 +1076,239 @@ hasError = true; break; } + + //判断该授权方有没有对此物品的授权权利 + //本条记录中有相关的注册证,说明是新添加的 + //修改为保存的时候验证 +// if(certificatesContainsRegistrationCertificate(certificates, authorizer, disposableGoods)){ +// disposableGoodss.add(disposableGoods); +// }else if(supplierManager.canAuthorizeDisposableGoods(authorizer, disposableGoods)){ +// disposableGoodss.add(disposableGoods); +// }else{ +// failureCount = appendFailureRowNumAndRecordFailureNum( +// failureCount, sb, recordLine+1,disposableGoodsNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_CAN_NOT_AUTHORIZE); +// hasError = true; +// break; +// } disposableGoodss.add(disposableGoods); + } recordLine--; - //在注册证所关联的一次性物品处理过程中,出现错误,或者,没有一次性物品定义绑定到该注册证,跳出当前证件循环 - if(hasError == true || disposableGoodss.isEmpty()){ + //在授权书所关联的一次性物品处理过程中,出现错误跳出当前证件循环 + if(hasError == true){ break; } - //对读到的数据进行保存 + //****修改供应商信息 + if(DatabaseUtil.isPoIdValid(supplier.getId())){ + certificate = certificateManager.getAuthorizationCertificate( + supplier, authorizer, authorizationProductRange, validityDate); + } + if(certificate == null){ certificate = new Certificate(); } + certificate.setSupplier(supplier); certificate.setCertificateNumber(certificateNumber); - certificate.setCertificationGrade(registrationCertificateGrade); certificate.setEstablishmentDate(establishmentDate); certificate.setLicenseDate(licenseDate); - certificate.setType(certificateType); certificate.setValidityDate(validityDate); - certificate.setSupplier(registrationCertificateOwner); + certificate.setType(certificateType); + certificate.setProductRange(authorizationProductRange); certificate.setIsNowUsing(true); certificate.setIsNeedWarning(true); - mergeDisposableGoodsInRegistrationCertificate(certificate,disposableGoodss); - if(!certificates.contains(certificate)){ - certificates.add(certificate); + //****获取授权证关联的授权记录,如果没有,则新建一个 + AuthorizationRecord authorizationRecord = certificate.getAuthorizationRecord(); + if(authorizationRecord == null){ + authorizationRecord = new AuthorizationRecord(); } - if(!supplier.getRegistrationCertificates().contains(certificate)){ - supplier.getRegistrationCertificates().add(certificate); - } - }else - //***********************************授权证的处理********************************************** - //TODO 授权证 - if(Certificate.CERTIFICATE_TYPE_AUTHORIZATIONCERTIFICATE.equals(certificateType)){ - - //授权书的授权产品范围是必须的,根据这个来判断唯一(还有授权方) - String authorizationProductRange = ParerUtils.getCellFormatValue(row, authorizationProductRangeIndex); - if(StringUtils.isBlank(authorizationProductRange)){//授权产品范围不能为空 + certificate.setAuthorizationRecord(authorizationRecord); + + authorizationRecord.setAuthorized(supplier); + authorizationRecord.setAuthorizedName(supplier.getCompanyName()); + authorizationRecord.setAuthorizer(authorizer); + authorizationRecord.setAuthorizerName(authorizer.getCompanyName()); + authorizationRecord.setValidityDate(validityDate); + authorizationRecord.setManufacturerId(authorizer.getId()); + //如果授权书没有关联具体的一次性物品,则表示对于该授权方(必须是厂家)的所有一次性物品全部授权 + if(disposableGoodss.isEmpty()){ + disposableGoodss = supplierManager.getAllDisposableGoodsOfManufacturer(authorizer.getId()); + if(disposableGoodss.isEmpty()){//授权方没有一次性物品可以授权 failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,authorizationProductRangeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_AUTHORIZER_HAS_NO_DISPOSABLEGOODS); hasError = true; break; } - - //****授权方的名称 - String authorizerName = ParerUtils.getCellFormatValue(row, authorizerIndex); - if(StringUtils.isBlank(authorizerName)){//授权厂家名字不能为空 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); - hasError = true; - break; - } - Supplier authorizer = supplierManager.getSupplierByName(authorizerName); - if(authorizer == null){ - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_SUPPLIER_IS_NOT_FOUND); - hasError = true; - break; - } - //如果不是生产厂家则报错,授权方必须是生产厂家 - if(!authorizer.getIsManufacturer()){ - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_AUTHORIZER_IS_NOT_MANUFACTURER); - hasError = true; - break; - } - - //****授权证书号码 - String certificateNumber = ParerUtils.getCellFormatValue(row, certificateNumberIndex); - - - //****成立日期 - String establishmentDateString = ParerUtils.getCellFormatValue(row, establishmentDateIndex); - Date establishmentDate = null; - if(StringUtils.isNotBlank(establishmentDateString)){ - try { - establishmentDate = sdf.parse(establishmentDateString); - } catch (ParseException e) {//日期格式错误 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,establishmentDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; - } - } - - //****发证日期 - String licenseDateString = ParerUtils.getCellFormatValue(row, licenseDateIndex); - Date licenseDate = null; - if(StringUtils.isNotBlank(licenseDateString)){ - try { - licenseDate = sdf.parse(licenseDateString); - } catch (ParseException e) {//日期格式错误 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,licenseDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; - } - } - //****有效期至 - String validityDateString = ParerUtils.getCellFormatValue(row, validityDateIndex); + } + mergeDisposableGoodsInAuthorizationRecord(authorizationRecord,disposableGoodss); +// for (DisposableGoods disposableGoods : authorizationRecord.getDisposableGoodss()) { +// disposableGoods.setIsNeedAuthorization(true); +// } + + if(!certificates.contains(certificate)){ + certificates.add(certificate); + } + }else + //*****************这几种证件都是根据有效期来判断的,因为每一个supplier只会有一个这些类型的证件。如果*************** + if(Certificate.CERTIFICATE_TYPE_PRODUCTIONCERTIFICATE.equals(certificateType) || //生产许可证 + Certificate.CERTIFICATE_TYPE_BUSINESSLICENSE.equals(certificateType) || //营业执照 + Certificate.CERTIFICATE_TYPE_BUSINESSCERTIFICATE.equals(certificateType) || //经营许可证 + Certificate.CERTIFICATE_TYPE_QUALITYGUARANTEE.equals(certificateType) || //质量保证书 + Certificate.CERTIFICATE_TYPE_AUTHORIZATIONLETTER.equals(certificateType)){ //法人委托授权书 + + if(Certificate.CERTIFICATE_TYPE_PRODUCTIONCERTIFICATE.equals(certificateType)){ + if(!supplier.getIsManufacturer()){ + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,certificateTypeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_TYPE_UNMATCH); + hasError = true; + break; + } + }else{ + if(!supplier.getIsSupplier()){ + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,certificateTypeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_TYPE_UNMATCH); + hasError = true; + break; + } + } + + if(DatabaseUtil.isPoIdValid(supplier.getId())){ + certificate = certificateManager.getUniqueCertificate(supplier.getId(), certificateType); + } + + //****有效期至 + String validityDateString = ParerUtils.getCellFormatValue(row, validityDateIndex); + if(StringUtils.isNotBlank(validityDateString)){ + try { Date validityDate = null; - if(StringUtils.isNotBlank(validityDateString)){ - try { - validityDate = sdf.parse(validityDateString); - } catch (ParseException e) {//日期格式错误 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; - } - }else{ //有效期不能为空 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; + if("长期".equals(validityDateString)){ + validityDate = Certificate.LONG_TERM_VALIDITY_DATE; + }else{ + validityDate = sdf.parse(validityDateString); } - - //由于一条授权书可能对应多个一次性物品定义,所以有可能有多行数据 - int authorizationEndLine = getEndRowNumber(supplierSheet, - recordLine, recordEndRowNum, certificateTypeIndex); - - List disposableGoodss = new ArrayList(); - //****获取此注册证关联的所有一次性物品定义 - for(; recordLine <= authorizationEndLine; recordLine++){ - row = supplierSheet.getRow(recordLine); - - //****一次性物品名称 - String disposableGoodsName = ParerUtils.getCellFormatValue(row, disposableGoodsNameIndex); - if(StringUtils.isBlank(disposableGoodsName)){//一次性物品的名称不能为空 - //如果为空,则设定为是全部授权 - recordLine++; - break; -// failureCount = appendFailureRowNumAndRecordFailureNum( -// failureCount, sb, recordLine+1,disposableGoodsNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); -// hasError = true; -// break; - } - - //****一次性物品规格 - String disposableGoodsSpecification = ParerUtils.getCellFormatValue(row, disposableGoodsSpecificationIndex); - DisposableGoods disposableGoods = diposableGoodsManager.get(disposableGoodsName, disposableGoodsSpecification); - if(disposableGoods == null){ + if(certificate != null){ //找到相关证件 + if(validityDate.before(certificate.getValidityDate())){ //有效期输入值太早 failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,disposableGoodsNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_DISPOSABLEGOODS_UNDEFINED); + failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_DATE_IS_TO_EARLY); hasError = true; break; - } - - //判断该授权方有没有对此物品的授权权利 - //本条记录中有相关的注册证,说明是新添加的 - //修改为保存的时候验证 -// if(certificatesContainsRegistrationCertificate(certificates, authorizer, disposableGoods)){ -// disposableGoodss.add(disposableGoods); -// }else if(supplierManager.canAuthorizeDisposableGoods(authorizer, disposableGoods)){ -// disposableGoodss.add(disposableGoods); -// }else{ -// failureCount = appendFailureRowNumAndRecordFailureNum( -// failureCount, sb, recordLine+1,disposableGoodsNameIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_CAN_NOT_AUTHORIZE); -// hasError = true; -// break; -// } - disposableGoodss.add(disposableGoods); + // TODO 逻辑有待商榷 + }else if(validityDate.after(certificate.getValidityDate())){ //有效期输入值比现存的晚,说明是新证件 + certificate.setIsNowUsing(false); + certificate.setIsNeedWarning(false); + if(!certificates.contains(certificate)){ + certificates.add(certificate); + } + certificate = new Certificate(); + }else{ //有效期输入值与现在的一样,老证件,不做任何事 - } - recordLine--; - - //在授权书所关联的一次性物品处理过程中,出现错误跳出当前证件循环 - if(hasError == true){ - break; - } - - //****修改供应商信息 - if(DatabaseUtil.isPoIdValid(supplier.getId())){ - certificate = certificateManager.getAuthorizationCertificate( - supplier, authorizer, authorizationProductRange, validityDate); - } - - if(certificate == null){ + } + }else{ //未找到相关证件(一种情况是,这个这个supplier是新建的,一种情况是这个supplier没有相关的有效证件) certificate = new Certificate(); } - certificate.setSupplier(supplier); - certificate.setCertificateNumber(certificateNumber); - certificate.setEstablishmentDate(establishmentDate); - certificate.setLicenseDate(licenseDate); certificate.setValidityDate(validityDate); certificate.setType(certificateType); - certificate.setProductRange(authorizationProductRange); + certificate.setSupplier(supplier); certificate.setIsNowUsing(true); certificate.setIsNeedWarning(true); - //****获取授权证关联的授权记录,如果没有,则新建一个 - AuthorizationRecord authorizationRecord = certificate.getAuthorizationRecord(); - if(authorizationRecord == null){ - authorizationRecord = new AuthorizationRecord(); - } - certificate.setAuthorizationRecord(authorizationRecord); - - authorizationRecord.setAuthorized(supplier); - authorizationRecord.setAuthorizedName(supplier.getCompanyName()); - authorizationRecord.setAuthorizer(authorizer); - authorizationRecord.setAuthorizerName(authorizer.getCompanyName()); - authorizationRecord.setValidityDate(validityDate); - authorizationRecord.setManufacturerId(authorizer.getId()); - //如果授权书没有关联具体的一次性物品,则表示对于该授权方(必须是厂家)的所有一次性物品全部授权 - if(disposableGoodss.isEmpty()){ - disposableGoodss = supplierManager.getAllDisposableGoodsOfManufacturer(authorizer.getId()); - if(disposableGoodss.isEmpty()){//授权方没有一次性物品可以授权 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,authorizerIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_AUTHORIZER_HAS_NO_DISPOSABLEGOODS); - hasError = true; - break; - } - } - mergeDisposableGoodsInAuthorizationRecord(authorizationRecord,disposableGoodss); -// for (DisposableGoods disposableGoods : authorizationRecord.getDisposableGoodss()) { -// disposableGoods.setIsNeedAuthorization(true); -// } - - if(!certificates.contains(certificate)){ - certificates.add(certificate); - } - }else - //*****************这几种证件都是根据有效期来判断的,因为每一个supplier只会有一个这些类型的证件。如果*************** - if(Certificate.CERTIFICATE_TYPE_PRODUCTIONCERTIFICATE.equals(certificateType) || //生产许可证 - Certificate.CERTIFICATE_TYPE_BUSINESSLICENSE.equals(certificateType) || //营业执照 - Certificate.CERTIFICATE_TYPE_BUSINESSCERTIFICATE.equals(certificateType) || //经营许可证 - Certificate.CERTIFICATE_TYPE_QUALITYGUARANTEE.equals(certificateType) || //质量保证书 - Certificate.CERTIFICATE_TYPE_AUTHORIZATIONLETTER.equals(certificateType)){ //法人委托授权书 - - if(Certificate.CERTIFICATE_TYPE_PRODUCTIONCERTIFICATE.equals(certificateType)){ - if(!supplier.getIsManufacturer()){ - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,certificateTypeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_TYPE_UNMATCH); - hasError = true; - break; - } - }else{ - if(!supplier.getIsSupplier()){ - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,certificateTypeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_TYPE_UNMATCH); - hasError = true; - break; - } - } - - if(DatabaseUtil.isPoIdValid(supplier.getId())){ - certificate = certificateManager.getUniqueCertificate(supplier.getId(), certificateType); - } - - //****有效期至 - String validityDateString = ParerUtils.getCellFormatValue(row, validityDateIndex); - if(StringUtils.isNotBlank(validityDateString)){ - try { - Date validityDate = null; - if("长期".equals(validityDateString)){ - validityDate = new Date(2528380800000L); - }else{ - validityDate = sdf.parse(validityDateString); - } - if(certificate != null){ //找到相关证件 - if(validityDate.before(certificate.getValidityDate())){ //有效期输入值太早 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_DATE_IS_TO_EARLY); - hasError = true; - break; - // TODO 逻辑有待商榷 - }else if(validityDate.after(certificate.getValidityDate())){ //有效期输入值比现存的晚,说明是新证件 - certificate.setIsNowUsing(false); - certificate.setIsNeedWarning(false); - if(!certificates.contains(certificate)){ - certificates.add(certificate); - } - certificate = new Certificate(); - }else{ //有效期输入值与现在的一样,老证件,不做任何事 - - } - }else{ //未找到相关证件(一种情况是,这个这个supplier是新建的,一种情况是这个supplier没有相关的有效证件) - certificate = new Certificate(); - } - certificate.setValidityDate(validityDate); - certificate.setType(certificateType); - certificate.setSupplier(supplier); - certificate.setIsNowUsing(true); - certificate.setIsNeedWarning(true); - - } catch (ParseException e) {//日期格式错误 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; - } - }else{ //****有效期不能为空 + } catch (ParseException e) {//日期格式错误 failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); hasError = true; break; } - - //****证件号码 - String certificateNumber = ParerUtils.getCellFormatValue(row, certificateNumberIndex); - if(StringUtils.isBlank(certificateNumber) && - !Certificate.CERTIFICATE_TYPE_AUTHORIZATIONLETTER.equals(certificateType) && - !Certificate.CERTIFICATE_TYPE_QUALITYGUARANTEE.equals(certificateType) ){ - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,certificateNumberIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); - hasError = true; - break; - } - certificate.setCertificateNumber(certificateNumber); + }else{ //****有效期不能为空 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,validityDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); + hasError = true; + break; + } - //****成立日期 - String establishmentDate = ParerUtils.getCellFormatValue(row, establishmentDateIndex); - if(StringUtils.isNotBlank(establishmentDate)){ - try { - certificate.setEstablishmentDate(sdf.parse(establishmentDate)); - } catch (ParseException e) {//日期格式错误 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,establishmentDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; - } - } - - //****发证日期 - String licenseDate = ParerUtils.getCellFormatValue(row, licenseDateIndex); - if(StringUtils.isNotBlank(licenseDate)){ - try { - certificate.setLicenseDate(sdf.parse(licenseDate)); - } catch (ParseException e) {//日期格式错误 - failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,licenseDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); - hasError = true; - break; - } - } - - //****生产/经营范围 - String productRange = ParerUtils.getCellFormatValue(row, productRangeIndex); - if(StringUtils.isNotBlank(productRange)){ - certificate.setProductRange(productRange); - } - if(!certificates.contains(certificate)){ - certificates.add(certificate); - } - }else{//未找到证件类型 + //****证件号码 + String certificateNumber = ParerUtils.getCellFormatValue(row, certificateNumberIndex); + if(StringUtils.isBlank(certificateNumber) && + !Certificate.CERTIFICATE_TYPE_AUTHORIZATIONLETTER.equals(certificateType) && + !Certificate.CERTIFICATE_TYPE_QUALITYGUARANTEE.equals(certificateType) ){ failureCount = appendFailureRowNumAndRecordFailureNum( - failureCount, sb, recordLine+1,certificateTypeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_TYPE_INVALID); + failureCount, sb, recordLine+1,certificateNumberIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_BLANK); hasError = true; break; } - }//证件处理结束 - - //****在处理证件的过程中,出现了错误。则整条数据(供应商)都不保存 - if(hasError){ - continue; - } - if(supplier != null){ - boolean success = true; - try{ - saveSupplierAndCertificates_TRANS_NEW(totalCount,supplier,certificates); + certificate.setCertificateNumber(certificateNumber); + + //****成立日期 + String establishmentDate = ParerUtils.getCellFormatValue(row, establishmentDateIndex); + if(StringUtils.isNotBlank(establishmentDate)){ + try { + certificate.setEstablishmentDate(sdf.parse(establishmentDate)); + } catch (ParseException e) {//日期格式错误 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,establishmentDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); + hasError = true; + break; + } } - catch(RuntimeException e){ - e.printStackTrace(); - - if (sb.length() > 0) { - sb.append("|"); + + //****发证日期 + String licenseDate = ParerUtils.getCellFormatValue(row, licenseDateIndex); + if(StringUtils.isNotBlank(licenseDate)){ + try { + certificate.setLicenseDate(sdf.parse(licenseDate)); + } catch (ParseException e) {//日期格式错误 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,licenseDateIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_IS_NOT_DATE); + hasError = true; + break; } - sb.append("第" + (recordStartRowNum+1) + "行附近,厂商\"" + supplier.getCompanyName() + "\"保存时出错:" + e.getMessage()); - failureCount++; - success = false; } - if(success){ - successCount++; + + //****生产/经营范围 + String productRange = ParerUtils.getCellFormatValue(row, productRangeIndex); + if(StringUtils.isNotBlank(productRange)){ + certificate.setProductRange(productRange); } + if(!certificates.contains(certificate)){ + certificates.add(certificate); + } + }else{//未找到证件类型 + failureCount = appendFailureRowNumAndRecordFailureNum( + failureCount, sb, recordLine+1,certificateTypeIndex,com.forgon.disinfectsystem.common.Constants.ERROR_TYPE_TYPE_INVALID); + hasError = true; + break; } -// if(supplier != null){ -// totalCount = saveOrUpdateAndClearCache(totalCount,supplier); -// successCount++; -// for (Certificate certificate : certificates) { -//// if(certificate.getType() != Certificate.CERTIFICATE_TYPE_REGISTRATIONCERTIFICATE){ -//// certificate.setSupplier(supplier); -//// } -// objectDao.saveOrUpdate(certificate); -// } -// } + }//证件处理结束 + + //****在处理证件的过程中,出现了错误。则整条数据(供应商)都不保存 + if(hasError){ + parameters.put("failureCount", failureCount); + return ; } - - // 格式:成功插入数量#插入失败数量#失败行1,失败行2... - msg.put("供应商与证件管理", - successCount + "#" + failureCount + "#" + sb.toString()); - objectDao.getHibernateSession().clear(); - supplierManager.updateSupplierAndCertificateStatus(); - return totalCount; - + if(supplier != null){ + boolean success = true; + try{ + saveSupplierAndCertificates(totalCount,supplier,certificates); + } + catch(RuntimeException e){ + if (sb.length() > 0) { + sb.append("|"); + } + sb.append("第" + (recordStartRowNum+1) + "行附近,厂商\"" + supplier.getCompanyName() + "\"保存时出错:" + e.getMessage()); + failureCount++; + success = false; + } + if(success){ + successCount++; + } + } + parameters.put("successCount", successCount); + parameters.put("failureCount", failureCount); + parameters.put("totalCount", totalCount); } - private int saveSupplierAndCertificates_TRANS_NEW(int totalCount, Supplier supplier, List certificates){ + private int saveSupplierAndCertificates(int totalCount, Supplier supplier, List certificates){ supplierManager.saveOrUpdate(supplier); List registratonCertificates = certificates.stream(). filter(p->p.getType().equals(Certificate.CERTIFICATE_TYPE_REGISTRATIONCERTIFICATE)).collect(Collectors.toList()); @@ -1217,29 +1328,6 @@ } /** - * 检查本条供应商记录已经保存到certificates集合(还没有持久化到数据库中)的证件中,有没有该产品的注册证 - * @param certificates - * @param authorizer - * @param disposableGoods - * @return - */ - private boolean certificatesContainsRegistrationCertificate( - List certificates, Supplier authorizer, DisposableGoods disposableGoods) { - if(certificates == null || certificates.isEmpty()){ - return false; - } - for (Certificate certificate : certificates) { - if(Certificate.CERTIFICATE_TYPE_REGISTRATIONCERTIFICATE.equals(certificate.getType()) && - certificate.getIsNowUsing() && certificate.getDisposableGoodss() != null){ - if(certificate.getDisposableGoodss().contains(disposableGoods)){ - return true; - } - } - } - return false; - } - - /** * 把注册证certificate关联到一次性物品disposableGoodss。 * @param certificate * @param disposableGoodss @@ -6044,4 +6132,5 @@ objectDao.delete(cssdHandleTousses); } } + } Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierView.jsp =================================================================== diff -u -r23486 -r23501 --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierView.jsp (.../supplierView.jsp) (revision 23486) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierView.jsp (.../supplierView.jsp) (revision 23501) @@ -70,6 +70,8 @@ var supplier = '<%=Supplier.SUPPLIER_TYPE_SUPPLIER%>';//供货单位 var expensivegoodssupplier = '<%=Supplier.SUPPLIER_TYPE_EXPENSIVEGOODSSUPPLIER%>';//高值耗材供应商 var warningDays = '<%=Certificate.WARNINGDAYS%>'//默认预警天数 +var longTermValidityDateTime = '<%=Certificate.LONG_TERM_VALIDITY_DATE.getTime()%>'//长期有效对应存储的值 +var longTermValidityDate = new Date(+longTermValidityDateTime); var warningStatus_warning = '<%=Supplier.SUPPLIER_WRANINGSTATUS_WARNING%>' //预警状态 var warningStatus_expired = '<%=Supplier.SUPPLIER_WRANINGSTATUS_EXPIRED%>' //过期状态 Index: ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/importbasedata/service/ImportBasedataManager.java =================================================================== diff -u -r17534 -r23501 --- ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/importbasedata/service/ImportBasedataManager.java (.../ImportBasedataManager.java) (revision 17534) +++ ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/importbasedata/service/ImportBasedataManager.java (.../ImportBasedataManager.java) (revision 23501) @@ -8,6 +8,9 @@ import org.apache.poi.hssf.usermodel.HSSFSheet; +import com.forgon.disinfectsystem.entity.basedatamanager.supplier.Certificate; +import com.forgon.disinfectsystem.entity.basedatamanager.supplier.Supplier; + /** * * @author qjw @@ -42,4 +45,12 @@ * @return */ public Map importInterfereOrgUnitData(HttpServletRequest re); + + + + public void readManufacturerAndSave_TRANS_NEW(int recordStartRowNum, + int recordEndRowNum, Map parameters); + + public void readSupplierAndSave_TRANS_NEW(int recordStartRowNum, + int recordEndRowNum, Map parameters); }