Index: ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillManagerImpl.java =================================================================== diff -u -r21932 -r21970 --- ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillManagerImpl.java (.../ExpensiveGoodsBillManagerImpl.java) (revision 21932) +++ ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillManagerImpl.java (.../ExpensiveGoodsBillManagerImpl.java) (revision 21970) @@ -1,73 +1,33 @@ package com.forgon.disinfectsystem.expensiveGoods.service; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.OutputStream; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; -import javassist.expr.NewArray; import net.sf.json.JSONArray; import net.sf.json.JSONObject; 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.springframework.stereotype.Service; -import org.springframework.test.context.jdbc.Sql; -import com.forgon.Constants; -import com.forgon.directory.model.BarcodeDevice; import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; -import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManagerImpl; -import com.forgon.disinfectsystem.common.CssdUtils; import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveGoods; import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveGoodsBill; import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveGoodsBillItem; -import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveGoodsGodownEntry; -import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveGoodsGodownEntryItem; import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveGoodsInstance; -import com.forgon.disinfectsystem.entity.assestmanagement.GodownEntry; -import com.forgon.disinfectsystem.entity.assestmanagement.GoodPurchaseItem; -import com.forgon.disinfectsystem.entity.assestmanagement.GoodPurchasePlan; import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig; -import com.forgon.disinfectsystem.expensivegoods.ExpensiveGoodsServiceContext; -import com.forgon.disinfectsystem.vo.GodownEntryItemPrintVO; -import com.forgon.serialnumber.model.SerialNum; -import com.forgon.serialnumber.service.SerialNumManager; import com.forgon.tools.MathTools; -import com.forgon.tools.Path; -import com.forgon.tools.StrutsParamUtils; import com.forgon.tools.date.DateTools; 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; import com.forgon.tools.string.StringTools; -import com.forgon.tools.util.ForgonDateUtils; -import com.forgon.tools.util.SqlUtils; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; /** * 高值耗材发票ManagerImpl @@ -77,9 +37,6 @@ @Service("expensiveGoodsBillManagerTarget") public class ExpensiveGoodsBillManagerImpl extends BasePoManagerImplimplements ExpensiveGoodsBillManager { - - private SerialNumManager serialNumManager; - private ExpensiveGoodsManager expensiveGoodsManager; private SupplyRoomConfigManager supplyRoomConfigManager; @@ -97,10 +54,6 @@ this.supplyRoomConfigManager = supplyRoomConfigManager; } - public void setSerialNumManager(SerialNumManager serialNumManager) { - this.serialNumManager = serialNumManager; - } - public void saveOrUpdate(ExpensiveGoodsBill expensiveGoodsBill) { objectDao.saveOrUpdate(expensiveGoodsBill); } @@ -327,7 +280,6 @@ if(SupplierName != null && !originalSupplierName.equals(SupplierName)){ curExpensiveGoodsBill.setSupplierName(SupplierName); } - } /** @@ -411,9 +363,9 @@ @SuppressWarnings("unchecked") List instanceList = objectDao.findBySql(ExpensiveGoodsInstance.class.getSimpleName(),sql); - //若查到的为空则默认数量为0 + //若查到的为空则返回信息 if(CollectionUtils.isEmpty(instanceList)){ - int usedAmount = 0; + throw new IllegalArgumentException("物品:"+goodName+"预入库,自购入库的验收且已使用总数量为:"+0+" 小于结算数量:"+billAmount+"!"); } //判断已使用的预入库,自购入库高值耗材实例数量是否大于等于结算数量 int usedAmount = instanceList.size(); @@ -438,7 +390,8 @@ throw new IllegalArgumentException("物品:"+goodName+"对应的页面的高值耗材实例为空"); } idToExpensiveGoodsInstanceMap.put(expensiveGoodsId, expensiveGoodsInstanceList); - + } +} // //自购入库实例集合 // List purchaseInstanceList = new ArrayList(); // //预入库实例集合 @@ -468,25 +421,7 @@ // } //根据发票明细的高值耗材定义id汇总高值耗材实例集合 // idToExpensiveGoodsInstanceMap.put(expensiveGoodsId, expensiveGoodsInstanceList); - } -} - /** - * 设置结算的高值耗材实例详细 - */ -// private void setReturnDetails(ExpensiveGoodsBill expensiveGoodsBill,Map result){ -// JSONArray printItemJsonArray = new JSONArray(); -// List billItemList = expensiveGoodsBill.getItems(); -// for (ExpensiveGoodsBillItem billItem : billItemList) { -// List expensiveGoodsInstanceList = billItem.getExpensiveGoodsInstanceList(objectDao); -// for (ExpensiveGoodsInstance expensiveGoodsInstance : expensiveGoodsInstanceList) { -// JSONObject printItemObj = new JSONObject(); -// printItemObj.put("id", expensiveGoodsInstance.getId()); -// } -// result.put("itemsDetails", printItemJsonArray); -// } -// } - @Override public void updateBillInfo(ExpensiveGoodsBill bill,JSONObject billInfo,boolean committedStatus) { if(bill == null || billInfo == null){ @@ -495,7 +430,7 @@ //获得表单的数据 Long id = billInfo.optLong("id"); String remark = billInfo.optString("remark"); - String timeStr = billInfo.optString("time"); +// String timeStr = billInfo.optString("time"); String settledTimeStr = billInfo.optString("settledTime"); String operator = billInfo.optString("operator"); String serialNumber = billInfo.optString("serialNumber"); @@ -544,6 +479,7 @@ } //新建发票明细 + @SuppressWarnings("unchecked") private ExpensiveGoodsBillItem parseExpensiveGoodsBillItem(ExpensiveGoodsBill bill,JSONObject itemObject,JSONArray instanceItemsArray) { if(itemObject == null){ throw new IllegalArgumentException("itemObjec不能为空"); @@ -629,6 +565,7 @@ return expensiveGoodsBillItem; } + @SuppressWarnings("unchecked") @Override public JSONArray getExpensiveGoodsInstanceDtailByBillId(String id) { if(!DatabaseUtil.isPoIdValid(id)){ @@ -639,9 +576,6 @@ String hql = String.format( "select po from ExpensiveGoodsInstance po where po.expensiveGoodsBillId = %s order by po.expensiveGoods.id",id); expensiveGoodsInstanceList = objectDao.findByHql(hql); -// expensiveGoodsInstanceList = objectDao.findByProperty( -// ExpensiveGoodsInstance.class.getSimpleName(),"expensiveGoodsBillId", id); - //返回高值耗材实例详细 if(CollectionUtils.isNotEmpty(expensiveGoodsInstanceList)){ SimpleDateFormat format=new SimpleDateFormat("yyy-MM-dd"); @@ -664,6 +598,7 @@ return null; } + @SuppressWarnings("unchecked") @Override public JSONArray getExpensiveGoodsInstanceDtailByExpensiveGoodsId(String settledTimeStr,String billAmount,String expensiveGoodsId,Map result) { if(!DatabaseUtil.isPoIdValid(expensiveGoodsId)||!StringTools.isNumber(billAmount)){ @@ -739,199 +674,19 @@ return null; } -//////////////////////////////////// - // 获取入库单打印信息 -/* @Override - public void loadGoodPurchasePlanPrintData( - String[] invoiceIds,JSONObject jsonObject) { - Collection tousseList = CollectionUtils.emptyCollection(); - jsonObject.put("goods", tousseList); - if (ArrayUtils.isEmpty(invoiceIds)){ - return ; - } - - String idsStr = StringUtils.join(invoiceIds, ","); - String sql = String.format(" where po.id in (%s)", idsStr); - List list = objectDao.findBySql( - GoodPurchasePlan.class.getSimpleName(), sql); - if (list == null || list.size() == 0){ - return ; - } - String serialNumber = ""; - String applicant = ""; - String time = ""; - String supplierName = "";//供应商 - if(list.size() == 1){ - GoodPurchasePlan plan = list.get(0); - serialNumber = plan.getSerialNumber(); - time = ForgonDateUtils.safelyFormatDate(plan.getTime(), Constants.DATEFORMAT_YYYYMMDD, ""); - List items = plan.getItemsList(); - if(items != null && items.size() > 0){ - supplierName = items.get(0).getSupplierName(); - } - } - jsonObject.put("serialNumber", serialNumber); - jsonObject.put("applicant", applicant); - jsonObject.put("godownEntryTime", time); - jsonObject.put("supplierName", supplierName); - - tousseList = loadToussePrintData(list); - jsonObject.put("goods", tousseList); - } -*/ - // 找出已经存在项 -/* private Collection loadToussePrintData( - Collection plans) { - if (CollectionUtils.isEmpty(plans)) { - return CollectionUtils.emptyCollection(); - } - - List voList = new ArrayList(); -// for (GoodPurchasePlan plan : plans) { -// List items = plan.getItemsList(); -// for (GoodPurchaseItem item : items) { -// JSONObject obj = CssdUtils.getGoodsNameAndSp(item.getName()); -// DisposableGoods diposableGoods = diposableGoodsManager.get( -// obj.optString("materialName"), -// obj.optString("specification")); -// GodownEntryItemPrintVO tempVo = new GodownEntryItemPrintVO(); -// if(diposableGoods == null && DatabaseUtil.isPoIdValid(item.getMaterialDefinitionId())){ -// MaterialDefinition md = -// (MaterialDefinition)objectDao.getBySql(MaterialDefinition.class.getSimpleName(), "where id=" + item.getMaterialDefinitionId()); -// if(md == null){ -// continue; -// } -// tempVo.setCode(md.getExternalCode()); -// tempVo.setName(md.getName()); -// tempVo.setSpecification(md.getSpecification()); -// tempVo.setInventorySerialNumber(md.getInventorySerialNumber()); -// tempVo.setUnit(md.getUnit()); -// }else{ -// tempVo.setCode(diposableGoods.getExternalCode()); -// tempVo.setName(diposableGoods.getName()); -// tempVo.setSpecification(diposableGoods.getSpecification()); -// tempVo.setInventorySerialNumber(diposableGoods.getInventorySerialNumber()); -// tempVo.setUnit(diposableGoods.getUnit()); -// tempVo.setCertification(diposableGoods.getCertification()); -// } -// tempVo.setAmount(Long.valueOf(item.getScheduleAmout())); -// tempVo.setPrice(item.getPurchase()); -// tempVo.setRowPrice(item.getTotalPrice()); -// tempVo.setTotalPrice(tempVo.getRowPrice()); -// tempVo.setBatchNumber(""); -// tempVo.setSupplierName(item.getSupplierName()); -// voList.add(tempVo); + /** + * 设置结算的高值耗材实例详细 + */ +// private void setReturnDetails(ExpensiveGoodsBill expensiveGoodsBill,Map result){ +// JSONArray printItemJsonArray = new JSONArray(); +// List billItemList = expensiveGoodsBill.getItems(); +// for (ExpensiveGoodsBillItem billItem : billItemList) { +// List expensiveGoodsInstanceList = billItem.getExpensiveGoodsInstanceList(objectDao); +// for (ExpensiveGoodsInstance expensiveGoodsInstance : expensiveGoodsInstanceList) { +// JSONObject printItemObj = new JSONObject(); +// printItemObj.put("id", expensiveGoodsInstance.getId()); // } +// result.put("itemsDetails", printItemJsonArray); // } - return voList; - } -*/ - -// @Override -// public void exportGoodPurchasePlan(OutputStream ops, String ids) { -// String sql = String.format(" where po.id in (%s)", ids); -// -// @SuppressWarnings("unchecked") -// List list = objectDao.findBySql( -// GoodPurchasePlan.class.getSimpleName(), sql); -// Collection itemVos = loadToussePrintData(list); -// createExportFile(itemVos, ops); -// // } - private void createExportFile(Collection itemVos, - OutputStream ops) { - String inputFile = Path.getWebAppRoot() - + "/disinfectsystem/reportforms/receiveDetail.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); - - HSSFRow operatingRow1 = sheet.createRow(0); - createCell(operatingRow1, cellStyle, 0, "编码"); - createCell(operatingRow1, cellStyle, 1, "名称"); - createCell(operatingRow1, cellStyle, 2, "规格"); - createCell(operatingRow1, cellStyle, 3, "单位"); - createCell(operatingRow1, cellStyle, 4, "数量"); - createCell(operatingRow1, cellStyle, 5, "进价"); - createCell(operatingRow1, cellStyle, 6, "进价金额"); - createCell(operatingRow1, cellStyle, 7, "产地"); - createCell(operatingRow1, cellStyle, 8, "供应商"); - createCell(operatingRow1, cellStyle, 9, "注册证号"); - - int row = 1; - for (GodownEntryItemPrintVO item : itemVos) { - HSSFRow operatingRow = sheet.createRow(row); - createCell(operatingRow, cellStyle, 0, item.getCode()); - createCell(operatingRow, cellStyle, 1,item.getName()); - createCell(operatingRow, cellStyle, 2, item.getSpecification()); - createCell(operatingRow, cellStyle, 3, item.getUnit()); - Long storage = item.getAmount(); - if (storage != null) { - createCell(operatingRow, cellStyle, 4, - Integer.parseInt("" + storage)); - } else { - createCell(operatingRow, cellStyle, 4, 0); - } - - createCell(operatingRow, cellStyle, 5, item.getPrice()); - createCell(operatingRow, cellStyle, 6,item.getTotalPrice()); - createCell(operatingRow, cellStyle, 7,item.getProducingArea()); - createCell(operatingRow, cellStyle, 8,item.getSupplierName()); - createCell(operatingRow, cellStyle, 9,item.getCertification()); - row++; - } - wb.write(ops); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - ops.close(); - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - private void createCell(HSSFRow row, HSSFCellStyle cellStyle, - int cellIndex,Object value){ - HSSFCell cell = row.createCell(cellIndex); - cell.setCellStyle(cellStyle); - if(value != null){ - if(value instanceof Double){ - cell.setCellValue((Double) value); - }else if(value instanceof Integer){ - cell.setCellValue((Integer)value); - }else if(value instanceof Boolean){ - cell.setCellValue((Boolean)value); - }else if(value instanceof Date){ - cell.setCellValue((Date)value); - }else if(value instanceof Calendar){ - cell.setCellValue((Calendar)value); - }else if(value instanceof RichTextString){ - cell.setCellValue((RichTextString)value); - }else{ - cell.setCellValue(value.toString()); - } - } - } - } Index: ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillTableFilterManagerImpl.java =================================================================== diff -u -r21030 -r21970 --- ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillTableFilterManagerImpl.java (.../ExpensiveGoodsBillTableFilterManagerImpl.java) (revision 21030) +++ ssts-expensivegoods/src/main/java/com/forgon/disinfectsystem/expensiveGoods/service/ExpensiveGoodsBillTableFilterManagerImpl.java (.../ExpensiveGoodsBillTableFilterManagerImpl.java) (revision 21970) @@ -1,7 +1,5 @@ package com.forgon.disinfectsystem.expensiveGoods.service; -import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoods; -import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveGoods; import com.forgon.search.service.TBarFilterManager; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service;