Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsBill/expensiveGoodsBillView.js =================================================================== diff -u -r22337 -r23395 --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsBill/expensiveGoodsBillView.js (.../expensiveGoodsBillView.js) (revision 22337) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsBill/expensiveGoodsBillView.js (.../expensiveGoodsBillView.js) (revision 23395) @@ -99,7 +99,8 @@ {name : 'entryDate'}, {name : 'expDate'}, {name : 'batchNumber'}, - {name : 'patientName'} + {name : 'patientName'}, + {name : 'useEnteringDate'}//实例录用时间 ]); //var selectModel = new top.Ext.grid.CheckboxSelectionModel({ @@ -434,7 +435,7 @@ expensiveGoodBillFormLoad(id,committedStatus); } -//获的发票信息 +//获得发票信息 function expensiveGoodBillFormLoad(id,committedStatus){ top.Ext.getCmp('expensiveGoodBillForm').form.load({ url : WWWROOT + '/disinfectSystem/expensiveGoodsBillAction!loadExopensiveGoodsBill.do', Index: ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillManagerImpl.java =================================================================== diff -u -r22364 -r23395 --- ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillManagerImpl.java (.../ExpensiveGoodsBillManagerImpl.java) (revision 22364) +++ ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillManagerImpl.java (.../ExpensiveGoodsBillManagerImpl.java) (revision 23395) @@ -3,6 +3,8 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -17,6 +19,7 @@ import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; +import com.forgon.Constants; import com.forgon.databaseadapter.service.DateQueryAdapter; import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveGoods; @@ -25,6 +28,7 @@ import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveGoodsInstance; import com.forgon.disinfectsystem.entity.basedatamanager.supplier.ExpensiveGoodsSupplier; import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig; +import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; import com.forgon.entity.ExtJsEntity; import com.forgon.tools.MathTools; import com.forgon.tools.date.DateTools; @@ -33,8 +37,11 @@ import com.forgon.tools.json.JSONUtil; import com.forgon.tools.string.StringTools; import com.forgon.tools.util.ExtJsUtil; +import com.forgon.tools.util.SqlUtils; import com.forgon.util.ExtGridUtils; +import edu.emory.mathcs.backport.java.util.Arrays; + /** * 高值耗材发票ManagerImpl * @author YanWeiNing @@ -379,7 +386,7 @@ int billAmount = expensiveGoodsBillItem.getAmount().intValue();//结算数量 //获得物品可结算的高值耗材实例 - List canBillInstanceList = canBillExpensiveGoodsInstanceList(expensiveGoodsId,supplierId); + List canBillInstanceList = canBillInstanceListByexpensiveGoodsId(expensiveGoodsId,supplierId); //若可结算数量为空则返回信息 if(CollectionUtils.isEmpty(canBillInstanceList)){ @@ -390,7 +397,6 @@ if( MathTools.sub(usedAmount,billAmount).intValue()<0){ throw new IllegalArgumentException(String.format("(%s)%s预入库/自购入库的可结算实例数量为:%s 小于结算数量:%s!",mFName,goodName,usedAmount,billAmount)); } - //获取页面对应的高值耗材实例集合 List itemInstanceList = expensiveGoodsBillItem.getExpensiveGoodsInstanceList(); List expensiveGoodsInstanceList = new ArrayList(); @@ -405,8 +411,12 @@ } } }else{ - throw new IllegalArgumentException(String.format("(%s)%s对应的页面的高值耗材实例为空", mFName,goodName)); + throw new IllegalArgumentException(String.format("(%s)%s对应的页面的高值耗材实例为空!", mFName,goodName)); } + //选择的可结算实例数量是否和物品结算数量一致 + if(expensiveGoodsInstanceList.size() != billAmount){ + throw new IllegalArgumentException(String.format("(%s)%s结算数量为:%s和选择的可结算实例数量:%s不一致!", mFName,goodName,billAmount,expensiveGoodsInstanceList.size())); + } //记录每个高值耗材id对应的实例集合 idToExpensiveGoodsInstanceMap.put(expensiveGoodsId, expensiveGoodsInstanceList); } @@ -568,18 +578,19 @@ //返回高值耗材实例详细 if(CollectionUtils.isNotEmpty(expensiveGoodsInstanceList)){ SimpleDateFormat format=new SimpleDateFormat("yyy-MM-dd"); - for (ExpensiveGoodsInstance ExpensiveGoodsInstance : expensiveGoodsInstanceList) { + for (ExpensiveGoodsInstance expensiveGoodsInstance : expensiveGoodsInstanceList) { JSONObject jsonObj = new JSONObject(); - jsonObj.put("id", ExpensiveGoodsInstance.getId()); - jsonObj.put("expensiveGoodsId", ExpensiveGoodsInstance.getExpensiveGoods().getId()); - jsonObj.put("showName", ExpensiveGoodsInstance.getShowName()); - jsonObj.put("entryType", ExpensiveGoodsInstance.getEntryType()); - jsonObj.put("entryDate", format.format(ExpensiveGoodsInstance.getEntryDate())); - jsonObj.put("expDate", format.format(ExpensiveGoodsInstance.getExpDate())); - jsonObj.put("price", ExpensiveGoodsInstance.getPrice()); - jsonObj.put("model", ExpensiveGoodsInstance.getModel()); - if(ExpensiveGoodsInstance.getUseRecord()!=null){ - jsonObj.put("patientName", ExpensiveGoodsInstance.getUseRecord().getPatientName()); + jsonObj.put("id", expensiveGoodsInstance.getId()); + jsonObj.put("expensiveGoodsId", expensiveGoodsInstance.getExpensiveGoods().getId()); + jsonObj.put("showName", expensiveGoodsInstance.getShowName()); + jsonObj.put("entryType", expensiveGoodsInstance.getEntryType()); + jsonObj.put("entryDate", format.format(expensiveGoodsInstance.getEntryDate())); + jsonObj.put("expDate", format.format(expensiveGoodsInstance.getExpDate())); + jsonObj.put("price", expensiveGoodsInstance.getPrice()); + jsonObj.put("model", expensiveGoodsInstance.getModel()); + if(expensiveGoodsInstance.getUseRecord()!=null){ + jsonObj.put("patientName", expensiveGoodsInstance.getUseRecord().getPatientName()); + jsonObj.put("useEnteringDate", format.format(expensiveGoodsInstance.getUseRecord().getEnteringDate())); } jsonArray.add(jsonObj); } @@ -593,37 +604,44 @@ if(dataJson == null){ return null; } - try { - Long expensiveGoodsId = JSONUtil.optLong(dataJson, "expensiveGoodsId", null); - Long supplierId = JSONUtil.optLong(dataJson, "supplierId", null); - Long amountLong = JSONUtil.optLong(dataJson, "amount", null); - String settledTimeStr = JSONUtil.optString(dataJson, "settledTime", null); - if(DatabaseUtil.isPoIdValid(expensiveGoodsId) && DatabaseUtil.isPoIdValid(supplierId) && amountLong!=null && settledTimeStr!=null){ - int amount = amountLong.intValue(); - JSONArray jsonArray = new JSONArray(); - SimpleDateFormat format=new SimpleDateFormat(DateTools.COMMON_DATE_PATTEN); - List expensiveGoodsInstanceList = new ArrayList(); - List dateWarning = new ArrayList();//用于记录发票预警时间提示 - SupplyRoomConfig supplyRoomConfig = supplyRoomConfigManager.getSystemParamsObj(); - Long billDateWarning = 0L; - //获得可结算的高值耗材实例 - expensiveGoodsInstanceList = canBillExpensiveGoodsInstanceList(expensiveGoodsId,supplierId); + JSONArray jsonArray = new JSONArray(); + SimpleDateFormat format=new SimpleDateFormat(DateTools.COMMON_DATE_PATTEN); + SupplyRoomConfig supplyRoomConfig = supplyRoomConfigManager.getSystemParamsObj(); + Long billDateWarning = 0L; + Map warningMap = new HashMap();//用于记录相同入库单实例的预警天数 + List dateWarning = new ArrayList();//用于记录发票预警时间提示 + Long expensiveGoodsId = JSONUtil.optLong(dataJson, "expensiveGoodsId", null);//高值耗材物品id + Long supplierId = JSONUtil.optLong(dataJson, "supplierId", null);//供应商id + String settledTimeStr = JSONUtil.optString(dataJson, "settledTime", null);//开发票时间 + Long amountLong = JSONUtil.optLong(dataJson, "amount", null);//物品需要结算的数量 + boolean isAllAmount = JSONUtil.optBoolean(dataJson, "isAllAmount", false);//是否获得该高值耗材全部可结算实例数 + int amount = amountLong.intValue(); + // + if(DatabaseUtil.isPoIdValid(expensiveGoodsId) && DatabaseUtil.isPoIdValid(supplierId) && amountLong!=null && settledTimeStr!=null){ + //1.获得可结算的高值耗材实例 + List expensiveGoodsInstanceList = canBillInstanceListByexpensiveGoodsId(expensiveGoodsId,supplierId); + //是否有可结算物品 if(CollectionUtils.isNotEmpty(expensiveGoodsInstanceList)){ List instanceList = new ArrayList(); - //前台结算数量是否大于可结算数量,若大于则获取可结算的全部实例集合 - if(expensiveGoodsInstanceList.size() >= amount){ - instanceList.addAll(expensiveGoodsInstanceList.subList(0, amount)); - }else{ + //2.是否返回全部可结算的实例集合 + if(isAllAmount){ instanceList = expensiveGoodsInstanceList; + }else{ + //前台结算数量是否大于可结算数量,若大于则获取可结算的全部实例集合 + if(expensiveGoodsInstanceList.size() >= amount){ + instanceList.addAll(expensiveGoodsInstanceList.subList(0, amount)); + }else{ + instanceList = expensiveGoodsInstanceList; + } } if(supplyRoomConfig.getExpensiveGoodsBillWarningTime()!=null){ //配置的开票时间大于入库时间的预警时间 billDateWarning = supplyRoomConfig.getExpensiveGoodsBillWarningTime().longValue(); } - //用于记录相同入库单实例的预警天数 - Map warningMap = new HashMap(); + //3.按使用时间排序 + expensiveGoodsInstanceListSort(instanceList); + //4.返回实例集合(判断开票时间大于入库时间太长则提示) for (ExpensiveGoodsInstance expensiveGoodsInstance : instanceList) { - //判断开票时间大于入库时间太长则提示 if(billDateWarning >0 ){ String entryDateStr = format.format(expensiveGoodsInstance.getEntryDate()); //获得发票时间和入库时间的相差天数entryDateStr @@ -635,7 +653,7 @@ String tips = String.format("%s实例:开票时间大于入库时间%s天
",expensiveGoodsInstance.getShowName(),day); warningMap.put(expensiveGoodsInstance.getGodownEntryId(),tips); } -// dateWarning.add(String.format("%s实例:开票时间大于入库时间%s天
",expensiveGoodsInstance.getShowName(),day)); + // dateWarning.add(String.format("%s实例:开票时间大于入库时间%s天
",expensiveGoodsInstance.getShowName(),day)); } } } @@ -651,13 +669,15 @@ jsonObj.put("batchNumber", expensiveGoodsInstance.getBatchNumber()); jsonObj.put("model", expensiveGoodsInstance.getModel()); if(expensiveGoodsInstance.getUseRecord()!=null){ - jsonObj.put("patientName", expensiveGoodsInstance.getUseRecord().getPatientName()); + jsonObj.put("patientName", expensiveGoodsInstance.getUseRecord().getPatientName());//使用病人名 + jsonObj.put("useEnteringDate", format.format(expensiveGoodsInstance.getUseRecord().getEnteringDate()));//录用时间 } jsonArray.add(jsonObj); -// if(CollectionUtils.isNotEmpty(dateWarning)){ -// result.put("warning", dateWarning); -// } + // if(CollectionUtils.isNotEmpty(dateWarning)){ + // result.put("warning", dateWarning); + // } } + //5.添加预警提示 if(!warningMap.isEmpty()){ for (String value : warningMap.values()) { //若有相同警告的则不用显示 @@ -667,23 +687,24 @@ } result.put("warning", dateWarning); } + System.out.println(jsonArray); return jsonArray; - }else{ - ExpensiveGoods expensiveGoods = expensiveGoodsManager.get(expensiveGoodsId); - String esName =""; - if(expensiveGoods.getRegistrationCertification() !=null){ - ExpensiveGoodsSupplier es = expensiveGoods.getRegistrationCertification().getExpensiveGoodsSupplier(); - if(es!=null){ - esName = "("+es.getCompanyName()+")";//生产厂家 - } + }else{ + //返回可结算物品数量为0的消息 + ExpensiveGoods expensiveGoods = expensiveGoodsManager.get(expensiveGoodsId); + String esName =""; + if(expensiveGoods.getRegistrationCertification() !=null){ + ExpensiveGoodsSupplier es = expensiveGoods.getRegistrationCertification().getExpensiveGoodsSupplier(); + if(es!=null){ + esName = "("+es.getCompanyName()+")";//生产厂家 } - result.put("warning",String.format("%s%s的可结算数量为0",esName,expensiveGoods.getShowName())); } + result.put("warning",String.format("%s%s的可结算数量为0",esName,expensiveGoods.getShowName())); } - } catch (Exception e) { - e.printStackTrace(); + }else{ + return null; } - return null; + return null; } /** @@ -692,12 +713,12 @@ * @param expensiveGoodsId * @return */ - private List canBillExpensiveGoodsInstanceList(Long expensiveGoodsId,Long supplierId){ + private List canBillInstanceListByexpensiveGoodsId(Long expensiveGoodsId,Long supplierId){ if(DatabaseUtil.isPoIdValid(expensiveGoodsId) && DatabaseUtil.isPoIdValid(supplierId)){ String sql = String.format(" where po.expensiveGoods.id = %s and po.supplierId = %s " + " and po.checkStatus = '%s' and po.settledStatus = '%s' " - + " and ( ( po.entryType = '%s')or( po.entryType = '%s' and po.status = '%s')) order by po.entryType desc, po.entryDate asc ", + + " and ( ( po.entryType = '%s')or( po.entryType = '%s' and po.status = '%s')) order by po.entryType desc, po.entryDate asc ", expensiveGoodsId,supplierId, ExpensiveGoodsInstance.CHECK_STATUS_CHECKED,ExpensiveGoodsInstance.STATUS_NOSETTLED, ExpensiveGoodsInstance.ENTRY_TYPE_PURCHASE,ExpensiveGoodsInstance.ENTRY_TYPE_PREPARE,ExpensiveGoodsInstance.STATUS_USED); @@ -769,4 +790,125 @@ } } } + +//////////////// + @Override + public JSONArray getExpensiveGoodsInstanceDtailByExpensiveGoodsIdsAndTime(List expensiveGoodsIdList,Long supplierId + ,String startUseEnteringDateStr,String endUseEnteringDateStr,String startInvoicePlanDateStr,String endInvoicePlanDateStr) { + JSONArray result = new JSONArray(); + //1.校验日期是否正确 + try { + Date startUseEDate = StringUtils.isNotBlank(startUseEnteringDateStr) ? new SimpleDateFormat(DateTools.COMMON_DATE_ONLY).parse(startUseEnteringDateStr) : null; + Date endUseEDate = StringUtils.isNotBlank(endUseEnteringDateStr) ? new SimpleDateFormat(DateTools.COMMON_DATE_ONLY).parse(endUseEnteringDateStr) : null; + Date startInvoicePDate = StringUtils.isNotBlank(startInvoicePlanDateStr) ? new SimpleDateFormat(DateTools.COMMON_DATE_ONLY).parse(startInvoicePlanDateStr) : null; + Date endInvoicePDate = StringUtils.isNotBlank(endInvoicePlanDateStr) ? new SimpleDateFormat(DateTools.COMMON_DATE_ONLY).parse(endInvoicePlanDateStr) : null; + } catch (ParseException e) { + e.printStackTrace(); + throw new RuntimeException("日期格式错误!"); + } + //2.获得可结算高级耗材实例 + List canExpensiveGoodsInstanceList = getExpensiveGoodsInstanceDtailByFilter(expensiveGoodsIdList,supplierId, + startUseEnteringDateStr,endUseEnteringDateStr,startInvoicePlanDateStr,endInvoicePlanDateStr); + //排序 + expensiveGoodsInstanceListSort(canExpensiveGoodsInstanceList); + //3.返回数据 + SimpleDateFormat format = new SimpleDateFormat(DateTools.COMMON_DATE_PATTEN); + for (ExpensiveGoodsInstance expensiveGoodsInstance : canExpensiveGoodsInstanceList) { + JSONObject jsonObj = new JSONObject(); + jsonObj.put("id", expensiveGoodsInstance.getId()); + jsonObj.put("expensiveGoodsId", expensiveGoodsInstance.getExpensiveGoods().getId()); + jsonObj.put("showName", expensiveGoodsInstance.getShowName()); + jsonObj.put("entryDate", format.format(expensiveGoodsInstance.getEntryDate())); + jsonObj.put("expDate", format.format(expensiveGoodsInstance.getExpDate())); + jsonObj.put("entryType", expensiveGoodsInstance.getEntryType()); + jsonObj.put("price", expensiveGoodsInstance.getPrice()); + jsonObj.put("warehouseName", expensiveGoodsInstance.getWarehouseName()); + jsonObj.put("batchNumber", expensiveGoodsInstance.getBatchNumber()); + jsonObj.put("model", expensiveGoodsInstance.getModel()); + if(expensiveGoodsInstance.getUseRecord()!=null){ + jsonObj.put("patientName", expensiveGoodsInstance.getUseRecord().getPatientName());//使用病人名 + jsonObj.put("useEnteringDate", format.format(expensiveGoodsInstance.getUseRecord().getEnteringDate()));//录用时间 + } + result.add(jsonObj); + } + System.out.println(result); + return result; + } + + /** + * 按过滤条件获得可结算的高值耗材实例集合 + * @param expensiveGoodsIds 高值耗材id集合 + * @param supplierId 供应商 + * @param startUseEnteringDate 开始使用时间 + * @param endUseEnteringDate 结束使用时间 + * @param startInvoicePlanDate 开始申请时间 + * @param endInvoicePlanDate 结束申请时间 + * @return + */ + @SuppressWarnings("unchecked") + private List getExpensiveGoodsInstanceDtailByFilter(List expensiveGoodsIds,Long supplierId + ,String startUseEnteringDate,String endUseEnteringDate,String startInvoicePlanDate,String endInvoicePlanDate){ + List instanceList = new ArrayList(); + if (CollectionUtils.isNotEmpty(expensiveGoodsIds) && DatabaseUtil.isPoIdValid(supplierId)){ + String whereSql = String.format("where %s and po.supplierId = %s " + + " and po.checkStatus = '%s' and po.settledStatus = '%s' " + + " and (( po.entryType = '%s')or( po.entryType = '%s' and po.status = '%s'))", + SqlUtils.getNonStringFieldInCollectionsPredicate("po.expensiveGoods.id", expensiveGoodsIds),supplierId, + ExpensiveGoodsInstance.CHECK_STATUS_CHECKED,ExpensiveGoodsInstance.STATUS_NOSETTLED, + ExpensiveGoodsInstance.ENTRY_TYPE_PURCHASE,ExpensiveGoodsInstance.ENTRY_TYPE_PREPARE,ExpensiveGoodsInstance.STATUS_USED); + String orderSql = "order by po.expensiveGoods.id"; + //添加申请单时间过滤 + if(StringUtils.isNotBlank(startInvoicePlanDate) && StringUtils.isNotBlank(endInvoicePlanDate)){ + whereSql += String.format("and po.invoicePlanId in (select ip.id from %s ip where %s ) " + ,InvoicePlan.class.getSimpleName(),dateQueryAdapter.dateAreaSql("ip.applicationTime",startInvoicePlanDate, endInvoicePlanDate,true)); + } + //添加使用记录时间过滤 + if(StringUtils.isNotBlank(startUseEnteringDate) && StringUtils.isNotBlank(endUseEnteringDate)){ + whereSql += String.format(" and %s ", dateQueryAdapter.dateAreaSql("po.useRecord.enteringDate", startUseEnteringDate, endUseEnteringDate,true)); + orderSql += ",po.useRecord.enteringDate"; + } + String sql = whereSql+orderSql; + instanceList = objectDao.findBySql(ExpensiveGoodsInstance.class.getSimpleName(),sql); + return instanceList; + }else{ + throw new IllegalArgumentException("参数有误!"); + } + } + + //按高值耗材实例关联的使用记录时间:排序 + private void expensiveGoodsInstanceListSort(List list) { + Collections.sort(list, new Comparator() { + @Override + public int compare(ExpensiveGoodsInstance o1, ExpensiveGoodsInstance o2) { + try { + if(o1.getExpensiveGoodsId() == o2.getExpensiveGoodsId()){ + if(o1.getUseRecord()!=null && o2.getUseRecord()!=null){ + Date dt1 = o1.getUseRecord().getEnteringDate(); + Date dt2 = o2.getUseRecord().getEnteringDate(); + if (dt1.getTime() > dt2.getTime()) { + return 1; + } else if (dt1.getTime() < dt2.getTime()) { + return -1; + } else { + return 0; + } + } + if(o1.getUseRecord()==null && o2.getUseRecord()==null){ + return 0; + } + if(o1.getUseRecord() != null && o2.getUseRecord()==null){ + return -1; + } + if(o1.getUseRecord() == null && o2.getUseRecord()!=null){ + return 1; + } + } + return (int) (o1.getExpensiveGoodsId() - o2.getExpensiveGoodsId()); + } catch (Exception e) { + e.printStackTrace(); + } + return 0; + } + }); + } } Index: ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/action/ExpensiveGoodsBillAction.java =================================================================== diff -u -r22884 -r23395 --- ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/action/ExpensiveGoodsBillAction.java (.../ExpensiveGoodsBillAction.java) (revision 22884) +++ ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/action/ExpensiveGoodsBillAction.java (.../ExpensiveGoodsBillAction.java) (revision 23395) @@ -26,6 +26,8 @@ import com.forgon.tools.json.JSONUtil; import com.forgon.tools.util.PageUtil; import com.opensymphony.xwork2.ModelDriven; + +import edu.emory.mathcs.backport.java.util.Arrays; /** * 高值耗材发票管理action * @author YanWeiNing @@ -280,12 +282,11 @@ e.printStackTrace(); } } - /** * 根据发票id获的发票已结算的高值耗材实例 */ public void loadBillExpensiveGoodsInstanceById() { - String id = StrutsParamUtils.getPraramValue("id", ""); + String id = StrutsParamUtils.getPraramValue("billId", ""); JSONObject dataObj = new JSONObject(); JSONArray jsonArray = new JSONArray(); if (StringUtils.isNotBlank(id)) {// 初始化加载的数据 @@ -331,21 +332,32 @@ } } -// // 合并打印 -// public void mergeLoadToussePrintData() { -// try { -// String idsStr = StrutsParamUtils.getPraramValue("ids", ""); -// String[] idStrs = StringUtils.split(idsStr, ','); -// -// JSONObject jsonObject = new JSONObject(); -// expensiveGoodsPurchasePlanManager.loadGoodPurchasePlanPrintData(idStrs, jsonObject); -// jsonObject.put("success", true); -// HttpServletResponse response = StrutsParamUtils.getResponse(); -// response.setCharacterEncoding("UTF-8"); -// response.getWriter() -// .println(jsonObject.toString()); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } + /** + * 根据时间,高值耗材物品获得可结算的高值耗材实例集合 + */ + public void loadExpensiveGoodsInstanceByFilter(){ + String filterParam = StrutsParamUtils.getPraramValue("filterParam", ""); + JSONArray jsonArray = new JSONArray(); + JSONObject resultObj = new JSONObject(); + if (StringUtils.isNotBlank(filterParam)) { + JSONObject filterParamJson = JSONObject.fromObject(filterParam); //获得页面过滤参数 + String startUseEnteringDate = JSONUtil.optString(filterParamJson,"startUseEnteringDate", null);//开始使用时间 + String endUseEnteringDate = JSONUtil.optString(filterParamJson,"endUseEnteringDate", null);//结束使用时间 + String startInvoicePlanDate = JSONUtil.optString(filterParamJson,"startInvoicePlanDate", null);//开始申请时间 + String endInvoicePlanDate = JSONUtil.optString(filterParamJson,"endInvoicePlanDate", null);//结束申请时间 + Long supplierId = JSONUtil.optLong(filterParamJson,"supplierId",null);//供应商id + String expensiveGoodsIdS = JSONUtil.optString(filterParamJson,"expensiveGoodsIds", null);//高值耗材ids + String[] expensiveGoodsIdArray = expensiveGoodsIdS.split(Constants.IDS_SEPARATOR); + List expensiveGoodsIdList = Arrays.asList(expensiveGoodsIdArray); + try { + jsonArray = expensiveGoodsBillManager.getExpensiveGoodsInstanceDtailByExpensiveGoodsIdsAndTime(expensiveGoodsIdList,supplierId, + startUseEnteringDate,endUseEnteringDate,startInvoicePlanDate,endInvoicePlanDate); + } catch (Exception e) { + e.printStackTrace(); + resultObj.put("message", e.getMessage()); + } + } + resultObj.put("data", jsonArray); + StrutsResponseUtils.output(resultObj); + } } Index: ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillManager.java =================================================================== diff -u -r22884 -r23395 --- ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillManager.java (.../ExpensiveGoodsBillManager.java) (revision 22884) +++ ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillManager.java (.../ExpensiveGoodsBillManager.java) (revision 23395) @@ -107,4 +107,20 @@ * @return JSONObject */ public JSONObject loadWarningExpensiveGoodsInstance(); + + /** + * 根据高值耗材id集合,供应商id,时间过滤条件:获得可结算的高值耗材实例集合 + * 1.时间过滤条件全为空: 只根据高值耗材id集合,供应商id获得高值耗材实例集合 + * 2.(开始录用时间,结束录用时间)同时不为空才能为有效的过滤条件 + * 3.(开始申请时间,结束申请时间)同时不为空才能为有效的过滤条件 + * @param expensiveGoodsIds 高值耗材id集合 + * @param supplierId 供应商id + * @param startUseEnteringDate 开始录用时间 + * @param endUseEnteringDate 结束录用时间 + * @param startInvoicePlanDate 开始申请时间 + * @param endInvoicePlanDate 结束申请时间 + * @return + */ + public JSONArray getExpensiveGoodsInstanceDtailByExpensiveGoodsIdsAndTime(List expensiveGoodsIds,Long supplierId + ,String startUseEnteringDate,String endUseEnteringDate,String startInvoicePlanDate,String endInvoicePlanDate); } Index: ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsBill/expensiveGoodsBillForm.js =================================================================== diff -u -r22364 -r23395 --- ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsBill/expensiveGoodsBillForm.js (.../expensiveGoodsBillForm.js) (revision 22364) +++ ssts-web/src/main/webapp/disinfectsystem/assestManagement/expensiveGoods/expensiveGoodsBill/expensiveGoodsBillForm.js (.../expensiveGoodsBillForm.js) (revision 23395) @@ -1,5 +1,6 @@ var windowObj = null; var form = null; +var selectModel = new top.Ext.grid.CheckboxSelectionModel();//可结算实例明细复选框 /** * 打开已保存并结算的发票单(显示结算的实例明细) */ @@ -22,16 +23,15 @@ {name : 'entryDate',mapping : 'entryDate'}, {name : 'expDate',mapping : 'expDate'}, {name : 'model',mapping : 'model'}, - {name : 'patientName',mapping : 'patientName'} + {name : 'patientName',mapping : 'patientName'}, + {name : 'useEnteringDate',mapping : 'useEnteringDate'} ]), listeners : { beforeload:function(thiz){ -// console.log("id"); - thiz.baseParams["id"] = id; + thiz.baseParams["billId"] = id; } } }); - //第二工具栏 var tbar2 = new top.Ext.Toolbar({ items:[ @@ -92,19 +92,62 @@ } ] }); - if(id==undefined || id == "" || id < 0){ - disableShowImageButton = true; - }else{ + + //时间过滤工具栏 + var timeTbar2 = new top.Ext.Toolbar({ + items:[{ + text: '申请开始时间:' + },{ + xtype: 'datefieldWithMin', + id: 'startInvoicePlanDate', + format: 'Y-m-d', + readOnly: true, + editable: false, + width: sstsConfig.timeSearchFmt ? 130 : 100 + },{ + text: '申请结束日期:' + }, + { + xtype: 'datefieldWithMin', + id: 'endInvoicePlanDate', + readOnly: true, + editable: false, + format: 'Y-m-d', + width: sstsConfig.timeSearchFmt ? 130 : 100 + },{ + xtype: 'button', + text: '查询', + iconCls: 'icon_search', + hidden :committedStatus, + handler: reloadTime + },{ + xtype: 'button', + text: '重置', + iconCls: 'icon_set', + handler: function(){ + top.Ext.getCmp("startUseEnteringDate").setValue(null); + top.Ext.getCmp("endUseEnteringDate").setValue(null); + top.Ext.getCmp("startInvoicePlanDate").setValue(null); + top.Ext.getCmp("endInvoicePlanDate").setValue(null); + } + }] + }); + + //若是已提交的发票:则加载发票的实例明细 + if(!isUndefinedOrNullOrEmpty(id) && committedStatus){ disableShowImageButton = false; expensiveGoodsInstanceStore.load(); + }else{ + disableShowImageButton = true; } + //开始创建from表单 form = new top.Ext.FormPanel({ id : 'expensiveGoodBillForm', frame : true, labelSeparator : ':', bodyStyle : 'padding:5px 5px 0px 5px', width : 1000, - height : 600, + height : 645, // autoScroll : true, labelAlign : 'left', items:[{ @@ -322,15 +365,15 @@ items:[{ layout : 'form', columnWidth : 0.47, - autoScroll: true, +// autoScroll: true, items : [ new top.Ext.grid.EditorGridPanel({ id : 'goodBillItemGrid', bodyStyle : 'border:1px solid #afd7af', frame :false, title : '发票单明细', width :480, - height : 380, + height : 396, store : new top.Ext.data.Store({ reader : new top.Ext.data.JsonReader({ fields : [ @@ -448,45 +491,69 @@ } } })] - } - ,{ + },{ layout : 'form', columnWidth : 0.53, - items:[new top.Ext.grid.EditorGridPanel({ + autoScroll: true, + items:[ + new top.Ext.grid.EditorGridPanel({ id : 'expensiveGoodsInstanceGrid', title : '高值耗材实例明细', + width : 520, + height : 396, store : expensiveGoodsInstanceStore, - cm : new top.Ext.grid.ColumnModel([ + sm : selectModel, + cm : new top.Ext.grid.ColumnModel([selectModel, {header : "id",dataIndex : 'id',hidden : true}, {header : "高值耗材定义id",dataIndex : 'expensiveGoodsId',hidden : true}, - {header : "物品",dataIndex : 'showName',width : 70,menuDisabled : true}, - {header : "型号",dataIndex : 'model',width : 50,menuDisabled : true}, - {header : "入库类型",dataIndex : 'entryType',width : 50,menuDisabled : true}, - {header : "单价",dataIndex : 'price',width : 50,menuDisabled : true}, - {header : "入库日期",dataIndex : 'entryDate',width : 50,menuDisabled : true}, - {header : "病人姓名",dataIndex : 'patientName',width : 50,menuDisabled : true} - + {header : "物品",dataIndex : 'showName',width : 100,menuDisabled : true}, + {header : "型号",dataIndex : 'model',width : 70,menuDisabled : true}, + {header : "使用时间",dataIndex :'useEnteringDate',width : 70,menuDisabled : true}, + {header : "病人",dataIndex : 'patientName',width : 50,menuDisabled : true}, + {header : "入库类型",dataIndex : 'entryType',width : 60,menuDisabled : true}, + {header : "入库日期",dataIndex : 'entryDate',width : 70,menuDisabled : true}, + {id:'price', header : "单价",dataIndex : 'price',width : 40,menuDisabled : true} ]), - enableHdMenu : false, - width : 530, - height : 380, - autoExpandColumn : 'deleteItem', - frame : false, + autoExpandColumn : 'price', + tbar : [{ + text: '使用开始时间:' + },{ + xtype: 'datefieldWithMin', + id: 'startUseEnteringDate', + format: 'Y-m-d', + readOnly: true, + editable: false, + width: sstsConfig.timeSearchFmt ? 130 : 100 + },{ + text: '结束使用日期:' + }, + { + xtype: 'datefieldWithMin', + id: 'endUseEnteringDate', + readOnly: true, + editable: false, + format: 'Y-m-d', + width: sstsConfig.timeSearchFmt ? 130 : 100 + }], +// frame : false, bodyStyle : 'border:1px solid #afd7af', - viewConfig : {forceFit : true}, - clicksToEdit : 1, - selModel : new top.Ext.grid.RowSelectionModel({ - singleSelect : false - }), - listeners : { - validateedit : function(o) { - if (!isPositiveInteger(o.value)){ - return false; - } - } +// viewConfig : {forceFit : true}, +// clicksToEdit : 1, + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }), + listeners : { +// validateedit : function(o) { +// if (!isPositiveInteger(o.value)){ +// return false; +// } +// } + render : function() { + timeTbar2.render(this.tbar); } - })] - } + } + })] + } ] }], buttons : [{ @@ -522,13 +589,12 @@ } }] }); - windowObj = new top.Ext.Window( { id : 'expensiveGoodsBill', layout : 'fit', title : '高值耗材发票单', width : 1000, - height :600, + height :615, modal : true, border :false, plain : true, @@ -545,26 +611,11 @@ }); windowObj.show(); // top.Ext.getCmp('name1').focus(false, 100); - } /** - * 检查是否同一个供应商 - */ -function isSameSupplierId(supplierId){ - for(var i = 0;i < top.Ext.getCmp('goodBillItemGrid').getStore().getCount();i++){ - var goodBillItemGridData = top.Ext.getCmp('goodBillItemGrid').getStore().getAt(i).data; - if(goodBillItemGridData.supplierId != supplierId){ - showResult("一张入库单只能填同一个供应商!"); - return false; - } - } - return true; -} - -/** * 提交或者暂存高值耗材申请单. - * @param commit 是否提交操作(为true则为提交操作,否则为暂存操作) + * @param commit 是否提交操作(为true则为提交操作,false为暂存操作) */ function saveOrTemporarySaveBill(commit){ if(!form.getForm().isValid()){ @@ -573,10 +624,30 @@ } var time = top.Ext.getCmp('time').getValue().format('Y-m-d H:i:s'); var settledTime = top.Ext.getCmp('settledTime').getValue().format('Y-m-d H:i:s'); - var items = buildJSONStringFromStore(top.Ext.getCmp('goodBillItemGrid').getStore()); - var instanceItems = buildJSONStringFromStore(top.Ext.getCmp('expensiveGoodsInstanceGrid').getStore()); + var billItemStore = top.Ext.getCmp('goodBillItemGrid').getStore();//发票明细数据 + var items = buildJSONStringFromStore(billItemStore); +// var instanceItems = buildJSONStringFromStore(top.Ext.getCmp('expensiveGoodsInstanceGrid').getStore()); + //勾选的可结算实例集合 + var instanceSelectItems = top.Ext.getCmp('expensiveGoodsInstanceGrid').getSelectionModel().getSelections(); + var len = instanceSelectItems.length; + //结算时需要判断 + if(commit){ + //否有勾选择实例明细 + if(len == 0 ){ + showResult("请先选择可结算的实例明细!"); + return false; + }; + } + var instanceItems = []; + for (var i = 0; i < len; i++) { + var record = instanceSelectItems[i]; + instanceItems.push({ + id : record.data.id,//高值耗材物品实例id + expensiveGoodsId : record.data.expensiveGoodsId//高值耗材物品id + }) + } var supplierId = top.Ext.getCmp('supplierId').getValue(); - //是否同一个供应商 + //检查是否同一个供应商 if(!isSameSupplierId(supplierId)){ return false; } @@ -592,7 +663,7 @@ var jsonstr = JSON.stringify(json); top.Ext.getCmp("formParams").setValue(jsonstr); top.Ext.getCmp("items").setValue(items); - top.Ext.getCmp("instanceItems").setValue(instanceItems); + top.Ext.getCmp("instanceItems").setValue(JSON.stringify(instanceItems)); // items为json数组字符串,不能为null if(items == '[]'||items.length==0){ showResult('发票列表不能为空'); @@ -624,22 +695,24 @@ var amount = expensiveGoodsBillItem.data.amount; var supplierId = top.Ext.getCmp('supplierId').getValue(); var settledTime = top.Ext.getCmp('settledTime').getValue().format('Y-m-d H:i:s'); - var data ={"expensiveGoodsId":expensiveGoodsId, + var data ={ + "expensiveGoodsId":expensiveGoodsId, "amount" : amount, + "isAllAmount" : true,//是否显示全部可结算数量 "supplierId" : supplierId, - "settledTime" : settledTime}; + "settledTime" : settledTime + }; var jsonstr = JSON.stringify(data); // console.log(data); Ext.Ajax.request({ url : WWWROOT + '/disinfectSystem/expensiveGoodsBillAction!loadExpensiveGoodsInstanceByExpensiveGoodsId.do', + async:false, params : { data : jsonstr }, success : function(response) { var result = Ext.decode(response.responseText).data; var message = Ext.decode(response.responseText).message; -// console.log(result); -// console.log(message); if(message.warning!=null){ showResult(message.warning); } @@ -654,9 +727,12 @@ entryDate : result[i].entryDate, expDate:result[i].expDate, model: result[i].model, - patientName: result[i].patientName + patientName: result[i].patientName, + useEnteringDate: result[i].useEnteringDate//实例录用时间 }); - top.Ext.getCmp('expensiveGoodsInstanceGrid').getStore().insert(0 , expensiveGoodsInstanceItem); +// console.log(expensiveGoodsInstanceItem); +// top.Ext.getCmp('expensiveGoodsInstanceGrid').getStore().insert(0 , expensiveGoodsInstanceItem); + top.Ext.getCmp('expensiveGoodsInstanceGrid').getStore().add(expensiveGoodsInstanceItem); } } @@ -666,3 +742,142 @@ } }); } + +/** + * 检查是否同一个供应商 + */ +function isSameSupplierId(supplierId){ + for(var i = 0;i < top.Ext.getCmp('goodBillItemGrid').getStore().getCount();i++){ + var goodBillItemGridData = top.Ext.getCmp('goodBillItemGrid').getStore().getAt(i).data; + if(goodBillItemGridData.supplierId != supplierId){ + showResult("一张入库单只能填同一个供应商!"); + return false; + } + } + return true; +} +////////////////////// +/** + * 根据时间查询可结算的高值耗材实例 + */ +function reloadTime(){ + //过滤申请时间段 + var startInvoicePlanDate = top.Ext.getCmp("startInvoicePlanDate").getValue(); + var endInvoicePlanDate = top.Ext.getCmp("endInvoicePlanDate").getValue(); + //过滤使用时间段 + var startUseEnteringDate = top.Ext.getCmp("startUseEnteringDate").getValue(); + var endUseEnteringDate = top.Ext.getCmp("endUseEnteringDate").getValue(); + //获得发票明细物品 + var billItemStoreList = top.Ext.getCmp('goodBillItemGrid').getStore(); + //若4个过滤时间为空则获取全部 + if((isUndefinedOrNullOrEmpty(startInvoicePlanDate)&&isUndefinedOrNullOrEmpty(endInvoicePlanDate)) + &&(isUndefinedOrNullOrEmpty(startUseEnteringDate)&&isUndefinedOrNullOrEmpty(endUseEnteringDate))){ + if(billItemStoreList.getCount() > 0){ + //按时间过滤 + filterInstanceItemByTime(billItemStoreList,null,null,null,null); + }else{ + showResult('请先选择要录入的物品!'); + return; + }; + //若有选择过滤时间 + }else{ + if(isUndefinedOrNullOrEmpty(startInvoicePlanDate) && !isUndefinedOrNullOrEmpty(endInvoicePlanDate) ){ + showResult('请选择申请开始时间!'); + return; + }; + if(!isUndefinedOrNullOrEmpty(startInvoicePlanDate) && isUndefinedOrNullOrEmpty(endInvoicePlanDate)){ + showResult('请选择申请结束时间!'); + return; + }; + if(isUndefinedOrNullOrEmpty(startUseEnteringDate) && !isUndefinedOrNullOrEmpty(endUseEnteringDate)){ + showResult('请选择使用开始时间!'); + return; + }; + if(!isUndefinedOrNullOrEmpty(startUseEnteringDate) && isUndefinedOrNullOrEmpty(endUseEnteringDate)){ + showResult('请选择使用结束时间!'); + return; + } + if ((startInvoicePlanDate > endInvoicePlanDate) || (startUseEnteringDate > endUseEnteringDate)) { + showResult('开始时间不能大于结束时间!'); + return; + }; + if(billItemStoreList.getCount() > 0){ + //按时间过滤 + filterInstanceItemByTime(billItemStoreList,startUseEnteringDate,endUseEnteringDate,startInvoicePlanDate,endInvoicePlanDate); + }else{ + showResult('请先选择要录入的物品!'); + return; + }; + } +} +//按时间过滤获得可结算实例 +function filterInstanceItemByTime(billItemStoreList,startUseEnteringDate,endUseEnteringDate,startInvoicePlanDate,endInvoicePlanDate){ + //发票明细数据 + var len = billItemStoreList.getCount(); + var expensiveGoodsIds = null; + for ( var i = 0, len ; i < len; i++) { + var record = billItemStoreList.getAt(i); + if (expensiveGoodsIds == null) { + expensiveGoodsIds = record.data.expensiveGoodsId;//高值耗材物品id + } else { + expensiveGoodsIds = expensiveGoodsIds + ';' + record.data.expensiveGoodsId; + } + } + var settledTime = top.Ext.getCmp('settledTime').getValue().format('Y-m-d H:i:s'); + var supplierId = top.Ext.getCmp('supplierId').getValue(); + var filterParam ={ + "expensiveGoodsIds":expensiveGoodsIds,//发票明细数据 + "supplierId" : supplierId, + "startUseEnteringDate" : fromatTime(startUseEnteringDate),//开始使用时间 + "endUseEnteringDate" : fromatTime(endUseEnteringDate),//结束使用时间 + "startInvoicePlanDate" : fromatTime(startInvoicePlanDate),//开始申请时间 + "endInvoicePlanDate" : fromatTime(endInvoicePlanDate)//结束申请时间 + }; + var filterParamStr = JSON.stringify(filterParam); + //按照过滤获取实例集合 + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/expensiveGoodsBillAction!loadExpensiveGoodsInstanceByFilter.do', + async:false, + params : { + filterParam : filterParamStr + }, + success : function(response) { + var result = Ext.decode(response.responseText).data + var message = Ext.decode(response.responseText).message; + //清除实例store所有数据 + var InstanceGridStore = top.Ext.getCmp('expensiveGoodsInstanceGrid').getStore(); + InstanceGridStore.removeAll(); + if(message!=null){ + showResult(message); + }; + if(result){ + for (var i = 0; i < result.length; i++) { + var expensiveGoodsInstanceItem = new expensiveGoodsInstanceItemRecord({ + id : result[i].id, + expensiveGoodsId : result[i].expensiveGoodsId, + showName : result[i].showName, + entryType : result[i].entryType, + price : result[i].price, + entryDate : result[i].entryDate, + expDate:result[i].expDate, + model: result[i].model, + patientName: result[i].patientName, + useEnteringDate: result[i].useEnteringDate//实例录用时间 + }); +// top.Ext.getCmp('expensiveGoodsInstanceGrid').getStore().insert(0 , expensiveGoodsInstanceItem); + top.Ext.getCmp('expensiveGoodsInstanceGrid').getStore().add(expensiveGoodsInstanceItem); + } + } + }, + failure : function(response, options) { + showResult(response.responseText); + } + }); +} +function fromatTime(dateStr){ + if(!isUndefinedOrNullOrEmpty(dateStr)){ + var date = new Date(dateStr); + return TimeStr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate(); + } + +} \ No newline at end of file