From 5e05f53af2fba4bef5b26afcf9fb08617bec74a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Wed, 30 Aug 2017 00:14:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=8E=E7=AB=AF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jsh/action/basic/DepotAction.java | 571 ++++++++++-------- .../com/jsh/action/basic/FunctionsAction.java | 65 +- .../com/jsh/action/basic/SupplierAction.java | 376 ++++++++++-- .../java/com/jsh/action/basic/UnitAction.java | 295 +++++++++ .../java/com/jsh/action/basic/UserAction.java | 35 +- .../jsh/action/basic/UserBusinessAction.java | 38 ++ .../jsh/action/materials/DepotHeadAction.java | 406 +++++++------ .../jsh/action/materials/DepotItemAction.java | 363 ++++++++--- .../jsh/action/materials/MaterialAction.java | 239 +++++++- .../materials/MaterialCategoryAction.java | 44 ++ .../jsh/action/materials/PersonAction.java | 75 +++ .../java/com/jsh/dao/basic/SupplierDAO.java | 9 +- .../java/com/jsh/dao/basic/SupplierIDAO.java | 1 + src/main/java/com/jsh/dao/basic/UnitDAO.java | 17 + src/main/java/com/jsh/dao/basic/UnitIDAO.java | 9 + .../com/jsh/dao/materials/DepotHeadDAO.java | 71 +-- .../com/jsh/dao/materials/DepotHeadIDAO.java | 4 +- .../com/jsh/dao/materials/DepotItemDAO.java | 24 +- .../com/jsh/dao/materials/MaterialDAO.java | 25 + .../com/jsh/dao/materials/MaterialIDAO.java | 6 +- src/main/java/com/jsh/model/po/Depot.java | 36 +- src/main/java/com/jsh/model/po/DepotHead.java | 127 +++- src/main/java/com/jsh/model/po/DepotItem.java | 136 ++++- src/main/java/com/jsh/model/po/Functions.java | 10 +- src/main/java/com/jsh/model/po/Material.java | 136 ++++- .../com/jsh/model/po/MaterialCategory.java | 2 +- src/main/java/com/jsh/model/po/Supplier.java | 185 +++++- src/main/java/com/jsh/model/po/Unit.java | 39 ++ .../java/com/jsh/model/po/UserBusiness.java | 9 +- .../com/jsh/model/vo/basic/DepotModel.java | 128 ++-- .../jsh/model/vo/basic/FunctionsModel.java | 14 +- .../com/jsh/model/vo/basic/SupplierModel.java | 125 +++- .../com/jsh/model/vo/basic/UnitModel.java | 98 +++ .../com/jsh/model/vo/basic/UnitShowModel.java | 43 ++ .../jsh/model/vo/basic/UserBusinessModel.java | 9 + .../model/vo/materials/DepotHeadModel.java | 113 +++- .../model/vo/materials/DepotItemModel.java | 118 ++++ .../jsh/model/vo/materials/MaterialModel.java | 126 +++- .../jsh/service/basic/SupplierIService.java | 9 + .../jsh/service/basic/SupplierService.java | 452 +++++++++++++- .../com/jsh/service/basic/UnitIService.java | 9 + .../com/jsh/service/basic/UnitService.java | 24 + .../service/materials/DepotHeadIService.java | 4 +- .../service/materials/DepotHeadService.java | 8 +- .../service/materials/MaterialIService.java | 13 +- .../service/materials/MaterialService.java | 323 +++++++++- .../java/com/jsh/util/MaterialConstants.java | 94 +++ .../java/com/jsh/util/SupplierConstants.java | 115 ++++ src/main/java/com/jsh/util/Tools.java | 28 +- 49 files changed, 4413 insertions(+), 793 deletions(-) create mode 100644 src/main/java/com/jsh/action/basic/UnitAction.java create mode 100644 src/main/java/com/jsh/dao/basic/UnitDAO.java create mode 100644 src/main/java/com/jsh/dao/basic/UnitIDAO.java create mode 100644 src/main/java/com/jsh/model/po/Unit.java create mode 100644 src/main/java/com/jsh/model/vo/basic/UnitModel.java create mode 100644 src/main/java/com/jsh/model/vo/basic/UnitShowModel.java create mode 100644 src/main/java/com/jsh/service/basic/UnitIService.java create mode 100644 src/main/java/com/jsh/service/basic/UnitService.java create mode 100644 src/main/java/com/jsh/util/MaterialConstants.java create mode 100644 src/main/java/com/jsh/util/SupplierConstants.java diff --git a/src/main/java/com/jsh/action/basic/DepotAction.java b/src/main/java/com/jsh/action/basic/DepotAction.java index 07eb98f8..fbe3e292 100644 --- a/src/main/java/com/jsh/action/basic/DepotAction.java +++ b/src/main/java/com/jsh/action/basic/DepotAction.java @@ -25,251 +25,260 @@ import com.jsh.util.PageUtil; @SuppressWarnings("serial") public class DepotAction extends BaseAction { - private DepotIService depotService; - private UserBusinessIService userBusinessService; - private DepotModel model = new DepotModel(); - - + private DepotIService depotService; + private UserBusinessIService userBusinessService; + private DepotModel model = new DepotModel(); + + @SuppressWarnings({ "rawtypes", "unchecked" }) public String getBasicData() - { - Map mapData = model.getShowModel().getMap(); - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(0); - pageUtil.setCurPage(0); - try - { - Map condition = pageUtil.getAdvSearch(); - condition.put("sort_s_order", "asc"); - depotService.find(pageUtil); - mapData.put("depotList", pageUtil.getPageList()); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); - model.getShowModel().setMsgTip("exceptoin"); - } - return SUCCESS; - } - + { + Map mapData = model.getShowModel().getMap(); + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + try + { + Map condition = pageUtil.getAdvSearch(); + condition.put("sort_s_order", "asc"); + depotService.find(pageUtil); + mapData.put("depotList", pageUtil.getPageList()); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); + model.getShowModel().setMsgTip("exceptoin"); + } + return SUCCESS; + } + /** * 增加仓库 * @return */ public void create() { - Log.infoFileSync("==================开始调用增加仓库信息方法create()==================="); - Boolean flag = false; + Log.infoFileSync("==================开始调用增加仓库信息方法create()==================="); + Boolean flag = false; try { Depot depot = new Depot(); depot.setName(model.getName()); + depot.setAddress(model.getAddress()); + depot.setWarehousing(model.getWarehousing()); + depot.setTruckage(model.getTruckage()); depot.setType(model.getType()); depot.setSort(model.getSort()); depot.setRemark(model.getRemark()); depotService.create(depot); - + //========标识位=========== flag = true; //记录操作日志使用 tipMsg = "成功"; - tipType = 0; + tipType = 0; } catch (DataAccessException e) { Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加仓库信息异常", e); flag = false; tipMsg = "失败"; - tipType = 1; + tipType = 1; } finally { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>增加仓库信息回写客户端结果异常", e); - } + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>增加仓库信息回写客户端结果异常", e); + } } - + logService.create(new Logdetails(getUser(), "增加仓库", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "增加仓库名称为 "+ model.getName() + " " + tipMsg + "!", "增加仓库" + tipMsg)); + new Timestamp(System.currentTimeMillis()) + , tipType, "增加仓库名称为 "+ model.getName() + " " + tipMsg + "!", "增加仓库" + tipMsg)); Log.infoFileSync("==================结束调用增加仓库方法create()==================="); } - + /** * 删除仓库 * @return */ public String delete() { - Log.infoFileSync("====================开始调用删除仓库信息方法delete()================"); - try - { - depotService.delete(model.getDepotID()); - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotID() + " 的仓库异常", e); - tipMsg = "失败"; - tipType = 1; - } - model.getShowModel().setMsgTip(tipMsg); - logService.create(new Logdetails(getUser(), "删除仓库", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "删除仓库ID为 "+ model.getDepotID() + " " + tipMsg + "!", "删除仓库" + tipMsg)); - Log.infoFileSync("====================结束调用删除仓库信息方法delete()================"); - return SUCCESS; + Log.infoFileSync("====================开始调用删除仓库信息方法delete()================"); + try + { + depotService.delete(model.getDepotID()); + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotID() + " 的仓库异常", e); + tipMsg = "失败"; + tipType = 1; + } + model.getShowModel().setMsgTip(tipMsg); + logService.create(new Logdetails(getUser(), "删除仓库", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "删除仓库ID为 "+ model.getDepotID() + " " + tipMsg + "!", "删除仓库" + tipMsg)); + Log.infoFileSync("====================结束调用删除仓库信息方法delete()================"); + return SUCCESS; } - + /** * 更新仓库 * @return */ public void update() { - Boolean flag = false; - try - { - Depot depot = depotService.get(model.getDepotID()); - depot.setName(model.getName()); + Boolean flag = false; + try + { + Depot depot = depotService.get(model.getDepotID()); + depot.setName(model.getName()); + depot.setAddress(model.getAddress()); + depot.setWarehousing(model.getWarehousing()); + depot.setTruckage(model.getTruckage()); depot.setType(model.getType()); - depot.setSort(model.getSort()); - depot.setRemark(model.getRemark()); - depotService.update(depot); - - flag = true; - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>修改仓库ID为 : " + model.getDepotID() + "信息失败", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>修改仓库回写客户端结果异常", e); - } - } - logService.create(new Logdetails(getUser(), "更新仓库", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "更新仓库ID为 "+ model.getDepotID() + " " + tipMsg + "!", "更新仓库" + tipMsg)); + depot.setSort(model.getSort()); + depot.setRemark(model.getRemark()); + depotService.update(depot); + + flag = true; + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>修改仓库ID为 : " + model.getDepotID() + "信息失败", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>修改仓库回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "更新仓库", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "更新仓库ID为 "+ model.getDepotID() + " " + tipMsg + "!", "更新仓库" + tipMsg)); } - + /** * 批量删除指定ID仓库 * @return */ public String batchDelete() { - try - { - depotService.batchDelete(model.getDepotIDs()); - model.getShowModel().setMsgTip("成功"); - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>批量删除仓库ID为:" + model.getDepotIDs() + "信息异常", e); - tipMsg = "失败"; - tipType = 1; - } - - logService.create(new Logdetails(getUser(), "批量删除仓库", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "批量删除仓库ID为 "+ model.getDepotIDs() + " " + tipMsg + "!", "批量删除仓库" + tipMsg)); - return SUCCESS; + try + { + depotService.batchDelete(model.getDepotIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量删除仓库ID为:" + model.getDepotIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量删除仓库", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量删除仓库ID为 "+ model.getDepotIDs() + " " + tipMsg + "!", "批量删除仓库" + tipMsg)); + return SUCCESS; } - + /** * 检查输入名称是否存在 */ public void checkIsNameExist() { - Boolean flag = false; - try - { - flag = depotService.checkIsNameExist("name",model.getName(),"id", model.getDepotID()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!"); - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>回写检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!",e); - } - } + Boolean flag = false; + try + { + flag = depotService.checkIsNameExist("name",model.getName(),"id", model.getDepotID()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!"); + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>回写检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!",e); + } + } } - + /** * 查找仓库信息 * @return */ - public void findBy() + public void findBy() { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getCondition()); - depotService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Depot depot:dataList) - { - JSONObject item = new JSONObject(); - item.put("id", depot.getId()); - //供应商名称 - item.put("name", depot.getName()); + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getCondition()); + depotService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Depot depot:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", depot.getId()); + //供应商名称 + item.put("name", depot.getName()); + item.put("address", depot.getAddress()); + item.put("warehousing", depot.getWarehousing()); + item.put("truckage", depot.getTruckage()); item.put("type", depot.getType()); - item.put("sort", depot.getSort()); - item.put("remark", depot.getRemark()); - item.put("op", 1); - dataArray.add(item); - } - } - outer.put("rows", dataArray); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库信息异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库信息结果异常", e); - } + item.put("sort", depot.getSort()); + item.put("remark", depot.getRemark()); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库信息结果异常", e); + } } /** @@ -311,82 +320,132 @@ public class DepotAction extends BaseAction Log.errorFileSync(">>>>>>>>>回写查询仓库信息结果异常", e); } } - + /** * 用户对应仓库显示 * @return */ - public void findUserDepot() + public void findUserDepot() { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(100); - //pageUtil.setCurPage(model.getPageNo()); + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(100); + //pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getCondition_UserDepot()); - depotService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接json数据 - JSONObject outer = new JSONObject(); - outer.put("id", 1); - outer.put("text", "仓库列表"); - outer.put("state", "open"); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Depot depot:dataList) - { - JSONObject item = new JSONObject(); - item.put("id", depot.getId()); - item.put("text", depot.getName()); - //勾选判断1 - Boolean flag = false; - try - { - flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的仓库:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); - } - if (flag==true){item.put("checked", true);} - //结束 - dataArray.add(item); - } - } - outer.put("children", dataArray); - //回写查询结果 - toClient("["+outer.toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库结果异常", e); - } + pageUtil.setAdvSearch(getCondition_UserDepot()); + depotService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接json数据 + JSONObject outer = new JSONObject(); + outer.put("id", 1); + outer.put("text", "仓库列表"); + outer.put("state", "open"); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Depot depot:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", depot.getId()); + item.put("text", depot.getName()); + //勾选判断1 + Boolean flag = false; + try + { + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的仓库:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){item.put("checked", true);} + //结束 + dataArray.add(item); + } + } + outer.put("children", dataArray); + //回写查询结果 + toClient("["+outer.toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库结果异常", e); + } } - + + /** + * 根据用户查找对应仓库列表-仅显示有权限的 + * @return + */ + public void findDepotByUserId(){ + try{ + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + pageUtil.setAdvSearch(getCondition_UserDepot()); + depotService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Depot depot:dataList) + { + JSONObject item = new JSONObject(); + //勾选判断1 + Boolean flag = false; + try + { + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){ + item.put("id", depot.getId()); + item.put("depotName", depot.getName()); + dataArray.add(item); + } + } + } + //回写查询结果 + toClient(dataArray.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库结果异常", e); + } + } + /** * 拼接搜索条件 * @return */ private Map getCondition() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("name_s_like", model.getName()); - condition.put("remark_s_like", model.getRemark()); + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("name_s_like", model.getName()); + condition.put("remark_s_like", model.getRemark()); condition.put("type_n_eq", model.getType()); //0-仓库,1-礼品卡 - condition.put("sort_s_order", "asc"); - return condition; - } + condition.put("sort_s_order", "asc"); + return condition; + } /** * 拼接搜索条件 @@ -402,22 +461,22 @@ public class DepotAction extends BaseAction condition.put("sort_s_order", "asc"); return condition; } - + /** - * 拼接搜索条件-用户对应部门 + * 拼接搜索条件-用户对应仓库 * @return */ private Map getCondition_UserDepot() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); condition.put("type_n_eq", 0); - condition.put("sort_s_order", "asc"); - return condition; - } - + condition.put("sort_s_order", "asc"); + return condition; + } + //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== @Override public DepotModel getModel() @@ -425,12 +484,12 @@ public class DepotAction extends BaseAction return model; } public void setDepotService(DepotIService depotService) - { - this.depotService = depotService; - } + { + this.depotService = depotService; + } public void setUserBusinessService(UserBusinessIService userBusinessService) { this.userBusinessService = userBusinessService; } - + } diff --git a/src/main/java/com/jsh/action/basic/FunctionsAction.java b/src/main/java/com/jsh/action/basic/FunctionsAction.java index 1d2ee60c..1cdbedce 100644 --- a/src/main/java/com/jsh/action/basic/FunctionsAction.java +++ b/src/main/java/com/jsh/action/basic/FunctionsAction.java @@ -47,7 +47,7 @@ public class FunctionsAction extends BaseAction functions.setSort(model.getSort()); functions.setEnabled(model.getEnabled()); functions.setType(model.getType()); - + functions.setPushBtn(model.getPushBtn()); functionsService.create(functions); //========标识位=========== @@ -126,6 +126,7 @@ public class FunctionsAction extends BaseAction functions.setSort(model.getSort()); functions.setEnabled(model.getEnabled()); functions.setType(model.getType()); + functions.setPushBtn(model.getPushBtn()); functionsService.update(functions); flag = true; @@ -246,6 +247,7 @@ public class FunctionsAction extends BaseAction item.put("Sort", functions.getSort()); item.put("Enabled", functions.getEnabled()); item.put("Type", functions.getType()); + item.put("PushBtn", functions.getPushBtn()); item.put("op", 1); dataArray.add(item); } @@ -263,6 +265,49 @@ public class FunctionsAction extends BaseAction Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询功能信息结果异常", e); } } + + /** + * 根据id列表查找功能信息 + * @return + */ + public void findByIds() + { + try { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + pageUtil.setAdvSearch(getConditionByIds()); + functionsService.find(pageUtil); + List dataList = pageUtil.getPageList(); + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Functions functions:dataList) + { + JSONObject item = new JSONObject(); + item.put("Id", functions.getId()); + item.put("Name", functions.getName()); + item.put("PushBtn", functions.getPushBtn()); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找功能信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询功能信息结果异常", e); + } + } /** @@ -497,7 +542,7 @@ public class FunctionsAction extends BaseAction else { //不是目录,有链接 - item2.put("text", ""+functions2.getName()+""); + item2.put("text", ""+functions2.getName()+""); } dataArray2.add(item2); @@ -508,7 +553,7 @@ public class FunctionsAction extends BaseAction else { //不是目录,有链接 - item1.put("text", ""+functions1.getName()+""); + item1.put("text", ""+functions1.getName()+""); } dataArray1.add(item1); @@ -519,7 +564,7 @@ public class FunctionsAction extends BaseAction else { //不是目录,有链接 - item.put("text", ""+functions.getName()+""); + item.put("text", ""+functions.getName()+""); } dataArray.add(item); @@ -569,6 +614,18 @@ public class FunctionsAction extends BaseAction condition.put("Sort_s_order", "asc"); return condition; } + + /** + * 拼接搜索条件-角色对应功能 + * @return + */ + private Map getConditionByIds() { + Map condition = new HashMap(); + condition.put("Enabled_n_eq", 1); + condition.put("Id_s_in", model.getFunctionsIDs()); + condition.put("Sort_s_order", "asc"); + return condition; + } //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== @Override diff --git a/src/main/java/com/jsh/action/basic/SupplierAction.java b/src/main/java/com/jsh/action/basic/SupplierAction.java index e95e8b9d..429711e2 100644 --- a/src/main/java/com/jsh/action/basic/SupplierAction.java +++ b/src/main/java/com/jsh/action/basic/SupplierAction.java @@ -1,34 +1,40 @@ package com.jsh.action.basic; -import java.io.IOException; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import org.springframework.dao.DataAccessException; - import com.jsh.base.BaseAction; import com.jsh.base.Log; import com.jsh.model.po.Logdetails; import com.jsh.model.po.Supplier; import com.jsh.model.vo.basic.SupplierModel; import com.jsh.service.basic.SupplierIService; +import com.jsh.service.basic.UserBusinessIService; import com.jsh.util.JshException; import com.jsh.util.PageUtil; +import com.jsh.util.SupplierConstants; +import com.jsh.util.Tools; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.springframework.dao.DataAccessException; + +import java.io.IOException; +import java.io.InputStream; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /* * 单位管理 - * @author jishenghua qq:752718920 + * @author ji-sheng-hua qq:7 5 2 7 1 8 9 2 0 */ @SuppressWarnings("serial") public class SupplierAction extends BaseAction { private SupplierIService supplierService; + private UserBusinessIService userBusinessService; private SupplierModel model = new SupplierModel(); private final static Integer ISYSTEM = 1; + public static final String EXCEL = "excel"; //action返回excel结果 /** * 增加供应商 * @return @@ -48,9 +54,18 @@ public class SupplierAction extends BaseAction supplier.setBeginNeedGet(model.getBeginNeedGet()); supplier.setBeginNeedPay(model.getBeginNeedPay()); supplier.setIsystem((short)1); + supplier.setEnabled(true); supplier.setPhonenum(model.getPhonenum()); supplier.setSupplier(model.getSupplier()); - supplier.setEnabled(model.getEnabled()); + + supplier.setFax(model.getFax()); + supplier.setTelephone(model.getTelephone()); + supplier.setAddress(model.getAddress()); + supplier.setTaxNum(model.getTaxNum()); + supplier.setBankName(model.getBankName()); + supplier.setAccountNumber(model.getAccountNumber()); + supplier.setTaxRate(model.getTaxRate()); + supplierService.create(supplier); //========标识位=========== @@ -131,7 +146,16 @@ public class SupplierAction extends BaseAction supplier.setIsystem((short)1); supplier.setPhonenum(model.getPhonenum()); supplier.setSupplier(model.getSupplier()); - supplier.setEnabled(model.getEnabled()); + + supplier.setFax(model.getFax()); + supplier.setTelephone(model.getTelephone()); + supplier.setAddress(model.getAddress()); + supplier.setTaxNum(model.getTaxNum()); + supplier.setBankName(model.getBankName()); + supplier.setAccountNumber(model.getAccountNumber()); + supplier.setTaxRate(model.getTaxRate()); + + supplier.setEnabled(supplier.getEnabled()); supplierService.update(supplier); flag = true; @@ -181,6 +205,15 @@ public class SupplierAction extends BaseAction supplier.setIsystem((short)1); supplier.setPhonenum(supplier.getPhonenum()); supplier.setSupplier(supplier.getSupplier()); + + supplier.setFax(supplier.getFax()); + supplier.setTelephone(supplier.getTelephone()); + supplier.setAddress(supplier.getAddress()); + supplier.setTaxNum(supplier.getTaxNum()); + supplier.setBankName(supplier.getBankName()); + supplier.setAccountNumber(supplier.getAccountNumber()); + supplier.setTaxRate(supplier.getTaxRate()); + supplier.setEnabled(supplier.getEnabled()); supplierService.update(supplier); @@ -237,6 +270,33 @@ public class SupplierAction extends BaseAction , tipType, "批量删除供应商ID为 "+ model.getSupplierIDs() + " " + tipMsg + "!", "批量删除供应商" + tipMsg)); return SUCCESS; } + + /** + * 批量设置状态-启用或者禁用 + * @return + */ + public String batchSetEnable() + { + try + { + supplierService.batchSetEnable(model.getEnabled(),model.getSupplierIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量修改状态,单位ID为:" + model.getSupplierIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量修改单位状态", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量修改状态,单位ID为 "+ model.getSupplierIDs() + " " + tipMsg + "!", "批量修改单位状态" + tipMsg)); + return SUCCESS; + } /** * 检查输入名称是否存在 @@ -278,6 +338,17 @@ public class SupplierAction extends BaseAction pageUtil.setCurPage(model.getPageNo()); pageUtil.setAdvSearch(getCondition()); supplierService.find(pageUtil); + String sName = ""; + if((model.getType()).equals("供应商")){ + sName = "pageUtilVendor"; + } + else if((model.getType()).equals("客户")){ + sName = "pageUtilCustomer"; + } + else if((model.getType()).equals("会员")){ + sName = "pageUtilMember"; + } + getSession().put(sName, pageUtil); List dataList = pageUtil.getPageList(); JSONObject outer = new JSONObject(); @@ -301,6 +372,15 @@ public class SupplierAction extends BaseAction item.put("BeginNeedPay",supplier.getBeginNeedPay()); item.put("isystem", supplier.getIsystem() == (short)0?"是":"否"); item.put("description", supplier.getDescription()); + + item.put("fax", supplier.getFax()); + item.put("telephone", supplier.getTelephone()); + item.put("address", supplier.getAddress()); + item.put("taxNum", supplier.getTaxNum()); + item.put("bankName", supplier.getBankName()); + item.put("accountNumber", supplier.getAccountNumber()); + item.put("taxRate", supplier.getTaxRate()); + item.put("enabled", supplier.getEnabled()); item.put("op", supplier.getIsystem()); dataArray.add(item); @@ -319,6 +399,65 @@ public class SupplierAction extends BaseAction Log.errorFileSync(">>>>>>>>>回写查询供应商信息结果异常", e); } } + + /** + * 根据id查找信息 + * @return + */ + public void findById() { + try { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + pageUtil.setAdvSearch(getConditionById()); + supplierService.find(pageUtil); + List dataList = pageUtil.getPageList(); + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Supplier supplier:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", supplier.getId()); + //名称 + item.put("supplier", supplier.getSupplier()); + item.put("type", supplier.getType()); + item.put("contacts",supplier.getContacts()); + item.put("phonenum", supplier.getPhonenum()); + item.put("email", supplier.getEmail()); + item.put("AdvanceIn",supplier.getAdvanceIn()); + item.put("BeginNeedGet",supplier.getBeginNeedGet()); + item.put("BeginNeedPay",supplier.getBeginNeedPay()); + item.put("isystem", supplier.getIsystem() == (short)0?"是":"否"); + item.put("description", supplier.getDescription()); + + item.put("fax", supplier.getFax()); + item.put("telephone", supplier.getTelephone()); + item.put("address", supplier.getAddress()); + item.put("taxNum", supplier.getTaxNum()); + item.put("bankName", supplier.getBankName()); + item.put("accountNumber", supplier.getAccountNumber()); + item.put("taxRate", supplier.getTaxRate()); + + item.put("enabled", supplier.getEnabled()); + item.put("op", supplier.getIsystem()); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>查找信息异常", e); + } + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e); + } + } /** * 查找供应商信息-下拉框 @@ -363,10 +502,8 @@ public class SupplierAction extends BaseAction * 查找客户信息-下拉框 * @return */ - public void findBySelect_cus() - { - try - { + public void findBySelect_cus() { + try { PageUtil pageUtil = new PageUtil(); pageUtil.setPageSize(0); pageUtil.setCurPage(0); @@ -375,32 +512,37 @@ public class SupplierAction extends BaseAction List dataList = pageUtil.getPageList(); //存放数据json数组 JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Supplier supplier:dataList) - { + if(null != dataList) { + for(Supplier supplier:dataList) { JSONObject item = new JSONObject(); - item.put("id", supplier.getId()); - //客户名称 - item.put("supplier", supplier.getSupplier()); - dataArray.add(item); + //勾选判断1 + Boolean flag = false; + try{ + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+supplier.getId().toString()+"]"); + } + catch (DataAccessException e){ + Log.errorFileSync(">>>>>>>>>>>>>>>>>查询用户对应的客户:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){ + item.put("id", supplier.getId()); + item.put("supplier", supplier.getSupplier()); //客户名称 + dataArray.add(item); + } } } //回写查询结果 toClient(dataArray.toString()); } - catch (DataAccessException e) - { + catch (DataAccessException e) { Log.errorFileSync(">>>>>>>>>查找客户信息异常", e); } - catch (IOException e) - { + catch (IOException e) { Log.errorFileSync(">>>>>>>>>回写查询客户信息结果异常", e); } } /** - * 查找散户信息-下拉框 + * 查找会员信息-下拉框 * @return */ public void findBySelect_retail() @@ -479,27 +621,176 @@ public class SupplierAction extends BaseAction Log.errorFileSync(">>>>>>>>>回写查询客户信息结果异常", e); } } + + /** + * 用户对应客户显示 + * @return + */ + public void findUserCustomer() { + try { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(500); + + Map condition = new HashMap(); + condition.put("type_s_eq", "客户"); + condition.put("id_s_order", "desc"); + + pageUtil.setAdvSearch(condition); + supplierService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接json数据 + JSONObject outer = new JSONObject(); + outer.put("id", 1); + outer.put("text", "客户列表"); + outer.put("state", "open"); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList){ + for(Supplier supplier:dataList){ + JSONObject item = new JSONObject(); + item.put("id", supplier.getId()); + item.put("text", supplier.getSupplier()); + //勾选判断1 + Boolean flag = false; + try{ + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+supplier.getId().toString()+"]"); + } + catch (DataAccessException e){ + Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的客户:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){item.put("checked", true);} + //结束 + dataArray.add(item); + } + } + outer.put("children", dataArray); + //回写查询结果 + toClient("["+outer.toString()+"]"); + } + catch (DataAccessException e){ + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找客户异常", e); + } + catch (IOException e){ + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询客户结果异常", e); + } + } + + public String importFun(){ + //excel表格file + Boolean result = false; + String returnStr = ""; + try { + InputStream in = supplierService.importExcel(model.getSupplierFile()); + + if(null != in) + { + model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls"); + model.setExcelStream(in); + returnStr = SupplierConstants.BusinessForExcel.EXCEL; + } + else { + result = true; + try { + toClient(result.toString()); + } catch (IOException e) { + Log.errorFileSync(">>>>>>>>>回写导入信息结果异常", e); + } + //导入数据成功 + returnStr = SUCCESS; + } + + } + catch (JshException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>导入excel表格信息异常", e); + } + return returnStr; + } + + /** + * 导入excel表格-供应商 + * @return + */ + @SuppressWarnings("unchecked") + public String importExcelVendor() { + return importFun(); + } + + /** + * 导入excel表格-客户 + * @return + */ + @SuppressWarnings("unchecked") + public String importExcelCustomer() { + return importFun(); + } + + /** + * 导入excel表格-会员 + * @return + */ + @SuppressWarnings("unchecked") + public String importExcelMember() { + return importFun(); + } + + + /** + * 导出excel表格 + * @return + */ + @SuppressWarnings("unchecked") + public String exportExcel() { + Log.infoFileSync("===================调用导出信息action方法exportExcel开始======================="); + try { + String sName = "pageUtil" + model.getType(); + PageUtil pageUtil = (PageUtil)getSession().get(sName); + + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + String isCurrentPage = "allPage"; + model.setFileName(Tools.changeUnicode("report" + System.currentTimeMillis() + ".xls",model.getBrowserType())); + model.setExcelStream(supplierService.exmportExcel(isCurrentPage,pageUtil)); + } + catch (Exception e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常",e); + model.getShowModel().setMsgTip("export excel exception"); + } + Log.infoFileSync("===================调用导出信息action方法exportExcel结束=================="); + return EXCEL; + } /** * 拼接搜索条件 * @return */ - private Map getCondition() - { + private Map getCondition() { /** * 拼接搜索条件 */ Map condition = new HashMap(); condition.put("supplier_s_like", model.getSupplier()); condition.put("type_s_like", model.getType()); - condition.put("contacts_s_like", model.getContacts()); - condition.put("phonenum_s_like", model.getPhonenum()); - condition.put("email_s_like", model.getEmail()); + condition.put("phonenum_s_like",model.getPhonenum()); + condition.put("telephone_s_like", model.getTelephone()); condition.put("description_s_like", model.getDescription()); condition.put("isystem_n_eq", ISYSTEM); condition.put("id_s_order", "desc"); return condition; } + + /** + *搜索条件 + */ + private Map getConditionById() { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("Id_n_eq", model.getSupplierID()); + return condition; + } /** * 拼接搜索条件-下拉框-供应商 @@ -512,6 +803,7 @@ public class SupplierAction extends BaseAction */ Map condition = new HashMap(); condition.put("type_s_like", "供应商"); + condition.put("enabled_s_eq",1); condition.put("id_s_order", "desc"); return condition; } @@ -527,12 +819,13 @@ public class SupplierAction extends BaseAction */ Map condition = new HashMap(); condition.put("type_s_like", "客户"); + condition.put("enabled_s_eq",1); condition.put("id_s_order", "desc"); return condition; } /** - * 拼接搜索条件-下拉框-散户 + * 拼接搜索条件-下拉框-会员 * @return */ private Map getCondition_Select_retail() @@ -541,7 +834,8 @@ public class SupplierAction extends BaseAction * 拼接搜索条件 */ Map condition = new HashMap(); - condition.put("type_s_like", "散户"); + condition.put("type_s_like", "会员"); + condition.put("enabled_s_eq",1); condition.put("id_s_order", "desc"); return condition; } @@ -556,7 +850,7 @@ public class SupplierAction extends BaseAction * 拼接搜索条件 */ Map condition = new HashMap(); - condition.put("type_s_like", "散户"); + condition.put("type_s_like", "会员"); condition.put("isystem_n_eq", 0); condition.put("id_s_order", "desc"); return condition; @@ -572,4 +866,8 @@ public class SupplierAction extends BaseAction { this.supplierService = supplierService; } + + public void setUserBusinessService(UserBusinessIService userBusinessService) { + this.userBusinessService = userBusinessService; + } } diff --git a/src/main/java/com/jsh/action/basic/UnitAction.java b/src/main/java/com/jsh/action/basic/UnitAction.java new file mode 100644 index 00000000..2c29832a --- /dev/null +++ b/src/main/java/com/jsh/action/basic/UnitAction.java @@ -0,0 +1,295 @@ +package com.jsh.action.basic; + +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.model.po.Unit; +import com.jsh.model.po.Logdetails; +import com.jsh.model.vo.basic.UnitModel; +import com.jsh.service.basic.UnitIService; +import com.jsh.util.PageUtil; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.springframework.dao.DataAccessException; + +import java.io.IOException; +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 计量单位 + * @author ji shenghua qq:752 718 920 + */ +@SuppressWarnings("serial") +public class UnitAction extends BaseAction +{ + private UnitIService unitService; + private UnitModel model = new UnitModel(); + + + /** + * 增加计量单位 + * @return + */ + public void create() + { + Log.infoFileSync("==================开始调用增加计量单位方法create()==================="); + Boolean flag = false; + try + { + Unit unit = new Unit(); + unit.setUName(model.getUName()); + unitService.create(unit); + + //========标识位=========== + flag = true; + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加计量单位异常", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>增加计量单位回写客户端结果异常", e); + } + } + + logService.create(new Logdetails(getUser(), "增加计量单位", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "增加计量单位名称为 "+ model.getUName() + " " + tipMsg + "!", "增加计量单位" + tipMsg)); + Log.infoFileSync("==================结束调用增加计量单位方法create()==================="); + } + + /** + * 删除计量单位 + * @return + */ + public String delete() { + Log.infoFileSync("====================开始调用删除计量单位方法delete()================"); + try { + unitService.delete(model.getUnitID()); + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getUnitID() + " 的计量单位异常", e); + tipMsg = "失败"; + tipType = 1; + } + model.getShowModel().setMsgTip(tipMsg); + logService.create(new Logdetails(getUser(), "删除计量单位", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "删除计量单位ID为 "+ model.getUnitID() + " " + tipMsg + "!", "删除计量单位" + tipMsg)); + Log.infoFileSync("====================结束调用删除计量单位方法delete()================"); + return SUCCESS; + } + + /** + * 更新计量单位 + * @return + */ + public void update() { + Boolean flag = false; + try { + Unit unit = unitService.get(model.getUnitID()); + unit.setUName(model.getUName()); + unitService.update(unit); + + flag = true; + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>>>修改计量单位ID为 : " + model.getUnitID() + "信息失败", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally { + try { + toClient(flag.toString()); + } + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>>>>修改计量单位回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "更新计量单位", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "更新计量单位ID为 "+ model.getUnitID() + " " + tipMsg + "!", "更新计量单位" + tipMsg)); + } + + /** + * 批量删除指定ID计量单位 + * @return + */ + public String batchDelete() + { + try + { + unitService.batchDelete(model.getUnitIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量删除计量单位ID为:" + model.getUnitIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量删除计量单位", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量删除计量单位ID为 "+ model.getUnitIDs() + " " + tipMsg + "!", "批量删除计量单位" + tipMsg)); + return SUCCESS; + } + + /** + * 检查输入名称是否存在 + */ + public void checkIsNameExist() + { + Boolean flag = false; + try + { + flag = unitService.checkIsNameExist("UName",model.getUName(),"id", model.getUnitID()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>检查计量单位名称为:" + model.getUName() + " ID为: " + model.getUnitID() + " 是否存在异常!"); + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>回写检查计量单位名称为:" + model.getUName() + " ID为: " + model.getUnitID() + " 是否存在异常!",e); + } + } + } + + /** + * 查找计量单位信息 + * @return + */ + public void findBy() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getCondition()); + unitService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Unit unit:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", unit.getId()); + //名称 + item.put("UName", unit.getUName()); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找计量单位异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询计量单位结果异常", e); + } + } + + /** + * 查找计量单位信息-下拉框 + * @return + */ + public void findUnitDownList() { + try { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + pageUtil.setAdvSearch(getCondition()); + unitService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) { + for(Unit unit:dataList) { + JSONObject item = new JSONObject(); + item.put("id", unit.getId()); + //名称 + item.put("UName", unit.getUName()); + dataArray.add(item); + } + } + //回写查询结果 + toClient(dataArray.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找计量单位异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询计量单位结果异常", e); + } + } + + /** + * 拼接搜索条件 + * @return + */ + private Map getCondition() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("UName_s_like", model.getUName()); + condition.put("id_s_order", "asc"); + return condition; + } + + //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== + @Override + public UnitModel getModel() + { + return model; + } + + public void setUnitService(UnitIService unitService) { + this.unitService = unitService; + } +} diff --git a/src/main/java/com/jsh/action/basic/UserAction.java b/src/main/java/com/jsh/action/basic/UserAction.java index 3c51c16a..068efa0d 100644 --- a/src/main/java/com/jsh/action/basic/UserAction.java +++ b/src/main/java/com/jsh/action/basic/UserAction.java @@ -325,7 +325,40 @@ public class UserAction extends BaseAction new Timestamp(System.currentTimeMillis()) , tipType, "更新用户ID为 "+ model.getUserID() + "密码信息 " + tipMsg + "!", "更新用户" + tipMsg)); } - + + /** + * 重置用户的密码 + */ + public void resetPwd() { + Integer flag = 0; + try { + Basicuser user = userService.get(model.getUserID()); + String password = "123456"; + String md5Pwd = Tools.md5Encryp(password); + user.setPassword(md5Pwd); + userService.update(user); + flag = 1; + tipMsg = "成功"; + tipType = 0; + } + catch (Exception e) { + Log.errorFileSync(">>>>>>>>>>>>>修改用户ID为 : " + model.getUserID() + "密码信息失败", e); + flag = 0; + tipMsg = "失败"; + tipType = 1; + } + finally { + try { + toClient(flag.toString()); + } + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>>>>修改用户密码回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "重置用户密码", model.getClientIp(), + new Timestamp(System.currentTimeMillis()), tipType, "重置用户ID为 "+ model.getUserID() + "密码信息 " + tipMsg + "!", "重置用户密码" + tipMsg)); + } + /** * 批量删除指定ID用户 * @return diff --git a/src/main/java/com/jsh/action/basic/UserBusinessAction.java b/src/main/java/com/jsh/action/basic/UserBusinessAction.java index 63d68ae0..90efa725 100644 --- a/src/main/java/com/jsh/action/basic/UserBusinessAction.java +++ b/src/main/java/com/jsh/action/basic/UserBusinessAction.java @@ -5,6 +5,8 @@ import java.sql.Timestamp; import java.util.HashMap; import java.util.List; import java.util.Map; + +import com.jsh.model.po.Functions; import org.springframework.dao.DataAccessException; import com.jsh.base.BaseAction; import com.jsh.base.Log; @@ -173,6 +175,42 @@ public class UserBusinessAction extends BaseAction new Timestamp(System.currentTimeMillis()) , tipType, "更新UserBusiness的ID为 "+ id + " " + tipMsg + "!", "更新UserBusiness" + tipMsg)); } + + /** + * 更新角色的按钮权限 + * @return + */ + public void updateBtnStr() { + Boolean flag = false; + try { + UserBusiness userBusiness = userBusinessService.get(model.getUserBusinessID()); + userBusiness.setType(userBusiness.getType()); + userBusiness.setKeyId(userBusiness.getKeyId()); + userBusiness.setValue(userBusiness.getValue()); + userBusiness.setBtnStr(model.getBtnStr()); + userBusinessService.update(userBusiness); + flag = true; + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>>>修改角色按钮权限的ID为 : " + model.getUserBusinessID() + "信息失败", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally { + try { + toClient(flag.toString()); + } + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>>>>修改功能回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "更新角色按钮权限", model.getClientIp(), + new Timestamp(System.currentTimeMillis()), tipType, + "角色按钮权限的ID为 "+ model.getUserBusinessID() + " " + tipMsg + "!", "更新角色按钮权限" + tipMsg)); + } /** * 拼接搜索条件-RoleAPP diff --git a/src/main/java/com/jsh/action/materials/DepotHeadAction.java b/src/main/java/com/jsh/action/materials/DepotHeadAction.java index 02942fd3..e0bc8662 100644 --- a/src/main/java/com/jsh/action/materials/DepotHeadAction.java +++ b/src/main/java/com/jsh/action/materials/DepotHeadAction.java @@ -62,37 +62,62 @@ public class DepotHeadAction extends BaseAction } /** - * 增加仓管通 + * 增加单据 * @return */ - public void create() - { - Log.infoFileSync("==================开始调用增加仓管通信息信息方法create()==================="); + public void create(){ + Log.infoFileSync("==================开始调用增加单据信息信息方法create()==================="); Boolean flag = false; try { DepotHead depotHead = new DepotHead(); depotHead.setType(model.getType()); depotHead.setSubType(model.getSubType()); - depotHead.setProjectId(new Depot(model.getProjectId())); - depotHead.setNumber(model.getNumber()); + if(model.getProjectId()!=null){depotHead.setProjectId(new Depot(model.getProjectId()));} + //构造新的编号 + String number = model.getNumber(); + String allNewNumber = ""; + if(number.equals(model.getDefaultNumber())){ //两个编号一致说明没有修改过 + number = number.substring(0,12); //截取前缀 + String beginTime = Tools.getNow() + " 00:00:00"; + String endTime = Tools.getNow() + " 23:59:59"; + String newNumber = buildNumberFun(model.getType(), model.getSubType(), beginTime, endTime); //从数据库查询最新的编号+1,这样能防止重复 + allNewNumber = number + newNumber; + depotHead.setNumber(allNewNumber); + } + else { //修改过的编号 + depotHead.setNumber(model.getNumber()); + } + depotHead.setDefaultNumber(allNewNumber); //初始编号,一直都从后台取值 + depotHead.setOperPersonName(getUser().getUsername()); depotHead.setCreateTime(new Timestamp(new Date().getTime())); - try - { - depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd").getTime())); + try{ + depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd HH:mm:ss").getTime())); } - catch (ParseException e) - { + catch (ParseException e){ Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e); } if(model.getOrganId()!=null){depotHead.setOrganId(new Supplier(model.getOrganId()));} - if(model.getHandsPersonId()!=null){depotHead.setHandsPersonId(new Person(model.getHandsPersonId()));} + if(model.getHandsPersonId()!=null){depotHead.setHandsPersonId(new Person(model.getHandsPersonId()));} + if(model.getSalesman()!=null){ + depotHead.setSalesman(model.getSalesman().toString()); + } if(model.getAccountId()!=null){depotHead.setAccountId(new Account(model.getAccountId()));} depotHead.setChangeAmount(model.getChangeAmount()); + depotHead.setAccountIdList(model.getAccountIdList()); + depotHead.setAccountMoneyList(model.getAccountMoneyList()); + depotHead.setDiscount(model.getDiscount()); + depotHead.setDiscountMoney(model.getDiscountMoney()); + depotHead.setDiscountLastMoney(model.getDiscountLastMoney()); + depotHead.setOtherMoney(model.getOtherMoney()); + depotHead.setOtherMoneyList(model.getOtherMoneyList()); + depotHead.setOtherMoneyItem(model.getOtherMoneyItem()); + depotHead.setAccountDay(model.getAccountDay()); if(model.getAllocationProjectId()!=null){depotHead.setAllocationProjectId(new Depot(model.getAllocationProjectId()));} depotHead.setTotalPrice(model.getTotalPrice()); depotHead.setPayType(model.getPayType()); + depotHead.setStatus(false); depotHead.setRemark(model.getRemark()); depotHeadService.create(depotHead); @@ -102,88 +127,88 @@ public class DepotHeadAction extends BaseAction tipMsg = "成功"; tipType = 0; } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加仓管通信息异常", e); + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加单据信息异常", e); flag = false; tipMsg = "失败"; tipType = 1; } - finally - { - try - { + finally { + try { toClient(flag.toString()); } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>增加仓管通信息回写客户端结果异常", e); + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>>>>增加单据信息回写客户端结果异常", e); } } - logService.create(new Logdetails(getUser(), "增加仓管通", model.getClientIp(), + logService.create(new Logdetails(getUser(), "增加单据", model.getClientIp(), new Timestamp(System.currentTimeMillis()) - , tipType, "增加仓管通编号为 "+ model.getNumber() + " " + tipMsg + "!", "增加仓管通" + tipMsg)); - Log.infoFileSync("==================结束调用增加仓管通方法create()==================="); + , tipType, "增加单据编号为 "+ model.getNumber() + " " + tipMsg + "!", "增加单据" + tipMsg)); + Log.infoFileSync("==================结束调用增加单据方法create()==================="); } /** - * 删除仓管通 + * 删除单据 * @return */ - public String delete() - { - Log.infoFileSync("====================开始调用删除仓管通信息方法delete()================"); - try - { + public String delete() { + Log.infoFileSync("====================开始调用删除单据信息方法delete()================"); + try { depotHeadService.delete(model.getDepotHeadID()); tipMsg = "成功"; tipType = 0; } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotHeadID() + " 的仓管通异常", e); + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotHeadID() + " 的单据异常", e); tipMsg = "失败"; tipType = 1; } model.getShowModel().setMsgTip(tipMsg); - logService.create(new Logdetails(getUser(), "删除仓管通", model.getClientIp(), + logService.create(new Logdetails(getUser(), "删除单据", model.getClientIp(), new Timestamp(System.currentTimeMillis()) - , tipType, "删除仓管通ID为 "+ model.getDepotHeadID() + " " + tipMsg + "!", "删除仓管通" + tipMsg)); - Log.infoFileSync("====================结束调用删除仓管通信息方法delete()================"); + , tipType, "删除单据ID为 "+ model.getDepotHeadID() + " " + tipMsg + "!", "删除单据" + tipMsg)); + Log.infoFileSync("====================结束调用删除单据信息方法delete()================"); return SUCCESS; } /** - * 更新仓管通 + * 更新单据 * @return */ - public void update() - { + public void update() { Boolean flag = false; - try - { + try { DepotHead depotHead = depotHeadService.get(model.getDepotHeadID()); depotHead.setType(model.getType()); depotHead.setSubType(model.getSubType()); - depotHead.setProjectId(new Depot(model.getProjectId())); + if(model.getProjectId()!=null){depotHead.setProjectId(new Depot(model.getProjectId()));} depotHead.setNumber(model.getNumber()); depotHead.setOperPersonName(getUser().getUsername()); - try - { - depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd").getTime())); + try{ + depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd HH:mm:ss").getTime())); } - catch (ParseException e) - { + catch (ParseException e) { Log.errorFileSync(">>>>>>>>>>>>>>>解析入库时间格式异常", e); } if(model.getOrganId()!=null){depotHead.setOrganId(new Supplier(model.getOrganId()));} if(model.getHandsPersonId()!=null){depotHead.setHandsPersonId(new Person(model.getHandsPersonId()));} + depotHead.setSalesman(model.getSalesman()); if(model.getAccountId()!=null){depotHead.setAccountId(new Account(model.getAccountId()));} depotHead.setChangeAmount(model.getChangeAmount()); + depotHead.setAccountIdList(model.getAccountIdList()); + depotHead.setAccountMoneyList(model.getAccountMoneyList()); + depotHead.setDiscount(model.getDiscount()); + depotHead.setDiscountMoney(model.getDiscountMoney()); + depotHead.setDiscountLastMoney(model.getDiscountLastMoney()); + depotHead.setOtherMoney(model.getOtherMoney()); + depotHead.setOtherMoneyList(model.getOtherMoneyList()); + depotHead.setOtherMoneyItem(model.getOtherMoneyItem()); + depotHead.setAccountDay(model.getAccountDay()); if(model.getAllocationProjectId()!=null){depotHead.setAllocationProjectId(new Depot(model.getAllocationProjectId()));} depotHead.setTotalPrice(model.getTotalPrice()); depotHead.setPayType(model.getPayType()); + depotHead.setStatus(false); depotHead.setRemark(model.getRemark()); depotHeadService.update(depotHead); @@ -191,31 +216,27 @@ public class DepotHeadAction extends BaseAction tipMsg = "成功"; tipType = 0; } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>修改仓管通ID为 : " + model.getDepotHeadID() + "信息失败", e); + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>>>修改单据ID为 : " + model.getDepotHeadID() + "信息失败", e); flag = false; tipMsg = "失败"; tipType = 1; } - finally - { - try - { + finally { + try { toClient(flag.toString()); } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>修改仓管通回写客户端结果异常", e); + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>>>>修改单据回写客户端结果异常", e); } } - logService.create(new Logdetails(getUser(), "更新仓管通", model.getClientIp(), + logService.create(new Logdetails(getUser(), "更新单据", model.getClientIp(), new Timestamp(System.currentTimeMillis()) - , tipType, "更新仓管通ID为 "+ model.getDepotHeadID() + " " + tipMsg + "!", "更新仓管通" + tipMsg)); + , tipType, "更新单据ID为 "+ model.getDepotHeadID() + " " + tipMsg + "!", "更新单据" + tipMsg)); } /** - * 批量删除指定ID仓管通 + * 批量删除指定ID单据 * @return */ public String batchDelete() @@ -230,19 +251,130 @@ public class DepotHeadAction extends BaseAction } catch (DataAccessException e) { - Log.errorFileSync(">>>>>>>>>>>批量删除仓管通ID为:" + model.getDepotHeadIDs() + "信息异常", e); + Log.errorFileSync(">>>>>>>>>>>批量删除单据ID为:" + model.getDepotHeadIDs() + "信息异常", e); tipMsg = "失败"; tipType = 1; } - logService.create(new Logdetails(getUser(), "批量删除仓管通", model.getClientIp(), + logService.create(new Logdetails(getUser(), "批量删除单据", model.getClientIp(), new Timestamp(System.currentTimeMillis()) - , tipType, "批量删除仓管通ID为 "+ model.getDepotHeadIDs() + " " + tipMsg + "!", "批量删除仓管通" + tipMsg)); + , tipType, "批量删除单据ID为 "+ model.getDepotHeadIDs() + " " + tipMsg + "!", "批量删除单据" + tipMsg)); return SUCCESS; } - + /** - * 查找仓管通信息 + * 批量设置状态-审核或者反审核 + * @return + */ + public String batchSetStatus() { + try { + depotHeadService.batchSetStatus(model.getStatus(), model.getDepotHeadIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>批量修改状态,单据ID为:" + model.getDepotHeadIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量修改单据状态", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量修改状态,单据ID为 "+ model.getDepotHeadIDs() + " " + tipMsg + "!", "批量修改单据状态" + tipMsg)); + return SUCCESS; + } + + /** + * 检查单据编号是否存在 + */ + public void checkIsNumberExist() { + Boolean flag = false; + try { + flag = depotHeadService.checkIsNameExist("Number", model.getNumber(), "Id", model.getDepotHeadID()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>检查单据编号为:" + model.getNumber() + " ID为: " + model.getDepotHeadID() + " 是否存在出现异常!"); + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>回写检查单据编号为:" + model.getNumber() + " ID为: " + model.getDepotHeadID() + " 是否存在出现异常!",e); + } + } + } + + /** + * 单据编号生成接口,规则:查找当前类型单据下的当天最大的单据号,并加1 + */ + public void buildNumber(){ + try { + String beginTime = model.getBeginTime(); + String endTime = model.getEndTime(); + String newNumber = buildNumberFun(model.getType(), model.getSubType(), beginTime, endTime); + JSONObject outer = new JSONObject(); + outer.put("DefaultNumber", newNumber); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e); + } + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写单据编号生成接口异常", e); + } + } + + /** + * 查找单据编号 + * @return + */ + public String buildNumberFun(String type,String subType,String beginTime,String endTime){ + String newNumber = "0001"; //新编号 + try { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + pageUtil.setAdvSearch(buildNumberCondition(type, subType, beginTime, endTime)); + depotHeadService.find(pageUtil); + List dataList = pageUtil.getPageList(); + //存放数据json数组 + if (null != dataList && dataList.size() > 0) { + DepotHead depotHead = dataList.get(0); + if (depotHead != null) { + String number = depotHead.getDefaultNumber(); //最大的单据编号 + if (number != null) { + Integer lastNumber = Integer.parseInt(number.substring(12, 16)); //末四尾 + lastNumber = lastNumber + 1; + Integer nLen = lastNumber.toString().length(); + if (nLen == 1) { + newNumber = "000" + lastNumber.toString(); + } else if (nLen == 2) { + newNumber = "00" + lastNumber.toString(); + } else if (nLen == 3) { + newNumber = "0" + lastNumber.toString(); + } else if (nLen == 4) { + newNumber = lastNumber.toString(); + } + } + } + } + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e); + } + return newNumber; + } + + /** + * 查找单据信息 * @return */ public void findBy() @@ -270,19 +402,30 @@ public class DepotHeadAction extends BaseAction item.put("ProjectName", depotHead.getProjectId()==null?"":depotHead.getProjectId().getName()); item.put("Number", depotHead.getNumber()); item.put("OperPersonName", depotHead.getOperPersonName()); - item.put("CreateTime", Tools.getCurrentMonth(depotHead.getCreateTime())); - item.put("OperTime", Tools.getCurrentMonth(depotHead.getOperTime())); + item.put("CreateTime", Tools.getCenternTime(depotHead.getCreateTime())); + item.put("OperTime", Tools.getCenternTime(depotHead.getOperTime())); item.put("OrganId", depotHead.getOrganId()==null?"":depotHead.getOrganId().getId()); item.put("OrganName", depotHead.getOrganId()==null?"":depotHead.getOrganId().getSupplier()); item.put("HandsPersonId", depotHead.getHandsPersonId()==null?"":depotHead.getHandsPersonId().getId()); + item.put("Salesman", depotHead.getSalesman().toString()); item.put("HandsPersonName", depotHead.getHandsPersonId()==null?"":depotHead.getHandsPersonId().getName()); item.put("AccountId", depotHead.getAccountId()==null?"":depotHead.getAccountId().getId()); item.put("AccountName", depotHead.getAccountId()==null?"":depotHead.getAccountId().getName()); item.put("ChangeAmount", depotHead.getChangeAmount()==null?"":Math.abs(depotHead.getChangeAmount())); + item.put("AccountIdList", depotHead.getAccountIdList()); + item.put("AccountMoneyList", depotHead.getAccountMoneyList()); + item.put("Discount", depotHead.getDiscount()); + item.put("DiscountMoney", depotHead.getDiscountMoney()); + item.put("DiscountLastMoney", depotHead.getDiscountLastMoney()); + item.put("OtherMoney", depotHead.getOtherMoney()); + item.put("OtherMoneyList", depotHead.getOtherMoneyList()); //id列表 + item.put("OtherMoneyItem", depotHead.getOtherMoneyItem()); //money列表 + item.put("AccountDay", depotHead.getAccountDay()); //结算天数 item.put("AllocationProjectId", depotHead.getAllocationProjectId()==null?"":depotHead.getAllocationProjectId().getId()); item.put("AllocationProjectName", depotHead.getAllocationProjectId()==null?"":depotHead.getAllocationProjectId().getName()); item.put("TotalPrice", depotHead.getTotalPrice()==null?"":Math.abs(depotHead.getTotalPrice())); item.put("payType", depotHead.getPayType()==null?"":depotHead.getPayType()); + item.put("Status", depotHead.getStatus()); item.put("Remark", depotHead.getRemark()); item.put("op", 1); dataArray.add(item); @@ -294,16 +437,16 @@ public class DepotHeadAction extends BaseAction } catch (DataAccessException e) { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e); + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e); } catch (IOException e) { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e); + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e); } } /** - * 查找进销存_根据月份(报表) + * 查找单据_根据月份(报表) * @return */ public void findByMonth() { @@ -332,11 +475,11 @@ public class DepotHeadAction extends BaseAction } catch (DataAccessException e) { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e); + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e); } catch (IOException e) { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e); + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e); } } @@ -377,10 +520,10 @@ public class DepotHeadAction extends BaseAction toClient(outer.toString()); } catch (DataAccessException e) { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e); + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e); } catch (IOException e) { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e); + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e); } } @@ -449,98 +592,6 @@ public class DepotHeadAction extends BaseAction } return allMoney; } - - /** - *入库出库明细接口 - */ - public void findInDetail(){ - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - Long pid =model.getProjectId(); - String dids =model.getDepotIds(); - String beginTime = model.getBeginTime(); - String endTime = model.getEndTime(); - String type = model.getType(); - try{ - depotHeadService.findInDetail(pageUtil,beginTime,endTime,type,pid,dids); - List dataList = pageUtil.getPageList(); - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(dataList!=null){ - for(Integer i=0; i>>>>>>>>>>>>>>>>>>查找信息异常", e); - } - catch (IOException e) { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e); - } - } - - /** - *入库出库统计接口 - */ - public void findInOutMaterialCount(){ - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - Long pid =model.getProjectId(); - String dids =model.getDepotIds(); - String beginTime = model.getBeginTime(); - String endTime = model.getEndTime(); - String type = model.getType(); - try{ - depotHeadService.findInOutMaterialCount(pageUtil, beginTime, endTime, type, pid, dids); - List dataList = pageUtil.getPageList(); - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(dataList!=null){ - for(Integer i=0; i>>>>>>>>>>>>>>>>>>查找信息异常", e); - } - catch (IOException e) { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e); - } - } /** * 拼接搜索条件 @@ -552,14 +603,6 @@ public class DepotHeadAction extends BaseAction * 拼接搜索条件 */ Map condition = new HashMap(); - if(model.getAllocationProjectId()!=null) - {condition.put("AllocationProjectId_n_eq", model.getAllocationProjectId());} - if(model.getProjectId()!=null) { - condition.put("ProjectId_n_eq", model.getProjectId()); - } - else { - condition.put("ProjectId_s_in", model.getDepotIds()); - } condition.put("Type_s_eq",model.getType()); condition.put("SubType_s_eq",model.getSubType()); condition.put("Number_s_like",model.getNumber()); @@ -568,13 +611,20 @@ public class DepotHeadAction extends BaseAction condition.put("Id_s_order","desc"); return condition; } + + private Map buildNumberCondition(String type,String subType,String beginTime,String endTime) { + Map condition = new HashMap(); + condition.put("Type_s_eq", type); + condition.put("SubType_s_eq", subType); + condition.put("OperTime_s_gteq",beginTime); + condition.put("OperTime_s_lteq",endTime); + condition.put("Id_s_order","desc"); + return condition; + } private Map getConditionHead() { Map condition = new HashMap(); - if(model.getProjectId()!=null) { - condition.put("ProjectId_n_eq", model.getProjectId()); - } condition.put("OperTime_s_lteq",model.getMonthTime() + "-31 00:00:00"); return condition; } diff --git a/src/main/java/com/jsh/action/materials/DepotItemAction.java b/src/main/java/com/jsh/action/materials/DepotItemAction.java index f34f431a..aa78544e 100644 --- a/src/main/java/com/jsh/action/materials/DepotItemAction.java +++ b/src/main/java/com/jsh/action/materials/DepotItemAction.java @@ -1,29 +1,24 @@ package com.jsh.action.materials; -import java.io.File; +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.model.po.*; +import com.jsh.model.vo.materials.DepotItemModel; +import com.jsh.service.materials.DepotItemIService; +import com.jsh.service.materials.MaterialIService; +import com.jsh.util.JshException; +import com.jsh.util.PageUtil; +import com.jsh.util.Tools; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.commons.lang.StringUtils; +import org.springframework.dao.DataAccessException; + import java.io.IOException; import java.sql.Timestamp; 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; -import org.springframework.dao.DataAccessException; -import com.jsh.base.BaseAction; -import com.jsh.base.Log; -import com.jsh.util.AssetConstants; -import com.jsh.util.JshException; -import com.jsh.model.po.Asset; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.DepotItem; -import com.jsh.model.po.Logdetails; -import com.jsh.model.po.Material; -import com.jsh.model.vo.materials.DepotItemModel; -import com.jsh.service.materials.DepotHeadIService; -import com.jsh.service.materials.DepotItemIService; -import com.jsh.util.PageUtil; -import com.jsh.util.Tools; /* * 单据明细管理 * @author jishenghua qq:752718920 @@ -31,6 +26,7 @@ import com.jsh.util.Tools; @SuppressWarnings("serial") public class DepotItemAction extends BaseAction { + private MaterialIService materialService; private DepotItemIService depotItemService; private DepotItemModel model = new DepotItemModel(); /** @@ -42,12 +38,10 @@ public class DepotItemAction extends BaseAction * 保存明细 * @return */ - public void saveDetials() - { + public void saveDetials() { Log.infoFileSync("==================开始调用保存仓管通明细信息方法saveDetials()==================="); Boolean flag = false; - try - { + try { Long headerId=model.getHeaderId(); String inserted=model.getInserted(); String deleted=model.getDeleted(); @@ -56,40 +50,146 @@ public class DepotItemAction extends BaseAction JSONArray insertedJson = JSONArray.fromObject(inserted); JSONArray deletedJson = JSONArray.fromObject(deleted); JSONArray updatedJson = JSONArray.fromObject(updated); - if(null != insertedJson) - { - for(int i = 0;i < insertedJson.size(); i++) - { + if(null != insertedJson) { + for(int i = 0;i < insertedJson.size(); i++) { DepotItem depotItem = new DepotItem(); JSONObject tempInsertedJson = JSONObject.fromObject(insertedJson.get(i)); depotItem.setHeaderId(new DepotHead(headerId)); depotItem.setMaterialId(new Material(tempInsertedJson.getLong("MaterialId"))); - depotItem.setOperNumber(tempInsertedJson.getDouble("OperNumber")); - if(tempInsertedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempInsertedJson.getDouble("UnitPrice"));} - if(tempInsertedJson.get("AllPrice")!=null){depotItem.setAllPrice(tempInsertedJson.getDouble("AllPrice"));} + depotItem.setMUnit(tempInsertedJson.getString("Unit")); + if(!StringUtils.isEmpty(tempInsertedJson.get("OperNumber").toString())){ + depotItem.setOperNumber(tempInsertedJson.getDouble("OperNumber")); + try { + String Unit = tempInsertedJson.get("Unit").toString(); + Double oNumber = tempInsertedJson.getDouble("OperNumber"); + Long mId = Long.parseLong(tempInsertedJson.get("MaterialId").toString()); + //以下进行单位换算 + String UnitName = findUnitName(mId); //查询计量单位名称 + if(!UnitName.equals("")) { + String UnitList = UnitName.substring(0, UnitName.indexOf("(")); + String RatioList = UnitName.substring(UnitName.indexOf("(")); + String basicUnit = UnitList.substring(0, UnitList.indexOf(",")); //基本单位 + String otherUnit = UnitList.substring(UnitList.indexOf(",")+1); //副单位 + Integer ratio = Integer.parseInt(RatioList.substring(RatioList.indexOf(":") + 1).replace(")","")); //比例 + if(Unit.equals(basicUnit)){ //如果等于基础单位 + depotItem.setBasicNumber(oNumber); //数量一致 + } + else if(Unit.equals(otherUnit)){ //如果等于副单位 + depotItem.setBasicNumber(oNumber*ratio); //数量乘以比例 + } + } + else { + depotItem.setBasicNumber(oNumber); //其他情况 + } + } + catch(Exception e){ + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e); + } + } + if(!StringUtils.isEmpty(tempInsertedJson.get("UnitPrice").toString())){ + depotItem.setUnitPrice(tempInsertedJson.getDouble("UnitPrice")); + } + if(!StringUtils.isEmpty(tempInsertedJson.get("TaxUnitPrice").toString())){ + depotItem.setTaxUnitPrice(tempInsertedJson.getDouble("TaxUnitPrice")); + } + if(!StringUtils.isEmpty(tempInsertedJson.get("AllPrice").toString())){ + depotItem.setAllPrice(tempInsertedJson.getDouble("AllPrice")); + } depotItem.setRemark(tempInsertedJson.getString("Remark")); + if(tempInsertedJson.get("DepotId")!=null && !StringUtils.isEmpty(tempInsertedJson.get("DepotId").toString())){ + depotItem.setDepotId(new Depot(tempInsertedJson.getLong("DepotId"))); + } + if(tempInsertedJson.get("AnotherDepotId")!=null && !StringUtils.isEmpty(tempInsertedJson.get("AnotherDepotId").toString())){ + depotItem.setAnotherDepotId(new Depot(tempInsertedJson.getLong("AnotherDepotId"))); + } + if(!StringUtils.isEmpty(tempInsertedJson.get("TaxRate").toString())){ + depotItem.setTaxRate(tempInsertedJson.getDouble("TaxRate")); + } + if(!StringUtils.isEmpty(tempInsertedJson.get("TaxMoney").toString())){ + depotItem.setTaxMoney(tempInsertedJson.getDouble("TaxMoney")); + } + if(!StringUtils.isEmpty(tempInsertedJson.get("TaxLastMoney").toString())){ + depotItem.setTaxLastMoney(tempInsertedJson.getDouble("TaxLastMoney")); + } + if(tempInsertedJson.get("OtherField1")!=null){depotItem.setOtherField1(tempInsertedJson.getString("OtherField1"));} + if(tempInsertedJson.get("OtherField2")!=null){depotItem.setOtherField2(tempInsertedJson.getString("OtherField2"));} + if(tempInsertedJson.get("OtherField3")!=null){depotItem.setOtherField3(tempInsertedJson.getString("OtherField3"));} + if(tempInsertedJson.get("OtherField4")!=null){depotItem.setOtherField4(tempInsertedJson.getString("OtherField4"));} + if(tempInsertedJson.get("OtherField5")!=null){depotItem.setOtherField5(tempInsertedJson.getString("OtherField5"));} depotItemService.create(depotItem); } } - if(null != deletedJson) - { - for(int i = 0;i < deletedJson.size(); i++) - { + if(null != deletedJson) { + for(int i = 0;i < deletedJson.size(); i++) { JSONObject tempDeletedJson = JSONObject.fromObject(deletedJson.get(i)); depotItemService.delete(tempDeletedJson.getLong("Id")); } } - if(null != updatedJson) - { - for(int i = 0;i < updatedJson.size(); i++) - { + if(null != updatedJson) { + for(int i = 0;i < updatedJson.size(); i++) { JSONObject tempUpdatedJson = JSONObject.fromObject(updatedJson.get(i)); DepotItem depotItem = depotItemService.get(tempUpdatedJson.getLong("Id")); depotItem.setMaterialId(new Material(tempUpdatedJson.getLong("MaterialId"))); - depotItem.setOperNumber(tempUpdatedJson.getDouble("OperNumber")); - if(tempUpdatedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempUpdatedJson.getDouble("UnitPrice"));} - if(tempUpdatedJson.get("AllPrice")!=null){depotItem.setAllPrice(tempUpdatedJson.getDouble("AllPrice"));} + depotItem.setMUnit(tempUpdatedJson.getString("Unit")); + if(!StringUtils.isEmpty(tempUpdatedJson.get("OperNumber").toString())){ + depotItem.setOperNumber(tempUpdatedJson.getDouble("OperNumber")); + try { + String Unit = tempUpdatedJson.get("Unit").toString(); + Double oNumber = tempUpdatedJson.getDouble("OperNumber"); + Long mId = Long.parseLong(tempUpdatedJson.get("MaterialId").toString()); + //以下进行单位换算 + String UnitName = findUnitName(mId); //查询计量单位名称 + if(!UnitName.equals("")) { + String UnitList = UnitName.substring(0, UnitName.indexOf("(")); + String RatioList = UnitName.substring(UnitName.indexOf("(")); + String basicUnit = UnitList.substring(0, UnitList.indexOf(",")); //基本单位 + String otherUnit = UnitList.substring(UnitList.indexOf(",")+1); //副单位 + Integer ratio = Integer.parseInt(RatioList.substring(RatioList.indexOf(":") + 1).replace(")","")); //比例 + if(Unit.equals(basicUnit)){ //如果等于基础单位 + depotItem.setBasicNumber(oNumber); //数量一致 + } + else if(Unit.equals(otherUnit)){ //如果等于副单位 + depotItem.setBasicNumber(oNumber*ratio); //数量乘以比例 + } + } + else { + depotItem.setBasicNumber(oNumber); //其他情况 + } + } + catch(Exception e){ + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e); + } + } + if(!StringUtils.isEmpty(tempUpdatedJson.get("UnitPrice").toString())){ + depotItem.setUnitPrice(tempUpdatedJson.getDouble("UnitPrice")); + } + if(!StringUtils.isEmpty(tempUpdatedJson.get("TaxUnitPrice").toString())){ + depotItem.setTaxUnitPrice(tempUpdatedJson.getDouble("TaxUnitPrice")); + } + if(!StringUtils.isEmpty(tempUpdatedJson.get("AllPrice").toString())){ + depotItem.setAllPrice(tempUpdatedJson.getDouble("AllPrice")); + } depotItem.setRemark(tempUpdatedJson.getString("Remark")); + if(tempUpdatedJson.get("DepotId")!=null && !StringUtils.isEmpty(tempUpdatedJson.get("DepotId").toString())){ + depotItem.setDepotId(new Depot(tempUpdatedJson.getLong("DepotId"))); + } + if(tempUpdatedJson.get("AnotherDepotId")!=null && !StringUtils.isEmpty(tempUpdatedJson.get("AnotherDepotId").toString())){ + depotItem.setAnotherDepotId(new Depot(tempUpdatedJson.getLong("AnotherDepotId"))); + } + if(!StringUtils.isEmpty(tempUpdatedJson.get("TaxRate").toString())){ + depotItem.setTaxRate(tempUpdatedJson.getDouble("TaxRate")); + } + if(!StringUtils.isEmpty(tempUpdatedJson.get("TaxMoney").toString())){ + depotItem.setTaxMoney(tempUpdatedJson.getDouble("TaxMoney")); + } + if(!StringUtils.isEmpty(tempUpdatedJson.get("TaxLastMoney").toString())){ + depotItem.setTaxLastMoney(tempUpdatedJson.getDouble("TaxLastMoney")); + } + depotItem.setOtherField1(tempUpdatedJson.getString("OtherField1")); + depotItem.setOtherField2(tempUpdatedJson.getString("OtherField2")); + depotItem.setOtherField3(tempUpdatedJson.getString("OtherField3")); + depotItem.setOtherField4(tempUpdatedJson.getString("OtherField4")); + depotItem.setOtherField5(tempUpdatedJson.getString("OtherField5")); depotItemService.create(depotItem); } } @@ -100,21 +200,17 @@ public class DepotItemAction extends BaseAction tipMsg = "成功"; tipType = 0; } - catch (DataAccessException e) - { + catch (DataAccessException e) { Log.errorFileSync(">>>>>>>>>>>>>>>>>>>保存仓管通明细信息异常", e); flag = false; tipMsg = "失败"; tipType = 1; } - finally - { - try - { + finally { + try { toClient(flag.toString()); } - catch (IOException e) - { + catch (IOException e) { Log.errorFileSync(">>>>>>>>>>>>保存仓管通明细信息回写客户端结果异常", e); } } @@ -125,15 +221,39 @@ public class DepotItemAction extends BaseAction Log.infoFileSync("==================结束调用保存仓管通明细方法saveDetials()==================="); } + /** + * 查询计量单位信息 + * @return + */ + public String findUnitName(Long mId){ + String unitName =""; + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + try { + materialService.findUnitName(pageUtil, mId); + unitName = pageUtil.getPageList().toString(); + if(unitName!=null){ + unitName = unitName.substring(1,unitName.length()-1); + if(unitName.equals("null")){ + unitName = ""; + } + } + } + catch (JshException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return unitName; + } + /** - * 查找仓管通信息 + * 查找明细信息 * @return */ - public void findBy() - { - try - { + public void findBy() { + try { PageUtil pageUtil = new PageUtil(); pageUtil.setPageSize(model.getPageSize()); pageUtil.setCurPage(model.getPageNo()); @@ -145,23 +265,44 @@ public class DepotItemAction extends BaseAction outer.put("total", pageUtil.getTotalCount()); //存放数据json数组 JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(DepotItem depotItem:dataList) - { + if(null != dataList) { + for(DepotItem depotItem:dataList) { JSONObject item = new JSONObject(); item.put("Id", depotItem.getId()); item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId()); - String MaterialName = ((depotItem.getMaterialId().getModel() == null||depotItem.getMaterialId().getModel().equals(""))?"":depotItem.getMaterialId().getModel()+" ") + depotItem.getMaterialId().getName() - +((depotItem.getMaterialId().getStandard() == null||depotItem.getMaterialId().getStandard().equals(""))?"":"("+depotItem.getMaterialId().getStandard() + ")") - +((depotItem.getMaterialId().getColor() == null||depotItem.getMaterialId().getColor().equals(""))?"":"("+depotItem.getMaterialId().getColor() + ")") - +((depotItem.getMaterialId().getUnit() == null||depotItem.getMaterialId().getUnit().equals(""))?"":"("+depotItem.getMaterialId().getUnit() + ")"); + String ratio; //比例 + if(depotItem.getMaterialId().getUnitId() == null || depotItem.getMaterialId().getUnitId().equals("")){ + ratio = ""; + } + else { + ratio = depotItem.getMaterialId().getUnitId().getUName(); + ratio = ratio.substring(ratio.indexOf("(")); + } + //品名/型号/制造商/包装 + String MaterialName = depotItem.getMaterialId().getName() + ((depotItem.getMaterialId().getModel() == null||depotItem.getMaterialId().getModel().equals(""))?"":"("+depotItem.getMaterialId().getModel()+ ")") + +((depotItem.getMaterialId().getMfrs() == null||depotItem.getMaterialId().getMfrs().equals(""))?"":"("+depotItem.getMaterialId().getMfrs() + ")") + + ratio; item.put("MaterialName", MaterialName); + item.put("Unit", depotItem.getMUnit()); item.put("OperNumber", depotItem.getOperNumber()); + item.put("BasicNumber", depotItem.getBasicNumber()); item.put("UnitPrice", depotItem.getUnitPrice()); + item.put("TaxUnitPrice", depotItem.getTaxUnitPrice()); item.put("AllPrice", depotItem.getAllPrice()); item.put("Remark", depotItem.getRemark()); item.put("Img", depotItem.getImg()); + item.put("DepotId", depotItem.getDepotId()==null?"":depotItem.getDepotId().getId()); + item.put("DepotName", depotItem.getDepotId()==null?"":depotItem.getDepotId().getName()); + item.put("AnotherDepotId", depotItem.getAnotherDepotId()==null?"":depotItem.getAnotherDepotId().getId()); + item.put("AnotherDepotName", depotItem.getAnotherDepotId()==null?"":depotItem.getAnotherDepotId().getName()); + item.put("TaxRate", depotItem.getTaxRate()); + item.put("TaxMoney", depotItem.getTaxMoney()); + item.put("TaxLastMoney", depotItem.getTaxLastMoney()); + item.put("OtherField1", depotItem.getOtherField1()); + item.put("OtherField2", depotItem.getOtherField2()); + item.put("OtherField3", depotItem.getOtherField3()); + item.put("OtherField4", depotItem.getOtherField4()); + item.put("OtherField5", depotItem.getOtherField5()); item.put("op", 1); dataArray.add(item); } @@ -170,24 +311,20 @@ public class DepotItemAction extends BaseAction //回写查询结果 toClient(outer.toString()); } - catch (DataAccessException e) - { + catch (DataAccessException e) { Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e); } - catch (IOException e) - { + catch (IOException e) { Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e); } } /** - * 查找进销存 + * 查找所有的明细 * @return */ - public void findByAll() - { - try - { + public void findByAll() { + try { PageUtil pageUtil = new PageUtil(); pageUtil.setPageSize(model.getPageSize()); pageUtil.setCurPage(model.getPageNo()); @@ -200,10 +337,8 @@ public class DepotItemAction extends BaseAction //存放数据json数组 Integer pid = model.getProjectId(); JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(DepotItem depotItem:dataList) - { + if(null != dataList) { + for(DepotItem depotItem:dataList) { JSONObject item = new JSONObject(); Integer prevSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true); Integer InSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),false); @@ -218,7 +353,11 @@ public class DepotItemAction extends BaseAction item.put("MaterialStandard", depotItem.getMaterialId().getStandard()); item.put("MaterialColor", depotItem.getMaterialId().getColor()); item.put("MaterialUnit", depotItem.getMaterialId().getUnit()); - item.put("UnitPrice", (prevPrice + InPrice - OutPrice)/(prevSum + InSum - OutSum)); + Double unitPrice = 0.0; + if(prevSum + InSum - OutSum != 0.0){ + unitPrice = (prevPrice + InPrice - OutPrice)/(prevSum + InSum - OutSum); + } + item.put("UnitPrice", unitPrice); item.put("prevSum", prevSum); item.put("InSum", InSum); item.put("OutSum", OutSum); @@ -241,6 +380,50 @@ public class DepotItemAction extends BaseAction } } + /** + * 根据商品id和仓库id查询库存数量 + * @return + */ + public void findStockNumById() { + try { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getConditionById()); + depotItemService.find(pageUtil); + List dataList = pageUtil.getPageList(); + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + Integer pid = model.getProjectId(); + JSONArray dataArray = new JSONArray(); + if(null != dataList) { + for(DepotItem depotItem:dataList) { + JSONObject item = new JSONObject(); + Integer prevSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true); + Integer InSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),false); + Integer OutSum = sumNumber("出库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),false); + item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId()); + item.put("MaterialName", depotItem.getMaterialId().getName()); + item.put("MaterialModel", depotItem.getMaterialId().getModel()); + item.put("thisSum", prevSum + InSum - OutSum); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e); + } + } + /** * 查找礼品卡信息 * @return @@ -448,11 +631,9 @@ public class DepotItemAction extends BaseAction * @return */ @SuppressWarnings("unchecked") - public String exportExcel() - { + public String exportExcel() { Log.infoFileSync("===================调用导出信息action方法exportExcel开始======================="); - try - { + try { PageUtil pageUtil = new PageUtil(); pageUtil.setPageSize(model.getPageSize()); pageUtil.setCurPage(model.getPageNo()); @@ -463,10 +644,8 @@ public class DepotItemAction extends BaseAction //存放数据json数组 Integer pid = model.getProjectId(); JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(DepotItem depotItem:dataList) - { + if(null != dataList) { + for(DepotItem depotItem:dataList) { JSONObject item = new JSONObject(); Integer prevSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true); Integer InSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),false); @@ -494,8 +673,7 @@ public class DepotItemAction extends BaseAction model.setFileName(Tools.changeUnicode("report.xls",model.getBrowserType())); model.setExcelStream(depotItemService.exmportExcel(isCurrentPage,dataArray)); } - catch (Exception e) - { + catch (Exception e) { Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常",e); model.getShowModel().setMsgTip("export excel exception"); } @@ -668,6 +846,15 @@ public class DepotItemAction extends BaseAction condition.put("MaterialId_s_gb","aaa"); return condition; } + + private Map getConditionById() { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("MaterialId_n_eq", model.getMaterialId()); + return condition; + } //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== @Override @@ -679,4 +866,8 @@ public class DepotItemAction extends BaseAction { this.depotItemService = depotItemService; } + + public void setMaterialService(MaterialIService materialService) { + this.materialService = materialService; + } } diff --git a/src/main/java/com/jsh/action/materials/MaterialAction.java b/src/main/java/com/jsh/action/materials/MaterialAction.java index 94892115..dff7510e 100644 --- a/src/main/java/com/jsh/action/materials/MaterialAction.java +++ b/src/main/java/com/jsh/action/materials/MaterialAction.java @@ -1,20 +1,22 @@ package com.jsh.action.materials; import java.io.IOException; +import java.io.InputStream; import java.sql.Timestamp; +import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; + +import com.jsh.model.po.*; +import com.jsh.util.JshException; +import com.jsh.util.MaterialConstants; +import com.jsh.util.Tools; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.springframework.dao.DataAccessException; import com.jsh.base.BaseAction; import com.jsh.base.Log; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.Material; -import com.jsh.model.po.Logdetails; -import com.jsh.model.po.MaterialCategory; -import com.jsh.model.po.Supplier; import com.jsh.model.vo.materials.MaterialModel; import com.jsh.service.materials.MaterialIService; import com.jsh.util.PageUtil; @@ -27,6 +29,7 @@ public class MaterialAction extends BaseAction { private MaterialIService materialService; private MaterialModel model = new MaterialModel(); + public static final String EXCEL = "excel"; //action返回excel结果 /** * 增加商品 @@ -42,6 +45,9 @@ public class MaterialAction extends BaseAction material.setMaterialCategory(new MaterialCategory(model.getCategoryId())); material.setName(model.getName()); + material.setMfrs(model.getMfrs()); + material.setPacking(model.getPacking()); + material.setSafetyStock(model.getSafetyStock()); material.setModel(model.getModel()); material.setStandard(model.getStandard()); material.setColor(model.getColor()); @@ -50,7 +56,17 @@ public class MaterialAction extends BaseAction material.setLowPrice(model.getLowPrice()); material.setPresetPriceOne(model.getPresetPriceOne()); material.setPresetPriceTwo(model.getPresetPriceTwo()); + if(model.getUnitId()!=null){ + material.setUnitId(new Unit(model.getUnitId())); + } + else { + material.setUnitId(null); + } + material.setFirstOutUnit(model.getFirstOutUnit()); + material.setFirstInUnit(model.getFirstInUnit()); + material.setPriceStrategy(model.getPriceStrategy()); material.setRemark(model.getRemark()); + material.setEnabled(model.getEnabled()); materialService.create(material); //========标识位=========== @@ -124,6 +140,9 @@ public class MaterialAction extends BaseAction material.setMaterialCategory(new MaterialCategory(model.getCategoryId())); material.setName(model.getName()); + material.setMfrs(model.getMfrs()); + material.setPacking(model.getPacking()); + material.setSafetyStock(model.getSafetyStock()); material.setModel(model.getModel()); material.setStandard(model.getStandard()); material.setColor(model.getColor()); @@ -132,8 +151,16 @@ public class MaterialAction extends BaseAction material.setLowPrice(model.getLowPrice()); material.setPresetPriceOne(model.getPresetPriceOne()); material.setPresetPriceTwo(model.getPresetPriceTwo()); + if(model.getUnitId()!=null){ + material.setUnitId(new Unit(model.getUnitId())); + } + else { + material.setUnitId(null); + } + material.setFirstOutUnit(model.getFirstOutUnit()); + material.setFirstInUnit(model.getFirstInUnit()); + material.setPriceStrategy(model.getPriceStrategy()); material.setRemark(model.getRemark()); - material.setName(model.getName()); materialService.update(material); flag = true; @@ -189,6 +216,63 @@ public class MaterialAction extends BaseAction , tipType, "批量删除商品ID为 "+ model.getMaterialIDs() + " " + tipMsg + "!", "批量删除商品" + tipMsg)); return SUCCESS; } + + /** + * 批量设置状态-启用或者禁用 + * @return + */ + public String batchSetEnable() + { + try + { + materialService.batchSetEnable(model.getEnabled(),model.getMaterialIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量修改状态,商品ID为:" + model.getMaterialIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量修改商品状态", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量修改状态,商品ID为 "+ model.getMaterialIDs() + " " + tipMsg + "!", "批量修改商品状态" + tipMsg)); + return SUCCESS; + } + + /** + * 查找该商品是否存在 + * @return + */ + public void checkIsExist() { + try { + Boolean flag = false; + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + pageUtil.setAdvSearch(getConditionCheckIsExist()); + materialService.find(pageUtil); + List dataList = pageUtil.getPageList(); + if(null != dataList && dataList.size() > 0){ + flag = true; + } + else{ + flag = false; + } + //回写查询结果 + toClient(flag.toString()); + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品信息异常", e); + } + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品信息结果异常", e); + } + } /** * 查找商品信息 @@ -211,6 +295,7 @@ public class MaterialAction extends BaseAction pageUtil.setAdvSearch(getCondition()); } materialService.find(pageUtil); + getSession().put("pageUtilMaterial", pageUtil); List dataList = pageUtil.getPageList(); JSONObject outer = new JSONObject(); @@ -224,6 +309,11 @@ public class MaterialAction extends BaseAction JSONObject item = new JSONObject(); item.put("Id", material.getId()); item.put("Name", material.getName()); + item.put("CategoryId", material.getMaterialCategory().getId()); //类型Id + item.put("CategoryName", material.getMaterialCategory().getName()); //类型名称 + item.put("Mfrs", material.getMfrs()==null?"" : material.getMfrs()); + item.put("Packing", material.getPacking()==null?"" : material.getPacking()); + item.put("SafetyStock", material.getSafetyStock()==null?"" : material.getSafetyStock()); item.put("Model", material.getModel()==null?"" : material.getModel()); item.put("Standard", material.getStandard()==null?"": material.getStandard()); item.put("Color", material.getColor()==null?"": material.getColor()); @@ -232,6 +322,12 @@ public class MaterialAction extends BaseAction item.put("LowPrice", material.getLowPrice()); item.put("PresetPriceOne", material.getPresetPriceOne()==null? "":material.getPresetPriceOne()); item.put("PresetPriceTwo", material.getPresetPriceTwo()==null? "":material.getPresetPriceTwo()); + item.put("UnitId",material.getUnitId()==null? "": material.getUnitId().getId()); //计量单位Id + item.put("UnitName", material.getUnitId()==null? "": material.getUnitId().getUName()); //计量单位名称 + item.put("FirstOutUnit", material.getFirstOutUnit()); + item.put("FirstInUnit", material.getFirstInUnit()); + item.put("PriceStrategy", material.getPriceStrategy()); + item.put("Enabled", material.getEnabled()); item.put("Remark", material.getRemark()); item.put("op", 1); dataArray.add(item); @@ -273,6 +369,9 @@ public class MaterialAction extends BaseAction JSONObject item = new JSONObject(); item.put("Id", material.getId()); item.put("Name", material.getName()); + item.put("Mfrs", material.getMfrs()==null?"" : material.getMfrs()); + item.put("Packing", material.getPacking()==null?"" : material.getPacking()); + item.put("SafetyStock", material.getSafetyStock()==null?"" : material.getSafetyStock()); item.put("Model", material.getModel()); item.put("Standard", material.getStandard()); item.put("Color", material.getColor()); @@ -281,6 +380,11 @@ public class MaterialAction extends BaseAction item.put("LowPrice", material.getLowPrice()); item.put("PresetPriceOne", material.getPresetPriceOne()); item.put("PresetPriceTwo", material.getPresetPriceTwo()); + item.put("UnitId",material.getUnitId()==null? "": material.getUnitId().getId()); //计量单位Id + item.put("UnitName", material.getUnitId()==null? "": material.getUnitId().getUName()); //计量单位名称 + item.put("FirstOutUnit", material.getFirstOutUnit()); + item.put("FirstInUnit", material.getFirstInUnit()); + item.put("PriceStrategy", material.getPriceStrategy()); item.put("Remark", material.getRemark()); item.put("op", 1); dataArray.add(item); @@ -304,10 +408,8 @@ public class MaterialAction extends BaseAction * 查找商品信息-下拉框 * @return */ - public void findBySelect() - { - try - { + public void findBySelect() { + try { PageUtil pageUtil = new PageUtil(); pageUtil.setPageSize(0); pageUtil.setCurPage(0); @@ -316,17 +418,22 @@ public class MaterialAction extends BaseAction List dataList = pageUtil.getPageList(); //存放数据json数组 JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Material material:dataList) - { + if(null != dataList) { + for(Material material:dataList) { JSONObject item = new JSONObject(); item.put("Id", material.getId()); - //名称 - String MaterialName = ((material.getModel() == null || material.getModel().equals(""))?"":material.getModel() +" ") + material.getName() - + ((material.getStandard() == null || material.getStandard().equals(""))?"":"("+material.getStandard() + ")") - + ((material.getColor() == null || material.getColor().equals(""))?"":"("+material.getColor() + ")") - + ((material.getUnit() == null || material.getUnit().equals(""))?"":"("+material.getUnit() + ")"); + String ratio; //比例 + if(material.getUnitId() == null || material.getUnitId().equals("")){ + ratio = ""; + } + else { + ratio = material.getUnitId().getUName(); + ratio = ratio.substring(ratio.indexOf("(")); + } + //品名/型号/制造商/包装 + String MaterialName = material.getName() + ((material.getModel() == null || material.getModel().equals(""))?"":"("+material.getModel() + ")") + + ((material.getMfrs() == null || material.getMfrs().equals(""))?"":"("+material.getMfrs() + ")") + + ratio; item.put("MaterialName", MaterialName); dataArray.add(item); } @@ -334,12 +441,10 @@ public class MaterialAction extends BaseAction //回写查询结果 toClient(dataArray.toString()); } - catch (DataAccessException e) - { + catch (DataAccessException e) { Log.errorFileSync(">>>>>>>>>查找供应商信息异常", e); } - catch (IOException e) - { + catch (IOException e) { Log.errorFileSync(">>>>>>>>>回写查询供应商信息结果异常", e); } } @@ -384,6 +489,67 @@ public class MaterialAction extends BaseAction Log.errorFileSync(">>>>>>>>>回写查询供应商信息结果异常", e); } } + + /** + * 导入excel表格-供应商 + * @return + */ + @SuppressWarnings("unchecked") + public String importExcel() { + //excel表格file + Boolean result = false; + String returnStr = ""; + try { + InputStream in = materialService.importExcel(model.getMaterialFile()); + + if(null != in) + { + model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls"); + model.setExcelStream(in); + returnStr = MaterialConstants.BusinessForExcel.EXCEL; + } + else { + result = true; + try { + toClient(result.toString()); + } catch (IOException e) { + Log.errorFileSync(">>>>>>>>>回写导入信息结果异常", e); + } + //导入数据成功 + returnStr = SUCCESS; + } + + } + catch (JshException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>导入excel表格信息异常", e); + } + return returnStr; + } + + /** + * 导出excel表格 + * @return + */ + @SuppressWarnings("unchecked") + public String exportExcel() { + Log.infoFileSync("===================调用导出信息action方法exportExcel开始======================="); + try { + String sName = "pageUtilMaterial"; + PageUtil pageUtil = (PageUtil)getSession().get(sName); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + String isCurrentPage = "allPage"; + model.setFileName(Tools.changeUnicode("goods" + System.currentTimeMillis() + ".xls", model.getBrowserType())); + model.setExcelStream(materialService.exmportExcel(isCurrentPage,pageUtil)); + } + catch (Exception e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常",e); + model.getShowModel().setMsgTip("export excel exception"); + } + Log.infoFileSync("===================调用导出信息action方法exportExcel结束=================="); + return EXCEL; + } /** * 拼接搜索条件(查全部) @@ -395,6 +561,9 @@ public class MaterialAction extends BaseAction * 拼接搜索条件 */ Map condition = new HashMap(); + condition.put("Name_s_like", model.getName()); + condition.put("Model_s_like", model.getModel()); + condition.put("Mfrs_s_like", model.getMfrs()); condition.put("Id_s_order", "asc"); return condition; } @@ -403,17 +572,36 @@ public class MaterialAction extends BaseAction * 拼接搜索条件 * @return */ - private Map getCondition() - { + private Map getCondition() { /** * 拼接搜索条件 */ Map condition = new HashMap(); + condition.put("Name_s_like", model.getName()); + condition.put("Model_s_like", model.getModel()); + condition.put("Mfrs_s_like", model.getMfrs()); condition.put("CategoryId_s_in", model.getCategoryIds()); condition.put("Id_s_order", "asc"); return condition; } + private Map getConditionCheckIsExist() { + Map condition = new HashMap(); + if(model.getMaterialID()>0){ + condition.put("ID_n_neq", model.getMaterialID()); + } + condition.put("Name_s_eq", model.getName()); + condition.put("Model_s_eq", model.getModel()); + condition.put("Mfrs_s_eq", model.getMfrs()); + if(model.getUnit()!=null){ + condition.put("Unit_s_eq", model.getUnit()); + } + if(model.getUnitId()!=null){ + condition.put("UnitId_n_eq", model.getUnitId()); + } + return condition; + } + /** * 拼接搜索条件 * @return @@ -438,6 +626,7 @@ public class MaterialAction extends BaseAction * 拼接搜索条件 */ Map condition = new HashMap(); + condition.put("enabled_s_eq",1); condition.put("Id_s_order", "asc"); return condition; } diff --git a/src/main/java/com/jsh/action/materials/MaterialCategoryAction.java b/src/main/java/com/jsh/action/materials/MaterialCategoryAction.java index 938154d0..accacc3e 100644 --- a/src/main/java/com/jsh/action/materials/MaterialCategoryAction.java +++ b/src/main/java/com/jsh/action/materials/MaterialCategoryAction.java @@ -245,6 +245,36 @@ public class MaterialCategoryAction extends BaseAction Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e); } } + + /** + * 根据id来查询商品名称 + * @return + */ + public void findById() { + try { + PageUtil pageUtil = new PageUtil(); + pageUtil.setAdvSearch(getConditionById()); + materialCategoryService.find(pageUtil); + List dataList = pageUtil.getPageList(); + JSONObject outer = new JSONObject(); + if(null != dataList) { + for(MaterialCategory materialCategory : dataList) { + outer.put("name", materialCategory.getName()); + outer.put("parentId", materialCategory.getMaterialCategory().getId()); + } + } + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品类别信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e); + } + } /** * 拼接搜索条件 @@ -256,11 +286,25 @@ public class MaterialCategoryAction extends BaseAction * 拼接搜索条件 */ Map condition = new HashMap(); + condition.put("Name_s_like", model.getName()); condition.put("ParentId_n_eq", model.getParentId()); condition.put("Id_n_neq", 1); condition.put("Id_s_order", "asc"); return condition; } + + /** + * 拼接搜索条件 + * @return + */ + private Map getConditionById(){ + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("Id_n_eq", model.getMaterialCategoryID()); + return condition; + } //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== @Override diff --git a/src/main/java/com/jsh/action/materials/PersonAction.java b/src/main/java/com/jsh/action/materials/PersonAction.java index 94e9d984..0e673bdc 100644 --- a/src/main/java/com/jsh/action/materials/PersonAction.java +++ b/src/main/java/com/jsh/action/materials/PersonAction.java @@ -70,6 +70,81 @@ public class PersonAction extends BaseAction } return SUCCESS; } + + /** + * 根据类型获取经手人信息 1-业务员,2-仓管员,3-财务员 + * @return + */ + public void getPersonByNumType() { + try { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + Map condition = pageUtil.getAdvSearch(); + String type = ""; + if(model.getType().equals("1")){ + type = "业务员"; + } + else if(model.getType().equals("2")){ + type = "仓管员"; + } + else if(model.getType().equals("3")){ + type = "财务员"; + } + condition.put("Type_s_eq",type); + condition.put("Id_s_order", "asc"); + personService.find(pageUtil); + List dataList = pageUtil.getPageList(); + JSONArray dataArray = new JSONArray(); + if(null != dataList) { + for(Person person:dataList){ + JSONObject item = new JSONObject(); + item.put("id", person.getId()); + item.put("name", person.getName()); + dataArray.add(item); + } + } + //回写查询结果 + toClient(dataArray.toString()); + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>查找信息异常", e); + } + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e); + } + } + + /** + * 根据Id获取经手人信息 + * @return + */ + public void getPersonByIds() { + try { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + Map condition = pageUtil.getAdvSearch(); + condition.put("Id_s_in", model.getPersonIDs()); + condition.put("Id_s_order", "asc"); + personService.find(pageUtil); + List dataList = pageUtil.getPageList(); + StringBuffer sb = new StringBuffer(); + if(null != dataList) { + for(Person person:dataList){ + sb.append(person.getName() + " "); + } + } + //回写查询结果 + toClient(sb.toString()); + } + catch (DataAccessException e) { + Log.errorFileSync(">>>>>>>>>查找信息异常", e); + } + catch (IOException e) { + Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e); + } + } /** * 增加经手人 diff --git a/src/main/java/com/jsh/dao/basic/SupplierDAO.java b/src/main/java/com/jsh/dao/basic/SupplierDAO.java index 8459e135..617f26fa 100644 --- a/src/main/java/com/jsh/dao/basic/SupplierDAO.java +++ b/src/main/java/com/jsh/dao/basic/SupplierDAO.java @@ -2,7 +2,7 @@ package com.jsh.dao.basic; import com.jsh.base.BaseDAO; import com.jsh.model.po.Supplier; -import com.jsh.util.PageUtil; +import com.jsh.util.JshException; import com.jsh.util.SearchConditionUtil; import org.hibernate.Query; @@ -18,4 +18,11 @@ public class SupplierDAO extends BaseDAO implements SupplierIDAO return Supplier.class; } + @SuppressWarnings("unchecked") + @Override + public void batchSetEnable(Boolean enable,String supplierIDs) { + String sql="update jsh_supplier s set s.enabled=" + enable + " where s.id in (" + supplierIDs + ")"; + Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql); + query.executeUpdate(); + } } diff --git a/src/main/java/com/jsh/dao/basic/SupplierIDAO.java b/src/main/java/com/jsh/dao/basic/SupplierIDAO.java index 1b7b3a62..dbdf12f2 100644 --- a/src/main/java/com/jsh/dao/basic/SupplierIDAO.java +++ b/src/main/java/com/jsh/dao/basic/SupplierIDAO.java @@ -5,4 +5,5 @@ import com.jsh.model.po.Supplier; public interface SupplierIDAO extends BaseIDAO { + public void batchSetEnable(Boolean enable,String supplierIDs); } diff --git a/src/main/java/com/jsh/dao/basic/UnitDAO.java b/src/main/java/com/jsh/dao/basic/UnitDAO.java new file mode 100644 index 00000000..a083eb94 --- /dev/null +++ b/src/main/java/com/jsh/dao/basic/UnitDAO.java @@ -0,0 +1,17 @@ +package com.jsh.dao.basic; + +import com.jsh.base.BaseDAO; +import com.jsh.model.po.Unit; + +public class UnitDAO extends BaseDAO implements UnitIDAO +{ + /** + * 设置dao映射基类 + * @return + */ + @Override + public Class getEntityClass() + { + return Unit.class; + } +} diff --git a/src/main/java/com/jsh/dao/basic/UnitIDAO.java b/src/main/java/com/jsh/dao/basic/UnitIDAO.java new file mode 100644 index 00000000..aa6d389c --- /dev/null +++ b/src/main/java/com/jsh/dao/basic/UnitIDAO.java @@ -0,0 +1,9 @@ +package com.jsh.dao.basic; + +import com.jsh.base.BaseIDAO; +import com.jsh.model.po.Unit; + +public interface UnitIDAO extends BaseIDAO +{ + +} diff --git a/src/main/java/com/jsh/dao/materials/DepotHeadDAO.java b/src/main/java/com/jsh/dao/materials/DepotHeadDAO.java index 1cceb859..3c18fe50 100644 --- a/src/main/java/com/jsh/dao/materials/DepotHeadDAO.java +++ b/src/main/java/com/jsh/dao/materials/DepotHeadDAO.java @@ -5,12 +5,10 @@ import org.hibernate.Query; import com.jsh.base.BaseDAO; import com.jsh.util.JshException; import com.jsh.model.po.DepotHead; -import com.jsh.model.po.UserBusiness; import com.jsh.util.PageUtil; import com.jsh.util.SearchConditionUtil; -public class DepotHeadDAO extends BaseDAO implements DepotHeadIDAO -{ +public class DepotHeadDAO extends BaseDAO implements DepotHeadIDAO { /** * 设置dao映射基类 * @return @@ -46,67 +44,10 @@ public class DepotHeadDAO extends BaseDAO implements DepotHeadIDAO } @SuppressWarnings("unchecked") - public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException { - StringBuffer queryString = new StringBuffer(); - queryString.append("select dh.Number,m.`name`,m.Model,di.UnitPrice,di.OperNumber,di.AllPrice,s.supplier,d.dName,date_format(dh.OperTime, '%Y-%m-%d') " + - "from jsh_depothead dh inner join jsh_depotitem di on di.HeaderId=dh.id " + - "inner join jsh_material m on m.id=di.MaterialId " + - "inner join jsh_supplier s on s.id=dh.OrganId " + - "inner join (select id,name as dName from jsh_depot) d on d.id=dh.ProjectId " + - "where dh.Type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' "); - if(pid!=null){ - queryString.append(" and dh.ProjectId=" + pid ); - } - else { - queryString.append(" and dh.ProjectId in (" + dids + ")" ); - } - queryString.append(" ORDER BY OperTime DESC,Number desc"); - Query query; - query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - pageUtil.setTotalCount(query.list().size()); - // 分页查询 - int pageNo = pageUtil.getCurPage(); - int pageSize = pageUtil.getPageSize(); - if (0 != pageNo && 0 != pageSize) { - query.setFirstResult((pageNo - 1) * pageSize); - query.setMaxResults(pageSize); - } - pageUtil.setPageList(query.list()); - } - - @SuppressWarnings("unchecked") - public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException { - StringBuffer queryString = new StringBuffer(); - queryString.append("select di.MaterialId, m.mName,m.Model,m.categoryName, "+ - " (select sum(jsh_depotitem.AllPrice) priceSum from jsh_depothead INNER JOIN jsh_depotitem " + - "on jsh_depothead.id=jsh_depotitem.HeaderId where jsh_depotitem.MaterialId=di.MaterialId " + - " and jsh_depothead.type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"'"); - if(pid!=null){ - queryString.append(" and dh.ProjectId=" + pid ); - } - else { - queryString.append(" and dh.ProjectId in (" + dids + ")" ); - } - queryString.append(" ) priceSum from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId " + - " INNER JOIN (SELECT jsh_material.id,jsh_material.name mName, Model,jsh_materialcategory.`Name` categoryName from jsh_material INNER JOIN jsh_materialcategory on jsh_material.CategoryId=jsh_materialcategory.Id) m " + - " on m.Id=di.MaterialId where dh.type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' "); - if(pid!=null){ - queryString.append(" and dh.ProjectId=" + pid ); - } - else { - queryString.append(" and dh.ProjectId in (" + dids + ")" ); - } - queryString.append(" GROUP BY di.MaterialId,m.mName,m.Model,m.categoryName "); - Query query; - query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - pageUtil.setTotalCount(query.list().size()); - // 分页查询 - int pageNo = pageUtil.getCurPage(); - int pageSize = pageUtil.getPageSize(); - if (0 != pageNo && 0 != pageSize) { - query.setFirstResult((pageNo - 1) * pageSize); - query.setMaxResults(pageSize); - } - pageUtil.setPageList(query.list()); + @Override + public void batchSetStatus(Boolean status,String depotHeadIDs) { + String sql="update jsh_depothead d set d.Status=" + status + " where d.id in (" + depotHeadIDs + ")"; + Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql); + query.executeUpdate(); } } diff --git a/src/main/java/com/jsh/dao/materials/DepotHeadIDAO.java b/src/main/java/com/jsh/dao/materials/DepotHeadIDAO.java index 91302342..2f53496d 100644 --- a/src/main/java/com/jsh/dao/materials/DepotHeadIDAO.java +++ b/src/main/java/com/jsh/dao/materials/DepotHeadIDAO.java @@ -15,8 +15,6 @@ public interface DepotHeadIDAO extends BaseIDAO void findAllMoney(PageUtil pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException; - public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException; - - public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException; + public void batchSetStatus(Boolean status,String depotHeadIDs); } diff --git a/src/main/java/com/jsh/dao/materials/DepotItemDAO.java b/src/main/java/com/jsh/dao/materials/DepotItemDAO.java index fed874c1..0b8dc367 100644 --- a/src/main/java/com/jsh/dao/materials/DepotItemDAO.java +++ b/src/main/java/com/jsh/dao/materials/DepotItemDAO.java @@ -20,7 +20,7 @@ public class DepotItemDAO extends BaseDAO implements DepotItemIDAO { return DepotItem.class; } - + @SuppressWarnings("unchecked") @Override public void findByType(PageUtil pageUtil,String type,Integer ProjectId,Long MId,String MonthTime,Boolean isPrev) throws JshException @@ -29,19 +29,19 @@ public class DepotItemDAO extends BaseDAO implements DepotItemIDAO Query query; StringBuffer queryString = new StringBuffer(); if(isPrev) { - queryString.append("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'"); + queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'"); if(ProjectId!=null) { - queryString.append(" and ProjectId='" + ProjectId +"'"); + queryString.append(" and DepotId='" + ProjectId +"'"); } queryString.append(" and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' "); query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); } else { - queryString.append("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'"); + queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'"); if(ProjectId!=null) { - queryString.append(" and ProjectId='" + ProjectId +"'"); + queryString.append(" and DepotId='" + ProjectId +"'"); } - queryString.append(" and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' "); + queryString.append(" and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 59:59:59' "); query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); } pageUtil.setTotalCount(query.list().size()); @@ -58,16 +58,16 @@ public class DepotItemDAO extends BaseDAO implements DepotItemIDAO if (isPrev) { queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "'"); if (ProjectId != null) { - queryString.append(" and ProjectId='" + ProjectId + "'"); + queryString.append(" and DepotId='" + ProjectId + "'"); } queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime <'" + MonthTime + "-01 00:00:00' "); query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); } else { queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "'"); if (ProjectId != null) { - queryString.append(" and ProjectId='" + ProjectId + "'"); + queryString.append(" and DepotId='" + ProjectId + "'"); } - queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 00:00:00' "); + queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 59:59:59' "); query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); } pageUtil.setTotalCount(query.list().size()); @@ -81,10 +81,10 @@ public class DepotItemDAO extends BaseDAO implements DepotItemIDAO //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 Query query; if(sumType.equals("Number")) { - query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); } else { - query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); } pageUtil.setTotalCount(query.list().size()); pageUtil.setPageList(query.list()); @@ -103,7 +103,7 @@ public class DepotItemDAO extends BaseDAO implements DepotItemIDAO queryString.append(" and AllocationProjectId='" + ProjectId +"'"); //礼品充值时 } else if(type.equals("out")){ - queryString.append(" and ProjectId='" + ProjectId +"'"); + queryString.append(" and DepotId='" + ProjectId +"'"); } } queryString.append(" and MaterialId ="+ MId); diff --git a/src/main/java/com/jsh/dao/materials/MaterialDAO.java b/src/main/java/com/jsh/dao/materials/MaterialDAO.java index bbefa62a..6ed55173 100644 --- a/src/main/java/com/jsh/dao/materials/MaterialDAO.java +++ b/src/main/java/com/jsh/dao/materials/MaterialDAO.java @@ -2,6 +2,10 @@ package com.jsh.dao.materials; import com.jsh.base.BaseDAO; import com.jsh.model.po.Material; +import com.jsh.util.JshException; +import com.jsh.util.PageUtil; +import com.jsh.util.SearchConditionUtil; +import org.hibernate.Query; public class MaterialDAO extends BaseDAO implements MaterialIDAO { @@ -14,4 +18,25 @@ public class MaterialDAO extends BaseDAO implements MaterialIDAO { return Material.class; } + + @SuppressWarnings("unchecked") + @Override + public void batchSetEnable(Boolean enable,String supplierIDs) { + String sql="update jsh_material m set m.enabled=" + enable + " where m.id in (" + supplierIDs + ")"; + Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql); + query.executeUpdate(); + } + + @SuppressWarnings("unchecked") + @Override + public void findUnitName(PageUtil pageUtil,Long mId) throws JshException { + //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便, + StringBuffer queryString = new StringBuffer(); + queryString.append("select jsh_unit.UName from jsh_unit inner join jsh_material on UnitId=jsh_unit.id where jsh_material.id="+mId); + Query query; + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + pageUtil.setTotalCount(query.list().size()); + pageUtil.setPageList(query.list()); + } + } diff --git a/src/main/java/com/jsh/dao/materials/MaterialIDAO.java b/src/main/java/com/jsh/dao/materials/MaterialIDAO.java index 962ef83a..677be348 100644 --- a/src/main/java/com/jsh/dao/materials/MaterialIDAO.java +++ b/src/main/java/com/jsh/dao/materials/MaterialIDAO.java @@ -2,8 +2,12 @@ package com.jsh.dao.materials; import com.jsh.base.BaseIDAO; import com.jsh.model.po.Material; +import com.jsh.util.JshException; +import com.jsh.util.PageUtil; public interface MaterialIDAO extends BaseIDAO { - + public void batchSetEnable(Boolean enable,String supplierIDs); + + public void findUnitName(PageUtil pageUtil,Long mId) throws JshException; } diff --git a/src/main/java/com/jsh/model/po/Depot.java b/src/main/java/com/jsh/model/po/Depot.java index fe4da537..4989bdff 100644 --- a/src/main/java/com/jsh/model/po/Depot.java +++ b/src/main/java/com/jsh/model/po/Depot.java @@ -5,23 +5,29 @@ public class Depot implements java.io.Serializable { private Long id; private String name; + private String address; + private Double warehousing; + private Double truckage; private Integer type; private String sort; private String remark; public Depot() { - + } - + public Depot(Long id) { this.id = id ; } - public Depot(String name,Integer type, String sort, String remark) + public Depot(String name, String address, Double warehousing, Double truckage, Integer type, String sort, String remark) { this.name = name; + this.address = address; + this.warehousing = warehousing; + this.truckage = truckage; this.type = type; this.sort = sort; this.remark = remark; @@ -43,6 +49,30 @@ public class Depot implements java.io.Serializable this.name = name; } + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public Double getWarehousing() { + return warehousing; + } + + public void setWarehousing(Double warehousing) { + this.warehousing = warehousing; + } + + public Double getTruckage() { + return truckage; + } + + public void setTruckage(Double truckage) { + this.truckage = truckage; + } + public Integer getType() { return type; } diff --git a/src/main/java/com/jsh/model/po/DepotHead.java b/src/main/java/com/jsh/model/po/DepotHead.java index 5593b409..13b00f5c 100644 --- a/src/main/java/com/jsh/model/po/DepotHead.java +++ b/src/main/java/com/jsh/model/po/DepotHead.java @@ -9,17 +9,29 @@ public class DepotHead implements java.io.Serializable private String Type; private String SubType; private Depot ProjectId; + private String DefaultNumber; private String Number; private String OperPersonName; private Timestamp CreateTime; private Timestamp OperTime; private Supplier OrganId; private Person HandsPersonId; + private String Salesman; //业务员(可以多个)[2][3] private Account AccountId; private Double ChangeAmount; + private String AccountIdList; //多账户ID列表 [2][3] + private String AccountMoneyList; //多账户金额列表 [{"[2]",22},{"[3]",33}] + private Double Discount; //优惠率 0.10 + private Double DiscountMoney; //优惠金额 10 + private Double DiscountLastMoney; //优惠后金额 90 + private Double OtherMoney; //销售或采购费用 100 + private String OtherMoneyList; //销售或采购费用涉及项目Id数组(包括快递、招待等)[2][3] + private String OtherMoneyItem; //销售费用涉及项目(包括快递、招待等) [{"[2]",22},{"[3]",33}] + private Integer AccountDay; //结算天数 private Depot AllocationProjectId; private Double TotalPrice; private String PayType; + private Boolean Status = false; //单据状态 private String Remark; public DepotHead() @@ -32,25 +44,36 @@ public class DepotHead implements java.io.Serializable this.Id = Id ; } - public DepotHead(String type, String subType, Depot projectId, - String number, String operPersonName, Timestamp createTime, - Timestamp operTime, Supplier organId, Person handsPersonId, - Account accountId, Double changeAmount, Depot allocationProjectId, Double totalPrice,String payType, String remark) { + public DepotHead(String type, String subType, Depot projectId, String defaultNumber, String number, String operPersonName, Timestamp createTime, + Timestamp operTime, Supplier organId, Person handsPersonId, String salesman, String accountIdList,String accountMoneyList, + Double discount, Double discountMoney,Double discountLastMoney, Double otherMoney, String otherMoneyItem,Integer accountDay, + Account accountId, Double changeAmount, Depot allocationProjectId, Double totalPrice,String payType, Boolean status, String remark) { super(); Type = type; SubType = subType; ProjectId = projectId; + DefaultNumber = defaultNumber; Number = number; OperPersonName = operPersonName; CreateTime = createTime; OperTime = operTime; OrganId = organId; HandsPersonId = handsPersonId; + Salesman= salesman; + AccountIdList= accountIdList; + AccountMoneyList= accountMoneyList; + Discount= discount; + DiscountMoney = discountMoney; + DiscountLastMoney = discountLastMoney; + OtherMoney = otherMoney; + OtherMoneyItem = otherMoneyItem; + AccountDay = accountDay; AccountId = accountId; ChangeAmount = changeAmount; AllocationProjectId = allocationProjectId; TotalPrice = totalPrice; PayType = payType; + Status = status; Remark = remark; } @@ -86,6 +109,14 @@ public class DepotHead implements java.io.Serializable ProjectId = projectId; } + public String getDefaultNumber() { + return DefaultNumber; + } + + public void setDefaultNumber(String defaultNumber) { + DefaultNumber = defaultNumber; + } + public String getNumber() { return Number; } @@ -181,4 +212,92 @@ public class DepotHead implements java.io.Serializable public void setRemark(String remark) { Remark = remark; } + + public String getSalesman() { + return Salesman; + } + + public void setSalesman(String salesman) { + Salesman = salesman; + } + + public String getAccountIdList() { + return AccountIdList; + } + + public void setAccountIdList(String accountIdList) { + AccountIdList = accountIdList; + } + + public String getAccountMoneyList() { + return AccountMoneyList; + } + + public void setAccountMoneyList(String accountMoneyList) { + AccountMoneyList = accountMoneyList; + } + + public Double getDiscount() { + return Discount; + } + + public void setDiscount(Double discount) { + Discount = discount; + } + + public Double getDiscountMoney() { + return DiscountMoney; + } + + public void setDiscountMoney(Double discountMoney) { + DiscountMoney = discountMoney; + } + + public Double getDiscountLastMoney() { + return DiscountLastMoney; + } + + public void setDiscountLastMoney(Double discountLastMoney) { + DiscountLastMoney = discountLastMoney; + } + + public Double getOtherMoney() { + return OtherMoney; + } + + public void setOtherMoney(Double otherMoney) { + OtherMoney = otherMoney; + } + + public String getOtherMoneyList() { + return OtherMoneyList; + } + + public void setOtherMoneyList(String otherMoneyList) { + OtherMoneyList = otherMoneyList; + } + + public String getOtherMoneyItem() { + return OtherMoneyItem; + } + + public void setOtherMoneyItem(String otherMoneyItem) { + OtherMoneyItem = otherMoneyItem; + } + + public Integer getAccountDay() { + return AccountDay; + } + + public void setAccountDay(Integer accountDay) { + AccountDay = accountDay; + } + + public Boolean getStatus() { + return Status; + } + + public void setStatus(Boolean status) { + Status = status; + } } \ No newline at end of file diff --git a/src/main/java/com/jsh/model/po/DepotItem.java b/src/main/java/com/jsh/model/po/DepotItem.java index f3cec78b..e53863c9 100644 --- a/src/main/java/com/jsh/model/po/DepotItem.java +++ b/src/main/java/com/jsh/model/po/DepotItem.java @@ -6,11 +6,25 @@ public class DepotItem implements java.io.Serializable private Long Id; private DepotHead HeaderId; private Material MaterialId; + private String MUnit; //计量单位 private Double OperNumber; + private Double BasicNumber; private Double UnitPrice; + private Double TaxUnitPrice; //含税单价 private Double AllPrice; private String Remark; private String Img; + private Depot DepotId; //仓库ID + private Depot AnotherDepotId; //对方仓库Id + private Double TaxRate; //税率 + private Double TaxMoney; //税额 + private Double TaxLastMoney; //价税合计 + private String OtherField1; //自定义字段1-品名 + private String OtherField2; //自定义字段2-型号 + private String OtherField3; //自定义字段3-制造商 + private String OtherField4; //自定义字段4 + private String OtherField5; //自定义字段5 + public DepotItem() { @@ -22,17 +36,31 @@ public class DepotItem implements java.io.Serializable this.Id = Id ; } - public DepotItem(DepotHead headerId, Material materialId, - Double operNumber, Double unitPrice, Double allPrice, - String remark, String img) { + public DepotItem(DepotHead headerId, Material materialId, String mUnit, + Double operNumber, Double basicNumber, Double unitPrice, Double taxUnitPrice, Double allPrice, String remark, String img, + Depot depotId, Depot anotherDepotId, Double taxRate, Double taxMoney, Double taxLastMoney, + String otherField1, String otherField2, String otherField3, String otherField4, String otherField5) { super(); HeaderId = headerId; MaterialId = materialId; + MUnit = mUnit; OperNumber = operNumber; + BasicNumber = basicNumber; UnitPrice = unitPrice; + TaxUnitPrice = taxUnitPrice; AllPrice = allPrice; Remark = remark; Img = img; + DepotId = depotId; + AnotherDepotId = anotherDepotId; + TaxRate = taxRate; + TaxMoney = taxMoney; + TaxLastMoney = taxLastMoney; + OtherField1 = otherField1; + OtherField2 = otherField2; + OtherField3 = otherField3; + OtherField4 = otherField4; + OtherField5 = otherField5; } public Long getId() { @@ -59,6 +87,22 @@ public class DepotItem implements java.io.Serializable MaterialId = materialId; } + public String getMUnit() { + return MUnit; + } + + public void setMUnit(String MUnit) { + this.MUnit = MUnit; + } + + public Double getTaxUnitPrice() { + return TaxUnitPrice; + } + + public void setTaxUnitPrice(Double taxUnitPrice) { + TaxUnitPrice = taxUnitPrice; + } + public Double getOperNumber() { return OperNumber; } @@ -67,6 +111,14 @@ public class DepotItem implements java.io.Serializable OperNumber = operNumber; } + public Double getBasicNumber() { + return BasicNumber; + } + + public void setBasicNumber(Double basicNumber) { + BasicNumber = basicNumber; + } + public Double getUnitPrice() { return UnitPrice; } @@ -99,5 +151,83 @@ public class DepotItem implements java.io.Serializable Img = img; } + public Depot getDepotId() { + return DepotId; + } + public void setDepotId(Depot depotId) { + DepotId = depotId; + } + + public Depot getAnotherDepotId() { + return AnotherDepotId; + } + + public void setAnotherDepotId(Depot anotherDepotId) { + AnotherDepotId = anotherDepotId; + } + + public Double getTaxRate() { + return TaxRate; + } + + public void setTaxRate(Double taxRate) { + TaxRate = taxRate; + } + + public Double getTaxMoney() { + return TaxMoney; + } + + public void setTaxMoney(Double taxMoney) { + TaxMoney = taxMoney; + } + + public Double getTaxLastMoney() { + return TaxLastMoney; + } + + public void setTaxLastMoney(Double taxLastMoney) { + TaxLastMoney = taxLastMoney; + } + + public String getOtherField1() { + return OtherField1; + } + + public void setOtherField1(String otherField1) { + OtherField1 = otherField1; + } + + public String getOtherField2() { + return OtherField2; + } + + public void setOtherField2(String otherField2) { + OtherField2 = otherField2; + } + + public String getOtherField3() { + return OtherField3; + } + + public void setOtherField3(String otherField3) { + OtherField3 = otherField3; + } + + public String getOtherField4() { + return OtherField4; + } + + public void setOtherField4(String otherField4) { + OtherField4 = otherField4; + } + + public String getOtherField5() { + return OtherField5; + } + + public void setOtherField5(String otherField5) { + OtherField5 = otherField5; + } } diff --git a/src/main/java/com/jsh/model/po/Functions.java b/src/main/java/com/jsh/model/po/Functions.java index 121c661c..f416c65e 100644 --- a/src/main/java/com/jsh/model/po/Functions.java +++ b/src/main/java/com/jsh/model/po/Functions.java @@ -11,7 +11,8 @@ public class Functions implements java.io.Serializable private Boolean State; private String Sort; private Boolean Enabled; - private String Type; + private String Type; + private String PushBtn; public Functions() { @@ -90,4 +91,11 @@ public class Functions implements java.io.Serializable Type = type; } + public String getPushBtn() { + return PushBtn; + } + + public void setPushBtn(String pushBtn) { + PushBtn = pushBtn; + } } \ No newline at end of file diff --git a/src/main/java/com/jsh/model/po/Material.java b/src/main/java/com/jsh/model/po/Material.java index 52517bf3..9fd5344f 100644 --- a/src/main/java/com/jsh/model/po/Material.java +++ b/src/main/java/com/jsh/model/po/Material.java @@ -1,11 +1,16 @@ package com.jsh.model.po; +import java.util.Map; + @SuppressWarnings("serial") public class Material implements java.io.Serializable { private Long Id; private MaterialCategory materialCategory; private String Name; + private String Mfrs; + private Double Packing; + private Double SafetyStock; private String Model; private String Standard; private String Color; @@ -14,7 +19,25 @@ public class Material implements java.io.Serializable private Double LowPrice; private Double PresetPriceOne; private Double PresetPriceTwo; + private Unit UnitId; + private String FirstOutUnit; + private String FirstInUnit; + private String PriceStrategy; private String Remark; + private Boolean Enabled; + + //----------以下属性导入exel表格使用-------------------- + /** + * 类型 right--正确 warn--警告 wrong--错误 + */ + private Map cellInfo; + + /** + * 行号 + */ + private Integer rowLineNum; + + private String safetyStockStr; public Material() { @@ -26,13 +49,16 @@ public class Material implements java.io.Serializable this.Id = Id; } - public Material(MaterialCategory materialCategory, String name, - String model, String standard, String color, String unit, String remark, - Double retailPrice, Double lowPrice, Double presetPriceOne, Double presetPriceTwo) - { + public Material(MaterialCategory materialCategory, String name, String mfrs, Double packing, + Double safetyStock, String model, String standard, String color, String unit, String remark, + Double retailPrice, Double lowPrice, Double presetPriceOne, Double presetPriceTwo, + Unit unitId, String firstOutUnit, String firstInUnit, String priceStrategy, Boolean enabled) { super(); this.materialCategory = materialCategory; Name = name; + Mfrs = mfrs; + Packing = packing; + SafetyStock = safetyStock; Model = model; Standard = standard; Color = color; @@ -42,6 +68,11 @@ public class Material implements java.io.Serializable PresetPriceOne = presetPriceOne; PresetPriceTwo = presetPriceTwo; Remark = remark; + UnitId = unitId; + FirstOutUnit = firstOutUnit; + FirstInUnit = firstInUnit; + PriceStrategy = priceStrategy; + Enabled = enabled; } public Long getId() @@ -102,17 +133,15 @@ public class Material implements java.io.Serializable Color = color; } - public String getUnit() - { + public String getUnit() { return Unit; } - public void setUnit(String unit) - { + public void setUnit(String unit) { Unit = unit; } - - public void setRetailPrice(Double retailPrice) + + public void setRetailPrice(Double retailPrice) { RetailPrice = retailPrice; } @@ -162,4 +191,91 @@ public class Material implements java.io.Serializable Remark = remark; } + public String getMfrs() { + return Mfrs; + } + + public void setMfrs(String mfrs) { + Mfrs = mfrs; + } + + public Double getPacking() { + return Packing; + } + + public void setPacking(Double packing) { + Packing = packing; + } + + public Double getSafetyStock() { + return SafetyStock; + } + + public void setSafetyStock(Double safetyStock) { + SafetyStock = safetyStock; + } + + public Unit getUnitId() { + return UnitId; + } + + public void setUnitId(Unit unitId) { + UnitId = unitId; + } + + public String getFirstOutUnit() { + return FirstOutUnit; + } + + public void setFirstOutUnit(String firstOutUnit) { + FirstOutUnit = firstOutUnit; + } + + public String getFirstInUnit() { + return FirstInUnit; + } + + public void setFirstInUnit(String firstInUnit) { + FirstInUnit = firstInUnit; + } + + public String getPriceStrategy() { + return PriceStrategy; + } + + public void setPriceStrategy(String priceStrategy) { + PriceStrategy = priceStrategy; + } + + public Boolean getEnabled() { + return Enabled; + } + + public void setEnabled(Boolean enabled) { + Enabled = enabled; + } + + public Map getCellInfo() { + return cellInfo; + } + + public void setCellInfo(Map cellInfo) { + this.cellInfo = cellInfo; + } + + public Integer getRowLineNum() { + return rowLineNum; + } + + public void setRowLineNum(Integer rowLineNum) { + this.rowLineNum = rowLineNum; + } + + public String getSafetyStockStr() { + return safetyStockStr; + } + + public void setSafetyStockStr(String safetyStockStr) { + this.safetyStockStr = safetyStockStr; + } } diff --git a/src/main/java/com/jsh/model/po/MaterialCategory.java b/src/main/java/com/jsh/model/po/MaterialCategory.java index 7aac5457..22bc933b 100644 --- a/src/main/java/com/jsh/model/po/MaterialCategory.java +++ b/src/main/java/com/jsh/model/po/MaterialCategory.java @@ -57,5 +57,5 @@ public class MaterialCategory implements java.io.Serializable public void setMaterialCategory(MaterialCategory materialCategory) { this.materialCategory = materialCategory; } - + } \ No newline at end of file diff --git a/src/main/java/com/jsh/model/po/Supplier.java b/src/main/java/com/jsh/model/po/Supplier.java index 5702713d..74db12da 100644 --- a/src/main/java/com/jsh/model/po/Supplier.java +++ b/src/main/java/com/jsh/model/po/Supplier.java @@ -1,22 +1,53 @@ package com.jsh.model.po; +import java.util.Map; + @SuppressWarnings("serial") public class Supplier implements java.io.Serializable { - private Long id; - private String supplier; - private String type; - private String contacts; - private String phonenum; - private String email; - private Double advanceIn; - private Double BeginNeedGet; - private Double BeginNeedPay; - private Double AllNeedGet; - private Double AllNeedPay; - private Short isystem; - private String description; - private Boolean enabled; + private Long id =0l; + private String supplier = ""; + private String type = ""; + private String contacts = ""; + private String phonenum = ""; + private String fax = ""; + private String telephone = ""; + private String email = ""; + private String address = ""; + private Double advanceIn = 0d; + private String taxNum = ""; + private String bankName = ""; + private String accountNumber = ""; + private Double taxRate = 0d; + private Double BeginNeedGet = 0d; + private Double BeginNeedPay = 0d; + private Double AllNeedGet = 0d; + private Double AllNeedPay = 0d; + private Short isystem = 1; + private String description = ""; + private Boolean enabled = true; + + //----------以下属性导入exel表格使用-------------------- + /** + * 类型 right--正确 warn--警告 wrong--错误 + */ + private Map cellInfo; + + /** + * 行号 + */ + private Integer rowLineNum; + + private String advanceInStr; + + private String beginNeedGetStr; + + private String beginNeedPayStr; + + private String taxRateStr; + + private String enabledStr; + public Supplier() { @@ -28,14 +59,18 @@ public class Supplier implements java.io.Serializable this.id = id; } - public Supplier(String supplier, String type, String contacts, String phonenum, - String email, Short isystem, String description, Boolean enabled, Double advanceIn, - Double beginNeedGet,Double beginNeedPay,Double allNeedGet,Double allNeedPay) { + public Supplier(String supplier, String type, String contacts, String phonenum, + String fax,String telephone, String email, String address, Short isystem, String description, + Boolean enabled, Double advanceIn, String taxNum,String bankName,String accountNumber, Double taxRate, + Double beginNeedGet,Double beginNeedPay,Double allNeedGet,Double allNeedPay) { super(); this.supplier = supplier; this.type = type; this.contacts = contacts; this.phonenum = phonenum; + this.fax = fax; + this.telephone = telephone; + this.address = address; this.email = email; this.BeginNeedGet = beginNeedGet; this.BeginNeedPay = beginNeedPay; @@ -45,6 +80,10 @@ public class Supplier implements java.io.Serializable this.description = description; this.enabled = enabled; this.advanceIn = advanceIn; + this.taxNum = taxNum; + this.bankName = bankName; + this.accountNumber = accountNumber; + this.taxRate = taxRate; } public Long getId() @@ -169,4 +208,116 @@ public class Supplier implements java.io.Serializable public void setAdvanceIn(Double advanceIn) { this.advanceIn = advanceIn; } + + public String getFax() { + return fax; + } + + public void setFax(String fax) { + this.fax = fax; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getTaxNum() { + return taxNum; + } + + public void setTaxNum(String taxNum) { + this.taxNum = taxNum; + } + + public String getBankName() { + return bankName; + } + + public void setBankName(String bankName) { + this.bankName = bankName; + } + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public Double getTaxRate() { + return taxRate; + } + + public void setTaxRate(Double taxRate) { + this.taxRate = taxRate; + } + + public Map getCellInfo() { + return cellInfo; + } + + public void setCellInfo(Map cellInfo) { + this.cellInfo = cellInfo; + } + + public Integer getRowLineNum() { + return rowLineNum; + } + + public void setRowLineNum(Integer rowLineNum) { + this.rowLineNum = rowLineNum; + } + + public String getAdvanceInStr() { + return advanceInStr; + } + + public void setAdvanceInStr(String advanceInStr) { + this.advanceInStr = advanceInStr; + } + + public String getBeginNeedGetStr() { + return beginNeedGetStr; + } + + public void setBeginNeedGetStr(String beginNeedGetStr) { + this.beginNeedGetStr = beginNeedGetStr; + } + + public String getBeginNeedPayStr() { + return beginNeedPayStr; + } + + public void setBeginNeedPayStr(String beginNeedPayStr) { + this.beginNeedPayStr = beginNeedPayStr; + } + + public String getTaxRateStr() { + return taxRateStr; + } + + public void setTaxRateStr(String taxRateStr) { + this.taxRateStr = taxRateStr; + } + + public String getEnabledStr() { + return enabledStr; + } + + public void setEnabledStr(String enabledStr) { + this.enabledStr = enabledStr; + } } diff --git a/src/main/java/com/jsh/model/po/Unit.java b/src/main/java/com/jsh/model/po/Unit.java new file mode 100644 index 00000000..a639d54f --- /dev/null +++ b/src/main/java/com/jsh/model/po/Unit.java @@ -0,0 +1,39 @@ +package com.jsh.model.po; + +@SuppressWarnings("serial") +public class Unit implements java.io.Serializable +{ + private Long id; + private String UName; + + public Unit() + { + + } + + public Unit(Long id) { + this.id = id; + } + + public Unit(String UName) + { + this.UName = UName; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUName() { + return UName; + } + + public void setUName(String UName) { + this.UName = UName; + } + +} \ No newline at end of file diff --git a/src/main/java/com/jsh/model/po/UserBusiness.java b/src/main/java/com/jsh/model/po/UserBusiness.java index 0505abdf..421dc5df 100644 --- a/src/main/java/com/jsh/model/po/UserBusiness.java +++ b/src/main/java/com/jsh/model/po/UserBusiness.java @@ -7,6 +7,7 @@ public class UserBusiness implements java.io.Serializable private String Type; private String KeyId; private String Value; + private String BtnStr; public UserBusiness() { @@ -44,6 +45,12 @@ public class UserBusiness implements java.io.Serializable public void setValue(String value) { Value = value; } - + public String getBtnStr() { + return BtnStr; + } + + public void setBtnStr(String btnStr) { + BtnStr = btnStr; + } } \ No newline at end of file diff --git a/src/main/java/com/jsh/model/vo/basic/DepotModel.java b/src/main/java/com/jsh/model/vo/basic/DepotModel.java index 4fdc3c00..d341ddd0 100644 --- a/src/main/java/com/jsh/model/vo/basic/DepotModel.java +++ b/src/main/java/com/jsh/model/vo/basic/DepotModel.java @@ -5,63 +5,67 @@ import java.io.Serializable; @SuppressWarnings("serial") public class DepotModel implements Serializable { - private DepotShowModel showModel = new DepotShowModel(); + private DepotShowModel showModel = new DepotShowModel(); - /**======开始接受页面参数=================**/ - /** - * 仓库名称 - */ - private String name = ""; + /**======开始接受页面参数=================**/ + /** + * 仓库名称 + */ + private String name = ""; - /** - * 排序 - */ - private String sort = ""; + private String address = ""; //仓库地址 + private Double warehousing; //仓储费 + private Double truckage; //搬运费 + + /** + * 排序 + */ + private String sort = ""; /** * 类型 */ private Integer type = 0; - - /** - * 描述 - */ - private String remark = ""; - - /** - * 分类ID - */ - private Long depotID = 0l; - - /** - * 分类IDs 批量操作使用 - */ - private String depotIDs = ""; - - /** - * 每页显示的个数 - */ - private int pageSize = 10; - - /** - * 当前页码 - */ - private int pageNo = 1; - - /** - * 用户IP,用户记录操作日志 - */ - private String clientIp = ""; - - /** - * UBType,UserBusiness类型 - */ - private String UBType = ""; - - /** - * UBKeyId,UserBusiness关键id - */ - private String UBKeyId = ""; + + /** + * 描述 + */ + private String remark = ""; + + /** + * 分类ID + */ + private Long depotID = 0l; + + /** + * 分类IDs 批量操作使用 + */ + private String depotIDs = ""; + + /** + * 每页显示的个数 + */ + private int pageSize = 10; + + /** + * 当前页码 + */ + private int pageNo = 1; + + /** + * 用户IP,用户记录操作日志 + */ + private String clientIp = ""; + + /** + * UBType,UserBusiness类型 + */ + private String UBType = ""; + + /** + * UBKeyId,UserBusiness关键id + */ + private String UBKeyId = ""; public DepotShowModel getShowModel() { return showModel; @@ -79,6 +83,30 @@ public class DepotModel implements Serializable this.name = name; } + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public Double getWarehousing() { + return warehousing; + } + + public void setWarehousing(Double warehousing) { + this.warehousing = warehousing; + } + + public Double getTruckage() { + return truckage; + } + + public void setTruckage(Double truckage) { + this.truckage = truckage; + } + public Integer getType() { return type; } diff --git a/src/main/java/com/jsh/model/vo/basic/FunctionsModel.java b/src/main/java/com/jsh/model/vo/basic/FunctionsModel.java index ccc3315a..865aa408 100644 --- a/src/main/java/com/jsh/model/vo/basic/FunctionsModel.java +++ b/src/main/java/com/jsh/model/vo/basic/FunctionsModel.java @@ -39,7 +39,11 @@ public class FunctionsModel implements Serializable /** * 类型 */ - private String Type = ""; + private String Type = ""; + /** + * 功能按钮 + */ + private String PushBtn = ""; /** * 拥有的功能列表 */ @@ -215,5 +219,11 @@ public class FunctionsModel implements Serializable this.hasFunctions = hasFunctions; } - + public String getPushBtn() { + return PushBtn; + } + + public void setPushBtn(String pushBtn) { + PushBtn = pushBtn; + } } diff --git a/src/main/java/com/jsh/model/vo/basic/SupplierModel.java b/src/main/java/com/jsh/model/vo/basic/SupplierModel.java index 53da4bdf..4884f561 100644 --- a/src/main/java/com/jsh/model/vo/basic/SupplierModel.java +++ b/src/main/java/com/jsh/model/vo/basic/SupplierModel.java @@ -1,5 +1,7 @@ package com.jsh.model.vo.basic; +import java.io.File; +import java.io.InputStream; import java.io.Serializable; @SuppressWarnings("serial") @@ -9,7 +11,7 @@ public class SupplierModel implements Serializable /**======开始接受页面参数=================**/ /** - * 供应商名称 + * 名称 */ private String supplier = ""; @@ -62,6 +64,23 @@ public class SupplierModel implements Serializable * 描述信息 */ private String description = ""; + + private String fax = ""; + private String telephone = ""; + private String address = ""; + private String taxNum = ""; + private String bankName = ""; + private String accountNumber = ""; + private Double taxRate; + + private String UBType = ""; //UBType,UserBusiness类型 + + private String UBKeyId = ""; //UBKeyId,UserBusiness关键id + + /** + * 导入excel文件 + */ + private File supplierFile; /** * 启用 @@ -92,6 +111,9 @@ public class SupplierModel implements Serializable * 用户IP,用户记录操作日志 */ private String clientIp = ""; + private String browserType = ""; //浏览器类型 + private String fileName = ""; //文件名称 + private InputStream excelStream; //输入流,导出excel文件 public SupplierShowModel getShowModel() { return showModel; @@ -245,6 +267,107 @@ public class SupplierModel implements Serializable this.clientIp = clientIp; } + public String getFax() { + return fax; + } + public void setFax(String fax) { + this.fax = fax; + } + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getTaxNum() { + return taxNum; + } + + public void setTaxNum(String taxNum) { + this.taxNum = taxNum; + } + + public String getBankName() { + return bankName; + } + + public void setBankName(String bankName) { + this.bankName = bankName; + } + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public Double getTaxRate() { + return taxRate; + } + + public void setTaxRate(Double taxRate) { + this.taxRate = taxRate; + } + + public String getUBType() { + return UBType; + } + + public void setUBType(String UBType) { + this.UBType = UBType; + } + + public String getUBKeyId() { + return UBKeyId; + } + + public void setUBKeyId(String UBKeyId) { + this.UBKeyId = UBKeyId; + } + + public String getBrowserType() { + return browserType; + } + + public void setBrowserType(String browserType) { + this.browserType = browserType; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public InputStream getExcelStream() { + return excelStream; + } + + public void setExcelStream(InputStream excelStream) { + this.excelStream = excelStream; + } + + public File getSupplierFile() { + return supplierFile; + } + + public void setSupplierFile(File supplierFile) { + this.supplierFile = supplierFile; + } } diff --git a/src/main/java/com/jsh/model/vo/basic/UnitModel.java b/src/main/java/com/jsh/model/vo/basic/UnitModel.java new file mode 100644 index 00000000..a261b46b --- /dev/null +++ b/src/main/java/com/jsh/model/vo/basic/UnitModel.java @@ -0,0 +1,98 @@ +package com.jsh.model.vo.basic; + +import java.io.Serializable; + +@SuppressWarnings("serial") +public class UnitModel implements Serializable +{ + private DepotShowModel showModel = new DepotShowModel(); + + /**======开始接受页面参数=================**/ + /** + * 名称 + */ + private String UName = ""; + + /** + * ID + */ + private Long unitID = 0l; + + /** + * IDs 批量操作使用 + */ + private String unitIDs = ""; + + /** + * 每页显示的个数 + */ + private int pageSize = 10; + + /** + * 当前页码 + */ + private int pageNo = 1; + + /** + * 用户IP,用户记录操作日志 + */ + private String clientIp = ""; + + + public DepotShowModel getShowModel() { + return showModel; + } + + public void setShowModel(DepotShowModel showModel) { + this.showModel = showModel; + } + + public String getUName() { + return UName; + } + + public void setUName(String UName) { + this.UName = UName; + } + + public Long getUnitID() { + return unitID; + } + + public void setUnitID(Long unitID) { + this.unitID = unitID; + } + + public String getUnitIDs() { + return unitIDs; + } + + public void setUnitIDs(String unitIDs) { + this.unitIDs = unitIDs; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getClientIp() { + return clientIp; + } + + public void setClientIp(String clientIp) { + this.clientIp = clientIp; + } + +} diff --git a/src/main/java/com/jsh/model/vo/basic/UnitShowModel.java b/src/main/java/com/jsh/model/vo/basic/UnitShowModel.java new file mode 100644 index 00000000..6ab9ca86 --- /dev/null +++ b/src/main/java/com/jsh/model/vo/basic/UnitShowModel.java @@ -0,0 +1,43 @@ +package com.jsh.model.vo.basic; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@SuppressWarnings("serial") +public class UnitShowModel implements Serializable +{ + /** + * 提示信息 + */ + private String msgTip = ""; + + /** + * 系统数据 + */ + @SuppressWarnings("rawtypes") + private Map map = new HashMap(); + + public String getMsgTip() + { + return msgTip; + } + + public void setMsgTip(String msgTip) + { + this.msgTip = msgTip; + } + + @SuppressWarnings("rawtypes") + public Map getMap() { + return map; + } + + @SuppressWarnings("rawtypes") + public void setMap(Map map) { + this.map = map; + } + + +} diff --git a/src/main/java/com/jsh/model/vo/basic/UserBusinessModel.java b/src/main/java/com/jsh/model/vo/basic/UserBusinessModel.java index f44f0d8b..eec667ac 100644 --- a/src/main/java/com/jsh/model/vo/basic/UserBusinessModel.java +++ b/src/main/java/com/jsh/model/vo/basic/UserBusinessModel.java @@ -22,6 +22,8 @@ public class UserBusinessModel implements Serializable * 值 */ private String Value = ""; + + private String BtnStr = ""; /** * 分类ID @@ -120,4 +122,11 @@ public class UserBusinessModel implements Serializable this.clientIp = clientIp; } + public String getBtnStr() { + return BtnStr; + } + + public void setBtnStr(String btnStr) { + BtnStr = btnStr; + } } diff --git a/src/main/java/com/jsh/model/vo/materials/DepotHeadModel.java b/src/main/java/com/jsh/model/vo/materials/DepotHeadModel.java index 1f04f5d6..5b855c45 100644 --- a/src/main/java/com/jsh/model/vo/materials/DepotHeadModel.java +++ b/src/main/java/com/jsh/model/vo/materials/DepotHeadModel.java @@ -12,6 +12,7 @@ public class DepotHeadModel implements Serializable private String SubType = ""; private Long ProjectId; private String DepotIds = ""; + private String DefaultNumber = ""; private String Number = ""; private String OperPersonName = ""; private String OperTime; @@ -22,7 +23,19 @@ public class DepotHeadModel implements Serializable private Long AllocationProjectId; private Double TotalPrice; private String PayType = ""; - private String Remark = ""; + private String Remark = ""; + + private String Salesman; + private String AccountIdList; + private String AccountMoneyList; + private Double Discount; + private Double DiscountMoney; + private Double DiscountLastMoney; + private Double OtherMoney; + private String OtherMoneyList; + private String OtherMoneyItem; + private Integer AccountDay; + private Boolean Status = false; //单据状态 private String BeginTime; //查询开始时间 private String EndTime; //查询结束时间 @@ -95,6 +108,14 @@ public class DepotHeadModel implements Serializable DepotIds = depotIds; } + public String getDefaultNumber() { + return DefaultNumber; + } + + public void setDefaultNumber(String defaultNumber) { + DefaultNumber = defaultNumber; + } + public String getNumber() { return Number; } @@ -254,6 +275,92 @@ public class DepotHeadModel implements Serializable public void setSupplierId(String supplierId) { this.supplierId = supplierId; } - - + + public String getSalesman() { + return Salesman; + } + + public void setSalesman(String salesman) { + Salesman = salesman; + } + + public String getAccountIdList() { + return AccountIdList; + } + + public void setAccountIdList(String accountIdList) { + AccountIdList = accountIdList; + } + + public String getAccountMoneyList() { + return AccountMoneyList; + } + + public void setAccountMoneyList(String accountMoneyList) { + AccountMoneyList = accountMoneyList; + } + + public Double getDiscount() { + return Discount; + } + + public void setDiscount(Double discount) { + Discount = discount; + } + + public Double getDiscountMoney() { + return DiscountMoney; + } + + public void setDiscountMoney(Double discountMoney) { + DiscountMoney = discountMoney; + } + + public Double getDiscountLastMoney() { + return DiscountLastMoney; + } + + public void setDiscountLastMoney(Double discountLastMoney) { + DiscountLastMoney = discountLastMoney; + } + + public Double getOtherMoney() { + return OtherMoney; + } + + public void setOtherMoney(Double otherMoney) { + OtherMoney = otherMoney; + } + + public String getOtherMoneyList() { + return OtherMoneyList; + } + + public void setOtherMoneyList(String otherMoneyList) { + OtherMoneyList = otherMoneyList; + } + + public String getOtherMoneyItem() { + return OtherMoneyItem; + } + + public void setOtherMoneyItem(String otherMoneyItem) { + OtherMoneyItem = otherMoneyItem; + } + + public Integer getAccountDay() { + return AccountDay; + } + + public void setAccountDay(Integer accountDay) { + AccountDay = accountDay; + } + + public Boolean getStatus() { + return Status; + } + + public void setStatus(Boolean status) { + Status = status; + } } diff --git a/src/main/java/com/jsh/model/vo/materials/DepotItemModel.java b/src/main/java/com/jsh/model/vo/materials/DepotItemModel.java index c4bc607a..8cfbed5f 100644 --- a/src/main/java/com/jsh/model/vo/materials/DepotItemModel.java +++ b/src/main/java/com/jsh/model/vo/materials/DepotItemModel.java @@ -11,11 +11,25 @@ public class DepotItemModel implements Serializable /**======开始接受页面参数=================**/ private Long HeaderId; private Long MaterialId; + private String MUnit; //计量单位 private Double OperNumber; + private Double BasicNumber; private Double UnitPrice; + private Double TaxUnitPrice; //含税单价 private Double AllPrice; private String Remark = ""; private String Img = ""; + + private Long DepotId; + private Long AnotherDepotId; + private Double TaxRate; + private Double TaxMoney; + private Double TaxLastMoney; + private String OtherField1; + private String OtherField2; + private String OtherField3; + private String OtherField4; + private String OtherField5; private String Inserted = ""; //json插入记录 private String Deleted = ""; //json删除记录 @@ -85,6 +99,22 @@ public class DepotItemModel implements Serializable MaterialId = materialId; } + public String getMUnit() { + return MUnit; + } + + public void setMUnit(String MUnit) { + this.MUnit = MUnit; + } + + public Double getTaxUnitPrice() { + return TaxUnitPrice; + } + + public void setTaxUnitPrice(Double taxUnitPrice) { + TaxUnitPrice = taxUnitPrice; + } + public Double getOperNumber() { return OperNumber; } @@ -93,6 +123,14 @@ public class DepotItemModel implements Serializable OperNumber = operNumber; } + public Double getBasicNumber() { + return BasicNumber; + } + + public void setBasicNumber(Double basicNumber) { + BasicNumber = basicNumber; + } + public Double getUnitPrice() { return UnitPrice; } @@ -244,4 +282,84 @@ public class DepotItemModel implements Serializable public void setExcelStream(InputStream excelStream) { this.excelStream = excelStream; } + + public Long getDepotId() { + return DepotId; + } + + public void setDepotId(Long depotId) { + DepotId = depotId; + } + + public Long getAnotherDepotId() { + return AnotherDepotId; + } + + public void setAnotherDepotId(Long anotherDepotId) { + AnotherDepotId = anotherDepotId; + } + + public Double getTaxRate() { + return TaxRate; + } + + public void setTaxRate(Double taxRate) { + TaxRate = taxRate; + } + + public Double getTaxMoney() { + return TaxMoney; + } + + public void setTaxMoney(Double taxMoney) { + TaxMoney = taxMoney; + } + + public Double getTaxLastMoney() { + return TaxLastMoney; + } + + public void setTaxLastMoney(Double taxLastMoney) { + TaxLastMoney = taxLastMoney; + } + + public String getOtherField1() { + return OtherField1; + } + + public void setOtherField1(String otherField1) { + OtherField1 = otherField1; + } + + public String getOtherField2() { + return OtherField2; + } + + public void setOtherField2(String otherField2) { + OtherField2 = otherField2; + } + + public String getOtherField3() { + return OtherField3; + } + + public void setOtherField3(String otherField3) { + OtherField3 = otherField3; + } + + public String getOtherField4() { + return OtherField4; + } + + public void setOtherField4(String otherField4) { + OtherField4 = otherField4; + } + + public String getOtherField5() { + return OtherField5; + } + + public void setOtherField5(String otherField5) { + OtherField5 = otherField5; + } } diff --git a/src/main/java/com/jsh/model/vo/materials/MaterialModel.java b/src/main/java/com/jsh/model/vo/materials/MaterialModel.java index e79c17bf..52e5816d 100644 --- a/src/main/java/com/jsh/model/vo/materials/MaterialModel.java +++ b/src/main/java/com/jsh/model/vo/materials/MaterialModel.java @@ -1,5 +1,7 @@ package com.jsh.model.vo.materials; +import java.io.File; +import java.io.InputStream; import java.io.Serializable; @SuppressWarnings("serial") @@ -12,7 +14,12 @@ public class MaterialModel implements Serializable * 名称 */ private String Name = ""; - + + private String Mfrs = ""; //制造商 + + private Double Packing; //包装(KG/包) + + private Double SafetyStock; //安全存量(KG) /** * 型号 */ @@ -31,7 +38,7 @@ public class MaterialModel implements Serializable /** * 单位 */ - private String Unit = ""; + private String Unit = ""; /** * 零售价 @@ -57,6 +64,18 @@ public class MaterialModel implements Serializable * 备注 */ private String Remark = ""; + + private Long UnitId; + private String FirstOutUnit; + private String FirstInUnit; + private String PriceStrategy; + + /** + * 导入excel文件 + */ + private File materialFile; + + private Boolean Enabled = true; //是否启用 /** * CategoryId @@ -93,6 +112,10 @@ public class MaterialModel implements Serializable */ private String clientIp = ""; + private String browserType = ""; //浏览器类型 + private String fileName = ""; //文件名称 + private InputStream excelStream; //输入流,导出excel文件 + public MaterialShowModel getShowModel() { return showModel; } @@ -109,6 +132,30 @@ public class MaterialModel implements Serializable Name = name; } + public String getMfrs() { + return Mfrs; + } + + public void setMfrs(String mfrs) { + Mfrs = mfrs; + } + + public Double getPacking() { + return Packing; + } + + public void setPacking(Double packing) { + Packing = packing; + } + + public Double getSafetyStock() { + return SafetyStock; + } + + public void setSafetyStock(Double safetyStock) { + SafetyStock = safetyStock; + } + public String getModel() { return Model; } @@ -140,8 +187,8 @@ public class MaterialModel implements Serializable public void setUnit(String unit) { Unit = unit; } - - public void setRetailPrice(Double retailPrice) + + public void setRetailPrice(Double retailPrice) { RetailPrice = retailPrice; } @@ -245,4 +292,75 @@ public class MaterialModel implements Serializable CategoryIds = categoryIds; } + public Long getUnitId() { + return UnitId; + } + + public void setUnitId(Long unitId) { + UnitId = unitId; + } + + public String getFirstOutUnit() { + return FirstOutUnit; + } + + public void setFirstOutUnit(String firstOutUnit) { + FirstOutUnit = firstOutUnit; + } + + public String getFirstInUnit() { + return FirstInUnit; + } + + public void setFirstInUnit(String firstInUnit) { + FirstInUnit = firstInUnit; + } + + public String getPriceStrategy() { + return PriceStrategy; + } + + public void setPriceStrategy(String priceStrategy) { + PriceStrategy = priceStrategy; + } + + public Boolean getEnabled() { + return Enabled; + } + + public void setEnabled(Boolean enabled) { + Enabled = enabled; + } + + public String getBrowserType() { + return browserType; + } + + public void setBrowserType(String browserType) { + this.browserType = browserType; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public InputStream getExcelStream() { + return excelStream; + } + + public void setExcelStream(InputStream excelStream) { + this.excelStream = excelStream; + } + + public File getMaterialFile() { + return materialFile; + } + + public void setMaterialFile(File materialFile) { + this.materialFile = materialFile; + } } diff --git a/src/main/java/com/jsh/service/basic/SupplierIService.java b/src/main/java/com/jsh/service/basic/SupplierIService.java index a5fb7fec..3a637968 100644 --- a/src/main/java/com/jsh/service/basic/SupplierIService.java +++ b/src/main/java/com/jsh/service/basic/SupplierIService.java @@ -2,8 +2,17 @@ package com.jsh.service.basic; import com.jsh.base.BaseIService; import com.jsh.model.po.Supplier; +import com.jsh.util.JshException; +import com.jsh.util.PageUtil; + +import java.io.File; +import java.io.InputStream; public interface SupplierIService extends BaseIService { + public void batchSetEnable(Boolean enable,String supplierIDs); + public InputStream exmportExcel(String isAllPage,PageUtil pageUtil)throws JshException; + + public InputStream importExcel(File assetFile)throws JshException; } diff --git a/src/main/java/com/jsh/service/basic/SupplierService.java b/src/main/java/com/jsh/service/basic/SupplierService.java index d7922743..731c7cbd 100644 --- a/src/main/java/com/jsh/service/basic/SupplierService.java +++ b/src/main/java/com/jsh/service/basic/SupplierService.java @@ -1,27 +1,459 @@ package com.jsh.service.basic; import com.jsh.base.BaseService; +import com.jsh.base.Log; import com.jsh.dao.basic.SupplierIDAO; +import com.jsh.dao.basic.UserBusinessIDAO; import com.jsh.model.po.Supplier; -import com.jsh.util.JshException; +import com.jsh.util.*; +import jxl.Workbook; +import jxl.format.Colour; +import jxl.write.*; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; + +import java.io.*; +import java.lang.Boolean; +import java.util.*; public class SupplierService extends BaseService implements SupplierIService { @SuppressWarnings("unused") private SupplierIDAO supplierDao; + @SuppressWarnings("unused") + private UserBusinessIDAO userBusinessDao; + + /** + * 设置映射基类 + * @return + */ + @Override + protected Class getEntityClass() + { + return Supplier.class; + } public void setSupplierDao(SupplierIDAO supplierDao) { this.supplierDao = supplierDao; } - /** - * 设置映射基类 - * @return - */ - @Override - protected Class getEntityClass() - { - return Supplier.class; - } + public void setUserBusinessDao(UserBusinessIDAO userBusinessDao) { + this.userBusinessDao = userBusinessDao; + } + + public void batchSetEnable(Boolean enable,String supplierIDs){ + supplierDao.batchSetEnable(enable, supplierIDs); + } + + /** + * 初始化加载所有系统基础数据 + */ + @SuppressWarnings({"rawtypes"}) + private static Map mapData = new HashMap(); + + /** + * 错误的表格数据 + */ + private static List wrongData = new ArrayList(); + /** + * 导出Excel表格 + */ + @Override + public InputStream exmportExcel(String isAllPage, PageUtil pageUtil)throws JshException + { + try + { + //将OutputStream转化为InputStream + ByteArrayOutputStream out = new ByteArrayOutputStream(); + putDataOnOutputStream(out, pageUtil.getPageList()); + return new ByteArrayInputStream(out.toByteArray()); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常", e); + throw new JshException("导出信息为excel表格异常",e); + } + } + + /** + * 生成excel表格 + * @param os + */ + @SuppressWarnings("deprecation") + private void putDataOnOutputStream(OutputStream os, List dataList) { + WritableWorkbook workbook = null; + try { + workbook = Workbook.createWorkbook(os); + WritableSheet sheet = workbook.createSheet("信息报表", 0); + //增加列头 + String[] colunmName = {"名称","类型","联系人","电话","电子邮箱","预收款","期初应收","期初应付","备注","传真","手机","地址","纳税人识别号","开户行","账号","税率","状态"}; + for(int i = 0 ;i < colunmName.length;i ++) { + sheet.setColumnView(i, 10); + sheet.addCell(new Label(i, 0, colunmName[i])); + } + if (null != dataList && dataList.size() > 0) { + int i = 1; + for (Supplier supplier: dataList){ + int j = 0; + Map cellInfo = supplier.getCellInfo(); + sheet.addCell(new Label(j++,i, supplier.getSupplier())); + sheet.addCell(new Label(j++,i, supplier.getType())); + sheet.addCell(new Label(j++,i, supplier.getContacts() == null ?"": supplier.getContacts())); + sheet.addCell(new Label(j++,i, supplier.getPhonenum() == null ?"": supplier.getPhonenum())); + sheet.addCell(new Label(j++,i, supplier.getEmail() == null ?"": supplier.getEmail())); + sheet.addCell(getLabelInfo(cellInfo,j++,i, supplier.getAdvanceIn() == null ?"": supplier.getAdvanceIn().toString(),supplier)); + sheet.addCell(getLabelInfo(cellInfo,j++,i, supplier.getBeginNeedGet() == null ?"": supplier.getBeginNeedGet().toString(),supplier)); + sheet.addCell(getLabelInfo(cellInfo,j++,i, supplier.getBeginNeedPay() == null ?"": supplier.getBeginNeedPay().toString(),supplier)); + sheet.addCell(new Label(j++,i, supplier.getDescription() == null ?"": supplier.getDescription())); + sheet.addCell(new Label(j++,i, supplier.getFax() == null ?"": supplier.getFax())); + sheet.addCell(new Label(j++,i, supplier.getTelephone() == null ?"": supplier.getTelephone())); + sheet.addCell(new Label(j++,i, supplier.getAddress() == null ?"": supplier.getAddress())); + sheet.addCell(new Label(j++,i, supplier.getTaxNum() == null ?"": supplier.getTaxNum())); + sheet.addCell(new Label(j++,i, supplier.getBankName() == null ?"": supplier.getBankName())); + sheet.addCell(new Label(j++,i, supplier.getAccountNumber() == null ?"": supplier.getAccountNumber())); + sheet.addCell(getLabelInfo(cellInfo,j++,i, supplier.getTaxRate() == null ?"": supplier.getTaxRate().toString(),supplier)); + sheet.addCell(new Label(j++,i, supplier.getEnabled()?"启用":"禁用")); + i++; + } + } + workbook.write(); + workbook.close(); + } + catch (Exception e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常", e); + } + } + + /** + * 根据错误信息进行提示--excel表格背景设置为红色,表示导入信息有误 + * @param cellInfo + * @param cellNum + * @param columnNum + * @param value + * @return + */ + private Label getLabelInfo(Map cellInfo,int cellNum,int columnNum,String value,Supplier supplier) + { + Label label = null; + + //设置背景颜色 + WritableCellFormat cellFormat = new WritableCellFormat(); + try + { + cellFormat.setBackground(Colour.RED); + } + catch (WriteException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>设置单元格背景颜色错误", e); + } + + if(null == cellInfo || cellInfo.size() == 0) { + label = new Label(cellNum, columnNum, value); + } + else { + //表示此单元格有错误 + if(cellInfo.containsKey(cellNum)) { + if(cellNum == SupplierConstants.BusinessForExcel.EXCEL_ADVANCE_IN) { + label = new Label(cellNum, columnNum, supplier.getAdvanceInStr(), cellFormat); + } + else if(cellNum == SupplierConstants.BusinessForExcel.EXCEL_BEGIN_NEED_GET) { + label = new Label(cellNum, columnNum, supplier.getBeginNeedGetStr(), cellFormat); + } + else if(cellNum == SupplierConstants.BusinessForExcel.EXCEL_BEGIN_NEED_PAY) { + label = new Label(cellNum, columnNum, supplier.getBeginNeedPayStr(), cellFormat); + } + else if(cellNum == SupplierConstants.BusinessForExcel.EXCEL_TAX_RATE) { + label = new Label(cellNum, columnNum, supplier.getTaxRateStr(), cellFormat); + } + } + else{ + label = new Label(cellNum, columnNum, value); + } + } + return label; + } + + @Override + public InputStream importExcel(File assetFile) throws JshException { + //全局变量--每次调用前需要清空数据 + mapData.clear(); + //2、解析文件成资产数据 + parseFile(assetFile); + + if(null != wrongData && wrongData.size()>0) { + //将OutputStream转化为InputStream + ByteArrayOutputStream out = new ByteArrayOutputStream(); + putDataOnOutputStream(out,wrongData); + return new ByteArrayInputStream(out.toByteArray()); + } + else{ + return null; + } + } + + + /** + * 解析excel表格 + * @param assetFile + */ + @SuppressWarnings("unchecked") + private void parseFile(File assetFile) { + //每次调用前清空 + wrongData.clear(); + int totalRow = 0; + try { + //创建对Excel工作簿文件的引用 + HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(assetFile)); + //创建对工作表的引用,获取第一个工作表的内容 + HSSFSheet sheet = workbook.getSheetAt(0); + /** + * ===================================== + * 1、此处要增加文件的验证,如果不是资产文件需要进行特殊的处理,13列 + * 2、文件内容为空处理 + * 3、如果是修改过的文件内容 + */ + Iterator itsheet = sheet.rowIterator(); + while(itsheet.hasNext()) { + //获取当前行数据 + Row row = itsheet.next(); + //获取一行有多少单元格 +// System.out.println(row.getLastCellNum()); + + //excel表格第几行数据 从1开始 0 是表头 + int rowNum = row.getRowNum(); + /** + * 表头跳过不读 + */ + if(SupplierConstants.BusinessForExcel.EXCEL_TABLE_HEAD == rowNum) + continue; + + //开始处理excel表格内容 --每行数据读取,同时统计总共行数 + totalRow ++; + + //获取excel表格的每格数据内容 + Iterator it = row.cellIterator(); + //资产子类型--添加了一些excel表格数据 + Supplier supplier = new Supplier(); + //保存每个单元格错误类型 + Map cellType = new HashMap(); + Boolean hasBeginNeedGet = false; //是否存在期初应付 + //设置列号 + supplier.setRowLineNum(rowNum); + + Cell cell = null; + //判断列号--从零开始 + int cellIndex = 0; + while(it.hasNext()) { + //获取每个单元格对象 + cell = it.next(); + //获取列号 + cellIndex = cell.getColumnIndex(); + //设置此单元格为字符串类型 + cell.setCellType(Cell.CELL_TYPE_STRING); + + Log.infoFileSync("==================excel表格中第" + totalRow + "行的第 " + cellIndex + "列的值为" + cell.getStringCellValue()); + + //每行中数据顺序 "名称","类型","联系人","电话","电子邮箱","预收款","期初应收","期初应付","备注","传真","手机","地址","纳税人识别号","开户行","账号","税率" + switch(cellIndex) { + case SupplierConstants.BusinessForExcel.EXCEL_SUPPLIER : + String supplierName = cell.getStringCellValue(); + if(null == supplierName || "".equals(supplierName)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(名称)信息"); + break; + } + supplier.setSupplier(supplierName); + break; + case SupplierConstants.BusinessForExcel.EXCEL_TYPE : + String type = cell.getStringCellValue(); + if(null == type || "".equals(type)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(类型)信息"); + break; + } + supplier.setType(type); + break; + case SupplierConstants.BusinessForExcel.EXCEL_CONTACTS: + String contacts = cell.getStringCellValue(); + if(null == contacts || "".equals(contacts)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(联系人)信息"); + break; + } + supplier.setContacts(contacts); + break; + case SupplierConstants.BusinessForExcel.EXCEL_PHONE_NUM : + String phoneNum = cell.getStringCellValue(); + if(null == phoneNum || "".equals(phoneNum)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(电话)信息"); + break; + } + supplier.setPhonenum(phoneNum); + break; + case SupplierConstants.BusinessForExcel.EXCEL_EMAIL : + String email = cell.getStringCellValue(); + if(null == email || "".equals(email)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(电子邮箱)信息"); + break; + } + supplier.setEmail(email); + break; + case SupplierConstants.BusinessForExcel.EXCEL_ADVANCE_IN : + String advanceIn = cell.getStringCellValue(); + if(null == advanceIn || "".equals(advanceIn)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(预收款)信息"); + break; + } + if(Tools.checkStrIsNum(advanceIn)) { + supplier.setAdvanceIn(Double.parseDouble(advanceIn)); + } + else{ + Log.errorFileSync(">>>>>>>>>>>>>>>>>(预收款)不是数字格式"); + cellType.put(cellIndex, "wrong"); + supplier.setAdvanceIn(0.00d); + supplier.setAdvanceInStr(advanceIn); + } + break; + case SupplierConstants.BusinessForExcel.EXCEL_BEGIN_NEED_GET : + String beginNeedGet = cell.getStringCellValue(); + if(null == beginNeedGet || "".equals(beginNeedGet)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(期初应收)信息"); + break; + } + if(Tools.checkStrIsNum(beginNeedGet) && Double.parseDouble(beginNeedGet)>=0) { + if(Double.parseDouble(beginNeedGet)>0) { + hasBeginNeedGet = true; //存在期初应付信息 + } + supplier.setBeginNeedGet(Double.parseDouble(beginNeedGet)); + } + else{ + Log.errorFileSync(">>>>>>>>>>>>>>>>>(期初应收)不是数字格式"); + cellType.put(cellIndex, "wrong"); + supplier.setBeginNeedGet(0.00d); + supplier.setBeginNeedGetStr(beginNeedGet); + } + break; + case SupplierConstants.BusinessForExcel.EXCEL_BEGIN_NEED_PAY : + String beginNeedPay = cell.getStringCellValue(); + if(null == beginNeedPay || "".equals(beginNeedPay)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(期初应付)信息"); + break; + } + if(Tools.checkStrIsNum(beginNeedPay) && Double.parseDouble(beginNeedPay)>=0) { + if(hasBeginNeedGet){ //同时存在不允许 + Log.errorFileSync(">>>>>>>>>>>>>>>>>(期初应付)和期初应收不能同时存在"); + cellType.put(cellIndex, "wrong"); + supplier.setBeginNeedPay(0.00d); + supplier.setBeginNeedPayStr(beginNeedPay); + } + else { + supplier.setBeginNeedPay(Double.parseDouble(beginNeedPay)); + } + } + else{ + Log.errorFileSync(">>>>>>>>>>>>>>>>>(期初应付)不是数字格式"); + cellType.put(cellIndex, "wrong"); + supplier.setBeginNeedPay(0.00d); + supplier.setBeginNeedPayStr(beginNeedPay); + } + break; + case SupplierConstants.BusinessForExcel.EXCEL_DESCRIPTION : + String description = cell.getStringCellValue(); + if(null == description || "".equals(description)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(备注)信息"); + break; + } + supplier.setDescription(description); + break; + case SupplierConstants.BusinessForExcel.EXCEL_FAX : + String fax = cell.getStringCellValue(); + if(null == fax || "".equals(fax)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(传真)信息"); + break; + } + supplier.setFax(fax); + break; + case SupplierConstants.BusinessForExcel.EXCEL_TELEPHONE : + String telephone = cell.getStringCellValue(); + if(null == telephone || "".equals(telephone)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(手机)信息"); + break; + } + supplier.setTelephone(telephone); + break; + case SupplierConstants.BusinessForExcel.EXCEL_ADDRESS : + String address = cell.getStringCellValue(); + if(null == address || "".equals(address)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(地址)信息"); + break; + } + supplier.setAddress(address); + break; + case SupplierConstants.BusinessForExcel.EXCEL_TAX_NUM : + String taxNum = cell.getStringCellValue(); + if(null == taxNum || "".equals(taxNum)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(纳税人识别号)信息"); + break; + } + supplier.setTaxNum(taxNum); + break; + case SupplierConstants.BusinessForExcel.EXCEL_BANK_NAME : + String bankName = cell.getStringCellValue(); + if(null == bankName || "".equals(bankName)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(开户行)信息"); + break; + } + supplier.setBankName(bankName); + break; + case SupplierConstants.BusinessForExcel.EXCEL_ACCOUNT_NUMBER : + String accountNumber = cell.getStringCellValue(); + if(null == accountNumber || "".equals(accountNumber)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(账号)信息"); + break; + } + supplier.setAccountNumber(accountNumber); + break; + case SupplierConstants.BusinessForExcel.EXCEL_TAX_RATE : + String taxRate = cell.getStringCellValue(); + if(null == taxRate || "".equals(taxRate)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(税率)信息"); + break; + } + if(Tools.checkStrIsNum(taxRate)) { + supplier.setTaxRate(Double.parseDouble(taxRate)); + } + else{ + Log.errorFileSync(">>>>>>>>>>>>>>>>>(税率)不是数字格式"); + cellType.put(cellIndex, "wrong"); + supplier.setTaxRate(0.00d); + supplier.setTaxRateStr(taxRate); + } + break; + } + } + supplier.setCellInfo(cellType); + + Log.infoFileSync(totalRow + "行总共有" + cellIndex + "列"); + + //判断完成后增加数据 + if((null!=cellType && cellType.size() >0) || supplier.getSupplier() == null) { + wrongData.add(supplier); + } + else { + supplier.setEnabled(true); + supplier.setIsystem((short)1); + supplierDao.save(supplier); + } + } + } + catch (FileNotFoundException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>读取excel文件异常:找不到指定文件!",e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>读取excel文件异常,请确认文件格式是否正确 !",e); + } + Log.infoFileSync("===================excel表格总共有 " + totalRow + " 条记录!"); + } } diff --git a/src/main/java/com/jsh/service/basic/UnitIService.java b/src/main/java/com/jsh/service/basic/UnitIService.java new file mode 100644 index 00000000..13638946 --- /dev/null +++ b/src/main/java/com/jsh/service/basic/UnitIService.java @@ -0,0 +1,9 @@ +package com.jsh.service.basic; + +import com.jsh.base.BaseIService; +import com.jsh.model.po.Unit; + +public interface UnitIService extends BaseIService +{ + +} diff --git a/src/main/java/com/jsh/service/basic/UnitService.java b/src/main/java/com/jsh/service/basic/UnitService.java new file mode 100644 index 00000000..049ab3db --- /dev/null +++ b/src/main/java/com/jsh/service/basic/UnitService.java @@ -0,0 +1,24 @@ +package com.jsh.service.basic; + +import com.jsh.base.BaseService; +import com.jsh.dao.basic.UnitIDAO; +import com.jsh.model.po.Unit; + +public class UnitService extends BaseService implements UnitIService +{ + @SuppressWarnings("unused") + private UnitIDAO unitDao; + + + public void setUnitDao(UnitIDAO unitDao) + { + this.unitDao = unitDao; + } + + @Override + protected Class getEntityClass() + { + return Unit.class; + } + +} diff --git a/src/main/java/com/jsh/service/materials/DepotHeadIService.java b/src/main/java/com/jsh/service/materials/DepotHeadIService.java index 5e7d38d9..20defb42 100644 --- a/src/main/java/com/jsh/service/materials/DepotHeadIService.java +++ b/src/main/java/com/jsh/service/materials/DepotHeadIService.java @@ -15,7 +15,5 @@ public interface DepotHeadIService extends BaseIService void findAllMoney(PageUtil depotHead, Integer supplierId, String type, String subType, String mode)throws JshException; - public void findInDetail(PageUtil pageUtil,String beginTime,String endTime, String type, Long pid,String dids)throws JshException; - - public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime, String type, Long pid,String dids)throws JshException; + public void batchSetStatus(Boolean status,String depotHeadIDs); } diff --git a/src/main/java/com/jsh/service/materials/DepotHeadService.java b/src/main/java/com/jsh/service/materials/DepotHeadService.java index b344a05f..52e466d0 100644 --- a/src/main/java/com/jsh/service/materials/DepotHeadService.java +++ b/src/main/java/com/jsh/service/materials/DepotHeadService.java @@ -34,11 +34,7 @@ public class DepotHeadService extends BaseService implements DepotHea depotHeadDao.findAllMoney(pageUtil, supplierId, type, subType, mode); } - public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException { - depotHeadDao.findInDetail(pageUtil,beginTime,endTime,type,pid,dids); - } - - public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException { - depotHeadDao.findInOutMaterialCount(pageUtil,beginTime,endTime,type,pid,dids); + public void batchSetStatus(Boolean status,String depotHeadIDs){ + depotHeadDao.batchSetStatus(status, depotHeadIDs); } } diff --git a/src/main/java/com/jsh/service/materials/MaterialIService.java b/src/main/java/com/jsh/service/materials/MaterialIService.java index 47802496..681a4347 100644 --- a/src/main/java/com/jsh/service/materials/MaterialIService.java +++ b/src/main/java/com/jsh/service/materials/MaterialIService.java @@ -2,8 +2,19 @@ package com.jsh.service.materials; import com.jsh.base.BaseIService; import com.jsh.model.po.Material; +import com.jsh.util.JshException; +import com.jsh.util.PageUtil; + +import java.io.File; +import java.io.InputStream; public interface MaterialIService extends BaseIService { - + public void batchSetEnable(Boolean enable,String supplierIDs); + + public void findUnitName(PageUtil material, Long mId)throws JshException; + + public InputStream exmportExcel(String isAllPage,PageUtil pageUtil)throws JshException; + + public InputStream importExcel(File materialFile)throws JshException; } diff --git a/src/main/java/com/jsh/service/materials/MaterialService.java b/src/main/java/com/jsh/service/materials/MaterialService.java index a4d3921a..485861bb 100644 --- a/src/main/java/com/jsh/service/materials/MaterialService.java +++ b/src/main/java/com/jsh/service/materials/MaterialService.java @@ -1,8 +1,25 @@ package com.jsh.service.materials; import com.jsh.base.BaseService; +import com.jsh.base.Log; import com.jsh.dao.materials.MaterialIDAO; import com.jsh.model.po.Material; +import com.jsh.model.po.MaterialCategory; +import com.jsh.util.JshException; +import com.jsh.util.MaterialConstants; +import com.jsh.util.PageUtil; +import com.jsh.util.Tools; +import jxl.Workbook; +import jxl.format.Colour; +import jxl.write.*; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; + +import java.io.*; +import java.lang.Boolean; +import java.util.*; public class MaterialService extends BaseService implements MaterialIService { @@ -14,11 +31,315 @@ public class MaterialService extends BaseService implements MaterialIS this.materialDao = materialDao; } + public void batchSetEnable(Boolean enable,String supplierIDs){ + materialDao.batchSetEnable(enable, supplierIDs); + } + + + @Override + public void findUnitName(PageUtil pageUtil, Long mId) throws JshException + { + materialDao.findUnitName(pageUtil, mId); + } @Override protected Class getEntityClass() { return Material.class; } - + + /** + * 初始化加载所有系统基础数据 + */ + @SuppressWarnings({"rawtypes"}) + private static Map mapData = new HashMap(); + + /** + * 错误的表格数据 + */ + private static List wrongData = new ArrayList(); + /** + * 导出Excel表格 + */ + @Override + public InputStream exmportExcel(String isAllPage, PageUtil pageUtil)throws JshException + { + try + { + //将OutputStream转化为InputStream + ByteArrayOutputStream out = new ByteArrayOutputStream(); + putDataOnOutputStream(out, pageUtil.getPageList()); + return new ByteArrayInputStream(out.toByteArray()); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常", e); + throw new JshException("导出信息为excel表格异常",e); + } + } + + /** + * 生成excel表格 + * @param os + */ + @SuppressWarnings("deprecation") + private void putDataOnOutputStream(OutputStream os, List dataList) { + WritableWorkbook workbook = null; + try { + workbook = Workbook.createWorkbook(os); + WritableSheet sheet = workbook.createSheet("信息报表", 0); + //增加列头 + String[] colunmName = {"品名","类型","型号","制造商","规格","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态"}; + for(int i = 0 ;i < colunmName.length;i ++) { + sheet.setColumnView(i, 10); + sheet.addCell(new Label(i, 0, colunmName[i])); + } + if (null != dataList && dataList.size() > 0) { + int i = 1; + for (Material material: dataList){ + int j = 0; + Map cellInfo = material.getCellInfo(); + sheet.addCell(new Label(j++,i, material.getName())); + sheet.addCell(new Label(j++,i, material.getMaterialCategory().getName())); + sheet.addCell(new Label(j++,i, material.getModel() == null ?"": material.getModel())); + sheet.addCell(new Label(j++,i, material.getMfrs() == null ?"": material.getMfrs())); + sheet.addCell(new Label(j++,i, material.getStandard() == null ?"": material.getStandard())); + sheet.addCell(getLabelInfo(cellInfo,j++,i, material.getSafetyStock() == null ?"": material.getSafetyStock().toString(),material)); + sheet.addCell(new Label(j++,i, material.getUnit() == null ?"": material.getUnit())); + sheet.addCell(new Label(j++,i, material.getRetailPrice() == null ?"": material.getRetailPrice().toString())); + sheet.addCell(new Label(j++,i, material.getLowPrice() == null ?"": material.getLowPrice().toString())); + sheet.addCell(new Label(j++,i, material.getPresetPriceOne() == null ?"": material.getPresetPriceOne().toString())); + sheet.addCell(new Label(j++,i, material.getPresetPriceTwo() == null ?"": material.getPresetPriceTwo().toString())); + sheet.addCell(new Label(j++,i, material.getRemark() == null ?"": material.getRemark())); + sheet.addCell(new Label(j++,i, material.getEnabled()?"启用":"禁用")); + i++; + } + } + workbook.write(); + workbook.close(); + } + catch (Exception e) { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常", e); + } + } + + /** + * 根据错误信息进行提示--excel表格背景设置为红色,表示导入信息有误 + * @param cellInfo + * @param cellNum + * @param columnNum + * @param value + * @return + */ + private Label getLabelInfo(Map cellInfo,int cellNum,int columnNum,String value,Material material) + { + Label label = null; + + //设置背景颜色 + WritableCellFormat cellFormat = new WritableCellFormat(); + try + { + cellFormat.setBackground(Colour.RED); + } + catch (WriteException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>设置单元格背景颜色错误", e); + } + + if(null == cellInfo || cellInfo.size() == 0) { + label = new Label(cellNum, columnNum, value); + } + else { + //表示此单元格有错误 + if(cellInfo.containsKey(cellNum)) { + if(cellNum == MaterialConstants.BusinessForExcel.EXCEL_SAFETY_STOCK) { + label = new Label(cellNum, columnNum, material.getSafetyStockStr(), cellFormat); + } + } + else{ + label = new Label(cellNum, columnNum, value); + } + } + return label; + } + + @Override + public InputStream importExcel(File materialFile) throws JshException { + //全局变量--每次调用前需要清空数据 + mapData.clear(); + //2、解析文件成资产数据 + parseFile(materialFile); + + if(null != wrongData && wrongData.size()>0) { + //将OutputStream转化为InputStream + ByteArrayOutputStream out = new ByteArrayOutputStream(); + putDataOnOutputStream(out,wrongData); + return new ByteArrayInputStream(out.toByteArray()); + } + else{ + return null; + } + } + + + /** + * 解析excel表格 + * @param assetFile + */ + @SuppressWarnings("unchecked") + private void parseFile(File assetFile) { + //每次调用前清空 + wrongData.clear(); + int totalRow = 0; + try { + //创建对Excel工作簿文件的引用 + HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(assetFile)); + //创建对工作表的引用,获取第一个工作表的内容 + HSSFSheet sheet = workbook.getSheetAt(0); + /** + * ===================================== + * 1、此处要增加文件的验证,如果不是资产文件需要进行特殊的处理,13列 + * 2、文件内容为空处理 + * 3、如果是修改过的文件内容 + */ + Iterator itsheet = sheet.rowIterator(); + while(itsheet.hasNext()) { + //获取当前行数据 + Row row = itsheet.next(); + //获取一行有多少单元格 +// System.out.println(row.getLastCellNum()); + + //excel表格第几行数据 从1开始 0 是表头 + int rowNum = row.getRowNum(); + /** + * 表头跳过不读 + */ + if(MaterialConstants.BusinessForExcel.EXCEL_TABLE_HEAD == rowNum) + continue; + + //开始处理excel表格内容 --每行数据读取,同时统计总共行数 + totalRow ++; + + //获取excel表格的每格数据内容 + Iterator it = row.cellIterator(); + //资产子类型--添加了一些excel表格数据 + Material material = new Material(); + //保存每个单元格错误类型 + Map cellType = new HashMap(); + //设置列号 + material.setRowLineNum(rowNum); + + Cell cell = null; + //判断列号--从零开始 + int cellIndex = 0; + while(it.hasNext()) { + //获取每个单元格对象 + cell = it.next(); + //获取列号 + cellIndex = cell.getColumnIndex(); + //设置此单元格为字符串类型 + cell.setCellType(Cell.CELL_TYPE_STRING); + + Log.infoFileSync("==================excel表格中第" + totalRow + "行的第 " + cellIndex + "列的值为" + cell.getStringCellValue()); + + //每行中数据顺序 "品名","类型","型号","制造商","规格","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态" + switch(cellIndex) { + case MaterialConstants.BusinessForExcel.EXCEL_NAME : + String materialName = cell.getStringCellValue(); + if(null == materialName || "".equals(materialName)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(品名)信息"); + break; + } + material.setName(materialName); + break; + case MaterialConstants.BusinessForExcel.EXCEL_CATEGORY : + String category = cell.getStringCellValue(); + if(null == category || "".equals(category)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(类型)信息"); + break; + } + material.setMaterialCategory(new MaterialCategory(1l)); //根目录 + break; + case MaterialConstants.BusinessForExcel.EXCEL_MODEL: + String model = cell.getStringCellValue(); + if(null == model || "".equals(model)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(型号)信息"); + break; + } + material.setModel(model); + break; + case MaterialConstants.BusinessForExcel.EXCEL_MFRS : + String mfrs = cell.getStringCellValue(); + if(null == mfrs || "".equals(mfrs)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(制造商)信息"); + break; + } + material.setMfrs(mfrs); + break; + case MaterialConstants.BusinessForExcel.EXCEL_STANDARD : + String standard = cell.getStringCellValue(); + if(null == standard || "".equals(standard)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(规格)信息"); + break; + } + material.setStandard(standard); + break; + case MaterialConstants.BusinessForExcel.EXCEL_SAFETY_STOCK : + String safetyStock = cell.getStringCellValue(); + if(null == safetyStock || "".equals(safetyStock)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(安全存量)信息"); + break; + } + if(Tools.checkStrIsNum(safetyStock)) { + material.setSafetyStock(Double.parseDouble(safetyStock)); + } + else{ + Log.errorFileSync(">>>>>>>>>>>>>>>>>(安全存量)不是数字格式"); + cellType.put(cellIndex, "wrong"); + material.setSafetyStock(0.00d); + material.setSafetyStockStr(safetyStock); + } + break; + case MaterialConstants.BusinessForExcel.EXCEL_UNIT: + String unit = cell.getStringCellValue(); + if(null == unit || "".equals(unit)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(单位)信息"); + break; + } + material.setUnit(unit); + break; + case MaterialConstants.BusinessForExcel.EXCEL_REMARK : + String remark = cell.getStringCellValue(); + if(null == remark || "".equals(remark)) { + Log.errorFileSync(">>>>>>>>>>>>>>>>列表没有填写(备注)信息"); + break; + } + material.setRemark(remark); + break; + } + } + material.setCellInfo(cellType); + + Log.infoFileSync(totalRow + "行总共有" + cellIndex + "列"); + + //判断完成后增加数据 + if((null!=cellType && cellType.size() >0) || material.getName() == null) { + wrongData.add(material); + } + else { + material.setEnabled(true); + materialDao.save(material); + } + } + } + catch (FileNotFoundException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>读取excel文件异常:找不到指定文件!",e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>读取excel文件异常,请确认文件格式是否正确 !",e); + } + Log.infoFileSync("===================excel表格总共有 " + totalRow + " 条记录!"); + } } diff --git a/src/main/java/com/jsh/util/MaterialConstants.java b/src/main/java/com/jsh/util/MaterialConstants.java new file mode 100644 index 00000000..1bd26e87 --- /dev/null +++ b/src/main/java/com/jsh/util/MaterialConstants.java @@ -0,0 +1,94 @@ +package com.jsh.util; + +/** + * 定义商品信息常量 + * @author jishenghua + */ +public interface MaterialConstants +{ + /** + * 公共常量 + * @author ji sheng hua + */ + public class Common + { + + } + + /** + * 常量--导入导出excel表格业务相关 + * @author jishenghua + */ + public class BusinessForExcel + { + /** + * 名称 + */ + public static final int EXCEL_NAME = 0; + + /** + * 类型 + */ + public static final int EXCEL_CATEGORY = 1; + + /** + * 制造商 + */ + public static final int EXCEL_MFRS = 2; + + /** + * 型号 + */ + public static final int EXCEL_MODEL = 3; + + /** + * 规格 + */ + public static final int EXCEL_STANDARD = 4; + + /** + * 安全存量 + */ + public static final int EXCEL_SAFETY_STOCK = 5; + + /** + * 单位 + */ + public static final int EXCEL_UNIT = 6; + + /** + * 零售价 + */ + public static final int EXCEL_RETAILPRICE = 7; + + /** + * 最低售价 + */ + public static final int EXCEL_LOWPRICE = 8; + + /** + * 预设售价一 + */ + public static final int EXCEL_PRESETPRICEONE = 9; + + /** + * 预设售价二 + */ + public static final int EXCEL_PRESETPRICETWO = 10; + + /** + * 备注 + */ + public static final int EXCEL_REMARK = 11; + + /** + * 表头 + */ + public static final int EXCEL_TABLE_HEAD = 0; + + /** + * action返回excel结果 + */ + public static final String EXCEL = "excel"; + } +} diff --git a/src/main/java/com/jsh/util/SupplierConstants.java b/src/main/java/com/jsh/util/SupplierConstants.java new file mode 100644 index 00000000..9feb7c25 --- /dev/null +++ b/src/main/java/com/jsh/util/SupplierConstants.java @@ -0,0 +1,115 @@ +package com.jsh.util; + +/** + * 定义供应商、客户管理常量 + * @author jishenghua + */ +public interface SupplierConstants +{ + /** + * 公共常量 + * @author jishenghua + */ + public class Common + { + + } + + /** + * 常量--导入导出excel表格业务相关 + * @author jishenghua + */ + public class BusinessForExcel + { + /** + * 名称 + */ + public static final int EXCEL_SUPPLIER = 0; + + /** + * 类型 + */ + public static final int EXCEL_TYPE = 1; + + /** + * 联系人 + */ + public static final int EXCEL_CONTACTS = 2; + + /** + * 电话 + */ + public static final int EXCEL_PHONE_NUM = 3; + + /** + * 电子邮箱 + */ + public static final int EXCEL_EMAIL = 4; + + /** + * 预收款 + */ + public static final int EXCEL_ADVANCE_IN = 5; + + /** + * 期初应收 + */ + public static final int EXCEL_BEGIN_NEED_GET = 6; + + /** + * 期初应付 + */ + public static final int EXCEL_BEGIN_NEED_PAY = 7; + + /** + * 备注 + */ + public static final int EXCEL_DESCRIPTION = 8; + + /** + * 传真 + */ + public static final int EXCEL_FAX = 9; + + /** + * 手机 + */ + public static final int EXCEL_TELEPHONE = 10; + + /** + * 地址 + */ + public static final int EXCEL_ADDRESS = 11; + + /** + * 纳税人识别号 + */ + public static final int EXCEL_TAX_NUM = 12; + + /** + * 开户行 + */ + public static final int EXCEL_BANK_NAME = 13; + + /** + * 账号 + */ + public static final int EXCEL_ACCOUNT_NUMBER = 14; + + /** + * 税率 + */ + public static final int EXCEL_TAX_RATE = 15; + + + /** + * 表头 + */ + public static final int EXCEL_TABLE_HEAD = 0; + + /** + * action返回excel结果 + */ + public static final String EXCEL = "excel"; + } +} diff --git a/src/main/java/com/jsh/util/Tools.java b/src/main/java/com/jsh/util/Tools.java index 68e7daea..c37f976e 100644 --- a/src/main/java/com/jsh/util/Tools.java +++ b/src/main/java/com/jsh/util/Tools.java @@ -3,6 +3,7 @@ package com.jsh.util; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.InetAddress; +import java.net.URLDecoder; import java.net.URLEncoder; import java.net.UnknownHostException; import java.security.MessageDigest; @@ -48,7 +49,7 @@ public class Tools } /** - * 获取指定日期格式 yyyy-MM + * 获取指定日期格式 yyyy-MM-dd * @return */ public static String getCurrentMonth(Date date) @@ -230,6 +231,31 @@ public class Tools } return valueAfterTransCode; } + + /** + * 字符转码 + * @param aValue + * @return + * @see 转码后的字符串 + */ + public static String decodeValue(String aValue) + { + if(aValue.trim().length() ==0) + { + return ""; + } + String valueAfterTransCode = null; + try + { + valueAfterTransCode = URLDecoder.decode(aValue, "UTF-8"); + } + catch (UnsupportedEncodingException e) + { + e.getMessage(); + } + return valueAfterTransCode; + } + /** * 去除str中的' * @param str