Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/ContractItem.java =================================================================== diff -u -r23679 -r24207 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/ContractItem.java (.../ContractItem.java) (revision 23679) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/ContractItem.java (.../ContractItem.java) (revision 24207) @@ -44,12 +44,12 @@ public static final String CONTRACT_GOODS_TYPE_MATERIALDEFINITION = "器械材料"; /** - * 一次性物品定义Id + * 一次性物品定义Id(已不用) */ private Long disposableGoodsId; /** - * 材料定义id + * 材料定义id(已不用) */ private Long materialDefinitionId; @@ -61,14 +61,19 @@ /** * 规格 */ - private String specification; + //private String specification; /** * 单价 */ private Double price; /** + * 单位 + */ + private String unit; + + /** * 数量 */ private Integer amount; @@ -134,13 +139,6 @@ this.name = name; } - public String getSpecification() { - return specification; - } - public void setSpecification(String specification) { - this.specification = specification; - } - public Double getPrice() { return price; } @@ -174,5 +172,11 @@ public void setPlaceOfUse(String placeOfUse) { this.placeOfUse = placeOfUse; } + public String getUnit() { + return unit; + } + public void setUnit(String unit) { + this.unit = unit; + } } Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/action/ContractAction.java =================================================================== diff -u -r23679 -r24207 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/action/ContractAction.java (.../ContractAction.java) (revision 23679) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/action/ContractAction.java (.../ContractAction.java) (revision 24207) @@ -1,17 +1,9 @@ package com.forgon.disinfectsystem.diposablegoods.action; -import java.io.IOException; -import java.io.PrintWriter; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.servlet.http.HttpServletResponse; - import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -21,30 +13,13 @@ import org.apache.struts2.convention.annotation.ParentPackage; import com.forgon.Constants; -import com.forgon.directory.acegi.tools.AcegiHelper; -import com.forgon.directory.model.OrgUnit; -import com.forgon.directory.service.OrgUnitManager; -import com.forgon.disinfectsystem.basedatamanager.handover.service.HandoverManager; -import com.forgon.disinfectsystem.common.CssdUtils; import com.forgon.disinfectsystem.diposablegoods.service.ContractManager; -import com.forgon.disinfectsystem.diposablegoods.service.DiposableGoodsManager; -import com.forgon.disinfectsystem.diposablegoods.service.GoodPurchasePlanManager; -import com.forgon.disinfectsystem.diposablegoods.service.IdentificationOfDiposableGoodsManager; import com.forgon.disinfectsystem.entity.assestmanagement.Contract; import com.forgon.disinfectsystem.entity.assestmanagement.ContractItem; -import com.forgon.disinfectsystem.entity.assestmanagement.GoodPurchaseItem; -import com.forgon.disinfectsystem.entity.assestmanagement.GoodPurchasePlan; -import com.forgon.disinfectsystem.entity.handover.Handover; -import com.forgon.systemsetting.model.HttpOption; -import com.forgon.systemsetting.service.HttpOptionManager; import com.forgon.tools.StrutsParamUtils; import com.forgon.tools.StrutsResponseUtils; -import com.forgon.tools.date.DateTools; import com.forgon.tools.db.DatabaseUtil; -import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JSONUtil; -import com.forgon.tools.string.StringTools; -import com.forgon.tools.util.ForgonDateUtils; import com.forgon.tools.util.PageUtil; import com.opensymphony.xwork2.ModelDriven; @@ -182,6 +157,7 @@ double price = Double.valueOf(obj.optString("price")); String type = obj.optString("type",null); String name = obj.optString("name",null); + String unit = obj.optString("unit",null); // String specification = obj.optString("specification",null); String amortizationRemark = obj.optString("amortizationRemark", null);//分期情况 String placeOfUse = obj.optString("placeOfUse", null);//使用地方 @@ -196,6 +172,7 @@ contractItem.setMaterialDefinitionId(Long.parseLong(materialDefinitionId));//器械材料id } contractItem.setName(name);//名称 + contractItem.setUnit(unit);//单位 // contractItem.setSpecification(specification);//规格 contractItem.setType(type);//类型 contractItem.setPrice(price);//价格 Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/Contract.java =================================================================== diff -u -r23679 -r24207 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/Contract.java (.../Contract.java) (revision 23679) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/Contract.java (.../Contract.java) (revision 24207) @@ -14,7 +14,10 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToMany; +import javax.persistence.Transient; +import net.sf.json.JSONArray; + import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.Cascade; @@ -23,6 +26,8 @@ import org.hibernate.annotations.DynamicUpdate; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.forgon.Constants; +import com.google.gson.JsonArray; /** * 合同管理 @@ -33,16 +38,18 @@ @DynamicInsert(false) @DynamicUpdate(true) @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) -public class Contract { +public class Contract implements Comparable{ + public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); private Long id; /** *合同名称 */ - private String constractName; + private String contractName; + /** * 联系人 */ @@ -122,17 +129,28 @@ */ private Boolean isNeedWarning; + public static JSONArray contracrColumnNameAndPoPropertyNameArrray = new JSONArray();//合同管理excel表格列 + static{ + contracrColumnNameAndPoPropertyNameArrray.add("{header:'合同名称',dataIndex:'contractName',type:'string'}"); + contracrColumnNameAndPoPropertyNameArrray.add("{header:'合同编号',dataIndex:'serialNumber',type:'string'}"); + contracrColumnNameAndPoPropertyNameArrray.add("{header:'联系人',dataIndex:'contact',type:'string'}"); + contracrColumnNameAndPoPropertyNameArrray.add("{header:'联系方法',dataIndex:'contactLink',type:'string'}"); + contracrColumnNameAndPoPropertyNameArrray.add("{header:'购买时间',dataIndex:'purchaseTimeString',type:'string'}"); + contracrColumnNameAndPoPropertyNameArrray.add("{header:'供货商',dataIndex:'supplierName',type:'string'}"); + } + /** + * 已不用 + */ + private String constractName; + + /** * 合同明细 */ @JsonIgnore private List itemsList = new ArrayList(); - public Contract(){ - - } - @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { @@ -275,7 +293,24 @@ public void setIsNeedWarning(Boolean isNeedWarning) { this.isNeedWarning = isNeedWarning; } + + public String getContractName() { + return contractName; + } + public void setContractName(String contractName) { + this.contractName = contractName; + } + + @Transient + public String getPurchaseTimeString(){ + if(purchaseTime != null){ + String str = Constants.SIMPLEDATEFORMAT_YYYYMMDD.format(purchaseTime); + return str; + } + return ""; + } + /** * 计算总价 */ @@ -300,5 +335,22 @@ this.itemsList.add(item); } } + + /** + * 按购买时间排序升序 + */ + @Override + public int compareTo(Contract arg0) { + Date t_purchaseTime = this.getPurchaseTime(); + Date p_purchaseTime = arg0.getPurchaseTime(); + if(t_purchaseTime == null || p_purchaseTime == null){ + return 0; + } + if(t_purchaseTime.after(p_purchaseTime)){ + return 1; + }else{ + return -1; + } + } } Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/importbasedata/exportSupplier.xls =================================================================== diff -u Binary files differ Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/dwr/table/DiposableGoodsTableManager.java =================================================================== diff -u -r23824 -r24207 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/dwr/table/DiposableGoodsTableManager.java (.../DiposableGoodsTableManager.java) (revision 23824) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/dwr/table/DiposableGoodsTableManager.java (.../DiposableGoodsTableManager.java) (revision 24207) @@ -839,7 +839,7 @@ JSONObject jsonObject = new JSONObject(); jsonObject.put("id", list.get("id")); jsonObject.put("name", list.get("name")); - jsonObject.put("specification", list.get("specification")); + jsonObject.put("specification", list.get("specification") == null?"":list.get("specification")); array.add(jsonObject); } object.put("data",array); Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplier/service/SupplierManagerImpl.java =================================================================== diff -u -r23856 -r24207 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplier/service/SupplierManagerImpl.java (.../SupplierManagerImpl.java) (revision 23856) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplier/service/SupplierManagerImpl.java (.../SupplierManagerImpl.java) (revision 24207) @@ -12,6 +12,10 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.OutputStream; import java.sql.ResultSet; import java.sql.SQLException; import java.util.stream.Collectors; @@ -24,6 +28,8 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.hibernate.FlushMode; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -43,10 +49,14 @@ import com.forgon.disinfectsystem.entity.expensivegoods.ExpensiveGoodsModel; import com.forgon.disinfectsystem.entity.foreigntousseapplication.ForeignTousseApplication; import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; +import com.forgon.excel.service.CommonExportManager; import com.forgon.security.tools.Util; import com.forgon.tools.GB2Alpha; import com.forgon.tools.GB2WB; +import com.forgon.tools.Path; import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.excel.ExcelCellStyle; +import com.forgon.tools.excel.ExcelHelper; import com.forgon.tools.hibernate.BasePoManagerImpl; import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JSONUtil; @@ -60,13 +70,19 @@ public class SupplierManagerImpl extends BasePoManagerImpl implements SupplierManager { private CertificateManager certificateManager; + + private CommonExportManager commonExportManager; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); public void setCertificateManager(CertificateManager certificateManager){ this.certificateManager = certificateManager; } + public void setCommonExportManager(CommonExportManager commonExportManager) { + this.commonExportManager = commonExportManager; + } + private final Pattern pat = Pattern.compile("[\\u4E00-\\u9FA5]+"); // 匹配中文字符的正则表达式 public void saveOrUpdate(Supplier supplier){ @@ -664,6 +680,7 @@ @Override public void saveAuthorizationCertificates(Supplier supplier, List newCertificates) { List oldCertificates = certificateManager.getAuthorizationCertificates(supplier.getId()); + //保存更新授权证 oldCertificates = mergeCertificateListAndSave(oldCertificates, newCertificates); //***************通过授权证,来关联保存注册证*******************************************// @@ -1317,7 +1334,8 @@ //0、若需要校验注册证 且 注册证id为空则根据生产厂家,注册证号获得注册证id(前台可能是手动输入注册证) if(needVerifyCertification && !DatabaseUtil.isPoIdValid(certificationId) && StringUtils.isNotBlank(certificationNumber)){ - String hql = String.format("where po.certificateNumber = '%s' and po.supplier.id = %s ", certificationNumber,manufacturer.getId()); + String hql = String.format("where po.certificateNumber = '%s' and po.supplier.id = %s and po.type = '%s'", + certificationNumber,manufacturer.getId(),Certificate.CERTIFICATE_TYPE_REGISTRATIONCERTIFICATE); Certificate certificate = (Certificate) objectDao.getBySql(Certificate.class.getSimpleName(), hql); if(null != certificate){ certificationId = certificate.getId().toString(); @@ -1363,15 +1381,20 @@ //2.校验供应商 resultJson = checkSupplierOrManufacturerValidity(supplier,manufacturer,disposableGood,certificationId,needVerifyCertification); if(resultJson.isEmpty()){ - //2.1查找上一级的被授权厂商(通过生产厂家id,一次性物品id,供应商id) - String hql = String.format("select ar.authorizer from AuthorizationRecord ar join ar.disposableGoodss dg" - + " where ar.authorized = %s and ar.manufacturerId = %s and dg.id = %s",supplier.getId(),manufacturer.getId(),disposableGood.getId()); + //2.1查找这级的授权方(用于做上一级的被授权厂商(通过生产厂家id,一次性物品id,供应商id) + String hql = String.format("select ar.authorizer from AuthorizationRecord ar join ar.disposableGoodss dg " + + " where ar.authorized = %s and ar.manufacturerId = %s and dg.id = %s" + +" and ar.id in (select ct.authorizationRecord.id from %s ct where ct.isNowUsing = 1 )", + supplier.getId(),manufacturer.getId(),disposableGood.getId(),Certificate.class.getSimpleName()); @SuppressWarnings("unchecked") List authorizers = objectDao.findByHql(hql); - // if(CollectionUtils.isNotEmpty(authorizers)){ + if(CollectionUtils.isNotEmpty(authorizers)){ //递归校验直到查到生产厂家 return checkSupplierValidity(authorizers.get(0),manufacturer,disposableGood,certificationId,needVerifyCertification); - // }else{ + }else{ + resultJson.put("message",String.format("生产厂家:'%s'的授权链下缺少供应商:'%s'对物品:'%s'的有效授权证书!", manufacturer.getCompanyName(),supplier.getCompanyName(),disposableGood.getName())); + return resultJson; + } // //2.2 若找不到上一级厂商则(可能是没关联一次性物品的全部授权) // //查找上一级的被授权厂商(导入时全部物品授权则不关联一次性物品) // String hql2 = String.format("select ar.authorizer from AuthorizationRecord ar" @@ -1430,28 +1453,28 @@ ,supplierId,Certificate.CERTIFICATE_TYPE_AUTHORIZATIONCERTIFICATE,manufacturerId,disposableGoodsID); int isNowUsingAtuhorCount = objectDao.countBySql(sql); if(isNowUsingAtuhorCount == 0){ - resultJson.put("message",String.format("生产厂家:'%s'下缺少供应商:'%s'对物品:'%s'的有效授权证书!", manufacturer.getCompanyName(),supplier.getCompanyName(),dG.getName())); + resultJson.put("message",String.format("生产厂家:'%s'的授权链下缺少供应商:'%s'对物品:'%s'的有效授权证书!", manufacturer.getCompanyName(),supplier.getCompanyName(),dG.getName())); return resultJson; } } //1-2.经营许可证 if(certificateList.stream().noneMatch(cc -> Certificate.CERTIFICATE_TYPE_BUSINESSCERTIFICATE.equals(cc.getType()))){ - resultJson.put("message",String.format("供应商'%s'没有正在使用的经营许可证!",supplier.getCompanyName())); + resultJson.put("message",String.format("生产厂家:'%s'的授权链下缺少供应商'%s'的有效经营许可证!", manufacturer.getCompanyName(),supplier.getCompanyName())); return resultJson; } //1-3.营业执照 if(certificateList.stream().noneMatch(cc -> Certificate.CERTIFICATE_TYPE_BUSINESSLICENSE.equals(cc.getType()))){ - resultJson.put("message",String.format("供应商'%s'没有正在使用的营业执照!",supplier.getCompanyName())); + resultJson.put("message",String.format("生产厂家:'%s'的授权链下缺少供应商'%s'的有效营业执照!", manufacturer.getCompanyName(),supplier.getCompanyName())); return resultJson; } //1-4.法人授权委托书 if(certificateList.stream().noneMatch(cc -> Certificate.CERTIFICATE_TYPE_AUTHORIZATIONLETTER.equals(cc.getType()))){ - resultJson.put("message",String.format("供应商'%s'没有正在使用的法人授权委托书!",supplier.getCompanyName())); + resultJson.put("message",String.format("生产厂家:'%s'的授权链下缺少供应商'%s'的有效法人授权委托书!", manufacturer.getCompanyName(),supplier.getCompanyName())); return resultJson; } //1-5. 质量保证书 if(certificateList.stream().noneMatch(cc -> Certificate.CERTIFICATE_TYPE_QUALITYGUARANTEE.equals(cc.getType()))){ - resultJson.put("message",String.format("供应商'%s'没有正在使用的质量保证书!",supplier.getCompanyName())); + resultJson.put("message",String.format("生产厂家:'%s'的授权链下缺少供应商'%s'的有效质量保证书!", manufacturer.getCompanyName(),supplier.getCompanyName())); return resultJson; } } @@ -1599,4 +1622,50 @@ Certificate.CERTIFICATE_TYPE_REGISTRATIONCERTIFICATE + "')"; return objectDao.findBySql(DisposableGoods.class.getSimpleName(), hql); } + + /***************导出供应商******************/ + @Override + public void exportSupplier(OutputStream out) { + try { + // + HSSFWorkbook wb = getExportWorkbook(); + if(wb != null){ + wb.write(out); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + + } catch(Exception e){ + System.out.println(e); + } + finally { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + private HSSFWorkbook getExportWorkbook(){ + try{ + String fileName = Path.getWebAppRoot()+ "/disinfectsystem/basedatamanager/importbasedata/exportSupplier.xls"; + FileInputStream fin = new FileInputStream(fileName); + POIFSFileSystem fs = new POIFSFileSystem(fin); + HSSFWorkbook wb = new HSSFWorkbook(fs); + ExcelHelper.setWorkbook(wb); + ExcelCellStyle.iniAllStyles(); + //获取导出xls表格数据 + commonExportManager.printContentWithParams(wb.getSheet("供应商管理"),Supplier.class, "where 1=1 order by rentTousse", null); + return wb; + }catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + } Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/exportSupplier.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/exportSupplier.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/exportSupplier.jsp (revision 24207) @@ -0,0 +1,18 @@ +<%@page import="com.forgon.disinfectsystem.basedatamanager.supplier.service.SupplierManager"%> +<%@ page contentType="text/html; charset=UTF-8"%><%@ page + import="com.forgon.tools.*,org.apache.commons.lang.*,com.forgon.directory.service.*"%> +<% +String time = request.getParameter("time"); +if(StringUtils.isBlank(time)){ + time = ""; +} +String fileName= "供应商管理.xls"; +ServletOutputStream servletOutputStream = response.getOutputStream(); +response.setContentType("application/octet-stream"); +response.addHeader("Content-Disposition","attachment;filename=" + new String(fileName.getBytes("GBK"), "ISO8859_1")); +SupplierManager supplierManager2 = (SupplierManager)SpringBeanManger.getBean("supplierManager"); +supplierManager2.exportSupplier(response.getOutputStream()); +servletOutputStream.flush(); +out.clear(); +out = pageContext.pushBody(); +%> \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/authorizationCertificateForm.js =================================================================== diff -u -r23696 -r24207 --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/authorizationCertificateForm.js (.../authorizationCertificateForm.js) (revision 23696) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/authorizationCertificateForm.js (.../authorizationCertificateForm.js) (revision 24207) @@ -2,7 +2,7 @@ var uniqueCertificateWin = null; var certificatePageColumnLeftWidth = 300; -var allowMultilevelAuthorization = false; +var allowMultilevelAuthorization = true; //删除当前选择的一次性物品(授权证关联的) function deleteSelectedDisposableGoodsItem(id){ @@ -322,7 +322,7 @@ // width : certificatePageColumnLeftWidth, items : { xtype : 'combo', - fieldLabel : "生产厂家",//此授权证所授权的物品,为哪家生产厂家所生产,复大肿瘤为一级授权,所以先隐藏这个域,后期改为配置项 + fieldLabel : "生产厂家",//此授权证所授权的物品,为哪家生产厂家所生产 id : 'manufacturerCombo', name : 'manufacturerCombo', queryParam : 'supplierName', Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractView.js =================================================================== diff -u -r23679 -r24207 --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractView.js (.../contractView.js) (revision 23679) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractView.js (.../contractView.js) (revision 24207) @@ -266,7 +266,7 @@ } setSupplierInfo(data.supplierId,data.supplierName);//设置供货商 top.Ext.getCmp("supplier1").setValue(data.supplierName);//供货商名字 - top.Ext.getCmp("constractName").setValue(data.constractName);//合同名字 + top.Ext.getCmp("contractName").setValue(data.contractName);//合同名字 top.Ext.getCmp("contact").setValue(data.contact);//联系人 top.Ext.getCmp("contactLink").setValue(data.contactLink);//联系方式 top.Ext.getCmp("time").setValue(time);//操作时间 @@ -284,6 +284,7 @@ name:data.itemsList[i].name, type:data.itemsList[i].type, name : data.itemsList[i].name, + unit : data.itemsList[i].unit, // specification : data.itemsList[i].specification, amount : data.itemsList[i].amount, price : data.itemsList[i].price, @@ -298,7 +299,7 @@ } setTotalMoney(top.Ext.getCmp('contractItemGrid')); //1、 保存原始数据,只需要保存需要修改的属性 - setOriginalFormParams(form,['id','purchaseTime','warningTime','constractName','contact','contactLink','supplierId','supplierName']); + setOriginalFormParams(form,['id','purchaseTime','warningTime','contractName','contact','contactLink','supplierId','supplierName']); //添加操作时间,购买时间的string类型(防止JSON.encode转换date对象格式不对) var originalFormParams = top.Ext.getCmp("originalFormParams").getValue(); //String转为json对象 @@ -342,7 +343,7 @@ Ext.onReady(function() { Ext.QuickTips.init(); var columns = [ - {header : "合同名字",width : 200,dataIndex : 'constractName', renderer : modifyRecord}, + {header : "合同名字",width : 200,dataIndex : 'contractName', renderer : modifyRecord}, {header : "合同编号",width : 200,dataIndex : 'serialNumber', renderer : modifyRecord}, {header : "购买日期",width : 200,dataIndex : 'purchaseTime', renderer : myDateFormatByMinute}, {header : "供货商",width : 200,dataIndex : 'supplierName', renderer : myDateFormatByMinute}, @@ -355,7 +356,7 @@ {name : 'id'}, {name : 'serialNumber'}, {name : 'supplierName'}, - {name : 'constractName'}, + {name : 'contractName'}, {name : 'purchaseTime'}, {name : 'contractType'}, {name : 'operator'}, @@ -367,7 +368,7 @@ filters:[ {type: 'string', dataIndex: 'serialNumber'}, {type: 'string', dataIndex: 'supplierName'}, - {type: 'string', dataIndex: 'constractName'}, + {type: 'string', dataIndex: 'contractName'}, {type: 'date', dataIndex: 'purchaseTime'}, {type: 'string', dataIndex: 'operator'}, {type: 'string', dataIndex: 'warningStatus'}, @@ -398,6 +399,12 @@ handler : function() { deleteConstract(grid); } + },'-',{ + text : '导出', + iconCls:'btn_ext_download', + handler : function() { + location.href = WWWROOT + "/disinfectsystem/assestManagement/contract/exportContract.jsp?contractType=" + encodeURI(contractType) + "&time=" + new Date(); + } }]; grid = new Ext.ux.ForgonPageGrid( { Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/exportContract.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/exportContract.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/exportContract.jsp (revision 24207) @@ -0,0 +1,19 @@ +<%@page import="com.forgon.disinfectsystem.diposablegoods.service.ContractManager"%> +<%@ page contentType="text/html; charset=UTF-8"%><%@ page + import="com.forgon.tools.*,org.apache.commons.lang.*,com.forgon.directory.service.*"%> +<% +String time = request.getParameter("time"); +if(StringUtils.isBlank(time)){ + time = ""; +} +String contractType = request.getParameter("contractType"); +String fileName= contractType + "合同.xls"; +ServletOutputStream servletOutputStream = response.getOutputStream(); +response.setContentType("application/octet-stream"); +response.addHeader("Content-Disposition","attachment;filename=" + new String(fileName.getBytes("GBK"), "ISO8859_1")); +ContractManager contractManager = (ContractManager)SpringBeanManger.getBean("contractManager"); +contractManager.exportContract(response.getOutputStream(),contractType); +servletOutputStream.flush(); +out.clear(); +out = pageContext.pushBody(); +%> \ No newline at end of file Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplier/service/SupplierManager.java =================================================================== diff -u -r23856 -r24207 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplier/service/SupplierManager.java (.../SupplierManager.java) (revision 23856) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplier/service/SupplierManager.java (.../SupplierManager.java) (revision 24207) @@ -1,5 +1,6 @@ package com.forgon.disinfectsystem.basedatamanager.supplier.service; +import java.io.OutputStream; import java.util.List; import java.util.Map; import java.util.Set; @@ -99,9 +100,9 @@ * @param certificationId 注册证id * @param certificationNumber 注册证号 * @param needVerifyCertification 是否需要校验注册证 - * @return + * @return 若校验有误:"message":校验结果 否则返回空 */ - JSONObject checkItemValidity(String disposableGoodsID, String supplierId,String manufacturerId + public JSONObject checkItemValidity(String disposableGoodsID, String supplierId,String manufacturerId , String certificationId,String certificationNumber,Boolean needVerifyCertification); /** @@ -188,5 +189,11 @@ * @param manufacturerId * @return List> */ - List> getCertificationListByManufacturerId(String manufacturerId); + public List> getCertificationListByManufacturerId(String manufacturerId); + + /** + * 导出全部供应商 + * @param OutputStream out + */ + public void exportSupplier(OutputStream out); } Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractFrom.js =================================================================== diff -u -r23918 -r24207 --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractFrom.js (.../contractFrom.js) (revision 23918) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractFrom.js (.../contractFrom.js) (revision 24207) @@ -53,8 +53,8 @@ items : [{ xtype : 'textfield', fieldLabel : '合同名字', - id : 'constractName', - name : 'constractName', + id : 'contractName', + name : 'contractName', allowBlank : false, anchor : '95%' }] @@ -67,8 +67,6 @@ fieldLabel : '合同编号', id : 'serialNumber', name : 'serialNumber', - regex: /^\d+$/, - regexText:'只能输入整数', allowBlank : false, anchor : '95%' }] @@ -240,7 +238,7 @@ cm : new top.Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {header : "id",dataIndex : 'id',hidden : true}, {header : "物品类型",dataIndex : 'type',width : 80,menuDisabled : true}, - {header : "名称",dataIndex : 'name',width : 200,menuDisabled : true}, + {header : "名称",dataIndex : 'name',width : 170,menuDisabled : true}, // {header : "规格",dataIndex : 'specification',width : 105,menuDisabled : true}, {header : "数量",dataIndex : 'amount',width : 60,menuDisabled : true/*, editor : new top.Ext.form.TextField({ @@ -256,7 +254,8 @@ } } })*/ - }, + }, + {header : "单位",dataIndex : 'unit',width : 60,menuDisabled : true}, {header : "单价",width : 60,dataIndex : 'price',menuDisabled : true /*, editor : new top.Ext.form.TextField({ regex: /^(([1-9]+[0-9]*.{1}[0-9]+)|([0].{1}[1-9]+[0-9]*)|([1-9][0-9]*)|([0][.][0-9]+[1-9]*))$/, @@ -305,9 +304,9 @@ mode : 'local', triggerAction : 'all', store : typeStore, - forceSelection : true, + forceSelection : false, allowBlank : true, -// editable:true, + editable:true, width : 150, listeners : { render : function(field,e){ @@ -453,10 +452,28 @@ listeners : { specialkey : function(field, e) { if (e.getKey() == Ext.EventObject.ENTER) { - focusTo('purchase'); + focusTo('unit1'); } } } + },{ + text : '单  位:' + },{ + xtype : 'textfield', + maxLength : '16', + id : 'unit1', + name : 'unit1', + allowBlank:true, + width : 100, + anchor : '95%', + tabIndex : 2, + listeners : { + specialkey : function(field, e) { + if (e.getKey() == Ext.EventObject.ENTER) { + focusTo('price1'); + } + } + } }], listeners: { render : function() { @@ -659,6 +676,7 @@ var name = top.Ext.getCmp('name1').getValue(); var amount = top.Ext.getCmp('amount1').getValue(); var type = top.Ext.getCmp('type1').getValue(); + var unit = top.Ext.getCmp('unit1').getValue(); // if(type == TYPE_EQUIPMENT){ // name = top.Ext.getCmp('name2').getRawValue(); // } @@ -669,11 +687,11 @@ var placeOfUse = top.Ext.getCmp('placeOfUse1').getValue(); var amortizationRemark = top.Ext.getCmp('amortizationRemark1').getValue(); return addItems(disposableGoodsId,materialDefinitionId,name,amount,type,specification, - price,amortization,placeOfUse,amortizationRemark); + price,amortization,placeOfUse,amortizationRemark,unit); } function addItems(disposableGoodsId,materialDefinitionId,name,amount,type,specification, - price,amortization,placeOfUse,amortizationRemark){ + price,amortization,placeOfUse,amortizationRemark,unit){ for(var i = 0;i < top.Ext.getCmp('contractItemGrid').getStore().getCount();i++){ if(top.Ext.getCmp('contractItemGrid').getStore().getAt(i).data.name == name){ showResult("该物品已经存在,不能重复添加!"); @@ -705,6 +723,7 @@ name : name, // specification : specification, amount : amount, + unit : unit, price : price, amortization : amortization, amortizationRemark : amortizationRemark, Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractWarningView.js =================================================================== diff -u -r23679 -r24207 --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractWarningView.js (.../contractWarningView.js) (revision 23679) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractWarningView.js (.../contractWarningView.js) (revision 24207) @@ -232,7 +232,7 @@ } setSupplierInfo(data.supplierId,data.supplierName);//设置供货商 top.Ext.getCmp("supplier1").setValue(data.supplierName);//供货商名字 - top.Ext.getCmp("constractName").setValue(data.constractName);//合同名字 + top.Ext.getCmp("contractName").setValue(data.contractName);//合同名字 top.Ext.getCmp("contact").setValue(data.contact);//联系人 top.Ext.getCmp("contactLink").setValue(data.contactLink);//联系方式 top.Ext.getCmp("time").setValue(time);//操作时间 @@ -250,6 +250,7 @@ name:data.itemsList[i].name, type:data.itemsList[i].type, name : data.itemsList[i].name, + unit : data.itemsList[i].unit, // specification : data.itemsList[i].specification, amount : data.itemsList[i].amount, price : data.itemsList[i].price, @@ -264,7 +265,7 @@ } setTotalMoney(top.Ext.getCmp('contractItemGrid')); //1、 保存原始数据,只需要保存需要修改的属性 - setOriginalFormParams(form,['id','purchaseTime','warningTime','constractName','contact','contactLink','supplierId','supplierName']); + setOriginalFormParams(form,['id','purchaseTime','warningTime','contractName','contact','contactLink','supplierId','supplierName']); //添加操作时间,购买时间的string类型(防止JSON.encode转换date对象格式不对) var originalFormParams = top.Ext.getCmp("originalFormParams").getValue(); //String转为json对象 @@ -308,7 +309,7 @@ Ext.onReady(function() { Ext.QuickTips.init(); var columns = [ - {header : "合同名字",width : 200,dataIndex : 'constractName', renderer : modifyRecord}, + {header : "合同名字",width : 200,dataIndex : 'contractName', renderer : modifyRecord}, {header : "合同编号",width : 200,dataIndex : 'serialNumber', renderer : modifyRecord}, {header : "合同类型",width : 200,dataIndex : 'contractType', renderer : modifyRecord}, {header : "购买日期",width : 200,dataIndex : 'purchaseTime', renderer : myDateFormatByMinute}, @@ -323,7 +324,7 @@ {name : 'serialNumber'}, {name : 'supplierName'}, {name : 'contractType'}, - {name : 'constractName'}, + {name : 'contractName'}, {name : 'purchaseTime'}, {name : 'contractType'}, {name : 'operator'}, @@ -336,7 +337,7 @@ {type: 'string', dataIndex: 'serialNumber'}, {type: 'string', dataIndex: 'supplierName'}, {type: 'string', dataIndex: 'contractType'}, - {type: 'string', dataIndex: 'constractName'}, + {type: 'string', dataIndex: 'contractName'}, {type: 'date', dataIndex: 'purchaseTime'}, {type: 'string', dataIndex: 'operator'}, {type: 'string', dataIndex: 'warningStatus'}, Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierView.js =================================================================== diff -u -r23696 -r24207 --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierView.js (.../supplierView.js) (revision 23696) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/supplier/supplierView.js (.../supplierView.js) (revision 24207) @@ -235,6 +235,12 @@ hidden : !needCertificate, iconCls : 'btn_ext_application_go', handler : updateWarningStatus + },'-',{ + text : '导出', + iconCls:'btn_ext_download', + handler : function() { + location.href = WWWROOT + "/disinfectsystem/basedatamanager/supplier/exportSupplier.jsp?time=" + new Date(); + } } ]; var dwrCallParams = null; Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractWarningFrom.js =================================================================== diff -u -r23918 -r24207 --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractWarningFrom.js (.../contractWarningFrom.js) (revision 23918) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/contract/contractWarningFrom.js (.../contractWarningFrom.js) (revision 24207) @@ -53,8 +53,8 @@ items : [{ xtype : 'textfield', fieldLabel : '合同名字', - id : 'constractName', - name : 'constractName', + id : 'contractName', + name : 'contractName', allowBlank : false, anchor : '95%' }] @@ -231,6 +231,7 @@ {header : "物品类型",dataIndex : 'type',width : 80,menuDisabled : true}, {header : "名称",dataIndex : 'name',width : 200,menuDisabled : true}, {header : "数量",dataIndex : 'amount',width : 60,menuDisabled : true}, + {header : "单位",dataIndex : 'unit',width : 60,menuDisabled : true}, {header : "单价",width : 60,dataIndex : 'price',menuDisabled : true }, {header : "金额",width : 60,menuDisabled : true,dataIndex : 'totalPrice', renderer:renderTotalPrice}, {header : "分期数",width : 70,dataIndex : 'amortization',menuDisabled : true}, @@ -301,6 +302,24 @@ } } } + },{ + text : '单  位:' + },{ + xtype : 'textfield', + maxLength : '16', + id : 'unit1', + name : 'unit1', + allowBlank:true, + width : 100, + anchor : '95%', + tabIndex : 2, + listeners : { + specialkey : function(field, e) { + if (e.getKey() == Ext.EventObject.ENTER) { + focusTo('price1'); + } + } + } }], listeners: { render : function() { @@ -504,17 +523,18 @@ var name = top.Ext.getCmp('name1').getValue(); var amount = top.Ext.getCmp('amount1').getValue(); var type = top.Ext.getCmp('type1').getValue(); + var unit = top.Ext.getCmp('unit1').getValue(); var specification = ''; var price = top.Ext.getCmp('price1').getValue(); var amortization = top.Ext.getCmp('amortization1').getValue(); var placeOfUse = top.Ext.getCmp('placeOfUse1').getValue(); var amortizationRemark = top.Ext.getCmp('amortizationRemark1').getValue(); return addItems(disposableGoodsId,materialDefinitionId,name,amount,type,specification, - price,amortization,placeOfUse,amortizationRemark); + price,amortization,placeOfUse,amortizationRemark,unit); } function addItems(disposableGoodsId,materialDefinitionId,name,amount,type,specification, - price,amortization,placeOfUse,amortizationRemark){ + price,amortization,placeOfUse,amortizationRemark,unit){ for(var i = 0;i < top.Ext.getCmp('contractItemGrid').getStore().getCount();i++){ if(top.Ext.getCmp('contractItemGrid').getStore().getAt(i).data.name == name){ showResult("该物品已经存在,不能重复添加!"); @@ -544,6 +564,7 @@ disposableGoodsId : disposableGoodsId, materialDefinitionId : materialDefinitionId, name : name, + unit : unit, amount : amount, price : price, amortization : amortization, Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/ContractManagerImpl.java =================================================================== diff -u -r23831 -r24207 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/ContractManagerImpl.java (.../ContractManagerImpl.java) (revision 23831) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/ContractManagerImpl.java (.../ContractManagerImpl.java) (revision 24207) @@ -6,31 +6,28 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import net.sf.json.JSONArray; import net.sf.json.JSONObject; +import net.sf.json.JsonConfig; +import net.sf.json.util.PropertyFilter; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang3.ArrayUtils; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.apache.poi.ss.usermodel.RichTextString; -import org.w3c.dom.ranges.RangeException; import com.forgon.Constants; import com.forgon.databaseadapter.service.DateQueryAdapter; @@ -40,19 +37,12 @@ import com.forgon.disinfectsystem.entity.assestmanagement.Contract; import com.forgon.disinfectsystem.entity.assestmanagement.ContractItem; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoods; -import com.forgon.disinfectsystem.entity.assestmanagement.GodownEntry; -import com.forgon.disinfectsystem.entity.assestmanagement.GodownEntryItem; -import com.forgon.disinfectsystem.entity.assestmanagement.GoodPurchaseItem; -import com.forgon.disinfectsystem.entity.assestmanagement.GoodPurchasePlan; -import com.forgon.disinfectsystem.entity.assestmanagement.GoodPurchasePlanGangedInfo; import com.forgon.disinfectsystem.entity.basedatamanager.materialdefinition.MaterialDefinition; import com.forgon.disinfectsystem.entity.basedatamanager.supplier.Supplier; -import com.forgon.disinfectsystem.entity.goodsstock.GoodsStock; -import com.forgon.disinfectsystem.vo.GodownEntryItemPrintVO; +import com.forgon.excel.service.ExcelUtils; import com.forgon.log.model.Log; import com.forgon.log.service.LogManager; import com.forgon.security.tools.Util; -import com.forgon.serialnumber.model.SerialNum; import com.forgon.serialnumber.service.SerialNumManager; import com.forgon.systemsetting.model.HttpOption; import com.forgon.systemsetting.service.HttpOptionManager; @@ -61,15 +51,9 @@ import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.excel.ExcelCellStyle; import com.forgon.tools.excel.ExcelHelper; -import com.forgon.tools.hibernate.BasePoManager; import com.forgon.tools.hibernate.BasePoManagerImpl; -import com.forgon.tools.hibernate.ObjectDao; -import com.forgon.tools.string.StringTools; -import com.forgon.tools.util.ForgonDateUtils; import com.forgon.tools.util.SqlUtils; -import freemarker.template.utility.DateUtil; - public class ContractManagerImpl extends BasePoManagerImpl implements ContractManager { private SerialNumManager serialNumManager; @@ -321,10 +305,10 @@ } //合同名字 - String originalConstractName = originalContract.getConstractName(); - String constractName = newContract.getConstractName(); - if(originalConstractName != null && !originalConstractName.equals(constractName)){ - nowContract.setConstractName(constractName); + String originalContractName = originalContract.getContractName(); + String contractName = newContract.getContractName(); + if(originalContractName != null && !originalContractName.equals(contractName)){ + nowContract.setContractName(contractName); } } @@ -367,14 +351,14 @@ contractJson.put("购买时间",purchaseTimeStr); contractJson.put("预警时间",warningTimeStr); contractJson.put("供货商", controct.getSupplierName()); - contractJson.put("合同名字", controct.getConstractName()); + contractJson.put("合同名字", controct.getContractName()); contractJson.put("联系人", controct.getContact()); contractJson.put("联系方式", controct.getContactLink()); //明细 for (ContractItem item : itemList) { JSONObject Item = new JSONObject(); Item.put("名称", item.getName()); - Item.put("规格", item.getSpecification()); + Item.put("单位", item.getUnit()); Item.put("数量", item.getAmount()); Item.put("价格", item.getPrice()); Item.put("物品类型", item.getType()); @@ -428,7 +412,7 @@ contract.setSupplierName(formParamsObj.optString("supplierName"));//供货商名字 contract.setContact(formParamsObj.optString("contact"));//联系人 contract.setContactLink(formParamsObj.optString("contactLink"));//联系方式 - contract.setConstractName(formParamsObj.optString("constractName"));//合同名字 + contract.setContractName(formParamsObj.optString("contractName"));//合同名字 try { Date purchaseTime = new SimpleDateFormat(DateTools.COMMON_DATE_ONLY).parse(formParamsObj.optString("purchaseTime")); if(StringUtils.isNotBlank(formParamsObj.optString("warningTime"))){ @@ -451,7 +435,7 @@ } resultJson.put("id", contract.getId());//合同id resultJson.put("serialNumber", contract.getSerialNumber());//合同编号 - resultJson.put("constractName", contract.getConstractName());//合同名称 + resultJson.put("contractName", contract.getContractName());//合同名称 resultJson.put("supplierId", contract.getSupplierId());//供货商id resultJson.put("supplierName", contract.getSupplierName());//供货商名称 resultJson.put("operator", contract.getOperator());//操作员 @@ -470,7 +454,7 @@ item.put("id", contractItem.getId());//明细id item.put("type", contractItem.getType());//类型 item.put("name", contractItem.getName());//名称 - item.put("specification", contractItem.getSpecification());//规格 + item.put("unit", contractItem.getUnit());//规格 item.put("price", contractItem.getPrice());//价格 item.put("amount", contractItem.getAmount());//数量 item.put("totalPrice",contractItem.getPrice() * contractItem.getAmount());//金额:价格*数量 @@ -617,7 +601,7 @@ cloneContract.setContractType(source.getContractType());//合同状态 cloneContract.setContact(source.getContact());//联系人 cloneContract.setContactLink(source.getContactLink());//联系方式 - cloneContract.setConstractName(source.getConstractName());//合同名字 + cloneContract.setContractName(source.getContractName());//合同名字 // //设置item项 for(ContractItem item : source.getItemsList()){ ContractItem newItem = new ContractItem(); @@ -629,11 +613,144 @@ newItem.setName(item.getName()); newItem.setPlaceOfUse(item.getPlaceOfUse()); newItem.setPrice(item.getPrice()); - newItem.setSpecification(item.getSpecification()); + newItem.setUnit(item.getUnit()); newItem.setType(item.getType()); newItem.setContract(cloneContract); cloneContract.addItem(newItem); } return cloneContract; } +/***********导出合同信息**************/ + @Override + public void exportContract(OutputStream ops,String type){ + if(StringUtils.isNotBlank(type)){ + List contractList = this.getByProperty("contractType", type); + if(CollectionUtils.isNotEmpty(contractList)){ + createExportFile(contractList,ops); + } + } + } + + + private void createExportFile(List contractList,OutputStream ops) { + String inputFile = Path.getWebAppRoot()+ "/disinfectsystem/reportforms/emptyExcelDemo.xls"; + FileInputStream fos = null; + POIFSFileSystem fs = null; + HSSFWorkbook wb = null; + try { + fos = new FileInputStream(inputFile); + fs = new POIFSFileSystem(fos); + wb = new HSSFWorkbook(fs); + ExcelHelper.setWorkbook(wb); + ExcelCellStyle.iniAllStyles(); + HSSFSheet sheet = wb.getSheetAt(0); + + HSSFCellStyle cellStyle = wb.createCellStyle(); // 数据单元格格式 + cellStyle.setWrapText(true); + cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); + cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); + cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); + cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); + cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT); + HSSFFont font = wb.createFont(); + font.setFontHeightInPoints((short) 10); // 设置字体大小为10 + font.setFontName("宋体"); + cellStyle.setFont(font); + + JSONArray columnJsonArray = JSONArray.fromObject(Contract.contracrColumnNameAndPoPropertyNameArrray); + int sheetColumnSize = columnJsonArray.size(); + + //excel列头 + HSSFRow operatingRow1 = sheet.createRow(0); + if(columnJsonArray != null){ + for(int i = 0 ; i < columnJsonArray.size() ; i ++){ + JSONObject obj = columnJsonArray.optJSONObject(i); + ExcelUtils.createStringCell(operatingRow1, cellStyle, i, obj.optString("header")); + } + } + + //excel内容填充 + int row = 1; + Collections.sort(contractList); + //因为Contract和里面的itemsList属性双向关联,用JSONArray.fromObject会导致死循环报错,所以需要把itemsList过滤掉 + JsonConfig cfg = new JsonConfig(); + cfg.setJsonPropertyFilter(new PropertyFilter(){ + public boolean apply(Object source, String name, Object value) { + if(name.equals("itemsList")) { + return true; + } else { + return false; + } + } + }); + JSONArray contractArray = JSONArray.fromObject(contractList,cfg); + for (int i = 0 ; i < contractArray.size() ; i ++) { + HSSFRow operatingRow = sheet.createRow(row); + JSONObject contractObj = contractArray.optJSONObject(i); + for(int j = 0 ; j < columnJsonArray.size() ; j ++){ + JSONObject configObj = columnJsonArray.optJSONObject(j); + String propertyName = configObj.optString("dataIndex"); + if(configObj.optString("type").equals("int")){ + ExcelUtils.createIntCell(operatingRow, cellStyle, j,contractObj.optInt(propertyName)); + }else if(configObj.optString("type").equals("double")){ + ExcelUtils.createDoubleCell(operatingRow, cellStyle, j,contractObj.optDouble(propertyName)); + }else{ + ExcelUtils.createStringCell(operatingRow, cellStyle, j,contractObj.optString(propertyName)); + } + } + row++; +// createStringCell(operatingRow, cellStyle, 0, contract.getContractName()); +// createStringCell(operatingRow, cellStyle, 1,contract.getSerialNumber()); +// createStringCell(operatingRow, cellStyle, 2, contract.getContact()); +// createStringCell(operatingRow, cellStyle, 3, contract.getContactLink()); +// createStringCell(operatingRow, cellStyle, 4, contract.getPurchaseTimeString()); +// createStringCell(operatingRow, cellStyle, 5, contract.getSupplierName()); +// row++; + } + //调整列宽度 + for(int i = 0 ;i> getAuthorizedDisposableGoodsSimpleData(String manufacturerId, String authorizedId, String certificateId); + public List> getAuthorizedDisposableGoodsSimpleData(String manufacturerId, String authorizedId, + String certificateId,List isNoUsingAuthorizedCertificateIds); /** * 检查生产厂家对供应商关于一次性物品的授权(直接授权或者间接授权)是否有效(整个授权链)
@@ -210,9 +212,17 @@ public List> getCanBeAuthorizedDisposableGoods(String authorizerId, String authorizedId, String manufacturerId, String certificateId); - - - - - + /** + * 根据授权方id,被授权方的id,生产厂家id,来获得“被授权方”可以被“授权方”授权的且由“生产厂家”生产的一次性物品的简单信息(id,name,specification) + * @param authorizerId + * @param authorizedId + * @param manufacturerId + * @param certificateId + * @param isNoUsingAuthorizedCertificateId 过期的授权证证件id(若不为空则过滤) + * @param certificateId 返回的集合中不能排除此授权证中关联的一次性物品 + * @return + */ + public List> getCanBeAuthorizedDisposableGoods2( + String authorizerId, String authorizedId, String manufacturerId, String certificateId,ListisNoUsingAuthorizedCertificateId); + } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/certificate/service/CertificateManagerImpl.java =================================================================== diff -u -r23823 -r24207 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/certificate/service/CertificateManagerImpl.java (.../CertificateManagerImpl.java) (revision 23823) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/certificate/service/CertificateManagerImpl.java (.../CertificateManagerImpl.java) (revision 24207) @@ -18,6 +18,7 @@ import net.sf.json.JSONArray; import net.sf.json.JSONObject; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; @@ -26,9 +27,6 @@ import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; //import com.forgon.disinfectsystem.basedatamanager.supplier.service.SupplierManager; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoods; -import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsIdentification; -import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveDisposablegoods; -import com.forgon.disinfectsystem.entity.basedatamanager.departmentapplicationtemplate.DiposableGoodsTemplateItem; import com.forgon.disinfectsystem.entity.basedatamanager.imagefilemanager.ImageFile; import com.forgon.disinfectsystem.entity.basedatamanager.supplier.AuthorizationRecord; import com.forgon.disinfectsystem.entity.basedatamanager.supplier.Certificate; @@ -233,12 +231,81 @@ @Override public void save(List certificates, boolean needCheckValidityDate) { if(certificates != null){ + //授权证校验 + if(certificates.stream().anyMatch(c -> Certificate.CERTIFICATE_TYPE_AUTHORIZATIONCERTIFICATE.equals(c.getType()))){ + checkCertificatesForAuthorization(certificates); + } for (Certificate certificate : certificates) { save(certificate, needCheckValidityDate); } } } + //授权证校验 + //1)自己不能给自己授权 + //2)同一家生产厂家的同一个一次性物品不能多次授权给同一个supplier授权证校验.同一家生产厂家的同一个一次性物品不能多次授权给同一个supplier + private void checkCertificatesForAuthorization(List needCheckCertificates){ + //1、获得未过期的授权证的证书 + List authorizationC_isUsing = needCheckCertificates.stream() + .filter(c->(c.getIsNowUsing()==true + && Certificate.CERTIFICATE_TYPE_AUTHORIZATIONCERTIFICATE.equals(c.getType()))) + .collect(Collectors.toList()); + //2、获得已过期的授权证书id集合 + List authorizationC_isNoUsingIds = needCheckCertificates.stream() + .filter(c -> (c.getIsNowUsing()==false + && Certificate.CERTIFICATE_TYPE_AUTHORIZATIONCERTIFICATE.equals(c.getType()))) + .map(isNoUseingC -> isNoUseingC.getId()) + .collect(Collectors.toList()); + //3、遍历未过期的授权证书 + for (Certificate certificate : authorizationC_isUsing) { + AuthorizationRecord authorizationRecord = certificate.getAuthorizationRecord(); + //3-1、自己不能给自己授权 + if(authorizationRecord.getAuthorizer().getId().equals(authorizationRecord.getAuthorized().getId())){ + throw new RuntimeException("授权证书" + certificate.getCertificateNumber() + ": " + + authorizationRecord.getAuthorizer().getCompanyName() + "不能自己给自己授权"); + } + //3-2、看授权证的授权物品是否可以被授权 + //首先获得这张授权书要关联的一次性物品 + List disposableGoodss = certificate.getAuthorizationRecord().getDisposableGoodss(); + if(disposableGoodss == null || disposableGoodss.size() == 0){ + throw new RuntimeException("授权证书" + certificate.getCertificateNumber() + ": 必须关联一次性物品"); + } + String certificateIdStr = certificate.getId()==null ?null:certificate.getId().toString();//证件id + //再获得可以被授权的一次性物品(先获得全部可授权的物品,再减去已被改供应商授权的物品(过滤已过期的授权)) + List> canBeAuthorizedDisposableGoods = getCanBeAuthorizedDisposableGoods2( + authorizationRecord.getAuthorizer().getId().toString(), + authorizationRecord.getAuthorized().getId().toString(), + authorizationRecord.getManufacturerId().toString(), + certificateIdStr,authorizationC_isNoUsingIds); + Set ids = new HashSet(); + if(canBeAuthorizedDisposableGoods != null){ + for (Map item : canBeAuthorizedDisposableGoods) { + ids.add((Long) item.get("id")); + } + } +// Set registrationCertificates = certificate.getSupplier().getRegistrationCertificates(); +// Set disposableGoodsIds = new HashSet();//用来保存此授权书关联的一次性物品的id + //遍历,如果这张授权书要关联的一次性物品不在可以被授权的物品中,就不让保存,抛出异常 + for (DisposableGoods disposableGoods : disposableGoodss) { + //有过授权记录的一次性物品,就修改为是需要授权的物品 + disposableGoods.setIsNeedAuthorization(true); +// disposableGoodsIds.add(disposableGoods.getId()); + if(!ids.contains(disposableGoods.getId())){ + String certificateMessage = ""; + if(StringUtils.isNotEmpty(certificate.getCertificateNumber())){ + certificateMessage += "授权证号码:" + certificate.getCertificateNumber() + ","; + } + if(StringUtils.isNotEmpty(certificate.getProductRange())){ + certificateMessage += "授权范围:" + certificate.getProductRange() + ","; + } + certificateMessage += "授权证中,"; + throw new RuntimeException(certificateMessage + authorizationRecord.getAuthorizer().getCompanyName() + "没有物品" + + disposableGoods.getName() + "的授权权利,或者已经对相同的物品进行了授权!"); + } + } + } + } + @Override public void save(Certificate certificate, boolean needCheckValidityDate) { Date validityDate = certificate.getValidityDate(); @@ -255,11 +322,11 @@ throw new RuntimeException(certificate.getType()+"有效期已过期,不能保存"); } } - //授权证保存,需要验证一些信息 + //授权证保存,需要验证一些信息(已转移到checkCertificatesForAuthorization) //1)自己不能给自己授权 //2)同一家生产厂家的同一个一次性物品不能多次授权给同一个supplier if(Certificate.CERTIFICATE_TYPE_AUTHORIZATIONCERTIFICATE.equals(certificate.getType())){ - AuthorizationRecord authorizationRecord = certificate.getAuthorizationRecord(); + /* AuthorizationRecord authorizationRecord = certificate.getAuthorizationRecord(); if(authorizationRecord.getAuthorizer().getId().equals(authorizationRecord.getAuthorized().getId())){ throw new RuntimeException("授权证书" + certificate.getCertificateNumber() + ": " + authorizationRecord.getAuthorizer().getCompanyName() + "不能自己给自己授权"); @@ -307,7 +374,9 @@ //注册证需要验证 // 1)注册证号不能重复 // 2)同一个生产厂家生产的一次性物品,不能同时关联多个注册证 - }else if(Certificate.CERTIFICATE_TYPE_REGISTRATIONCERTIFICATE.equals(certificate.getType())){ + */ + } + else if(Certificate.CERTIFICATE_TYPE_REGISTRATIONCERTIFICATE.equals(certificate.getType())){ String certificateMessage = ""; if(StringUtils.isNotEmpty(certificate.getCertificateNumber())){ @@ -628,12 +697,16 @@ } @Override - public List> getAuthorizedDisposableGoodsSimpleData(String manufacturerId, String authorizedId, String certificateId) { + public List> getAuthorizedDisposableGoodsSimpleData(String manufacturerId, String authorizedId, + String certificateId,List isNoUsingAuthorizedCertificateIds) { String additionalSql = ""; if(DatabaseUtil.isPoIdValid(certificateId)){ additionalSql = " and ct.id != " + certificateId ; } + if(CollectionUtils.isNotEmpty(isNoUsingAuthorizedCertificateIds)){ + additionalSql += String.format(" and %s ", SqlUtils.getNonStringFieldNotInCollectionsPredicate("ct.id", isNoUsingAuthorizedCertificateIds)); + } String sql = "select distinct id, name, specification from DisposableGoods where id in " + "(select ar_dg.DisposableGoods_Id from certificate ct join AuthorizationRecord ar on ct.AuthorizationRecord_Id = ar.id " + additionalSql + " and ct.isNowUsing = 1 and ar.Authorized_Id = " + authorizedId + " and ar.manufacturerId = " + manufacturerId + @@ -755,6 +828,21 @@ public List> getCanBeAuthorizedDisposableGoods( String authorizerId, String authorizedId, String manufacturerId, String certificateId) { + return canBeAuthorizedDisposableGoods(authorizerId, authorizedId, manufacturerId, + certificateId,null); + + } + @Override + public List> getCanBeAuthorizedDisposableGoods2( + String authorizerId, String authorizedId, String manufacturerId, + String certificateId, List isNoUsingAuthorizedCertificateId) { + return canBeAuthorizedDisposableGoods(authorizerId, authorizedId, manufacturerId, + certificateId,isNoUsingAuthorizedCertificateId); + } + + + private List> canBeAuthorizedDisposableGoods(String authorizerId, + String authorizedId, String manufacturerId, String certificateId,List isNoUsingAuthorizedCertificateId) { List> lists = null; List> disposableGoodsCanBeAuthorized = null; List> disposableGoodsHaveBeenAuthorized = null; @@ -763,22 +851,21 @@ disposableGoodsCanBeAuthorized = getAllDisposableGoodsSimpleData("", manufacturerId); //再获取被授权方已经被此生产厂家授权过的一次性物品 if(DatabaseUtil.isPoIdValid(authorizedId)){ - disposableGoodsHaveBeenAuthorized = getAuthorizedDisposableGoodsSimpleData(manufacturerId, authorizedId, certificateId); + disposableGoodsHaveBeenAuthorized = getAuthorizedDisposableGoodsSimpleData(manufacturerId, authorizedId, certificateId,isNoUsingAuthorizedCertificateId); } }else{ //授权方不是生产厂家 //首先获得此授权方(供应商)被生产厂家授权过的一次性物品 - disposableGoodsCanBeAuthorized = getAuthorizedDisposableGoodsSimpleData(manufacturerId, authorizerId, null); + disposableGoodsCanBeAuthorized = getAuthorizedDisposableGoodsSimpleData(manufacturerId, authorizerId, null,null); removeUnvalidityGoods(disposableGoodsCanBeAuthorized, manufacturerId, authorizerId); //再获取被授权方已经被此生产厂家授权过(间接授权也算)的一次性物品 if(DatabaseUtil.isPoIdValid(authorizedId)){ - disposableGoodsHaveBeenAuthorized = getAuthorizedDisposableGoodsSimpleData(manufacturerId, authorizedId, certificateId); + disposableGoodsHaveBeenAuthorized = getAuthorizedDisposableGoodsSimpleData(manufacturerId, authorizedId, certificateId,isNoUsingAuthorizedCertificateId); removeUnvalidityGoods(disposableGoodsHaveBeenAuthorized, manufacturerId, authorizedId); } } removeFromList(disposableGoodsCanBeAuthorized, disposableGoodsHaveBeenAuthorized); lists = disposableGoodsCanBeAuthorized; return lists; - } /** Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/ContractManager.java =================================================================== diff -u -r23679 -r24207 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/ContractManager.java (.../ContractManager.java) (revision 23679) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/service/ContractManager.java (.../ContractManager.java) (revision 24207) @@ -7,11 +7,7 @@ import net.sf.json.JSONObject; import com.forgon.disinfectsystem.entity.assestmanagement.Contract; -import com.forgon.disinfectsystem.entity.assestmanagement.GodownEntry; -import com.forgon.disinfectsystem.entity.assestmanagement.GoodPurchaseItem; -import com.forgon.disinfectsystem.entity.assestmanagement.GoodPurchasePlan; import com.forgon.tools.hibernate.BasePoManager; -import com.forgon.workflow.model.WorkFlow; public interface ContractManager extends BasePoManager{ @@ -68,4 +64,10 @@ */ public void dealConstractWarningStatus(String id); + /** + * 根据合同类型导出合同信息 + * @param ops + * @param type 合同类型 + */ + public void exportContract(OutputStream ops, String type); }