diff --git a/erp_web/pages/materials/materialcategory.html b/erp_web/pages/materials/materialcategory.html index 0c71ecaa..31e80680 100644 --- a/erp_web/pages/materials/materialcategory.html +++ b/erp_web/pages/materials/materialcategory.html @@ -284,14 +284,6 @@ } }); }); - $('#btnSetFunctions').click(function () { - var currentRow = $("#tableData").datagrid("getSelected"); - if (currentRow == null) { - $.messager.alert('提示',"请选择一条数据再操作!",'warning'); - return false; - } - this.href = "/pages/manage/roleFunctions.html?id=" + currentRow.id; - }); //查询父级商品类别 $("#lookForSelectMaterialCategory").on("click", function () { $('#forSelectMaterialCategoryDlg').dialog({ diff --git a/src/main/java/com/jsh/erp/constants/ExceptionConstants.java b/src/main/java/com/jsh/erp/constants/ExceptionConstants.java index 2602e2e9..4f24aafb 100644 --- a/src/main/java/com/jsh/erp/constants/ExceptionConstants.java +++ b/src/main/java/com/jsh/erp/constants/ExceptionConstants.java @@ -18,6 +18,17 @@ public class ExceptionConstants { **/ public static final int SERVICE_SUCCESS_CODE = 200; public static final String SERVICE_SUCCESS_MSG = "操作成功"; + /** + * 数据查询异常 + */ + public static final int DATA_READ_FAIL_CODE = 300; + public static final String DATA_READ_FAIL_MSG = "数据查询异常"; + /** + * 数据写入异常 + */ + public static final int DATA_WRITE_FAIL_CODE = 301; + public static final String DATA_WRITE_FAIL_MSG = "数据写入异常"; + /** * 系统运行时未知错误 **/ diff --git a/src/main/java/com/jsh/erp/controller/AccountController.java b/src/main/java/com/jsh/erp/controller/AccountController.java index 169f8391..5de82737 100644 --- a/src/main/java/com/jsh/erp/controller/AccountController.java +++ b/src/main/java/com/jsh/erp/controller/AccountController.java @@ -1,6 +1,5 @@ package com.jsh.erp.controller; -import com.alibaba.druid.util.StringUtils; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; @@ -41,7 +40,7 @@ public class AccountController { * @return */ @GetMapping(value = "/findBySelect") - public String findBySelect(HttpServletRequest request) { + public String findBySelect(HttpServletRequest request) throws Exception { String res = null; try { List dataList = accountService.findBySelect(); @@ -70,7 +69,7 @@ public class AccountController { * @return */ @GetMapping(value = "/getAccount") - public BaseResponseInfo getAccount(HttpServletRequest request) { + public BaseResponseInfo getAccount(HttpServletRequest request) throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -100,7 +99,7 @@ public class AccountController { @RequestParam("pageSize") Integer pageSize, @RequestParam("accountId") Long accountId, @RequestParam("initialAmount") BigDecimal initialAmount, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -133,7 +132,7 @@ public class AccountController { @PostMapping(value = "/updateAmountIsDefault") public String updateAmountIsDefault(@RequestParam("isDefault") Boolean isDefault, @RequestParam("accountId") Long accountId, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ Map objectMap = new HashMap(); int res = accountService.updateAmountIsDefault(isDefault, accountId); if(res > 0) { diff --git a/src/main/java/com/jsh/erp/controller/AccountHeadController.java b/src/main/java/com/jsh/erp/controller/AccountHeadController.java index 1abbce8f..ae350955 100644 --- a/src/main/java/com/jsh/erp/controller/AccountHeadController.java +++ b/src/main/java/com/jsh/erp/controller/AccountHeadController.java @@ -40,7 +40,7 @@ public class AccountHeadController { * @return */ @GetMapping(value = "/getMaxId") - public BaseResponseInfo getMaxId(HttpServletRequest request) { + public BaseResponseInfo getMaxId(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -68,7 +68,7 @@ public class AccountHeadController { public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId, @RequestParam("endTime") String endTime, @RequestParam("supType") String supType, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -106,7 +106,7 @@ public class AccountHeadController { */ @GetMapping(value = "/getDetailByNumber") public BaseResponseInfo getDetailByNumber(@RequestParam("billNo") String billNo, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx(); try { @@ -132,7 +132,7 @@ public class AccountHeadController { * @param endTime * @return */ - public BigDecimal allMoney(String getS, String type, String mode, String endTime) { + public BigDecimal allMoney(String getS, String type, String mode, String endTime)throws Exception { BigDecimal allMoney = BigDecimal.ZERO; try { Integer supplierId = Integer.valueOf(getS); diff --git a/src/main/java/com/jsh/erp/controller/AccountItemController.java b/src/main/java/com/jsh/erp/controller/AccountItemController.java index af8b3e1f..7df8b649 100644 --- a/src/main/java/com/jsh/erp/controller/AccountItemController.java +++ b/src/main/java/com/jsh/erp/controller/AccountItemController.java @@ -55,7 +55,7 @@ public class AccountItemController { @RequestParam("updated") String updated, @RequestParam("headerId") Long headerId, @RequestParam("listType") String listType, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ Map objectMap = new HashMap(); try { @@ -70,7 +70,7 @@ public class AccountItemController { @GetMapping(value = "/getDetailList") public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { diff --git a/src/main/java/com/jsh/erp/controller/AppController.java b/src/main/java/com/jsh/erp/controller/AppController.java index 88d9dc1d..37601862 100644 --- a/src/main/java/com/jsh/erp/controller/AppController.java +++ b/src/main/java/com/jsh/erp/controller/AppController.java @@ -48,7 +48,7 @@ public class AppController { * @return */ @GetMapping(value = "/findAppByUserId") - public JSONObject findAppByUserId(@RequestParam("userId") String userId, HttpServletRequest request) { + public JSONObject findAppByUserId(@RequestParam("userId") String userId, HttpServletRequest request)throws Exception { List roleList = userBusinessService.findRoleByUserId(userId); String roles = null; if(roleList!=null && roleList.size()>0 && roleList.get(0)!=null){ @@ -109,7 +109,7 @@ public class AppController { } @GetMapping(value = "/findDesk") - public JSONObject findDesk(HttpServletRequest request) { + public JSONObject findDesk(HttpServletRequest request)throws Exception { JSONObject obj = new JSONObject(); List dockList = appService.findDock(); JSONArray dockArray = new JSONArray(); @@ -160,7 +160,7 @@ public class AppController { */ @PostMapping(value = "/findRoleAPP") public JSONArray findRoleAPP(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { JSONArray arr = new JSONArray(); try { List dataListApp = appService.findRoleAPP(); @@ -229,7 +229,7 @@ public class AppController { */ @PostMapping(value = "/uploadImg") public BaseResponseInfo uploadImg(MultipartFile fileInfo, @RequestParam("fileInfoName") String fileName, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { if (fileInfo != null) { diff --git a/src/main/java/com/jsh/erp/controller/DepotController.java b/src/main/java/com/jsh/erp/controller/DepotController.java index 6338420d..7a8b1db0 100644 --- a/src/main/java/com/jsh/erp/controller/DepotController.java +++ b/src/main/java/com/jsh/erp/controller/DepotController.java @@ -41,7 +41,7 @@ public class DepotController { private UserBusinessService userBusinessService; @GetMapping(value = "/getAllList") - public BaseResponseInfo getAllList(HttpServletRequest request) { + public BaseResponseInfo getAllList(HttpServletRequest request) throws Exception{ BaseResponseInfo res = new BaseResponseInfo(); try { List depotList = depotService.getAllList(); @@ -64,7 +64,7 @@ public class DepotController { */ @PostMapping(value = "/findUserDepot") public JSONArray findUserDepot(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ JSONArray arr = new JSONArray(); try { List dataList = depotService.findUserDepot(); @@ -104,7 +104,7 @@ public class DepotController { @RequestMapping(value = "/findDepotByUserId") public JSONArray findDepotByUserId(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ JSONArray arr = new JSONArray(); try { List dataList = depotService.findUserDepot(); @@ -145,7 +145,7 @@ public class DepotController { public String getDepotList( @RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, - @RequestParam(value = Constants.SEARCH, required = false) String search) { + @RequestParam(value = Constants.SEARCH, required = false) String search) throws Exception{ Map parameterMap = new HashMap(); //查询参数 JSONObject obj=JSON.parseObject(search); diff --git a/src/main/java/com/jsh/erp/controller/DepotHeadController.java b/src/main/java/com/jsh/erp/controller/DepotHeadController.java index 7b8f0aaa..c3559e76 100644 --- a/src/main/java/com/jsh/erp/controller/DepotHeadController.java +++ b/src/main/java/com/jsh/erp/controller/DepotHeadController.java @@ -55,7 +55,7 @@ public class DepotHeadController { @PostMapping(value = "/batchSetStatus") public String batchSetStatus(@RequestParam("status") String status, @RequestParam("depotHeadIDs") String depotHeadIDs, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ Map objectMap = new HashMap(); int res = depotHeadService.batchSetStatus(status, depotHeadIDs); if(res > 0) { @@ -71,7 +71,7 @@ public class DepotHeadController { * @return */ @GetMapping(value = "/buildNumber") - public BaseResponseInfo buildNumber(HttpServletRequest request) { + public BaseResponseInfo buildNumber(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -93,7 +93,7 @@ public class DepotHeadController { * @return */ @GetMapping(value = "/getMaxId") - public BaseResponseInfo getMaxId(HttpServletRequest request) { + public BaseResponseInfo getMaxId(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -117,7 +117,7 @@ public class DepotHeadController { */ @GetMapping(value = "/findByMonth") public BaseResponseInfo findByMonth(@RequestParam("monthTime") String monthTime, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -164,7 +164,7 @@ public class DepotHeadController { @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime, @RequestParam("type") String type, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -211,7 +211,7 @@ public class DepotHeadController { @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime, @RequestParam("type") String type, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -254,7 +254,7 @@ public class DepotHeadController { @RequestParam("endTime") String endTime, @RequestParam("organId") Integer organId, @RequestParam("supType") String supType, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -338,7 +338,7 @@ public class DepotHeadController { public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId, @RequestParam("endTime") String endTime, @RequestParam("supType") String supType, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -376,7 +376,7 @@ public class DepotHeadController { */ @GetMapping(value = "/getDetailByNumber") public BaseResponseInfo getDetailByNumber(@RequestParam("number") String number, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); DepotHeadVo4List dhl = new DepotHeadVo4List(); try { @@ -403,7 +403,7 @@ public class DepotHeadController { * @param mode 合计或者金额 * @return */ - public BigDecimal allMoney(String getS, String type, String subType, String mode, String endTime) { + public BigDecimal allMoney(String getS, String type, String subType, String mode, String endTime)throws Exception { BigDecimal allMoney = BigDecimal.ZERO; try { Integer supplierId = Integer.valueOf(getS); diff --git a/src/main/java/com/jsh/erp/controller/DepotItemController.java b/src/main/java/com/jsh/erp/controller/DepotItemController.java index 089e0ba1..e69a8fa2 100644 --- a/src/main/java/com/jsh/erp/controller/DepotItemController.java +++ b/src/main/java/com/jsh/erp/controller/DepotItemController.java @@ -51,7 +51,7 @@ public class DepotItemController { @GetMapping(value = "/getHeaderIdByMaterial") public BaseResponseInfo getHeaderIdByMaterial(@RequestParam("materialParam") String materialParam, @RequestParam("depotIds") String depotIds, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { List depotItemList = depotItemService.getHeaderIdByMaterial(materialParam, depotIds); @@ -89,7 +89,7 @@ public class DepotItemController { public String findDetailByTypeAndMaterialId( @RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, - @RequestParam("materialId") String mId, HttpServletRequest request) { + @RequestParam("materialId") String mId, HttpServletRequest request)throws Exception { Map parameterMap = ParamUtils.requestToMap(request); parameterMap.put("mId", mId); PageQueryInfo queryInfo = new PageQueryInfo(); @@ -139,7 +139,7 @@ public class DepotItemController { @RequestParam("projectId") Integer pid, @RequestParam("materialId") String mId, @RequestParam("monthTime") String monthTime, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ Map parameterMap = ParamUtils.requestToMap(request); parameterMap.put("mId", mId); parameterMap.put("monthTime", monthTime); @@ -203,7 +203,7 @@ public class DepotItemController { @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, @RequestParam("materialId") String mId, @RequestParam("monthTime") String monthTime, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ Map parameterMap = ParamUtils.requestToMap(request); parameterMap.put("mId", mId); parameterMap.put("monthTime", monthTime); @@ -250,7 +250,7 @@ public class DepotItemController { * @param mId * @return */ - public int sumNumberByMaterialId(String type, Long mId) { + public int sumNumberByMaterialId(String type, Long mId)throws Exception { int allNumber = 0; try { allNumber = depotItemService.findByTypeAndMaterialId(type, mId); @@ -291,7 +291,7 @@ public class DepotItemController { * * @return */ - public String findUnitName(Long mId) { + public String findUnitName(Long mId)throws Exception { String unitName = ""; try { unitName = materialService.findUnitName(mId); @@ -310,7 +310,7 @@ public class DepotItemController { @GetMapping(value = "/getDetailList") public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId, @RequestParam("mpList") String mpList, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -382,7 +382,7 @@ public class DepotItemController { * * @return */ - public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx) { + public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx)throws Exception { String materialOther = ""; for (int i = 0; i < mpArr.length; i++) { if (mpArr[i].equals("颜色")) { @@ -427,7 +427,7 @@ public class DepotItemController { @RequestParam("headIds") String headIds, @RequestParam("materialIds") String materialIds, @RequestParam("mpList") String mpList, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -497,7 +497,7 @@ public class DepotItemController { @RequestParam("monthTime") String monthTime, @RequestParam("headIds") String headIds, @RequestParam("materialIds") String materialIds, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -540,7 +540,7 @@ public class DepotItemController { @RequestParam("headIds") String headIds, @RequestParam("materialIds") String materialIds, @RequestParam("mpList") String mpList, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -600,7 +600,7 @@ public class DepotItemController { @RequestParam("headIds") String headIds, @RequestParam("materialIds") String materialIds, @RequestParam("mpList") String mpList, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -665,7 +665,7 @@ public class DepotItemController { @RequestParam("monthTime") String monthTime, @RequestParam("headIds") String headIds, @RequestParam("materialIds") String materialIds, - HttpServletRequest request, HttpServletResponse response) { + HttpServletRequest request, HttpServletResponse response)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); String message = "成功"; @@ -731,7 +731,7 @@ public class DepotItemController { * @param isPrev * @return */ - public BigDecimal sumNumber(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) { + public BigDecimal sumNumber(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception { BigDecimal sumNumber = BigDecimal.ZERO; try { BigDecimal sum = depotItemService.findByType(type, ProjectId, MId, MonthTime, isPrev); @@ -744,7 +744,7 @@ public class DepotItemController { return sumNumber; } - public BigDecimal assembleNumber(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) { + public BigDecimal assembleNumber(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws Exception{ BigDecimal assembleNumber = BigDecimal.ZERO; try { BigDecimal sum = depotItemService.findAssembleByType(subType, mType, ProjectId, MId, MonthTime, isPrev); @@ -766,7 +766,7 @@ public class DepotItemController { * @param isPrev * @return */ - public BigDecimal sumPrice(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) { + public BigDecimal sumPrice(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws Exception{ BigDecimal sumPrice = BigDecimal.ZERO; try { BigDecimal sum = depotItemService.findPriceByType(type, ProjectId, MId, MonthTime, isPrev); @@ -779,7 +779,7 @@ public class DepotItemController { return sumPrice; } - public BigDecimal sumNumberBuyOrSale(String type, String subType, Long MId, String MonthTime) { + public BigDecimal sumNumberBuyOrSale(String type, String subType, Long MId, String MonthTime)throws Exception { BigDecimal sumNumber = BigDecimal.ZERO; String sumType = "Number"; try { @@ -793,7 +793,7 @@ public class DepotItemController { return sumNumber; } - public BigDecimal sumPriceBuyOrSale(String type, String subType, Long MId, String MonthTime) { + public BigDecimal sumPriceBuyOrSale(String type, String subType, Long MId, String MonthTime)throws Exception { BigDecimal sumPrice = BigDecimal.ZERO; String sumType = "Price"; try { diff --git a/src/main/java/com/jsh/erp/controller/FunctionsController.java b/src/main/java/com/jsh/erp/controller/FunctionsController.java index 51c45e70..3ed5aa21 100644 --- a/src/main/java/com/jsh/erp/controller/FunctionsController.java +++ b/src/main/java/com/jsh/erp/controller/FunctionsController.java @@ -41,7 +41,7 @@ public class FunctionsController { @PostMapping(value = "/findMenu") public JSONArray findMenu(@RequestParam(value="pNumber") String pNumber, @RequestParam(value="hasFunctions") String hasFunctions, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { //存放数据json数组 JSONArray dataArray = new JSONArray(); try { @@ -124,7 +124,7 @@ public class FunctionsController { */ @PostMapping(value = "/findRoleFunctions") public JSONArray findRoleFunctions(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { JSONArray arr = new JSONArray(); try { List dataListFun = functionsService.findRoleFunctions("0"); @@ -277,7 +277,7 @@ public class FunctionsController { */ @GetMapping(value = "/findByIds") public BaseResponseInfo findByIds(@RequestParam("functionsIds") String functionsIds, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { List dataList = functionsService.findByIds(functionsIds); diff --git a/src/main/java/com/jsh/erp/controller/InOutItemController.java b/src/main/java/com/jsh/erp/controller/InOutItemController.java index fc920907..62f76885 100644 --- a/src/main/java/com/jsh/erp/controller/InOutItemController.java +++ b/src/main/java/com/jsh/erp/controller/InOutItemController.java @@ -35,7 +35,7 @@ public class InOutItemController { * @return */ @GetMapping(value = "/findBySelect") - public String findBySelect(@RequestParam("type") String type, HttpServletRequest request) { + public String findBySelect(@RequestParam("type") String type, HttpServletRequest request) throws Exception{ String res = null; try { List dataList = inOutItemService.findBySelect(type); diff --git a/src/main/java/com/jsh/erp/controller/MaterialCategoryController.java b/src/main/java/com/jsh/erp/controller/MaterialCategoryController.java index 3b91415c..6e0de93f 100644 --- a/src/main/java/com/jsh/erp/controller/MaterialCategoryController.java +++ b/src/main/java/com/jsh/erp/controller/MaterialCategoryController.java @@ -35,7 +35,7 @@ public class MaterialCategoryController { private MaterialCategoryService materialCategoryService; @GetMapping(value = "/getAllList") - public BaseResponseInfo getAllList(@RequestParam("parentId") Long parentId, HttpServletRequest request) { + public BaseResponseInfo getAllList(@RequestParam("parentId") Long parentId, HttpServletRequest request) throws Exception{ BaseResponseInfo res = new BaseResponseInfo(); try { List materialCategoryList = materialCategoryService.getAllList(parentId); @@ -56,7 +56,7 @@ public class MaterialCategoryController { * @return */ @RequestMapping(value = "/findById") - public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) { + public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { List dataList = materialCategoryService.findById(id); diff --git a/src/main/java/com/jsh/erp/controller/MaterialController.java b/src/main/java/com/jsh/erp/controller/MaterialController.java index d536ae82..4bf35c6b 100644 --- a/src/main/java/com/jsh/erp/controller/MaterialController.java +++ b/src/main/java/com/jsh/erp/controller/MaterialController.java @@ -46,7 +46,7 @@ public class MaterialController { @RequestParam("standard") String standard, @RequestParam("mfrs") String mfrs, @RequestParam("otherField1") String otherField1, @RequestParam("otherField2") String otherField2, @RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit,@RequestParam("unitId") Long unitId, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int exist = materialService.checkIsExist(id, name, model, color, standard, mfrs, otherField1, otherField2, otherField3, unit, unitId); @@ -68,7 +68,7 @@ public class MaterialController { @PostMapping(value = "/batchSetEnable") public String batchSetEnable(@RequestParam("enabled") Boolean enabled, @RequestParam("materialIDs") String materialIDs, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int res = materialService.batchSetEnable(enabled, materialIDs); if(res > 0) { @@ -85,7 +85,7 @@ public class MaterialController { * @return */ @GetMapping(value = "/findById") - public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) { + public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) throws Exception{ BaseResponseInfo res = new BaseResponseInfo(); try { List list = materialService.findById(id); @@ -106,7 +106,7 @@ public class MaterialController { * @return */ @GetMapping(value = "/findBySelect") - public JSONArray findBySelect(@RequestParam("mpList") String mpList, HttpServletRequest request) { + public JSONArray findBySelect(@RequestParam("mpList") String mpList, HttpServletRequest request) throws Exception{ JSONArray dataArray = new JSONArray(); try { List dataList = materialService.findBySelect(); @@ -163,7 +163,7 @@ public class MaterialController { * @return */ @GetMapping(value = "/findByOrder") - public BaseResponseInfo findByOrder(HttpServletRequest request) { + public BaseResponseInfo findByOrder(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -203,7 +203,7 @@ public class MaterialController { @RequestParam("model") String model, @RequestParam("categoryId") Long categoryId, @RequestParam("categoryIds") String categoryIds, - HttpServletRequest request, HttpServletResponse response) { + HttpServletRequest request, HttpServletResponse response)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); String message = "成功"; @@ -303,7 +303,7 @@ public class MaterialController { response.sendRedirect("../pages/materials/material.html"); } - public BigDecimal parseBigDecimalEx(String str){ + public BigDecimal parseBigDecimalEx(String str)throws Exception{ if(!StringUtil.isEmpty(str)) { return new BigDecimal(str); } else { @@ -313,7 +313,7 @@ public class MaterialController { @RequestMapping(value = "/getMaterialEnableSerialNumberList") public String getMaterialEnableSerialNumberList(@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, - @RequestParam(value = Constants.SEARCH, required = false) String search) { + @RequestParam(value = Constants.SEARCH, required = false) String search)throws Exception { Map parameterMap = new HashMap(); //查询参数 JSONObject obj=JSON.parseObject(search); diff --git a/src/main/java/com/jsh/erp/controller/PersonController.java b/src/main/java/com/jsh/erp/controller/PersonController.java index 6460f737..f80fe964 100644 --- a/src/main/java/com/jsh/erp/controller/PersonController.java +++ b/src/main/java/com/jsh/erp/controller/PersonController.java @@ -30,7 +30,7 @@ public class PersonController { private PersonService personService; @GetMapping(value = "/getAllList") - public BaseResponseInfo getAllList(HttpServletRequest request) { + public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -53,7 +53,8 @@ public class PersonController { * @return */ @GetMapping(value = "/getPersonByIds") - public BaseResponseInfo getPersonByIds(@RequestParam("personIDs") String personIDs, HttpServletRequest request) { + public BaseResponseInfo getPersonByIds(@RequestParam("personIDs") String personIDs, + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -76,7 +77,8 @@ public class PersonController { * @return */ @GetMapping(value = "/getPersonByType") - public BaseResponseInfo getPersonByType(@RequestParam("type") String type, HttpServletRequest request) { + public BaseResponseInfo getPersonByType(@RequestParam("type") String type, + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -99,7 +101,8 @@ public class PersonController { * @return */ @PostMapping(value = "/getPersonByNumType") - public JSONArray getPersonByNumType(@RequestParam("type") String typeNum, HttpServletRequest request) { + public JSONArray getPersonByNumType(@RequestParam("type") String typeNum, + HttpServletRequest request)throws Exception { JSONArray dataArray = new JSONArray(); try { String type = ""; diff --git a/src/main/java/com/jsh/erp/controller/ResourceController.java b/src/main/java/com/jsh/erp/controller/ResourceController.java index fca3ab3e..f1d15ab4 100644 --- a/src/main/java/com/jsh/erp/controller/ResourceController.java +++ b/src/main/java/com/jsh/erp/controller/ResourceController.java @@ -4,13 +4,16 @@ import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.service.CommonQueryManager; import com.jsh.erp.utils.*; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.*; + import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static com.jsh.erp.utils.ResponseJsonUtil.returnJson; @@ -25,7 +28,7 @@ public class ResourceController { private CommonQueryManager configResourceManager; @GetMapping(value = "/test/heart") - public JSONObject exitHeart(HttpServletRequest request) { + public JSONObject exitHeart(HttpServletRequest request)throws Exception { return JsonUtils.ok(); } @@ -34,7 +37,7 @@ public class ResourceController { @RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, @RequestParam(value = Constants.SEARCH, required = false) String search, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { Map parameterMap = ParamUtils.requestToMap(request); parameterMap.put(Constants.SEARCH, search); PageQueryInfo queryInfo = new PageQueryInfo(); @@ -60,7 +63,7 @@ public class ResourceController { @PostMapping(value = "/{apiName}/add", produces = {"application/javascript", "application/json"}) public String addResource(@PathVariable("apiName") String apiName, - @RequestParam("info") String beanJson, HttpServletRequest request) { + @RequestParam("info") String beanJson, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int insert = configResourceManager.insert(apiName, beanJson, request); if(insert > 0) { @@ -73,7 +76,7 @@ public class ResourceController { @PostMapping(value = "/{apiName}/update", produces = {"application/javascript", "application/json"}) public String updateResource(@PathVariable("apiName") String apiName, @RequestParam("info") String beanJson, - @RequestParam("id") Long id, HttpServletRequest request) { + @RequestParam("id") Long id, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int update = configResourceManager.update(apiName, beanJson, id, request); if(update > 0) { @@ -85,7 +88,7 @@ public class ResourceController { @PostMapping(value = "/{apiName}/{id}/delete", produces = {"application/javascript", "application/json"}) public String deleteResource(@PathVariable("apiName") String apiName, - @PathVariable Long id, HttpServletRequest request) { + @PathVariable Long id, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int delete = configResourceManager.delete(apiName, id, request); if(delete > 0) { @@ -97,7 +100,7 @@ public class ResourceController { @PostMapping(value = "/{apiName}/batchDelete", produces = {"application/javascript", "application/json"}) public String batchDeleteResource(@PathVariable("apiName") String apiName, - @RequestParam("ids") String ids, HttpServletRequest request) { + @RequestParam("ids") String ids, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int delete = configResourceManager.batchDelete(apiName, ids, request); if(delete > 0) { @@ -110,7 +113,7 @@ public class ResourceController { @GetMapping(value = "/{apiName}/checkIsNameExist") public String checkIsNameExist(@PathVariable("apiName") String apiName, @RequestParam Long id, @RequestParam(value ="name", required = false) String name, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int exist = configResourceManager.checkIsNameExist(apiName, id, name); if(exist > 0) { diff --git a/src/main/java/com/jsh/erp/controller/RoleController.java b/src/main/java/com/jsh/erp/controller/RoleController.java index 99ab8843..acef713d 100644 --- a/src/main/java/com/jsh/erp/controller/RoleController.java +++ b/src/main/java/com/jsh/erp/controller/RoleController.java @@ -37,7 +37,7 @@ public class RoleController { */ @PostMapping(value = "/findUserRole") public JSONArray findUserRole(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { JSONArray arr = new JSONArray(); try { List dataList = roleService.findUserRole(); @@ -76,7 +76,7 @@ public class RoleController { } @PostMapping(value = "/list") - public List list(HttpServletRequest request) { + public List list(HttpServletRequest request)throws Exception { return roleService.getRole(); } diff --git a/src/main/java/com/jsh/erp/controller/SerialNumberController.java b/src/main/java/com/jsh/erp/controller/SerialNumberController.java index 18412e1c..1d6bf07e 100644 --- a/src/main/java/com/jsh/erp/controller/SerialNumberController.java +++ b/src/main/java/com/jsh/erp/controller/SerialNumberController.java @@ -61,7 +61,7 @@ public class SerialNumberController { */ @PostMapping("/serialNumber/addSerialNumber") @ResponseBody - public Object addSerialNumber(@RequestParam("info") String beanJson){ + public Object addSerialNumber(@RequestParam("info") String beanJson)throws Exception{ JSONObject result = ExceptionConstants.standardSuccess(); SerialNumberEx sne= JSON.parseObject(beanJson, SerialNumberEx.class); serialNumberService.addSerialNumber(sne); @@ -78,7 +78,7 @@ public class SerialNumberController { */ @PostMapping("/serialNumber/updateSerialNumber") @ResponseBody - public Object updateSerialNumber(@RequestParam("info") String beanJson){ + public Object updateSerialNumber(@RequestParam("info") String beanJson)throws Exception{ JSONObject result = ExceptionConstants.standardSuccess(); SerialNumberEx sne= JSON.parseObject(beanJson, SerialNumberEx.class); @@ -100,7 +100,7 @@ public class SerialNumberController { @PostMapping("/serialNumber/batAddSerialNumber") @ResponseBody public Object batAddSerialNumber(@RequestParam("materialName") String materialName, @RequestParam("serialNumberPrefix") String serialNumberPrefix, - @RequestParam("batAddTotal") Integer batAddTotal,@RequestParam("remark") String remark){ + @RequestParam("batAddTotal") Integer batAddTotal,@RequestParam("remark") String remark)throws Exception{ JSONObject result = ExceptionConstants.standardSuccess(); serialNumberService.batAddSerialNumber(materialName,serialNumberPrefix,batAddTotal,remark); diff --git a/src/main/java/com/jsh/erp/controller/SupplierController.java b/src/main/java/com/jsh/erp/controller/SupplierController.java index 692e3aa6..8c0976f3 100644 --- a/src/main/java/com/jsh/erp/controller/SupplierController.java +++ b/src/main/java/com/jsh/erp/controller/SupplierController.java @@ -57,7 +57,7 @@ public class SupplierController { @PostMapping(value = "/updateAdvanceIn") public String updateAdvanceIn(@RequestParam("supplierId") Long supplierId, @RequestParam("advanceIn") BigDecimal advanceIn, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int res = supplierService.updateAdvanceIn(supplierId, advanceIn); if(res > 0) { @@ -73,7 +73,7 @@ public class SupplierController { * @return */ @PostMapping(value = "/findBySelect_cus") - public JSONArray findBySelectCus(HttpServletRequest request) { + public JSONArray findBySelectCus(HttpServletRequest request)throws Exception { JSONArray arr = new JSONArray(); try { List supplierList = supplierService.findBySelectCus(); @@ -108,7 +108,7 @@ public class SupplierController { * @return */ @PostMapping(value = "/findBySelect_sup") - public JSONArray findBySelectSup(HttpServletRequest request) { + public JSONArray findBySelectSup(HttpServletRequest request) throws Exception{ JSONArray arr = new JSONArray(); try { List supplierList = supplierService.findBySelectSup(); @@ -135,7 +135,7 @@ public class SupplierController { * @return */ @PostMapping(value = "/findBySelect_retail") - public JSONArray findBySelectRetail(HttpServletRequest request) { + public JSONArray findBySelectRetail(HttpServletRequest request)throws Exception { JSONArray arr = new JSONArray(); try { List supplierList = supplierService.findBySelectRetail(); @@ -165,7 +165,7 @@ public class SupplierController { */ @GetMapping(value = "/findById") public BaseResponseInfo findById(@RequestParam("supplierId") Long supplierId, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { JSONArray dataArray = new JSONArray(); @@ -221,7 +221,7 @@ public class SupplierController { @PostMapping(value = "/batchSetEnable") public String batchSetEnable(@RequestParam("enabled") Boolean enabled, @RequestParam("supplierIDs") String supplierIDs, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int res = supplierService.batchSetEnable(enabled, supplierIDs); if(res > 0) { @@ -240,7 +240,7 @@ public class SupplierController { */ @PostMapping(value = "/findUserCustomer") public JSONArray findUserCustomer(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ JSONArray arr = new JSONArray(); try { List dataList = supplierService.findUserCustomer(); @@ -295,7 +295,7 @@ public class SupplierController { @RequestParam("phonenum") String phonenum, @RequestParam("telephone") String telephone, @RequestParam("description") String description, - HttpServletRequest request, HttpServletResponse response) { + HttpServletRequest request, HttpServletResponse response)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); String message = "成功"; @@ -382,7 +382,7 @@ public class SupplierController { importFun(supplierFile); response.sendRedirect("../pages/manage/member.html"); } - public String importFun(MultipartFile supplierFile){ + public String importFun(MultipartFile supplierFile)throws Exception{ BaseResponseInfo info = new BaseResponseInfo(); Map data = new HashMap(); @@ -436,7 +436,7 @@ public class SupplierController { return null; } - public BigDecimal parseBigDecimalEx(String str){ + public BigDecimal parseBigDecimalEx(String str)throws Exception{ if(!StringUtil.isEmpty(str)) { return new BigDecimal(str); } else { diff --git a/src/main/java/com/jsh/erp/controller/UserBusinessController.java b/src/main/java/com/jsh/erp/controller/UserBusinessController.java index 66ef1dc9..155a6aa3 100644 --- a/src/main/java/com/jsh/erp/controller/UserBusinessController.java +++ b/src/main/java/com/jsh/erp/controller/UserBusinessController.java @@ -36,7 +36,7 @@ public class UserBusinessController { @GetMapping(value = "/getBasicData") public BaseResponseInfo getBasicData(@RequestParam(value = "KeyId") String keyId, @RequestParam(value = "Type") String type, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { List list = userBusinessService.getBasicData(keyId, type); @@ -55,7 +55,7 @@ public class UserBusinessController { @GetMapping(value = "/checkIsValueExist") public String checkIsValueExist(@RequestParam(value ="type", required = false) String type, @RequestParam(value ="keyId", required = false) String keyId, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); Long id = userBusinessService.checkIsValueExist(type, keyId); if(id != null) { @@ -76,7 +76,7 @@ public class UserBusinessController { @PostMapping(value = "/updateBtnStr") public BaseResponseInfo updateBtnStr(@RequestParam(value ="userBusinessId", required = false) Long userBusinessId, @RequestParam(value ="btnStr", required = false) String btnStr, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { int back = userBusinessService.updateBtnStr(userBusinessId, btnStr); diff --git a/src/main/java/com/jsh/erp/controller/UserController.java b/src/main/java/com/jsh/erp/controller/UserController.java index 4deab293..0699139f 100644 --- a/src/main/java/com/jsh/erp/controller/UserController.java +++ b/src/main/java/com/jsh/erp/controller/UserController.java @@ -59,7 +59,7 @@ public class UserController { @PostMapping(value = "/login") public BaseResponseInfo login(@RequestParam(value = "loginame", required = false) String loginame, @RequestParam(value = "password", required = false) String password, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { logger.info("============用户登录 login 方法调用开始=============="); String msgTip = ""; User user=null; @@ -150,7 +150,7 @@ public class UserController { } @GetMapping(value = "/getUserSession") - public BaseResponseInfo getSessionUser(HttpServletRequest request) { + public BaseResponseInfo getSessionUser(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { Map data = new HashMap(); @@ -171,7 +171,7 @@ public class UserController { } @GetMapping(value = "/logout") - public BaseResponseInfo logout(HttpServletRequest request, HttpServletResponse response) { + public BaseResponseInfo logout(HttpServletRequest request, HttpServletResponse response)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { request.getSession().removeAttribute("user"); @@ -192,7 +192,7 @@ public class UserController { @PostMapping(value = "/resetPwd") public String resetPwd(@RequestParam("id") Long id, - HttpServletRequest request) throws NoSuchAlgorithmException { + HttpServletRequest request) throws Exception { Map objectMap = new HashMap(); String password = "123456"; String md5Pwd = Tools.md5Encryp(password); @@ -206,7 +206,7 @@ public class UserController { @PostMapping(value = "/updatePwd") public String updatePwd(@RequestParam("userId") Long userId, @RequestParam("password") String password, - @RequestParam("oldpwd") String oldpwd, HttpServletRequest request) { + @RequestParam("oldpwd") String oldpwd, HttpServletRequest request)throws Exception { Integer flag = 0; Map objectMap = new HashMap(); try { @@ -242,7 +242,7 @@ public class UserController { * @return */ @GetMapping(value = "/getAllList") - public BaseResponseInfo getAllList(HttpServletRequest request) { + public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { Map data = new HashMap(); @@ -425,7 +425,7 @@ public class UserController { } @GetMapping("/getTenantStatus") - public BaseResponseInfo getTenantStatus(HttpServletRequest request) { + public BaseResponseInfo getTenantStatus(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { Map data = new HashMap(); diff --git a/src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java b/src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java index 46765fe6..a699dc0b 100644 --- a/src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java @@ -35,6 +35,14 @@ public class GlobalExceptionHandler { status.put(ExceptionConstants.GLOBAL_RETURNS_CODE, ExceptionConstants.SERVICE_SYSTEM_ERROR_CODE); status.put(ExceptionConstants.GLOBAL_RETURNS_MESSAGE, ExceptionConstants.SERVICE_SYSTEM_ERROR_MSG); log.error("Global Exception Occured => url : {}, msg : {}", request.getRequestURL(), e.getMessage()); + /** + * create by: qiankunpingtai + * create time: 2019/4/18 17:41 + * website:https://qiankunpingtai.cn + * description: + * 这里输出完整的堆栈信息,否则有些异常完全不知道哪里出错了。 + */ + log.error("Global Exception Occured => url : {}", request.getRequestURL(), e); e.printStackTrace(); return status; } diff --git a/src/main/java/com/jsh/erp/service/CommonQueryManager.java b/src/main/java/com/jsh/erp/service/CommonQueryManager.java index 3d91ba84..7525a062 100644 --- a/src/main/java/com/jsh/erp/service/CommonQueryManager.java +++ b/src/main/java/com/jsh/erp/service/CommonQueryManager.java @@ -1,9 +1,6 @@ package com.jsh.erp.service; import com.jsh.erp.constants.BusinessConstants; -import com.jsh.erp.datasource.entities.Log; -import com.jsh.erp.datasource.entities.User; -import com.jsh.erp.datasource.mappers.LogMapper; import com.jsh.erp.service.log.LogService; import com.jsh.erp.utils.StringUtil; import org.springframework.stereotype.Service; @@ -12,12 +9,9 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Map; -import static com.jsh.erp.utils.Tools.getLocalIp; - /** * @author jishenghua 752718920 2018-10-7 15:25:58 */ @@ -36,7 +30,7 @@ public class CommonQueryManager { * @param apiName 接口名称 * @param id ID */ - public Object selectOne(String apiName, String id) { + public Object selectOne(String apiName, String id) throws Exception{ if (StringUtil.isNotEmpty(apiName) && StringUtil.isNotEmpty(id)) { return container.getCommonQuery(apiName).selectOne(id); } @@ -49,7 +43,7 @@ public class CommonQueryManager { * @param parameterMap * @return */ - public List select(String apiName, Map parameterMap) { + public List select(String apiName, Map parameterMap)throws Exception { if (StringUtil.isNotEmpty(apiName)) { return container.getCommonQuery(apiName).select(parameterMap); } @@ -62,7 +56,7 @@ public class CommonQueryManager { * @param parameterMap * @return */ - public Long counts(String apiName, Map parameterMap) { + public Long counts(String apiName, Map parameterMap)throws Exception { if (StringUtil.isNotEmpty(apiName)) { return container.getCommonQuery(apiName).counts(parameterMap); } @@ -76,7 +70,7 @@ public class CommonQueryManager { * @return */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insert(String apiName, String beanJson, HttpServletRequest request) { + public int insert(String apiName, String beanJson, HttpServletRequest request) throws Exception{ if (StringUtil.isNotEmpty(apiName)) { logService.insertLog(apiName, BusinessConstants.LOG_OPERATION_TYPE_ADD, request); return container.getCommonQuery(apiName).insert(beanJson, request); @@ -92,7 +86,7 @@ public class CommonQueryManager { * @return */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int update(String apiName, String beanJson, Long id, HttpServletRequest request) { + public int update(String apiName, String beanJson, Long id, HttpServletRequest request)throws Exception { if (StringUtil.isNotEmpty(apiName)) { logService.insertLog(apiName, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request); @@ -108,7 +102,7 @@ public class CommonQueryManager { * @return */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int delete(String apiName, Long id, HttpServletRequest request) { + public int delete(String apiName, Long id, HttpServletRequest request)throws Exception { if (StringUtil.isNotEmpty(apiName)) { logService.insertLog(apiName, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request); @@ -124,7 +118,7 @@ public class CommonQueryManager { * @return */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDelete(String apiName, String ids, HttpServletRequest request) { + public int batchDelete(String apiName, String ids, HttpServletRequest request)throws Exception { if (StringUtil.isNotEmpty(apiName)) { logService.insertLog(apiName, "批量删除,id集:" + ids, request); return container.getCommonQuery(apiName).batchDelete(ids); @@ -139,7 +133,7 @@ public class CommonQueryManager { * @param name * @return */ - public int checkIsNameExist(String apiName, Long id, String name) { + public int checkIsNameExist(String apiName, Long id, String name) throws Exception{ if (StringUtil.isNotEmpty(apiName)) { return container.getCommonQuery(apiName).checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/ICommonQuery.java b/src/main/java/com/jsh/erp/service/ICommonQuery.java index dc078636..0927a71e 100644 --- a/src/main/java/com/jsh/erp/service/ICommonQuery.java +++ b/src/main/java/com/jsh/erp/service/ICommonQuery.java @@ -18,7 +18,7 @@ public interface ICommonQuery { * @param condition 资源id * @return 资源 */ - Object selectOne(String condition); + Object selectOne(String condition) throws Exception; /** * 自定义查询 @@ -26,7 +26,7 @@ public interface ICommonQuery { * @param parameterMap 查询参数 * @return 查询结果 */ - List select(Map parameterMap); + List select(Map parameterMap) throws Exception; /** * 查询数量 @@ -34,7 +34,7 @@ public interface ICommonQuery { * @param parameterMap 查询参数 * @return 查询结果 */ - Long counts(Map parameterMap); + Long counts(Map parameterMap) throws Exception; /** * 新增数据 @@ -42,7 +42,7 @@ public interface ICommonQuery { * @param beanJson * @return */ - int insert(String beanJson, HttpServletRequest request); + int insert(String beanJson, HttpServletRequest request) throws Exception; /** * 更新数据 @@ -50,7 +50,7 @@ public interface ICommonQuery { * @param beanJson * @return */ - int update(String beanJson, Long id); + int update(String beanJson, Long id) throws Exception; /** * 删除数据 @@ -58,7 +58,7 @@ public interface ICommonQuery { * @param id * @return */ - int delete(Long id); + int delete(Long id) throws Exception; /** * 批量删除数据 @@ -66,7 +66,7 @@ public interface ICommonQuery { * @param ids * @return */ - int batchDelete(String ids); + int batchDelete(String ids) throws Exception; /** * 查询名称是否存在 @@ -74,5 +74,5 @@ public interface ICommonQuery { * @param id * @return */ - int checkIsNameExist(Long id, String name); + int checkIsNameExist(Long id, String name) throws Exception; } \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/service/account/AccountComponent.java b/src/main/java/com/jsh/erp/service/account/AccountComponent.java index ffd0e032..3676bd8f 100644 --- a/src/main/java/com/jsh/erp/service/account/AccountComponent.java +++ b/src/main/java/com/jsh/erp/service/account/AccountComponent.java @@ -1,8 +1,6 @@ package com.jsh.erp.service.account; import com.jsh.erp.service.ICommonQuery; -import com.jsh.erp.service.depot.DepotResource; -import com.jsh.erp.service.depot.DepotService; import com.jsh.erp.utils.Constants; import com.jsh.erp.utils.QueryUtils; import com.jsh.erp.utils.StringUtil; @@ -26,11 +24,11 @@ public class AccountComponent implements ICommonQuery { } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getAccountList(map); } - private List getAccountList(Map map) { + private List getAccountList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String serialNo = StringUtil.getInfo(search, "serialNo"); @@ -40,7 +38,7 @@ public class AccountComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String serialNo = StringUtil.getInfo(search, "serialNo"); @@ -49,27 +47,27 @@ public class AccountComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception{ return accountService.insertAccount(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return accountService.updateAccount(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return accountService.deleteAccount(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return accountService.batchDeleteAccount(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return accountService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/account/AccountService.java b/src/main/java/com/jsh/erp/service/account/AccountService.java index 8666d2dd..ba995fce 100644 --- a/src/main/java/com/jsh/erp/service/account/AccountService.java +++ b/src/main/java/com/jsh/erp/service/account/AccountService.java @@ -62,15 +62,33 @@ public class AccountService { return accountMapper.selectByPrimaryKey(id); } - public List getAccount() { + public List getAccount() throws Exception{ AccountExample example = new AccountExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return accountMapper.selectByExample(example); + List list=null; + try{ + list=accountMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; + } - public List select(String name, String serialNo, String remark, int offset, int rows) { + public List select(String name, String serialNo, String remark, int offset, int rows) throws Exception{ List resList = new ArrayList(); - List list = accountMapperEx.selectByConditionAccount(name, serialNo, remark, offset, rows); + List list=null; + try{ + list = accountMapperEx.selectByConditionAccount(name, serialNo, remark, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } String timeStr = Tools.getCurrentMonth(); if (null != list && null !=timeStr) { for (AccountVo4List al : list) { @@ -89,53 +107,114 @@ public class AccountService { return resList; } - public Long countAccount(String name, String serialNo, String remark) { - return accountMapperEx.countsByAccount(name, serialNo, remark); + public Long countAccount(String name, String serialNo, String remark)throws Exception { + Long result=null; + try{ + result=accountMapperEx.countsByAccount(name, serialNo, remark); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertAccount(String beanJson, HttpServletRequest request) { + public int insertAccount(String beanJson, HttpServletRequest request)throws Exception { Account account = JSONObject.parseObject(beanJson, Account.class); if(account.getInitialamount() == null) { account.setInitialamount(BigDecimal.ZERO); } account.setIsdefault(false); - return accountMapper.insertSelective(account); + int result=0; + try{ + result = accountMapper.insertSelective(account); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateAccount(String beanJson, Long id) { + public int updateAccount(String beanJson, Long id)throws Exception { Account account = JSONObject.parseObject(beanJson, Account.class); account.setId(id); - return accountMapper.updateByPrimaryKeySelective(account); + int result=0; + try{ + result = accountMapper.updateByPrimaryKeySelective(account); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteAccount(Long id) { - return accountMapper.deleteByPrimaryKey(id); + public int deleteAccount(Long id) throws Exception{ + int result=0; + try{ + result = accountMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteAccount(String ids) { + public int batchDeleteAccount(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); AccountExample example = new AccountExample(); example.createCriteria().andIdIn(idList); - return accountMapper.deleteByExample(example); + int result=0; + try{ + result = accountMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { AccountExample example = new AccountExample(); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - - List list = accountMapper.selectByExample(example); - return list.size(); + List list=null; + try{ + list = accountMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } - public List findBySelect() { + public List findBySelect()throws Exception { AccountExample example = new AccountExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - return accountMapper.selectByExample(example); + List list=null; + try{ + list = accountMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } /** @@ -144,7 +223,7 @@ public class AccountService { * @param id * @return */ - public BigDecimal getAccountSum(Long id, String timeStr, String type) { + public BigDecimal getAccountSum(Long id, String timeStr, String type) throws Exception{ BigDecimal accountSum = BigDecimal.ZERO; try { DepotHeadExample example = new DepotHeadExample(); @@ -164,7 +243,15 @@ public class AccountService { example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款") .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); } - List dataList = depotHeadMapper.selectByExample(example); + List dataList=null; + try{ + dataList = depotHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (dataList != null) { for (DepotHead depotHead : dataList) { if(depotHead.getChangeamount()!=null) { @@ -184,7 +271,7 @@ public class AccountService { * @param id * @return */ - public BigDecimal getAccountSumByHead(Long id, String timeStr, String type) { + public BigDecimal getAccountSumByHead(Long id, String timeStr, String type) throws Exception{ BigDecimal accountSum = BigDecimal.ZERO; try { AccountHeadExample example = new AccountHeadExample(); @@ -205,7 +292,15 @@ public class AccountService { example.createCriteria().andAccountidEqualTo(id) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); } - List dataList = accountHeadMapper.selectByExample(example); + List dataList=null; + try{ + dataList = accountHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (dataList != null) { for (AccountHead accountHead : dataList) { if(accountHead.getChangeamount()!=null) { @@ -225,7 +320,7 @@ public class AccountService { * @param id * @return */ - public BigDecimal getAccountSumByDetail(Long id, String timeStr, String type) { + public BigDecimal getAccountSumByDetail(Long id, String timeStr, String type)throws Exception { BigDecimal accountSum =BigDecimal.ZERO ; try { AccountHeadExample example = new AccountHeadExample(); @@ -241,7 +336,15 @@ public class AccountService { .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); } } - List dataList = accountHeadMapper.selectByExample(example); + List dataList=null; + try{ + dataList = accountHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (dataList != null) { String ids = ""; for (AccountHead accountHead : dataList) { @@ -283,7 +386,7 @@ public class AccountService { * @param id * @return */ - public BigDecimal getManyAccountSum(Long id, String timeStr, String type) { + public BigDecimal getManyAccountSum(Long id, String timeStr, String type)throws Exception { BigDecimal accountSum = BigDecimal.ZERO; try { DepotHeadExample example = new DepotHeadExample(); @@ -304,7 +407,15 @@ public class AccountService { example.createCriteria().andAccountidlistLike("%" +id.toString() + "%") .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); } - List dataList = depotHeadMapper.selectByExample(example); + List dataList=null; + try{ + dataList = depotHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (dataList != null) { for (DepotHead depotHead : dataList) { String accountIdList = depotHead.getAccountidlist(); @@ -326,32 +437,68 @@ public class AccountService { return accountSum; } - public List findAccountInOutList(Long accountId, Integer offset, Integer rows) { - return accountMapperEx.findAccountInOutList(accountId, offset, rows); + public List findAccountInOutList(Long accountId, Integer offset, Integer rows) throws Exception{ + List list=null; + try{ + list = accountMapperEx.findAccountInOutList(accountId, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public int findAccountInOutListCount(Long accountId) { - return accountMapperEx.findAccountInOutListCount(accountId); + public int findAccountInOutListCount(Long accountId) throws Exception{ + int result=0; + try{ + result = accountMapperEx.findAccountInOutListCount(accountId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateAmountIsDefault(Boolean isDefault, Long accountId) { + public int updateAmountIsDefault(Boolean isDefault, Long accountId) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT,BusinessConstants.LOG_OPERATION_TYPE_EDIT+accountId, ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); Account account = new Account(); account.setIsdefault(isDefault); AccountExample example = new AccountExample(); example.createCriteria().andIdEqualTo(accountId); - return accountMapper.updateByExampleSelective(account, example); + int result=0; + try{ + result = accountMapper.updateByExampleSelective(account, example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteAccountByIds(String ids) { + public int batchDeleteAccountByIds(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return accountMapperEx.batchDeleteAccountByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result = accountMapperEx.batchDeleteAccountByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: qiankunpingtai @@ -379,7 +526,15 @@ public class AccountService { /** * 校验财务主表 jsh_accounthead * */ - List accountHeadList=accountHeadMapperEx.getAccountHeadListByAccountIds(idArray); + List accountHeadList=null; + try{ + accountHeadList = accountHeadMapperEx.getAccountHeadListByAccountIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(accountHeadList!=null&&accountHeadList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -389,7 +544,15 @@ public class AccountService { /** * 校验财务子表 jsh_accountitem * */ - List accountItemList=accountItemMapperEx.getAccountItemListByAccountIds(idArray); + List accountItemList=null; + try{ + accountItemList = accountItemMapperEx.getAccountItemListByAccountIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(accountItemList!=null&&accountItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -399,7 +562,15 @@ public class AccountService { /** * 校验单据主表 jsh_depothead * */ - List depotHeadList=depotHeadMapperEx.getDepotHeadListByAccountIds(idArray); + List depotHeadList =null; + try{ + depotHeadList = depotHeadMapperEx.getDepotHeadListByAccountIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(depotHeadList!=null&&depotHeadList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); diff --git a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java index d07e3e27..a9b67219 100644 --- a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java +++ b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java @@ -19,16 +19,16 @@ public class AccountHeadComponent implements ICommonQuery { private AccountHeadService accountHeadService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition) throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getAccountHeadList(map); } - private List getAccountHeadList(Map map) { + private List getAccountHeadList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String type = StringUtil.getInfo(search, "type"); String billNo = StringUtil.getInfo(search, "billNo"); @@ -39,7 +39,7 @@ public class AccountHeadComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String type = StringUtil.getInfo(search, "type"); String billNo = StringUtil.getInfo(search, "billNo"); @@ -49,27 +49,27 @@ public class AccountHeadComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception{ return accountHeadService.insertAccountHead(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return accountHeadService.updateAccountHead(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return accountHeadService.deleteAccountHead(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return accountHeadService.batchDeleteAccountHead(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return accountHeadService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java index bfc72f33..45cd02a7 100644 --- a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java +++ b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java @@ -42,18 +42,44 @@ public class AccountHeadService { @Resource private AccountItemMapperEx accountItemMapperEx; - public AccountHead getAccountHead(long id) { - return accountHeadMapper.selectByPrimaryKey(id); + public AccountHead getAccountHead(long id) throws Exception { + AccountHead result=null; + try{ + result=accountHeadMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getAccountHead() { + public List getAccountHead() throws Exception{ AccountHeadExample example = new AccountHeadExample(); - return accountHeadMapper.selectByExample(example); + List list=null; + try{ + list=accountHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String type, String billNo, String beginTime, String endTime, int offset, int rows) { + public List select(String type, String billNo, String beginTime, String endTime, int offset, int rows) throws Exception{ List resList = new ArrayList(); - List list = accountHeadMapperEx.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows); + List list=null; + try{ + list = accountHeadMapperEx.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (null != list) { for (AccountHeadVo4ListEx ah : list) { if(ah.getChangeamount() != null) { @@ -68,45 +94,107 @@ public class AccountHeadService { return resList; } - public Long countAccountHead(String type, String billNo, String beginTime, String endTime) { - return accountHeadMapperEx.countsByAccountHead(type, billNo, beginTime, endTime); + public Long countAccountHead(String type, String billNo, String beginTime, String endTime) throws Exception{ + Long result=null; + try{ + result = accountHeadMapperEx.countsByAccountHead(type, billNo, beginTime, endTime); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertAccountHead(String beanJson, HttpServletRequest request) { + public int insertAccountHead(String beanJson, HttpServletRequest request) throws Exception{ AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); - return accountHeadMapper.insertSelective(accountHead); + int result=0; + try{ + result = accountHeadMapper.insertSelective(accountHead); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateAccountHead(String beanJson, Long id) { + public int updateAccountHead(String beanJson, Long id)throws Exception { AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); accountHead.setId(id); - return accountHeadMapper.updateByPrimaryKeySelective(accountHead); + int result=0; + try{ + result = accountHeadMapper.updateByPrimaryKeySelective(accountHead); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteAccountHead(Long id) { - return accountHeadMapper.deleteByPrimaryKey(id); + public int deleteAccountHead(Long id)throws Exception { + int result=0; + try{ + result = accountHeadMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteAccountHead(String ids) { + public int batchDeleteAccountHead(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); AccountHeadExample example = new AccountHeadExample(); example.createCriteria().andIdIn(idList); - return accountHeadMapper.deleteByExample(example); + int result=0; + try{ + result = accountHeadMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { AccountHeadExample example = new AccountHeadExample(); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = accountHeadMapper.selectByExample(example); - return list.size(); + List list = null; + try{ + list = accountHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } - public Long getMaxId() { - return accountHeadMapperEx.getMaxId(); + public Long getMaxId()throws Exception { + Long result = null; + try{ + result = accountHeadMapperEx.getMaxId(); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } public BigDecimal findAllMoney(Integer supplierId, String type, String mode, String endTime) { @@ -116,12 +204,29 @@ public class AccountHeadService { } else if (mode.equals("合计")) { modeName = "TotalPrice"; } - return accountHeadMapperEx.findAllMoney(supplierId, type, modeName, endTime); + BigDecimal result = null; + try{ + result = accountHeadMapperEx.findAllMoney(supplierId, type, modeName, endTime); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getDetailByNumber(String billNo) { + public List getDetailByNumber(String billNo)throws Exception { List resList = new ArrayList(); - List list = accountHeadMapperEx.getDetailByNumber(billNo); + List list = null; + try{ + list = accountHeadMapperEx.getDetailByNumber(billNo); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (null != list) { for (AccountHeadVo4ListEx ah : list) { if(ah.getChangeamount() != null) { @@ -136,13 +241,22 @@ public class AccountHeadService { return resList; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteAccountHeadByIds(String ids) { + public int batchDeleteAccountHeadByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_HEAD, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return accountHeadMapperEx.batchDeleteAccountHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result = 0; + try{ + result = accountHeadMapperEx.batchDeleteAccountHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: qiankunpingtai @@ -168,7 +282,15 @@ public class AccountHeadService { /** * 校验财务子表 jsh_accountitem * */ - List accountItemList=accountItemMapperEx.getAccountItemListByHeaderIds(idArray); + List accountItemList = null; + try{ + accountItemList = accountItemMapperEx.getAccountItemListByHeaderIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(accountItemList!=null&&accountItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,HeaderIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); diff --git a/src/main/java/com/jsh/erp/service/accountItem/AccountItemComponent.java b/src/main/java/com/jsh/erp/service/accountItem/AccountItemComponent.java index 2258be84..f7ae1daf 100644 --- a/src/main/java/com/jsh/erp/service/accountItem/AccountItemComponent.java +++ b/src/main/java/com/jsh/erp/service/accountItem/AccountItemComponent.java @@ -19,16 +19,16 @@ public class AccountItemComponent implements ICommonQuery { private AccountItemService accountItemService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getAccountItemList(map); } - private List getAccountItemList(Map map) { + private List getAccountItemList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); @@ -38,7 +38,7 @@ public class AccountItemComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); @@ -47,27 +47,27 @@ public class AccountItemComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception{ return accountItemService.insertAccountItem(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return accountItemService.updateAccountItem(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return accountItemService.deleteAccountItem(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return accountItemService.batchDeleteAccountItem(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return accountItemService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/accountItem/AccountItemService.java b/src/main/java/com/jsh/erp/service/accountItem/AccountItemService.java index c1ad30dc..4aed68c9 100644 --- a/src/main/java/com/jsh/erp/service/accountItem/AccountItemService.java +++ b/src/main/java/com/jsh/erp/service/accountItem/AccountItemService.java @@ -3,12 +3,15 @@ package com.jsh.erp.service.accountItem; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; +import com.jsh.erp.datasource.entities.AccountHead; import com.jsh.erp.datasource.entities.AccountItem; import com.jsh.erp.datasource.entities.AccountItemExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.AccountItemMapper; import com.jsh.erp.datasource.mappers.AccountItemMapperEx; import com.jsh.erp.datasource.vo.AccountItemVo4List; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.ErpInfo; @@ -43,72 +46,179 @@ public class AccountItemService { @Resource private UserService userService; - public AccountItem getAccountItem(long id) { - return accountItemMapper.selectByPrimaryKey(id); + public AccountItem getAccountItem(long id)throws Exception { + AccountItem result=null; + try{ + result=accountItemMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getAccountItem() { + public List getAccountItem()throws Exception { AccountItemExample example = new AccountItemExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return accountItemMapper.selectByExample(example); + List list=null; + try{ + list=accountItemMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, Integer type, String remark, int offset, int rows) { - return accountItemMapperEx.selectByConditionAccountItem(name, type, remark, offset, rows); + public List select(String name, Integer type, String remark, int offset, int rows)throws Exception { + List list=null; + try{ + list = accountItemMapperEx.selectByConditionAccountItem(name, type, remark, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countAccountItem(String name, Integer type, String remark) { - return accountItemMapperEx.countsByAccountItem(name, type, remark); + public Long countAccountItem(String name, Integer type, String remark)throws Exception { + Long result=null; + try{ + result = accountItemMapperEx.countsByAccountItem(name, type, remark); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertAccountItem(String beanJson, HttpServletRequest request) { + public int insertAccountItem(String beanJson, HttpServletRequest request) throws Exception{ AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class); - return accountItemMapper.insertSelective(accountItem); + int result=0; + try{ + result = accountItemMapper.insertSelective(accountItem); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateAccountItem(String beanJson, Long id) { + public int updateAccountItem(String beanJson, Long id)throws Exception { AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class); accountItem.setId(id); - return accountItemMapper.updateByPrimaryKeySelective(accountItem); + int result=0; + try{ + result = accountItemMapper.updateByPrimaryKeySelective(accountItem); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteAccountItem(Long id) { - return accountItemMapper.deleteByPrimaryKey(id); + public int deleteAccountItem(Long id)throws Exception { + int result=0; + try{ + result = accountItemMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteAccountItem(String ids) { + public int batchDeleteAccountItem(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); AccountItemExample example = new AccountItemExample(); example.createCriteria().andIdIn(idList); - return accountItemMapper.deleteByExample(example); + int result=0; + try{ + result = accountItemMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { AccountItemExample example = new AccountItemExample(); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = accountItemMapper.selectByExample(example); - return list.size(); + List list = null; + try{ + list = accountItemMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertAccountItemWithObj(AccountItem accountItem) { - return accountItemMapper.insertSelective(accountItem); + public int insertAccountItemWithObj(AccountItem accountItem)throws Exception { + int result=0; + try{ + result = accountItemMapper.insertSelective(accountItem); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateAccountItemWithObj(AccountItem accountItem) { - return accountItemMapper.updateByPrimaryKeySelective(accountItem); + public int updateAccountItemWithObj(AccountItem accountItem)throws Exception { + int result=0; + try{ + result = accountItemMapper.updateByPrimaryKeySelective(accountItem); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } public List getDetailList(Long headerId) { - return accountItemMapperEx.getDetailList(headerId); + List list=null; + try{ + list = accountItemMapperEx.getDetailList(headerId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public String saveDetials(String inserted, String deleted, String updated, Long headerId, String listType) throws DataAccessException { + public String saveDetials(String inserted, String deleted, String updated, Long headerId, String listType) throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(",headerId:").append(headerId).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); @@ -181,12 +291,21 @@ public class AccountItemService { return null; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteAccountItemByIds(String ids) { + public int batchDeleteAccountItemByIds(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } } diff --git a/src/main/java/com/jsh/erp/service/app/AppComponent.java b/src/main/java/com/jsh/erp/service/app/AppComponent.java index d7d5f7f6..a5759efd 100644 --- a/src/main/java/com/jsh/erp/service/app/AppComponent.java +++ b/src/main/java/com/jsh/erp/service/app/AppComponent.java @@ -19,16 +19,16 @@ public class AppComponent implements ICommonQuery { private AppService appService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getAppList(map); } - private List getAppList(Map map) { + private List getAppList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -37,7 +37,7 @@ public class AppComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -45,27 +45,27 @@ public class AppComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return appService.insertApp(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return appService.updateApp(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return appService.deleteApp(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return appService.batchDeleteApp(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return 0; } diff --git a/src/main/java/com/jsh/erp/service/app/AppService.java b/src/main/java/com/jsh/erp/service/app/AppService.java index 150091a1..907d5c5c 100644 --- a/src/main/java/com/jsh/erp/service/app/AppService.java +++ b/src/main/java/com/jsh/erp/service/app/AppService.java @@ -2,12 +2,14 @@ package com.jsh.erp.service.app; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.App; import com.jsh.erp.datasource.entities.AppExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.UserBusiness; import com.jsh.erp.datasource.mappers.AppMapper; import com.jsh.erp.datasource.mappers.AppMapperEx; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.userBusiness.UserBusinessService; @@ -40,11 +42,19 @@ public class AppService { @Resource private UserBusinessService userBusinessService; - public List findDock(){ + public List findDock()throws Exception{ AppExample example = new AppExample(); example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } /** @@ -55,86 +65,191 @@ public class AppService { * @Param: null * @return */ - public List findDesk(){ + public List findDesk()throws Exception{ AppExample example = new AppExample(); example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } - public App getApp(long id) { - return appMapper.selectByPrimaryKey(id); + public App getApp(long id)throws Exception { + App result=null; + try{ + result=appMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getApp() { + public List getApp()throws Exception { AppExample example = new AppExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, String type, int offset, int rows) { - return appMapperEx.selectByConditionApp(name, type, offset, rows); + public List select(String name, String type, int offset, int rows)throws Exception { + List list=null; + try{ + list=appMapperEx.selectByConditionApp(name, type, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countApp(String name, String type) { - return appMapperEx.countsByApp(name, type); + public Long countApp(String name, String type)throws Exception { + Long result=null; + try{ + result=appMapperEx.countsByApp(name, type); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertApp(String beanJson, HttpServletRequest request) { + public int insertApp(String beanJson, HttpServletRequest request)throws Exception { App app = JSONObject.parseObject(beanJson, App.class); - return appMapper.insertSelective(app); + int result=0; + try{ + result=appMapper.insertSelective(app); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateApp(String beanJson, Long id) { + public int updateApp(String beanJson, Long id) throws Exception{ App app = JSONObject.parseObject(beanJson, App.class); app.setId(id); - return appMapper.updateByPrimaryKeySelective(app); + int result=0; + try{ + result=appMapper.updateByPrimaryKeySelective(app); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteApp(Long id) { - return appMapper.deleteByPrimaryKey(id); + public int deleteApp(Long id)throws Exception { + int result=0; + try{ + result=appMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteApp(String ids) { + public int batchDeleteApp(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); AppExample example = new AppExample(); example.createCriteria().andIdIn(idList); - return appMapper.deleteByExample(example); + int result=0; + try{ + result=appMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public List findRoleAPP(){ + public List findRoleAPP()throws Exception{ AppExample example = new AppExample(); example.createCriteria().andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } - public List findAppInIds(String ids, String type){ + public List findAppInIds(String ids, String type)throws Exception{ List idList = StringUtil.strToLongList(ids); AppExample example = new AppExample(); example.createCriteria().andZlEqualTo(type).andEnabledEqualTo(true).andIdIn(idList) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteAppByIds(String ids) { + public int batchDeleteAppByIds(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_APP, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return appMapperEx.batchDeleteAppByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result=appMapperEx.batchDeleteAppByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public List findAppByUserId(String userId) { + public List findAppByUserId(String userId)throws Exception { List roleList = userBusinessService.findRoleByUserId(userId); String roles = null; if(roleList!=null && roleList.size()>0 && roleList.get(0)!=null){ @@ -162,10 +277,19 @@ public class AppService { * @param numberList * @return */ - public List findAppByNumber(List numberList) { + public List findAppByNumber(List numberList) throws Exception{ AppExample example = new AppExample(); example.createCriteria().andEnabledEqualTo(true).andNumberIn(numberList); - return appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } } diff --git a/src/main/java/com/jsh/erp/service/depot/DepotComponent.java b/src/main/java/com/jsh/erp/service/depot/DepotComponent.java index f267fe68..7dc0f06c 100644 --- a/src/main/java/com/jsh/erp/service/depot/DepotComponent.java +++ b/src/main/java/com/jsh/erp/service/depot/DepotComponent.java @@ -20,16 +20,16 @@ public class DepotComponent implements ICommonQuery { private DepotService depotService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getDepotList(map); } - private List getDepotList(Map map) { + private List getDepotList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); @@ -39,7 +39,7 @@ public class DepotComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); @@ -48,27 +48,27 @@ public class DepotComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception{ return depotService.insertDepot(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return depotService.updateDepot(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return depotService.deleteDepot(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return depotService.batchDeleteDepot(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return depotService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/depot/DepotService.java b/src/main/java/com/jsh/erp/service/depot/DepotService.java index 8b2edfbc..b1ba5c8a 100644 --- a/src/main/java/com/jsh/erp/service/depot/DepotService.java +++ b/src/main/java/com/jsh/erp/service/depot/DepotService.java @@ -41,91 +41,214 @@ public class DepotService { @Resource private DepotItemMapperEx depotItemMapperEx; - public Depot getDepot(long id) { - return depotMapper.selectByPrimaryKey(id); + public Depot getDepot(long id)throws Exception { + Depot result=null; + try{ + result=depotMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getDepot() { + public List getDepot()throws Exception { DepotExample example = new DepotExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return depotMapper.selectByExample(example); + List list=null; + try{ + list=depotMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List getAllList() { + public List getAllList()throws Exception { DepotExample example = new DepotExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("sort"); - return depotMapper.selectByExample(example); + List list=null; + try{ + list=depotMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, Integer type, String remark, int offset, int rows) { - return depotMapperEx.selectByConditionDepot(name, type, remark, offset, rows); + public List select(String name, Integer type, String remark, int offset, int rows)throws Exception { + List list=null; + try{ + list=depotMapperEx.selectByConditionDepot(name, type, remark, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countDepot(String name, Integer type, String remark) { - return depotMapperEx.countsByDepot(name, type, remark); + public Long countDepot(String name, Integer type, String remark)throws Exception { + Long result=null; + try{ + result=depotMapperEx.countsByDepot(name, type, remark); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertDepot(String beanJson, HttpServletRequest request) { + public int insertDepot(String beanJson, HttpServletRequest request)throws Exception { Depot depot = JSONObject.parseObject(beanJson, Depot.class); - return depotMapper.insertSelective(depot); + int result=0; + try{ + result=depotMapper.insertSelective(depot); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateDepot(String beanJson, Long id) { + public int updateDepot(String beanJson, Long id) throws Exception{ Depot depot = JSONObject.parseObject(beanJson, Depot.class); depot.setId(id); - return depotMapper.updateByPrimaryKeySelective(depot); + int result=0; + try{ + result= depotMapper.updateByPrimaryKeySelective(depot); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteDepot(Long id) { - return depotMapper.deleteByPrimaryKey(id); + public int deleteDepot(Long id)throws Exception { + int result=0; + try{ + result= depotMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteDepot(String ids) { + public int batchDeleteDepot(String ids) throws Exception{ List idList = StringUtil.strToLongList(ids); DepotExample example = new DepotExample(); example.createCriteria().andIdIn(idList); - return depotMapper.deleteByExample(example); + int result=0; + try{ + result= depotMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { DepotExample example = new DepotExample(); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = depotMapper.selectByExample(example); - return list.size(); + List list=null; + try{ + list= depotMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } - public List findUserDepot(){ + public List findUserDepot()throws Exception{ DepotExample example = new DepotExample(); example.createCriteria().andTypeEqualTo(0).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = depotMapper.selectByExample(example); + List list=null; + try{ + list= depotMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } - public List findGiftByType(Integer type){ + public List findGiftByType(Integer type)throws Exception{ DepotExample example = new DepotExample(); example.createCriteria().andTypeEqualTo(type); example.setOrderByClause("Sort"); - List list = depotMapper.selectByExample(example); + List list=null; + try{ + list= depotMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } - public List getDepotList(Map parameterMap) { - return depotMapperEx.getDepotList(parameterMap); + public List getDepotList(Map parameterMap)throws Exception { + List list=null; + try{ + list= depotMapperEx.getDepotList(parameterMap); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteDepotByIds(String ids) { + public int batchDeleteDepotByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result= depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: qiankunpingtai @@ -153,7 +276,15 @@ public class DepotService { /** * 校验单据主表 jsh_depothead * */ - List depotHeadList=depotHeadMapperEx.getDepotHeadListByDepotIds(idArray); + List depotHeadList=null; + try{ + depotHeadList= depotHeadMapperEx.getDepotHeadListByDepotIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(depotHeadList!=null&&depotHeadList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -163,7 +294,15 @@ public class DepotService { /** * 校验单据子表 jsh_depotitem * */ - List depotItemList=depotItemMapperEx.getDepotItemListListByDepotIds(idArray); + List depotItemList=null; + try{ + depotItemList= depotItemMapperEx.getDepotItemListListByDepotIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(depotItemList!=null&&depotItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); diff --git a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java index 5f91eb1c..ba817286 100644 --- a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java +++ b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java @@ -19,16 +19,16 @@ public class DepotHeadComponent implements ICommonQuery { private DepotHeadService depotHeadService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getDepotHeadList(map); } - private List getDepotHeadList(Map map) { + private List getDepotHeadList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String type = StringUtil.getInfo(search, "type"); String subType = StringUtil.getInfo(search, "subType"); @@ -41,7 +41,7 @@ public class DepotHeadComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String type = StringUtil.getInfo(search, "type"); String subType = StringUtil.getInfo(search, "subType"); @@ -53,27 +53,27 @@ public class DepotHeadComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception{ return depotHeadService.insertDepotHead(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return depotHeadService.updateDepotHead(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return depotHeadService.deleteDepotHead(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return depotHeadService.batchDeleteDepotHead(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return depotHeadService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index a78aba33..28df070a 100644 --- a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -2,6 +2,7 @@ package com.jsh.erp.service.depotHead; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.DepotHead; import com.jsh.erp.datasource.entities.DepotHeadExample; import com.jsh.erp.datasource.entities.DepotItem; @@ -13,6 +14,7 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail; import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount; import com.jsh.erp.datasource.vo.DepotHeadVo4List; import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.depotItem.DepotItemService; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.serialNumber.SerialNumberService; @@ -58,19 +60,45 @@ public class DepotHeadService { private LogService logService; - public DepotHead getDepotHead(long id) { - return depotHeadMapper.selectByPrimaryKey(id); + public DepotHead getDepotHead(long id)throws Exception { + DepotHead result=null; + try{ + result=depotHeadMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getDepotHead() { + public List getDepotHead()throws Exception { DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return depotHeadMapper.selectByExample(example); + List list=null; + try{ + list=depotHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows) { + public List select(String type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows)throws Exception { List resList = new ArrayList(); - List list = depotHeadMapperEx.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows); + List list=null; + try{ + list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (null != list) { for (DepotHeadVo4List dh : list) { if(dh.getOthermoneylist() != null) { @@ -97,12 +125,21 @@ public class DepotHeadService { - public Long countDepotHead(String type, String subType, String number, String beginTime, String endTime, String dhIds) { - return depotHeadMapperEx.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds); + public Long countDepotHead(String type, String subType, String number, String beginTime, String endTime, String dhIds) throws Exception{ + Long result=null; + try{ + result=depotHeadMapperEx.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertDepotHead(String beanJson, HttpServletRequest request) { + public int insertDepotHead(String beanJson, HttpServletRequest request)throws Exception { DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); //判断用户是否已经登录过,登录过不再处理 Object userInfo = request.getSession().getAttribute("user"); @@ -113,42 +150,94 @@ public class DepotHeadService { } depotHead.setCreatetime(new Timestamp(System.currentTimeMillis())); depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT); - return depotHeadMapper.insert(depotHead); + int result=0; + try{ + result=depotHeadMapper.insert(depotHead); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateDepotHead(String beanJson, Long id) { - DepotHead dh = depotHeadMapper.selectByPrimaryKey(id); + public int updateDepotHead(String beanJson, Long id) throws Exception{ + DepotHead dh=null; + try{ + dh = depotHeadMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); depotHead.setId(id); depotHead.setStatus(dh.getStatus()); depotHead.setCreatetime(dh.getCreatetime()); depotHead.setOperpersonname(dh.getOperpersonname()); - return depotHeadMapper.updateByPrimaryKey(depotHead); + int result=0; + try{ + result = depotHeadMapper.updateByPrimaryKey(depotHead); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteDepotHead(Long id) { - return depotHeadMapper.deleteByPrimaryKey(id); + public int deleteDepotHead(Long id)throws Exception { + int result=0; + try{ + result = depotHeadMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteDepotHead(String ids) { + public int batchDeleteDepotHead(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andIdIn(idList); - return depotHeadMapper.deleteByExample(example); + int result=0; + try{ + result = depotHeadMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = depotHeadMapper.selectByExample(example); - return list.size(); + List list = null; + try{ + list = depotHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchSetStatus(String status, String depotHeadIDs) { + public int batchSetStatus(String status, String depotHeadIDs)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHeadIDs).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); @@ -157,15 +246,32 @@ public class DepotHeadService { depotHead.setStatus(status); DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andIdIn(ids); - return depotHeadMapper.updateByExampleSelective(depotHead, example); + int result = 0; + try{ + result = depotHeadMapper.updateByExampleSelective(depotHead, example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * 创建一个唯一的序列号 * */ - public String buildOnlyNumber(){ + public String buildOnlyNumber()throws Exception{ Long buildOnlyNumber=null; synchronized (this){ - buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ); + try{ + buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + } if(buildOnlyNumber findByMonth(String monthTime) { + public List findByMonth(String monthTime)throws Exception { DepotHeadExample example = new DepotHeadExample(); monthTime = monthTime + "-31 23:59:59"; Date month = StringUtil.getDateByString(monthTime, null); example.createCriteria().andOpertimeLessThanOrEqualTo(month).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return depotHeadMapper.selectByExample(example); + List list = null; + try{ + list = depotHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List getDepotHeadGiftOut(String projectId) { + public List getDepotHeadGiftOut(String projectId)throws Exception { DepotHeadExample example = new DepotHeadExample(); if (projectId != null) { example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId)); } - return depotHeadMapper.selectByExample(example); + List list = null; + try{ + list =depotHeadMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) { - return depotHeadMapperEx.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows); + public List findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) throws Exception{ + List list = null; + try{ + list =depotHeadMapperEx.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) { - return depotHeadMapperEx.findByAllCount(beginTime, endTime, type, pid, dids, oId); + public int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) throws Exception{ + int result = 0; + try{ + result =depotHeadMapperEx.findByAllCount(beginTime, endTime, type, pid, dids, oId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) { - return depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, offset, rows); + public List findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows)throws Exception { + List list = null; + try{ + list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) { - return depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId); + public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId)throws Exception { + int result = 0; + try{ + result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows) { - return depotHeadMapperEx.findStatementAccount(beginTime, endTime, organId, supType, offset, rows); + public List findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows)throws Exception { + List list = null; + try{ + list =depotHeadMapperEx.findStatementAccount(beginTime, endTime, organId, supType, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) { - return depotHeadMapperEx.findStatementAccountCount(beginTime, endTime, organId, supType); + public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) throws Exception{ + int result = 0; + try{ + result =depotHeadMapperEx.findStatementAccountCount(beginTime, endTime, organId, supType); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) { + public BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime)throws Exception { String modeName = ""; if (mode.equals("实际")) { modeName = "ChangeAmount"; } else if (mode.equals("合计")) { modeName = "DiscountLastMoney"; } - return depotHeadMapperEx.findAllMoney(supplierId, type, subType, modeName, endTime); + BigDecimal result = null; + try{ + result =depotHeadMapperEx.findAllMoney(supplierId, type, subType, modeName, endTime); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getDetailByNumber(String number) { + public List getDetailByNumber(String number)throws Exception { List resList = new ArrayList(); - List list = depotHeadMapperEx.getDetailByNumber(number); + List list = null; + try{ + list = depotHeadMapperEx.getDetailByNumber(number); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (null != list) { for (DepotHeadVo4List dh : list) { if(dh.getOthermoneylist() != null) { @@ -288,7 +500,15 @@ public class DepotHeadService { depotHead.setOperpersonname(userInfo==null?null:userInfo.getUsername()); depotHead.setCreatetime(new Timestamp(System.currentTimeMillis())); depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT); - depotHeadMapperEx.adddepotHead(depotHead); + try{ + depotHeadMapperEx.adddepotHead(depotHead); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + /**入库和出库处理预付款信息*/ if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPaytype())){ if(depotHead.getOrganid()!=null) { @@ -303,7 +523,14 @@ public class DepotHeadService { depotHeadOrders.setStatus(BusinessConstants.BILLS_STATUS_SKIP); DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andNumberEqualTo(depotHead.getLinknumber()); - depotHeadMapper.updateByExampleSelective(depotHeadOrders, example); + try{ + depotHeadMapper.updateByExampleSelective(depotHeadOrders, example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } } } /** @@ -331,7 +558,14 @@ public class DepotHeadService { User userInfo=userService.getCurrentUser(); depotHead.setOperpersonname(userInfo==null?null:userInfo.getUsername()); depotHead.setOpertime(new Timestamp(System.currentTimeMillis())); - depotHeadMapperEx.updatedepotHead(depotHead); + try{ + depotHeadMapperEx.updatedepotHead(depotHead); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } /**入库和出库处理预付款信息*/ if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPaytype())){ if(depotHead.getOrganid()!=null){ @@ -362,7 +596,16 @@ public class DepotHeadService { if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType()) &&!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())){ //查询单据子表列表 - List depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(id,BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED); + List depotItemList=null; + try{ + depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(id,BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + /**回收序列号*/ if(depotItemList!=null&&depotItemList.size()>0){ for(DepotItem depotItem:depotItemList){ @@ -372,7 +615,15 @@ public class DepotHeadService { } } /**删除单据子表数据*/ - depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long []{id}); + try{ + depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long []{id}); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + /**删除单据主表信息*/ batchDeleteDepotHeadByIds(id.toString()); } @@ -397,12 +648,21 @@ public class DepotHeadService { } } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteDepotHeadByIds(String ids) { + public int batchDeleteDepotHeadByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return depotHeadMapperEx.batchDeleteDepotHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result = depotHeadMapperEx.batchDeleteDepotHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } } diff --git a/src/main/java/com/jsh/erp/service/depotItem/DepotItemComponent.java b/src/main/java/com/jsh/erp/service/depotItem/DepotItemComponent.java index 15748e82..898d3999 100644 --- a/src/main/java/com/jsh/erp/service/depotItem/DepotItemComponent.java +++ b/src/main/java/com/jsh/erp/service/depotItem/DepotItemComponent.java @@ -19,16 +19,16 @@ public class DepotItemComponent implements ICommonQuery { private DepotItemService depotItemService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getDepotItemList(map); } - private List getDepotItemList(Map map) { + private List getDepotItemList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); @@ -38,7 +38,7 @@ public class DepotItemComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); @@ -47,27 +47,27 @@ public class DepotItemComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return depotItemService.insertDepotItem(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return depotItemService.updateDepotItem(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return depotItemService.deleteDepotItem(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return depotItemService.batchDeleteDepotItem(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return depotItemService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java b/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java index 48cc8070..33650f01 100644 --- a/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java +++ b/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java @@ -60,175 +60,394 @@ public class DepotItemService { @Resource private LogService logService; - public DepotItem getDepotItem(long id) { - return depotItemMapper.selectByPrimaryKey(id); + public DepotItem getDepotItem(long id)throws Exception { + DepotItem result=null; + try{ + result=depotItemMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getDepotItem() { + public List getDepotItem()throws Exception { DepotItemExample example = new DepotItemExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return depotItemMapper.selectByExample(example); + List list=null; + try{ + list=depotItemMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, Integer type, String remark, int offset, int rows) { - return depotItemMapperEx.selectByConditionDepotItem(name, type, remark, offset, rows); + public List select(String name, Integer type, String remark, int offset, int rows)throws Exception { + List list=null; + try{ + list=depotItemMapperEx.selectByConditionDepotItem(name, type, remark, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countDepotItem(String name, Integer type, String remark) { - return depotItemMapperEx.countsByDepotItem(name, type, remark); + public Long countDepotItem(String name, Integer type, String remark) throws Exception{ + Long result =null; + try{ + result=depotItemMapperEx.countsByDepotItem(name, type, remark); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertDepotItem(String beanJson, HttpServletRequest request) { + public int insertDepotItem(String beanJson, HttpServletRequest request)throws Exception { DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class); - return depotItemMapper.insertSelective(depotItem); + int result =0; + try{ + result=depotItemMapper.insertSelective(depotItem); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateDepotItem(String beanJson, Long id) { + public int updateDepotItem(String beanJson, Long id)throws Exception { DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class); depotItem.setId(id); - return depotItemMapper.updateByPrimaryKeySelective(depotItem); + int result =0; + try{ + result=depotItemMapper.updateByPrimaryKeySelective(depotItem); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteDepotItem(Long id) { - return depotItemMapper.deleteByPrimaryKey(id); + public int deleteDepotItem(Long id)throws Exception { + int result =0; + try{ + result=depotItemMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteDepotItem(String ids) { + public int batchDeleteDepotItem(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); DepotItemExample example = new DepotItemExample(); example.createCriteria().andIdIn(idList); - return depotItemMapper.deleteByExample(example); + int result =0; + try{ + result=depotItemMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { DepotItemExample example = new DepotItemExample(); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = depotItemMapper.selectByExample(example); - return list.size(); + List list =null; + try{ + list=depotItemMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } - public List getHeaderIdByMaterial(String materialParam, String depotIds) { - return depotItemMapperEx.getHeaderIdByMaterial(materialParam, depotIds); + public List getHeaderIdByMaterial(String materialParam, String depotIds)throws Exception { + List list =null; + try{ + list = depotItemMapperEx.getHeaderIdByMaterial(materialParam, depotIds); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List findDetailByTypeAndMaterialIdList(Map map) { + public List findDetailByTypeAndMaterialIdList(Map map)throws Exception { String mIdStr = map.get("mId"); Long mId = null; if(!StringUtil.isEmpty(mIdStr)) { mId = Long.parseLong(mIdStr); } - return depotItemMapperEx.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map)); + List list =null; + try{ + list = depotItemMapperEx.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map)); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long findDetailByTypeAndMaterialIdCounts(Map map) { + public Long findDetailByTypeAndMaterialIdCounts(Map map)throws Exception { String mIdStr = map.get("mId"); Long mId = null; if(!StringUtil.isEmpty(mIdStr)) { mId = Long.parseLong(mIdStr); } - return depotItemMapperEx.findDetailByTypeAndMaterialIdCounts(mId); + Long result =null; + try{ + result = depotItemMapperEx.findDetailByTypeAndMaterialIdCounts(mId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List findStockNumByMaterialIdList(Map map) { + public List findStockNumByMaterialIdList(Map map)throws Exception { String mIdStr = map.get("mId"); Long mId = null; if(!StringUtil.isEmpty(mIdStr)) { mId = Long.parseLong(mIdStr); } String monthTime = map.get("monthTime"); - return depotItemMapperEx.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map)); + List list =null; + try{ + list = depotItemMapperEx.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map)); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long findStockNumByMaterialIdCounts(Map map) { + public Long findStockNumByMaterialIdCounts(Map map)throws Exception { String mIdStr = map.get("mId"); Long mId = null; if(!StringUtil.isEmpty(mIdStr)) { mId = Long.parseLong(mIdStr); } String monthTime = map.get("monthTime"); - return depotItemMapperEx.findStockNumByMaterialIdCounts(mId, monthTime); + Long result =null; + try{ + result = depotItemMapperEx.findStockNumByMaterialIdCounts(mId, monthTime); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertDepotItemWithObj(DepotItem depotItem) { - return depotItemMapper.insertSelective(depotItem); + public int insertDepotItemWithObj(DepotItem depotItem)throws Exception { + int result =0; + try{ + result = depotItemMapper.insertSelective(depotItem); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateDepotItemWithObj(DepotItem depotItem) { + public int updateDepotItemWithObj(DepotItem depotItem)throws Exception { + int result =0; + try{ + result = depotItemMapper.updateByPrimaryKeySelective(depotItem); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return depotItemMapper.updateByPrimaryKeySelective(depotItem); } - public int findByTypeAndMaterialId(String type, Long mId) { - if(type.equals(TYPE)) { - return depotItemMapperEx.findByTypeAndMaterialIdIn(mId); - } else { - return depotItemMapperEx.findByTypeAndMaterialIdOut(mId); - } - } - - public List getDetailList(Long headerId) { - return depotItemMapperEx.getDetailList(headerId); - } - - public List findByAll(String headIds, String materialIds, Integer offset, Integer rows) { - return depotItemMapperEx.findByAll(headIds, materialIds, offset, rows); - } - - public int findByAllCount(String headIds, String materialIds) { - return depotItemMapperEx.findByAllCount(headIds, materialIds); - } - - public BigDecimal findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) { - if (TYPE.equals(type)) { - if (isPrev) { - return depotItemMapperEx.findByTypeInIsPrev(ProjectId, MId, MonthTime); + public int findByTypeAndMaterialId(String type, Long mId) throws Exception{ + int result =0; + try{ + if(type.equals(TYPE)) { + result= depotItemMapperEx.findByTypeAndMaterialIdIn(mId); } else { - return depotItemMapperEx.findByTypeInIsNotPrev(ProjectId, MId, MonthTime); - } - } else { - if (isPrev) { - return depotItemMapperEx.findByTypeOutIsPrev(ProjectId, MId, MonthTime); - } else { - return depotItemMapperEx.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime); + result= depotItemMapperEx.findByTypeAndMaterialIdOut(mId); } + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); } + return result; } - public BigDecimal findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) { - if (TYPE.equals(type)) { - if (isPrev) { - return depotItemMapperEx.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime); - } else { - return depotItemMapperEx.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime); - } - } else { - if (isPrev) { - return depotItemMapperEx.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime); - } else { - return depotItemMapperEx.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime); - } + public List getDetailList(Long headerId)throws Exception { + List list =null; + try{ + list = depotItemMapperEx.getDetailList(headerId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); } + return list; } - public BigDecimal findAssembleByType(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) { - if (isPrev) { - return depotItemMapperEx.findAssembleIsPrev(subType, mType, ProjectId, MId, MonthTime); - } else { - return depotItemMapperEx.findAssembleIsNotPrev(subType, mType, ProjectId, MId, MonthTime); + public List findByAll(String headIds, String materialIds, Integer offset, Integer rows)throws Exception { + List list =null; + try{ + list = depotItemMapperEx.findByAll(headIds, materialIds, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); } + return list; } - public BigDecimal buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) { - if (SUM_TYPE.equals(sumType)) { - return depotItemMapperEx.buyOrSaleNumber(type, subType, MId, MonthTime, sumType); - } else { - return depotItemMapperEx.buyOrSalePrice(type, subType, MId, MonthTime, sumType); + public int findByAllCount(String headIds, String materialIds)throws Exception { + int result=0; + try{ + result = depotItemMapperEx.findByAllCount(headIds, materialIds); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); } + return result; + } + + public BigDecimal findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception { + BigDecimal result=null; + try{ + if (TYPE.equals(type)) { + if (isPrev) { + result= depotItemMapperEx.findByTypeInIsPrev(ProjectId, MId, MonthTime); + } else { + result= depotItemMapperEx.findByTypeInIsNotPrev(ProjectId, MId, MonthTime); + } + } else { + if (isPrev) { + result= depotItemMapperEx.findByTypeOutIsPrev(ProjectId, MId, MonthTime); + } else { + result= depotItemMapperEx.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime); + } + } + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; + + } + + public BigDecimal findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception { + BigDecimal result=null; + try{ + if (TYPE.equals(type)) { + if (isPrev) { + result= depotItemMapperEx.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime); + } else { + result= depotItemMapperEx.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime); + } + } else { + if (isPrev) { + result= depotItemMapperEx.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime); + } else { + result= depotItemMapperEx.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime); + } + } + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; + + } + + public BigDecimal findAssembleByType(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception { + BigDecimal result=null; + try{ + if (isPrev) { + result= depotItemMapperEx.findAssembleIsPrev(subType, mType, ProjectId, MId, MonthTime); + } else { + result= depotItemMapperEx.findAssembleIsNotPrev(subType, mType, ProjectId, MId, MonthTime); + } + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; + + } + + public BigDecimal buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) throws Exception{ + BigDecimal result=null; + try{ + if (SUM_TYPE.equals(sumType)) { + result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, MonthTime, sumType); + } else { + result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, MonthTime, sumType); + } + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; + } /** @@ -241,9 +460,16 @@ public class DepotItemService { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_ITEM, BusinessConstants.LOG_OPERATION_TYPE_ADD, ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); - //查询单据主表信息 - DepotHead depotHead=depotHeadMapper.selectByPrimaryKey(headerId); + DepotHead depotHead=null; + try{ + depotHead =depotHeadMapper.selectByPrimaryKey(headerId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } //获得当前操作人 User userInfo=userService.getCurrentUser(); //转为json @@ -275,8 +501,8 @@ public class DepotItemService { continue; } if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())){ - serialNumberMapperEx.cancelSerialNumber(depotItem.getMaterialid(),depotItem.getHeaderid(),(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(), - new Date(),userInfo==null?null:userInfo.getId()); + serialNumberService.cancelSerialNumber(depotItem.getMaterialid(),depotItem.getHeaderid(),(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(), + userInfo); } } this.deleteDepotItem(tempDeletedJson.getLong("Id")); @@ -416,8 +642,8 @@ public class DepotItemService { * 判断商品是否开启序列号,开启的收回序列号,未开启的跳过 * */ if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())) { - serialNumberMapperEx.cancelSerialNumber(depotItem.getMaterialid(), depotItem.getHeaderid(), (depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(), - new Date(), userInfo == null ? null : userInfo.getId()); + serialNumberService.cancelSerialNumber(depotItem.getMaterialid(), depotItem.getHeaderid(), (depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(), + userInfo); } /**收回序列号的时候释放库存*/ depotItem.setOpernumber(BigDecimal.ZERO); @@ -525,7 +751,7 @@ public class DepotItemService { * * @return */ - public String findUnitName(Long mId) { + public String findUnitName(Long mId) throws Exception{ String unitName = ""; try { unitName = materialService.findUnitName(mId); @@ -544,7 +770,7 @@ public class DepotItemService { * 查询商品当前库存数量是否充足, * * */ - public int getCurrentInStock(Long materialId){ + public int getCurrentInStock(Long materialId)throws Exception{ //入库数量 int inSum = findByTypeAndMaterialId(BusinessConstants.DEPOTHEAD_TYPE_STORAGE, materialId); //出库数量 @@ -552,12 +778,21 @@ public class DepotItemService { return (inSum-outSum); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteDepotItemByIds(String ids) { + public int batchDeleteDepotItemByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_ITEM, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return depotItemMapperEx.batchDeleteDepotItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result =0; + try{ + result =depotItemMapperEx.batchDeleteDepotItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } } diff --git a/src/main/java/com/jsh/erp/service/functions/FunctionsComponent.java b/src/main/java/com/jsh/erp/service/functions/FunctionsComponent.java index 7ec2c311..a48aaff3 100644 --- a/src/main/java/com/jsh/erp/service/functions/FunctionsComponent.java +++ b/src/main/java/com/jsh/erp/service/functions/FunctionsComponent.java @@ -21,16 +21,16 @@ public class FunctionsComponent implements ICommonQuery { private FunctionsService functionsService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getFunctionsList(map); } - private List getFunctionsList(Map map) { + private List getFunctionsList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -39,7 +39,7 @@ public class FunctionsComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -47,27 +47,27 @@ public class FunctionsComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return functionsService.insertFunctions(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return functionsService.updateFunctions(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return functionsService.deleteFunctions(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return functionsService.batchDeleteFunctions(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return functionsService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/functions/FunctionsService.java b/src/main/java/com/jsh/erp/service/functions/FunctionsService.java index 1429b367..11e63de4 100644 --- a/src/main/java/com/jsh/erp/service/functions/FunctionsService.java +++ b/src/main/java/com/jsh/erp/service/functions/FunctionsService.java @@ -2,11 +2,14 @@ package com.jsh.erp.service.functions; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; +import com.jsh.erp.datasource.entities.DepotItem; import com.jsh.erp.datasource.entities.Functions; import com.jsh.erp.datasource.entities.FunctionsExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.FunctionsMapper; import com.jsh.erp.datasource.mappers.FunctionsMapperEx; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.StringUtil; @@ -36,92 +39,205 @@ public class FunctionsService { @Resource private LogService logService; - public Functions getFunctions(long id) { - return functionsMapper.selectByPrimaryKey(id); + public Functions getFunctions(long id)throws Exception { + Functions result=null; + try{ + result=functionsMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getFunctions() { + public List getFunctions()throws Exception { FunctionsExample example = new FunctionsExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return functionsMapper.selectByExample(example); + List list=null; + try{ + list=functionsMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, String type, int offset, int rows) { - return functionsMapperEx.selectByConditionFunctions(name, type, offset, rows); + public List select(String name, String type, int offset, int rows)throws Exception { + List list=null; + try{ + list=functionsMapperEx.selectByConditionFunctions(name, type, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countFunctions(String name, String type) { - return functionsMapperEx.countsByFunctions(name, type); + public Long countFunctions(String name, String type)throws Exception { + Long result=null; + try{ + result=functionsMapperEx.countsByFunctions(name, type); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertFunctions(String beanJson, HttpServletRequest request) { + public int insertFunctions(String beanJson, HttpServletRequest request)throws Exception { Functions depot = JSONObject.parseObject(beanJson, Functions.class); - return functionsMapper.insertSelective(depot); + int result=0; + try{ + result=functionsMapper.insertSelective(depot); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateFunctions(String beanJson, Long id) { + public int updateFunctions(String beanJson, Long id) throws Exception{ Functions depot = JSONObject.parseObject(beanJson, Functions.class); depot.setId(id); - return functionsMapper.updateByPrimaryKeySelective(depot); + int result=0; + try{ + result=functionsMapper.updateByPrimaryKeySelective(depot); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteFunctions(Long id) { - return functionsMapper.deleteByPrimaryKey(id); + public int deleteFunctions(Long id)throws Exception { + int result=0; + try{ + result=functionsMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteFunctions(String ids) { + public int batchDeleteFunctions(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); FunctionsExample example = new FunctionsExample(); example.createCriteria().andIdIn(idList); - return functionsMapper.deleteByExample(example); + int result=0; + try{ + result=functionsMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { FunctionsExample example = new FunctionsExample(); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = functionsMapper.selectByExample(example); - return list.size(); + List list=null; + try{ + list = functionsMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } - public List getRoleFunctions(String pNumber) { + public List getRoleFunctions(String pNumber)throws Exception { FunctionsExample example = new FunctionsExample(); example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pNumber) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = functionsMapper.selectByExample(example); + List list=null; + try{ + list = functionsMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } - public List findRoleFunctions(String pnumber){ + public List findRoleFunctions(String pnumber)throws Exception{ FunctionsExample example = new FunctionsExample(); example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pnumber) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = functionsMapper.selectByExample(example); + List list=null; + try{ + list =functionsMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } - public List findByIds(String functionsIds){ + public List findByIds(String functionsIds)throws Exception{ List idList = StringUtil.strToLongList(functionsIds); FunctionsExample example = new FunctionsExample(); example.createCriteria().andEnabledEqualTo(true).andIdIn(idList) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort asc"); - List list = functionsMapper.selectByExample(example); + List list=null; + try{ + list =functionsMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteFunctionsByIds(String ids) { + public int batchDeleteFunctionsByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_FUNCTIONS, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return functionsMapperEx.batchDeleteFunctionsByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result =functionsMapperEx.batchDeleteFunctionsByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } } diff --git a/src/main/java/com/jsh/erp/service/inOutItem/InOutItemComponent.java b/src/main/java/com/jsh/erp/service/inOutItem/InOutItemComponent.java index f5f41b97..9cce46bc 100644 --- a/src/main/java/com/jsh/erp/service/inOutItem/InOutItemComponent.java +++ b/src/main/java/com/jsh/erp/service/inOutItem/InOutItemComponent.java @@ -19,16 +19,16 @@ public class InOutItemComponent implements ICommonQuery { private InOutItemService inOutItemService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getFunctionsList(map); } - private List getFunctionsList(Map map) { + private List getFunctionsList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -38,7 +38,7 @@ public class InOutItemComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -47,27 +47,27 @@ public class InOutItemComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return inOutItemService.insertInOutItem(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return inOutItemService.updateInOutItem(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return inOutItemService.deleteInOutItem(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return inOutItemService.batchDeleteInOutItem(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return inOutItemService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/inOutItem/InOutItemService.java b/src/main/java/com/jsh/erp/service/inOutItem/InOutItemService.java index a3797a36..18446237 100644 --- a/src/main/java/com/jsh/erp/service/inOutItem/InOutItemService.java +++ b/src/main/java/com/jsh/erp/service/inOutItem/InOutItemService.java @@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.ExceptionConstants; -import com.jsh.erp.datasource.entities.AccountItem; -import com.jsh.erp.datasource.entities.InOutItem; -import com.jsh.erp.datasource.entities.InOutItemExample; -import com.jsh.erp.datasource.entities.User; +import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.mappers.AccountItemMapperEx; import com.jsh.erp.datasource.mappers.InOutItemMapper; import com.jsh.erp.datasource.mappers.InOutItemMapperEx; @@ -43,58 +40,139 @@ public class InOutItemService { @Resource private AccountItemMapperEx accountItemMapperEx; - public InOutItem getInOutItem(long id) { - return inOutItemMapper.selectByPrimaryKey(id); + public InOutItem getInOutItem(long id)throws Exception { + InOutItem result=null; + try{ + result=inOutItemMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getInOutItem() { + public List getInOutItem()throws Exception { InOutItemExample example = new InOutItemExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return inOutItemMapper.selectByExample(example); + List list=null; + try{ + list=inOutItemMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, String type, String remark, int offset, int rows) { - return inOutItemMapperEx.selectByConditionInOutItem(name, type, remark, offset, rows); + public List select(String name, String type, String remark, int offset, int rows)throws Exception { + List list=null; + try{ + list=inOutItemMapperEx.selectByConditionInOutItem(name, type, remark, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countInOutItem(String name, String type, String remark) { - return inOutItemMapperEx.countsByInOutItem(name, type, remark); + public Long countInOutItem(String name, String type, String remark)throws Exception { + Long result=null; + try{ + result=inOutItemMapperEx.countsByInOutItem(name, type, remark); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertInOutItem(String beanJson, HttpServletRequest request) { + public int insertInOutItem(String beanJson, HttpServletRequest request)throws Exception { InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class); - return inOutItemMapper.insertSelective(depot); + int result=0; + try{ + result=inOutItemMapper.insertSelective(depot); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateInOutItem(String beanJson, Long id) { + public int updateInOutItem(String beanJson, Long id)throws Exception { InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class); depot.setId(id); - return inOutItemMapper.updateByPrimaryKeySelective(depot); + int result=0; + try{ + result=inOutItemMapper.updateByPrimaryKeySelective(depot); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteInOutItem(Long id) { - return inOutItemMapper.deleteByPrimaryKey(id); + public int deleteInOutItem(Long id)throws Exception { + int result=0; + try{ + result=inOutItemMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteInOutItem(String ids) { + public int batchDeleteInOutItem(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); InOutItemExample example = new InOutItemExample(); example.createCriteria().andIdIn(idList); - return inOutItemMapper.deleteByExample(example); + int result=0; + try{ + result=inOutItemMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { InOutItemExample example = new InOutItemExample(); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = inOutItemMapper.selectByExample(example); - return list.size(); + List list = null; + try{ + list=inOutItemMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + + return list==null?0:list.size(); } - public List findBySelect(String type) { + public List findBySelect(String type)throws Exception { InOutItemExample example = new InOutItemExample(); if (type.equals("in")) { example.createCriteria().andTypeEqualTo("收入").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); @@ -102,16 +180,34 @@ public class InOutItemService { example.createCriteria().andTypeEqualTo("支出").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); } example.setOrderByClause("id desc"); - return inOutItemMapper.selectByExample(example); + List list = null; + try{ + list=inOutItemMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteInOutItemByIds(String ids) { + public int batchDeleteInOutItemByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_IN_OUT_ITEM, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return inOutItemMapperEx.batchDeleteInOutItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result = 0; + try{ + result=inOutItemMapperEx.batchDeleteInOutItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } /** * create by: qiankunpingtai @@ -137,7 +233,15 @@ public class InOutItemService { /** * 校验财务子表 jsh_accountitem * */ - List accountItemList=accountItemMapperEx.getAccountItemListByInOutItemIds(idArray); + List accountItemList=null; + try{ + accountItemList=accountItemMapperEx.getAccountItemListByInOutItemIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(accountItemList!=null&&accountItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,InOutItemIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); diff --git a/src/main/java/com/jsh/erp/service/log/LogComponent.java b/src/main/java/com/jsh/erp/service/log/LogComponent.java index 2a04bd71..00857c87 100644 --- a/src/main/java/com/jsh/erp/service/log/LogComponent.java +++ b/src/main/java/com/jsh/erp/service/log/LogComponent.java @@ -19,16 +19,16 @@ public class LogComponent implements ICommonQuery { private LogService logService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getUserList(map); } - private List getUserList(Map map) { + private List getUserList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String operation = StringUtil.getInfo(search, "operation"); Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID")); @@ -43,7 +43,7 @@ public class LogComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String operation = StringUtil.getInfo(search, "operation"); Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID")); @@ -56,27 +56,27 @@ public class LogComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return logService.insertLog(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return logService.updateLog(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return logService.deleteLog(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return logService.batchDeleteLog(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return 0; } diff --git a/src/main/java/com/jsh/erp/service/log/LogService.java b/src/main/java/com/jsh/erp/service/log/LogService.java index dc4809d0..9716c0b6 100644 --- a/src/main/java/com/jsh/erp/service/log/LogService.java +++ b/src/main/java/com/jsh/erp/service/log/LogService.java @@ -2,16 +2,15 @@ package com.jsh.erp.service.log; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.Log; import com.jsh.erp.datasource.entities.LogExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.LogMapper; import com.jsh.erp.datasource.mappers.LogMapperEx; import com.jsh.erp.datasource.vo.LogVo4List; -import com.jsh.erp.utils.ExceptionCodeConstants; -import com.jsh.erp.utils.JshException; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.utils.StringUtil; -import com.jsh.erp.utils.Tools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -19,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.security.NoSuchAlgorithmException; import java.util.Date; import java.util.List; @@ -34,50 +32,122 @@ public class LogService { @Resource private LogMapperEx logMapperEx; - public Log getLog(long id) { - return logMapper.selectByPrimaryKey(id); + public Log getLog(long id)throws Exception { + Log result=null; + try{ + result=logMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getLog() { + public List getLog()throws Exception { LogExample example = new LogExample(); - return logMapper.selectByExample(example); + List list=null; + try{ + list=logMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } public List select(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime, - String contentdetails, int offset, int rows) { - return logMapperEx.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime, - contentdetails, offset, rows); + String contentdetails, int offset, int rows)throws Exception { + List list=null; + try{ + list=logMapperEx.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime, + contentdetails, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } public Long countLog(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime, - String contentdetails) { - return logMapperEx.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails); + String contentdetails)throws Exception { + Long result=null; + try{ + result=logMapperEx.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertLog(String beanJson, HttpServletRequest request) { + public int insertLog(String beanJson, HttpServletRequest request) throws Exception{ Log log = JSONObject.parseObject(beanJson, Log.class); - return logMapper.insertSelective(log); + int result=0; + try{ + result=logMapper.insertSelective(log); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateLog(String beanJson, Long id) { + public int updateLog(String beanJson, Long id)throws Exception { Log log = JSONObject.parseObject(beanJson, Log.class); log.setId(id); - return logMapper.updateByPrimaryKeySelective(log); + int result=0; + try{ + result=logMapper.updateByPrimaryKeySelective(log); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteLog(Long id) { - return logMapper.deleteByPrimaryKey(id); + public int deleteLog(Long id)throws Exception { + int result=0; + try{ + result=logMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteLog(String ids) { + public int batchDeleteLog(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); LogExample example = new LogExample(); example.createCriteria().andIdIn(idList); - return logMapper.deleteByExample(example); + int result=0; + try{ + result=logMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** @@ -85,7 +155,7 @@ public class LogService { * @param request * @return */ - public Long getUserId(HttpServletRequest request) { + public Long getUserId(HttpServletRequest request) throws Exception{ Object userInfo = request.getSession().getAttribute("user"); if(userInfo!=null) { User user = (User) userInfo; @@ -95,7 +165,7 @@ public class LogService { } } - public String getModule(String apiName){ + public String getModule(String apiName)throws Exception{ String moduleName = null; switch (apiName) { case BusinessConstants.LOG_INTERFACE_NAME_USER: @@ -144,7 +214,7 @@ public class LogService { return moduleName; } - public void insertLog(String apiName, String type, HttpServletRequest request){ + public void insertLog(String apiName, String type, HttpServletRequest request)throws Exception{ Log log = new Log(); log.setUserid(getUserId(request)); log.setOperation(getModule(apiName)); @@ -154,7 +224,15 @@ public class LogService { log.setStatus(status); log.setContentdetails(type + getModule(apiName)); log.setRemark(type + getModule(apiName)); - logMapper.insertSelective(log); + try{ + logMapper.insertSelective(log); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + } } diff --git a/src/main/java/com/jsh/erp/service/material/MaterialComponent.java b/src/main/java/com/jsh/erp/service/material/MaterialComponent.java index 9e0021c5..7b2ca3d2 100644 --- a/src/main/java/com/jsh/erp/service/material/MaterialComponent.java +++ b/src/main/java/com/jsh/erp/service/material/MaterialComponent.java @@ -21,16 +21,16 @@ public class MaterialComponent implements ICommonQuery { private MaterialService materialService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getMaterialList(map); } - private List getMaterialList(Map map) { + private List getMaterialList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String model = StringUtil.getInfo(search, "model"); @@ -42,7 +42,7 @@ public class MaterialComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String model = StringUtil.getInfo(search, "model"); @@ -53,27 +53,27 @@ public class MaterialComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception{ return materialService.insertMaterial(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return materialService.updateMaterial(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return materialService.deleteMaterial(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return materialService.batchDeleteMaterial(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return materialService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/material/MaterialService.java b/src/main/java/com/jsh/erp/service/material/MaterialService.java index 431344e1..ac219245 100644 --- a/src/main/java/com/jsh/erp/service/material/MaterialService.java +++ b/src/main/java/com/jsh/erp/service/material/MaterialService.java @@ -39,20 +39,47 @@ public class MaterialService { @Resource private DepotItemMapperEx depotItemMapperEx; - public Material getMaterial(long id) { - return materialMapper.selectByPrimaryKey(id); + public Material getMaterial(long id)throws Exception { + Material result=null; + try{ + result=materialMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getMaterial() { + public List getMaterial() throws Exception{ MaterialExample example = new MaterialExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return materialMapper.selectByExample(example); + List list=null; + try{ + list=materialMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows) { + public List select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows) + throws Exception{ String[] mpArr = mpList.split(","); List resList = new ArrayList(); - List list = materialMapperEx.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows); + List list =null; + try{ + list= materialMapperEx.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (null != list) { for (MaterialVo4Unit m : list) { //扩展信息 @@ -84,53 +111,106 @@ public class MaterialService { return resList; } - public Long countMaterial(String name, String model,Long categoryId, String categoryIds,String mpList) { - return materialMapperEx.countsByMaterial(name, model,categoryId,categoryIds,mpList); + public Long countMaterial(String name, String model,Long categoryId, String categoryIds,String mpList)throws Exception { + Long result =null; + try{ + result= materialMapperEx.countsByMaterial(name, model,categoryId,categoryIds,mpList); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertMaterial(String beanJson, HttpServletRequest request) { + public int insertMaterial(String beanJson, HttpServletRequest request)throws Exception { Material material = JSONObject.parseObject(beanJson, Material.class); material.setEnabled(true); - return materialMapper.insertSelective(material); + int result =0; + try{ + result= materialMapper.insertSelective(material); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateMaterial(String beanJson, Long id) { + public int updateMaterial(String beanJson, Long id) throws Exception{ Material material = JSONObject.parseObject(beanJson, Material.class); material.setId(id); - int res = materialMapper.updateByPrimaryKeySelective(material); - Long unitId = material.getUnitid(); - if(unitId != null) { - materialMapperEx.updatePriceNullByPrimaryKey(id); //将价格置空 - } else { - materialMapperEx.updateUnitIdNullByPrimaryKey(id); //将多单位置空 + int res =0; + try{ + res= materialMapper.updateByPrimaryKeySelective(material); + Long unitId = material.getUnitid(); + if(unitId != null) { + materialMapperEx.updatePriceNullByPrimaryKey(id); //将价格置空 + } else { + materialMapperEx.updateUnitIdNullByPrimaryKey(id); //将多单位置空 + } + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); } + return res; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteMaterial(Long id) { - return materialMapper.deleteByPrimaryKey(id); + public int deleteMaterial(Long id)throws Exception { + int result =0; + try{ + result= materialMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteMaterial(String ids) { + public int batchDeleteMaterial(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); MaterialExample example = new MaterialExample(); example.createCriteria().andIdIn(idList); - return materialMapper.deleteByExample(example); + int result =0; + try{ + result= materialMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { MaterialExample example = new MaterialExample(); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = materialMapper.selectByExample(example); - return list.size(); + List list =null; + try{ + list= materialMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs, - String otherField1, String otherField2, String otherField3, String unit, Long unitId) { + String otherField1, String otherField2, String otherField3, String unit, Long unitId)throws Exception { MaterialExample example = new MaterialExample(); MaterialExample.Criteria criteria = example.createCriteria(); criteria.andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color) @@ -145,12 +225,20 @@ public class MaterialService { if (unitId !=null) { criteria.andUnitidEqualTo(unitId); } - List list = materialMapper.selectByExample(example); - return list.size(); + List list =null; + try{ + list= materialMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchSetEnable(Boolean enabled, String materialIDs) { + public int batchSetEnable(Boolean enabled, String materialIDs)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_MATERIAL, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialIDs).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); @@ -159,31 +247,84 @@ public class MaterialService { material.setEnabled(enabled); MaterialExample example = new MaterialExample(); example.createCriteria().andIdIn(ids); - return materialMapper.updateByExampleSelective(material, example); + int result =0; + try{ + result= materialMapper.updateByExampleSelective(material, example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public String findUnitName(Long mId){ - return materialMapperEx.findUnitName(mId); + public String findUnitName(Long mId)throws Exception{ + String result =null; + try{ + result= materialMapperEx.findUnitName(mId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List findById(Long id){ - return materialMapperEx.findById(id); + public List findById(Long id)throws Exception{ + List list =null; + try{ + list= materialMapperEx.findById(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List findBySelect(){ - return materialMapperEx.findBySelect(); + public List findBySelect()throws Exception{ + List list =null; + try{ + list= materialMapperEx.findBySelect(); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List findByOrder(){ + public List findByOrder()throws Exception{ MaterialExample example = new MaterialExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Name,Model asc"); - return materialMapper.selectByExample(example); + List list =null; + try{ + list= materialMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List findByAll(String name, String model, Long categoryId, String categoryIds) { + public List findByAll(String name, String model, Long categoryId, String categoryIds)throws Exception { List resList = new ArrayList(); - List list = materialMapperEx.findByAll(name, model, categoryId, categoryIds); + List list =null; + try{ + list= materialMapperEx.findByAll(name, model, categoryId, categoryIds); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (null != list) { for (MaterialVo4Unit m : list) { resList.add(m); @@ -205,6 +346,8 @@ public class MaterialService { info.code = 200; data.put("message", "成功"); } catch (Exception e) { + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); e.printStackTrace(); info.code = 500; data.put("message", e.getMessage()); @@ -213,17 +356,35 @@ public class MaterialService { return info; } - public List getMaterialEnableSerialNumberList(Map parameterMap) { - return materialMapperEx.getMaterialEnableSerialNumberList(parameterMap); + public List getMaterialEnableSerialNumberList(Map parameterMap)throws Exception { + List list =null; + try{ + list= materialMapperEx.getMaterialEnableSerialNumberList(parameterMap); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteMaterialByIds(String ids) { + public int batchDeleteMaterialByIds(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_MATERIAL, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return materialMapperEx.batchDeleteMaterialByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result =0; + try{ + result= materialMapperEx.batchDeleteMaterialByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: qiankunpingtai @@ -250,7 +411,15 @@ public class MaterialService { /** * 校验单据子表 jsh_depotitem * */ - List depotItemList=depotItemMapperEx.getDepotItemListListByMaterialIds(idArray); + List depotItemList =null; + try{ + depotItemList= depotItemMapperEx.getDepotItemListListByMaterialIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(depotItemList!=null&&depotItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,MaterialIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); diff --git a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java index 18395669..70598d69 100644 --- a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java +++ b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java @@ -21,16 +21,16 @@ public class MaterialCategoryComponent implements ICommonQuery { private MaterialCategoryService materialCategoryService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getMaterialCategoryList(map); } - private List getMaterialCategoryList(Map map) { + private List getMaterialCategoryList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId")); @@ -39,7 +39,7 @@ public class MaterialCategoryComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId")); @@ -47,27 +47,27 @@ public class MaterialCategoryComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return materialCategoryService.insertMaterialCategory(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return materialCategoryService.updateMaterialCategory(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return materialCategoryService.deleteMaterialCategory(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return materialCategoryService.batchDeleteMaterialCategory(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return materialCategoryService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java index 9ef30210..71c41bb3 100644 --- a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java +++ b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java @@ -40,64 +40,154 @@ public class MaterialCategoryService { @Resource private MaterialMapperEx materialMapperEx; - public MaterialCategory getMaterialCategory(long id) { - return materialCategoryMapper.selectByPrimaryKey(id); + public MaterialCategory getMaterialCategory(long id)throws Exception { + MaterialCategory result=null; + try{ + result=materialCategoryMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getMaterialCategory() { + public List getMaterialCategory()throws Exception { MaterialCategoryExample example = new MaterialCategoryExample(); - return materialCategoryMapper.selectByExample(example); + List list=null; + try{ + list=materialCategoryMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List getAllList(Long parentId) { + public List getAllList(Long parentId)throws Exception { MaterialCategoryExample example = new MaterialCategoryExample(); example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l); example.setOrderByClause("id"); - return materialCategoryMapper.selectByExample(example); + List list=null; + try{ + list=materialCategoryMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, Integer parentId, int offset, int rows) { - return materialCategoryMapperEx.selectByConditionMaterialCategory(name, parentId, offset, rows); + public List select(String name, Integer parentId, int offset, int rows) throws Exception{ + List list=null; + try{ + list=materialCategoryMapperEx.selectByConditionMaterialCategory(name, parentId, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countMaterialCategory(String name, Integer parentId) { - return materialCategoryMapperEx.countsByMaterialCategory(name, parentId); + public Long countMaterialCategory(String name, Integer parentId) throws Exception{ + Long result=null; + try{ + result=materialCategoryMapperEx.countsByMaterialCategory(name, parentId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertMaterialCategory(String beanJson, HttpServletRequest request) { + public int insertMaterialCategory(String beanJson, HttpServletRequest request)throws Exception { MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class); - return materialCategoryMapper.insertSelective(materialCategory); + int result=0; + try{ + result=materialCategoryMapper.insertSelective(materialCategory); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateMaterialCategory(String beanJson, Long id) { + public int updateMaterialCategory(String beanJson, Long id) throws Exception{ MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class); materialCategory.setId(id); - return materialCategoryMapper.updateByPrimaryKeySelective(materialCategory); + int result=0; + try{ + result=materialCategoryMapper.updateByPrimaryKeySelective(materialCategory); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteMaterialCategory(Long id) { - return materialCategoryMapper.deleteByPrimaryKey(id); + public int deleteMaterialCategory(Long id)throws Exception { + int result=0; + try{ + result=materialCategoryMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteMaterialCategory(String ids) { + public int batchDeleteMaterialCategory(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); MaterialCategoryExample example = new MaterialCategoryExample(); example.createCriteria().andIdIn(idList); - return materialCategoryMapper.deleteByExample(example); + int result=0; + try{ + result=materialCategoryMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return 0; } - public List findById(Long id) { + public List findById(Long id)throws Exception { MaterialCategoryExample example = new MaterialCategoryExample(); example.createCriteria().andIdEqualTo(id); - return materialCategoryMapper.selectByExample(example); + List list=null; + try{ + list=materialCategoryMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } /** * create by: cjl @@ -108,7 +198,16 @@ public class MaterialCategoryService { * @return java.util.List */ public List getMaterialCategoryTree(Long id) throws Exception{ - return materialCategoryMapperEx.getNodeTree(id); + List list=null; + try{ + list=materialCategoryMapperEx.getNodeTree(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } /** * create by: cjl @@ -144,7 +243,16 @@ public class MaterialCategoryService { mc.setUpdateTime(date); //更新人 mc.setUpdater(userInfo==null?null:userInfo.getId()); - return materialCategoryMapperEx.addMaterialCategory(mc); + int result=0; + try{ + result=materialCategoryMapperEx.addMaterialCategory(mc); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int batchDeleteMaterialCategoryByIds(String ids) throws Exception { @@ -160,11 +268,19 @@ public class MaterialCategoryService { if(strArray.length<1){ return 0; } - - return materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray); + int result=0; + try{ + result=materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int editMaterialCategory(MaterialCategory mc) { + public int editMaterialCategory(MaterialCategory mc) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_MATERIAL_CATEGORY, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(mc.getId()).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); @@ -180,12 +296,21 @@ public class MaterialCategoryService { //更新人 User userInfo=userService.getCurrentUser(); mc.setUpdater(userInfo==null?null:userInfo.getId()); - return materialCategoryMapperEx.editMaterialCategory(mc); + int result=0; + try{ + result= materialCategoryMapperEx.editMaterialCategory(mc); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * 根据商品类别编号判断商品类别是否已存在 * */ - public void checkMaterialCategorySerialNo(MaterialCategory mc) { + public void checkMaterialCategorySerialNo(MaterialCategory mc)throws Exception { if(mc==null){ return; } @@ -193,7 +318,15 @@ public class MaterialCategoryService { return; } //根据商品类别编号查询商品类别 - List mList=materialCategoryMapperEx.getMaterialCategoryBySerialNo(mc.getSerialNo()); + List mList=null; + try{ + mList= materialCategoryMapperEx.getMaterialCategoryBySerialNo(mc.getSerialNo()); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(mList==null||mList.size()<1){ //未查询到对应数据,编号可用 return; @@ -243,7 +376,15 @@ public class MaterialCategoryService { /** * 校验产品表 jsh_material * */ - List materialList=materialMapperEx.getMaterialListByCategoryIds(idArray); + List materialList=null; + try{ + materialList= materialMapperEx.getMaterialListByCategoryIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(materialList!=null&&materialList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -253,7 +394,15 @@ public class MaterialCategoryService { /** * 校验产品类型表 jsh_materialcategory * */ - List materialCategoryList=materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(idArray); + List materialCategoryList=null; + try{ + materialCategoryList= materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(materialCategoryList!=null&&materialCategoryList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); diff --git a/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyComponent.java b/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyComponent.java index 8ff03082..4d681484 100644 --- a/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyComponent.java +++ b/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyComponent.java @@ -19,16 +19,16 @@ public class MaterialPropertyComponent implements ICommonQuery { private MaterialPropertyService materialPropertyService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getMaterialPropertyList(map); } - private List getMaterialPropertyList(Map map) { + private List getMaterialPropertyList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String order = QueryUtils.order(map); @@ -36,34 +36,34 @@ public class MaterialPropertyComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); return materialPropertyService.countMaterialProperty(name); } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return materialPropertyService.insertMaterialProperty(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return materialPropertyService.updateMaterialProperty(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return materialPropertyService.deleteMaterialProperty(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return materialPropertyService.batchDeleteMaterialProperty(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return materialPropertyService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyService.java b/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyService.java index c5a44684..4e9537d7 100644 --- a/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyService.java +++ b/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyService.java @@ -2,11 +2,13 @@ package com.jsh.erp.service.materialProperty; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.MaterialProperty; import com.jsh.erp.datasource.entities.MaterialPropertyExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.MaterialPropertyMapper; import com.jsh.erp.datasource.mappers.MaterialPropertyMapperEx; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.StringUtil; @@ -36,61 +38,142 @@ public class MaterialPropertyService { @Resource private LogService logService; - public MaterialProperty getMaterialProperty(long id) { - return materialPropertyMapper.selectByPrimaryKey(id); + public MaterialProperty getMaterialProperty(long id)throws Exception { + MaterialProperty result=null; + try{ + result=materialPropertyMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getMaterialProperty() { + public List getMaterialProperty()throws Exception { MaterialPropertyExample example = new MaterialPropertyExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return materialPropertyMapper.selectByExample(example); + List list=null; + try{ + list=materialPropertyMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, int offset, int rows) { - return materialPropertyMapperEx.selectByConditionMaterialProperty(name, offset, rows); + public List select(String name, int offset, int rows)throws Exception { + List list=null; + try{ + list=materialPropertyMapperEx.selectByConditionMaterialProperty(name, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countMaterialProperty(String name) { - return materialPropertyMapperEx.countsByMaterialProperty(name); + public Long countMaterialProperty(String name)throws Exception { + Long result=null; + try{ + result=materialPropertyMapperEx.countsByMaterialProperty(name); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertMaterialProperty(String beanJson, HttpServletRequest request) { + public int insertMaterialProperty(String beanJson, HttpServletRequest request)throws Exception { MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class); - return materialPropertyMapper.insertSelective(materialProperty); + int result=0; + try{ + result=materialPropertyMapper.insertSelective(materialProperty); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateMaterialProperty(String beanJson, Long id) { + public int updateMaterialProperty(String beanJson, Long id)throws Exception { MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class); materialProperty.setId(id); - return materialPropertyMapper.updateByPrimaryKeySelective(materialProperty); + int result=0; + try{ + result=materialPropertyMapper.updateByPrimaryKeySelective(materialProperty); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteMaterialProperty(Long id) { - return materialPropertyMapper.deleteByPrimaryKey(id); + public int deleteMaterialProperty(Long id)throws Exception { + int result=0; + try{ + result=materialPropertyMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteMaterialProperty(String ids) { + public int batchDeleteMaterialProperty(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); MaterialPropertyExample example = new MaterialPropertyExample(); example.createCriteria().andIdIn(idList); - return materialPropertyMapper.deleteByExample(example); + int result=0; + try{ + result=materialPropertyMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return 0; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteMaterialPropertyByIds(String ids) { + public int batchDeleteMaterialPropertyByIds(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_MATERIAL_PROPERTY, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result=materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } } diff --git a/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelComponent.java b/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelComponent.java index 9ed17861..1d6776d4 100644 --- a/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelComponent.java +++ b/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelComponent.java @@ -22,44 +22,44 @@ public class OrgaUserRelComponent implements ICommonQuery { @Resource private OrgaUserRelService orgaUserRelService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map parameterMap) { + public List select(Map parameterMap)throws Exception { return getOrgaUserRelList(parameterMap); } - private List getOrgaUserRelList(Map map) { + private List getOrgaUserRelList(Map map)throws Exception { return null; } @Override - public Long counts(Map parameterMap) { + public Long counts(Map parameterMap)throws Exception { return null; } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return orgaUserRelService.insertOrgaUserRel(beanJson,request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return orgaUserRelService.updateOrgaUserRel(beanJson,id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return orgaUserRelService.deleteOrgaUserRel(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return orgaUserRelService.batchDeleteOrgaUserRel(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return 0; } } diff --git a/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelService.java b/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelService.java index 7daffcfe..d422ae07 100644 --- a/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelService.java +++ b/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelService.java @@ -2,9 +2,13 @@ package com.jsh.erp.service.orgaUserRel; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; -import com.jsh.erp.datasource.entities.*; +import com.jsh.erp.constants.ExceptionConstants; +import com.jsh.erp.datasource.entities.OrgaUserRel; +import com.jsh.erp.datasource.entities.OrgaUserRelExample; +import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.OrgaUserRelMapper; import com.jsh.erp.datasource.mappers.OrgaUserRelMapperEx; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.organization.OrganizationService; import com.jsh.erp.service.user.UserService; @@ -38,26 +42,62 @@ public class OrgaUserRelService { @Resource private LogService logService; @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertOrgaUserRel(String beanJson, HttpServletRequest request) { + public int insertOrgaUserRel(String beanJson, HttpServletRequest request) throws Exception{ OrgaUserRel orgaUserRel = JSONObject.parseObject(beanJson, OrgaUserRel.class); - return orgaUserRelMapper.insertSelective(orgaUserRel); + int result=0; + try{ + result=orgaUserRelMapper.insertSelective(orgaUserRel); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateOrgaUserRel(String beanJson, Long id) { + public int updateOrgaUserRel(String beanJson, Long id) throws Exception{ OrgaUserRel orgaUserRel = JSONObject.parseObject(beanJson, OrgaUserRel.class); orgaUserRel.setId(id); - return orgaUserRelMapper.updateByPrimaryKeySelective(orgaUserRel); + int result=0; + try{ + result=orgaUserRelMapper.updateByPrimaryKeySelective(orgaUserRel); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteOrgaUserRel(Long id) { - return orgaUserRelMapper.deleteByPrimaryKey(id); + public int deleteOrgaUserRel(Long id)throws Exception { + int result=0; + try{ + result=orgaUserRelMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteOrgaUserRel(String ids) { + public int batchDeleteOrgaUserRel(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); OrgaUserRelExample example = new OrgaUserRelExample(); example.createCriteria().andIdIn(idList); - return orgaUserRelMapper.deleteByExample(example); + int result=0; + try{ + result=orgaUserRelMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: cjl @@ -88,8 +128,16 @@ public class OrgaUserRelService { orgaUserRel.setUpdater(userInfo==null?null:userInfo.getId()); } orgaUserRel.setDeleteFlag(BusinessConstants.DELETE_FLAG_EXISTS); - int i=orgaUserRelMapperEx.addOrgaUserRel(orgaUserRel); - if(i>0){ + int result=0; + try{ + result=orgaUserRelMapperEx.addOrgaUserRel(orgaUserRel); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + if(result>0){ return orgaUserRel; } return null; @@ -103,7 +151,7 @@ public class OrgaUserRelService { * @return void */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public OrgaUserRel updateOrgaUserRel(OrgaUserRel orgaUserRel) { + public OrgaUserRel updateOrgaUserRel(OrgaUserRel orgaUserRel) throws Exception{ User userInfo=userService.getCurrentUser(); //更新时间 if(orgaUserRel.getUpdateTime()==null){ @@ -113,8 +161,16 @@ public class OrgaUserRelService { if(orgaUserRel.getUpdater()==null){ orgaUserRel.setUpdater(userInfo==null?null:userInfo.getId()); } - int i= orgaUserRelMapperEx.updateOrgaUserRel(orgaUserRel); - if(i>0){ + int result=0; + try{ + result=orgaUserRelMapperEx.updateOrgaUserRel(orgaUserRel); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + if(result>0){ return orgaUserRel; } return null; diff --git a/src/main/java/com/jsh/erp/service/organization/OrganizationComponent.java b/src/main/java/com/jsh/erp/service/organization/OrganizationComponent.java index c7ff227a..3b0a226a 100644 --- a/src/main/java/com/jsh/erp/service/organization/OrganizationComponent.java +++ b/src/main/java/com/jsh/erp/service/organization/OrganizationComponent.java @@ -23,44 +23,44 @@ public class OrganizationComponent implements ICommonQuery { @Resource private OrganizationService organizationService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map parameterMap) { + public List select(Map parameterMap)throws Exception { return getOrganizationList(parameterMap); } - private List getOrganizationList(Map map) { + private List getOrganizationList(Map map)throws Exception { return null; } @Override - public Long counts(Map parameterMap) { + public Long counts(Map parameterMap)throws Exception { return null; } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return organizationService.insertOrganization(beanJson,request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return organizationService.updateOrganization(beanJson,id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return organizationService.deleteOrganization(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return organizationService.batchDeleteOrganization(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return 0; } } diff --git a/src/main/java/com/jsh/erp/service/organization/OrganizationService.java b/src/main/java/com/jsh/erp/service/organization/OrganizationService.java index dd67b7ef..fcec30dc 100644 --- a/src/main/java/com/jsh/erp/service/organization/OrganizationService.java +++ b/src/main/java/com/jsh/erp/service/organization/OrganizationService.java @@ -3,6 +3,7 @@ package com.jsh.erp.service.organization; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.ExceptionConstants; +import com.jsh.erp.datasource.entities.MaterialProperty; import com.jsh.erp.datasource.entities.Organization; import com.jsh.erp.datasource.entities.OrganizationExample; import com.jsh.erp.datasource.entities.User; @@ -44,26 +45,62 @@ public class OrganizationService { @Resource private LogService logService; @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertOrganization(String beanJson, HttpServletRequest request) { + public int insertOrganization(String beanJson, HttpServletRequest request)throws Exception { Organization organization = JSONObject.parseObject(beanJson, Organization.class); - return organizationMapper.insertSelective(organization); + int result=0; + try{ + result=organizationMapper.insertSelective(organization); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateOrganization(String beanJson, Long id) { + public int updateOrganization(String beanJson, Long id)throws Exception { Organization organization = JSONObject.parseObject(beanJson, Organization.class); organization.setId(id); - return organizationMapper.updateByPrimaryKeySelective(organization); + int result=0; + try{ + result=organizationMapper.updateByPrimaryKeySelective(organization); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteOrganization(Long id) { - return organizationMapper.deleteByPrimaryKey(id); + public int deleteOrganization(Long id)throws Exception { + int result=0; + try{ + result=organizationMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteOrganization(String ids) { + public int batchDeleteOrganization(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); OrganizationExample example = new OrganizationExample(); example.createCriteria().andIdIn(idList); - return organizationMapper.deleteByExample(example); + int result=0; + try{ + result=organizationMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int addOrganization(Organization org) throws Exception{ @@ -92,7 +129,16 @@ public class OrganizationService { if(StringUtil.isEmpty(org.getOrgParentNo())){ org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_PARENT_NO); } - return organizationMapperEx.addOrganization(org); + int result=0; + try{ + result=organizationMapperEx.addOrganization(org); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int editOrganization(Organization org)throws Exception { @@ -116,23 +162,59 @@ public class OrganizationService { if(StringUtil.isEmpty(org.getOrgParentNo())){ org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_PARENT_NO); } - return organizationMapperEx.editOrganization(org); + int result=0; + try{ + result=organizationMapperEx.editOrganization(org); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } public List getOrganizationTree(Long id)throws Exception { - return organizationMapperEx.getNodeTree(id); + List list=null; + try{ + list=organizationMapperEx.getNodeTree(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } public List findById(Long id) throws Exception{ OrganizationExample example = new OrganizationExample(); example.createCriteria().andIdEqualTo(id); - return organizationMapper.selectByExample(example); + List list=null; + try{ + list=organizationMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } public List findByOrgNo(String orgNo)throws Exception { OrganizationExample example = new OrganizationExample(); example.createCriteria().andOrgNoEqualTo(orgNo).andOrgStcdNotEqualTo(BusinessConstants.ORGANIZATION_STCD_REMOVED); - return organizationMapper.selectByExample(example); + List list=null; + try{ + list=organizationMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } /** * create by: cjl @@ -177,6 +259,16 @@ public class OrganizationService { ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return organizationMapperEx.batchDeleteOrganizationByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result=organizationMapperEx.batchDeleteOrganizationByIds( + new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } } diff --git a/src/main/java/com/jsh/erp/service/person/PersonComponent.java b/src/main/java/com/jsh/erp/service/person/PersonComponent.java index 7e9a6e44..b7b6a6cc 100644 --- a/src/main/java/com/jsh/erp/service/person/PersonComponent.java +++ b/src/main/java/com/jsh/erp/service/person/PersonComponent.java @@ -21,16 +21,16 @@ public class PersonComponent implements ICommonQuery { private PersonService personService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getPersonList(map); } - private List getPersonList(Map map) { + private List getPersonList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -39,7 +39,7 @@ public class PersonComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -47,27 +47,27 @@ public class PersonComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return personService.insertPerson(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return personService.updatePerson(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return personService.deletePerson(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return personService.batchDeletePerson(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return personService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/person/PersonService.java b/src/main/java/com/jsh/erp/service/person/PersonService.java index 12a36f41..3dea10df 100644 --- a/src/main/java/com/jsh/erp/service/person/PersonService.java +++ b/src/main/java/com/jsh/erp/service/person/PersonService.java @@ -43,63 +43,151 @@ public class PersonService { @Resource private DepotHeadMapperEx depotHeadMapperEx; - public Person getPerson(long id) { - return personMapper.selectByPrimaryKey(id); + public Person getPerson(long id)throws Exception { + Person result=null; + try{ + result=personMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getPerson() { + public List getPerson()throws Exception { PersonExample example = new PersonExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return personMapper.selectByExample(example); + List list=null; + try{ + list=personMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, String type, int offset, int rows) { - return personMapperEx.selectByConditionPerson(name, type, offset, rows); + public List select(String name, String type, int offset, int rows)throws Exception { + List list=null; + try{ + list=personMapperEx.selectByConditionPerson(name, type, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countPerson(String name, String type) { - return personMapperEx.countsByPerson(name, type); + public Long countPerson(String name, String type)throws Exception { + Long result=null; + try{ + result=personMapperEx.countsByPerson(name, type); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertPerson(String beanJson, HttpServletRequest request) { + public int insertPerson(String beanJson, HttpServletRequest request)throws Exception { Person person = JSONObject.parseObject(beanJson, Person.class); - return personMapper.insertSelective(person); + int result=0; + try{ + result=personMapper.insertSelective(person); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updatePerson(String beanJson, Long id) { + public int updatePerson(String beanJson, Long id)throws Exception { Person person = JSONObject.parseObject(beanJson, Person.class); person.setId(id); - return personMapper.updateByPrimaryKeySelective(person); + int result=0; + try{ + result=personMapper.updateByPrimaryKeySelective(person); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deletePerson(Long id) { - return personMapper.deleteByPrimaryKey(id); + public int deletePerson(Long id)throws Exception { + int result=0; + try{ + result=personMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeletePerson(String ids) { + public int batchDeletePerson(String ids) throws Exception{ List idList = StringUtil.strToLongList(ids); PersonExample example = new PersonExample(); example.createCriteria().andIdIn(idList); - return personMapper.deleteByExample(example); + int result=0; + try{ + result=personMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name) throws Exception{ PersonExample example = new PersonExample(); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = personMapper.selectByExample(example); - return list.size(); + List list =null; + try{ + list=personMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } - public String getPersonByIds(String personIDs) { + public String getPersonByIds(String personIDs)throws Exception { List ids = StringUtil.strToLongList(personIDs); PersonExample example = new PersonExample(); example.createCriteria().andIdIn(ids).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Id asc"); - List list = personMapper.selectByExample(example); + List list =null; + try{ + list=personMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } StringBuffer sb = new StringBuffer(); if (null != list) { for (Person person : list) { @@ -109,21 +197,39 @@ public class PersonService { return sb.toString(); } - public List getPersonByType(String type) { + public List getPersonByType(String type)throws Exception { PersonExample example = new PersonExample(); example.createCriteria().andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Id asc"); - return personMapper.selectByExample(example); + List list =null; + try{ + list=personMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeletePersonByIds(String ids) { + public int batchDeletePersonByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_PERSON, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return personMapperEx.batchDeletePersonByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result =0; + try{ + result=personMapperEx.batchDeletePersonByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: qiankunpingtai @@ -150,7 +256,15 @@ public class PersonService { /** * 校验财务主表 jsh_accounthead * */ - List accountHeadList=accountHeadMapperEx.getAccountHeadListByHandsPersonIds(idArray); + List accountHeadList =null; + try{ + accountHeadList=accountHeadMapperEx.getAccountHeadListByHandsPersonIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(accountHeadList!=null&&accountHeadList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -160,7 +274,15 @@ public class PersonService { /** * 校验单据主表 jsh_depothead * */ - List depotHeadList=depotHeadMapperEx.getDepotHeadListByHandsPersonIds(idArray); + List depotHeadList =null; + try{ + depotHeadList=depotHeadMapperEx.getDepotHeadListByHandsPersonIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(depotHeadList!=null&&depotHeadList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); diff --git a/src/main/java/com/jsh/erp/service/role/RoleComponent.java b/src/main/java/com/jsh/erp/service/role/RoleComponent.java index dfbd0bf6..9c491a15 100644 --- a/src/main/java/com/jsh/erp/service/role/RoleComponent.java +++ b/src/main/java/com/jsh/erp/service/role/RoleComponent.java @@ -19,16 +19,16 @@ public class RoleComponent implements ICommonQuery { private RoleService roleService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getRoleList(map); } - private List getRoleList(Map map) { + private List getRoleList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String order = QueryUtils.order(map); @@ -37,34 +37,34 @@ public class RoleComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); return roleService.countRole(name); } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return roleService.insertRole(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return roleService.updateRole(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return roleService.deleteRole(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return roleService.batchDeleteRole(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return 0; } diff --git a/src/main/java/com/jsh/erp/service/role/RoleService.java b/src/main/java/com/jsh/erp/service/role/RoleService.java index 6fa3bb2d..74267a23 100644 --- a/src/main/java/com/jsh/erp/service/role/RoleService.java +++ b/src/main/java/com/jsh/erp/service/role/RoleService.java @@ -2,18 +2,18 @@ package com.jsh.erp.service.role; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.Role; import com.jsh.erp.datasource.entities.RoleExample; import com.jsh.erp.datasource.entities.User; -import com.jsh.erp.datasource.entities.UserExample; import com.jsh.erp.datasource.mappers.RoleMapper; import com.jsh.erp.datasource.mappers.RoleMapperEx; -import com.jsh.erp.datasource.mappers.UserMapper; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; -import com.jsh.erp.utils.QueryUtils; -import com.jsh.erp.utils.RegExpTools; import com.jsh.erp.utils.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestContextHolder; @@ -23,10 +23,10 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Date; import java.util.List; -import java.util.Map; @Service public class RoleService { + private Logger logger = LoggerFactory.getLogger(RoleService.class); @Resource private RoleMapper roleMapper; @@ -37,55 +37,135 @@ public class RoleService { @Resource private UserService userService; - public Role getRole(long id) { - return roleMapper.selectByPrimaryKey(id); + public Role getRole(long id)throws Exception { + Role result=null; + try{ + result=roleMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getRole() { + public List getRole()throws Exception { RoleExample example = new RoleExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return roleMapper.selectByExample(example); + List list=null; + try{ + list=roleMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, int offset, int rows) { - return roleMapperEx.selectByConditionRole(name, offset, rows); + public List select(String name, int offset, int rows)throws Exception { + List list=null; + try{ + list=roleMapperEx.selectByConditionRole(name, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countRole(String name) { - return roleMapperEx.countsByRole(name); + public Long countRole(String name)throws Exception { + Long result=null; + try{ + result=roleMapperEx.countsByRole(name); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertRole(String beanJson, HttpServletRequest request) { + public int insertRole(String beanJson, HttpServletRequest request)throws Exception { Role role = JSONObject.parseObject(beanJson, Role.class); - return roleMapper.insertSelective(role); + int result=0; + try{ + result=roleMapper.insertSelective(role); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateRole(String beanJson, Long id) { + public int updateRole(String beanJson, Long id) throws Exception{ Role role = JSONObject.parseObject(beanJson, Role.class); role.setId(id); - return roleMapper.updateByPrimaryKeySelective(role); + int result=0; + try{ + result=roleMapper.updateByPrimaryKeySelective(role); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteRole(Long id) { - return roleMapper.deleteByPrimaryKey(id); + public int deleteRole(Long id)throws Exception { + int result=0; + try{ + result=roleMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteRole(String ids) { + public int batchDeleteRole(String ids) throws Exception{ List idList = StringUtil.strToLongList(ids); RoleExample example = new RoleExample(); example.createCriteria().andIdIn(idList); - return roleMapper.deleteByExample(example); + int result=0; + try{ + result=roleMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public List findUserRole(){ + public List findUserRole()throws Exception{ RoleExample example = new RoleExample(); example.setOrderByClause("Id"); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = roleMapper.selectByExample(example); + List list=null; + try{ + list=roleMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } /** @@ -98,12 +178,21 @@ public class RoleService { * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteRoleByIds(String ids) { + public int batchDeleteRoleByIds(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SERIAL_NUMBER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return roleMapperEx.batchDeleteRoleByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result=roleMapperEx.batchDeleteRoleByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } } diff --git a/src/main/java/com/jsh/erp/service/serialNumber/SerialNumberComponent.java b/src/main/java/com/jsh/erp/service/serialNumber/SerialNumberComponent.java index 84c6d1f7..7cc89dde 100644 --- a/src/main/java/com/jsh/erp/service/serialNumber/SerialNumberComponent.java +++ b/src/main/java/com/jsh/erp/service/serialNumber/SerialNumberComponent.java @@ -26,16 +26,16 @@ public class SerialNumberComponent implements ICommonQuery { private SerialNumberService serialNumberService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getSerialNumberList(map); } - private List getSerialNumberList(Map map) { + private List getSerialNumberList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String serialNumber = StringUtil.getInfo(search, "serialNumber"); String materialName = StringUtil.getInfo(search, "materialName"); @@ -43,7 +43,7 @@ public class SerialNumberComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String serialNumber = StringUtil.getInfo(search, "serialNumber"); String materialName = StringUtil.getInfo(search, "materialName"); @@ -51,27 +51,27 @@ public class SerialNumberComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return serialNumberService.insertSerialNumber(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return serialNumberService.updateSerialNumber(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return serialNumberService.deleteSerialNumber(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return serialNumberService.batchDeleteSerialNumber(ids); } @Override - public int checkIsNameExist(Long id, String serialNumber) { + public int checkIsNameExist(Long id, String serialNumber) throws Exception{ return serialNumberService.checkIsNameExist(id, serialNumber); } } diff --git a/src/main/java/com/jsh/erp/service/serialNumber/SerialNumberService.java b/src/main/java/com/jsh/erp/service/serialNumber/SerialNumberService.java index 4a310c67..498ce83c 100644 --- a/src/main/java/com/jsh/erp/service/serialNumber/SerialNumberService.java +++ b/src/main/java/com/jsh/erp/service/serialNumber/SerialNumberService.java @@ -32,7 +32,7 @@ import java.util.List; */ @Service public class SerialNumberService { - private Logger logger = LoggerFactory.getLogger(MaterialService.class); + private Logger logger = LoggerFactory.getLogger(SerialNumberService.class); @Resource private SerialNumberMapper serialNumberMapper; @@ -48,84 +48,190 @@ public class SerialNumberService { private LogService logService; - public SerialNumber getSerialNumber(long id) { - return serialNumberMapper.selectByPrimaryKey(id); + public SerialNumber getSerialNumber(long id)throws Exception { + SerialNumber result=null; + try{ + result=serialNumberMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getSerialNumber() { + public List getSerialNumber()throws Exception { SerialNumberExample example = new SerialNumberExample(); - return serialNumberMapper.selectByExample(example); + List list=null; + try{ + list=serialNumberMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String serialNumber, String materialName, Integer offset, Integer rows) { - return serialNumberMapperEx.selectByConditionSerialNumber(serialNumber, materialName,offset, rows); + public List select(String serialNumber, String materialName, Integer offset, Integer rows)throws Exception { + List list=null; + try{ + list=serialNumberMapperEx.selectByConditionSerialNumber(serialNumber, materialName,offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countSerialNumber(String serialNumber,String materialName) { - return serialNumberMapperEx.countSerialNumber(serialNumber, materialName); + public Long countSerialNumber(String serialNumber,String materialName)throws Exception { + Long result=null; + try{ + result=serialNumberMapperEx.countSerialNumber(serialNumber, materialName); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertSerialNumber(String beanJson, HttpServletRequest request) { + public int insertSerialNumber(String beanJson, HttpServletRequest request)throws Exception { SerialNumber serialNumber = JSONObject.parseObject(beanJson, SerialNumber.class); logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SERIAL_NUMBER, BusinessConstants.LOG_OPERATION_TYPE_ADD, request); - return serialNumberMapper.insertSelective(serialNumber); + int result=0; + try{ + result=serialNumberMapper.insertSelective(serialNumber); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateSerialNumber(String beanJson, Long id) { + public int updateSerialNumber(String beanJson, Long id) throws Exception{ SerialNumber serialNumber = JSONObject.parseObject(beanJson, SerialNumber.class); serialNumber.setId(id); - int res = serialNumberMapper.updateByPrimaryKeySelective(serialNumber); - return res; + int result=0; + try{ + result=serialNumberMapper.updateByPrimaryKeySelective(serialNumber); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteSerialNumber(Long id) { - return serialNumberMapper.deleteByPrimaryKey(id); + public int deleteSerialNumber(Long id)throws Exception { + int result=0; + try{ + result=serialNumberMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteSerialNumber(String ids) { + public int batchDeleteSerialNumber(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); SerialNumberExample example = new SerialNumberExample(); example.createCriteria().andIdIn(idList); - return serialNumberMapper.deleteByExample(example); + int result=0; + try{ + result=serialNumberMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String serialNumber) { + public int checkIsNameExist(Long id, String serialNumber)throws Exception { SerialNumberExample example = new SerialNumberExample(); example.createCriteria().andIdNotEqualTo(id).andSerialNumberEqualTo(serialNumber).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = serialNumberMapper.selectByExample(example); - return list.size(); + List list=null; + try{ + list=serialNumberMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchSetEnable(Boolean enabled, String materialIDs) { + public int batchSetEnable(Boolean enabled, String materialIDs)throws Exception{ List ids = StringUtil.strToLongList(materialIDs); SerialNumber serialNumber = new SerialNumber(); SerialNumberExample example = new SerialNumberExample(); example.createCriteria().andIdIn(ids); - return serialNumberMapper.updateByExampleSelective(serialNumber, example); + int result=0; + try{ + result=serialNumberMapper.updateByExampleSelective(serialNumber, example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public List findById(Long id){ - return serialNumberMapperEx.findById(id); + public List findById(Long id)throws Exception{ + List list=null; + try{ + list=serialNumberMapperEx.findById(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public void checkIsExist(Long id, String materialName, String serialNumber) { + public void checkIsExist(Long id, String materialName, String serialNumber) throws Exception{ /** * 商品名称不为空时,检查商品名称是否存在 * */ if(StringUtil.isNotEmpty(materialName)){ - List mlist = materialMapperEx.findByMaterialName(materialName); + List mlist=null; + try{ + mlist = materialMapperEx.findByMaterialName(materialName); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + if(mlist==null||mlist.size()<1){ //商品名称不存在 throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE, @@ -140,7 +246,15 @@ public class SerialNumberService { /*** * 判断序列号是否已存在 * */ - List list = serialNumberMapperEx.findBySerialNumber(serialNumber); + List list=null; + try{ + list = serialNumberMapperEx.findBySerialNumber(serialNumber); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(list!=null&&list.size()>0){ if(list.size()>1){ //存在多个同名序列号 @@ -169,7 +283,7 @@ public class SerialNumberService { * 新增序列号信息 * */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public SerialNumberEx addSerialNumber(SerialNumberEx serialNumberEx) { + public SerialNumberEx addSerialNumber(SerialNumberEx serialNumberEx) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SERIAL_NUMBER,BusinessConstants.LOG_OPERATION_TYPE_ADD, ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); if(serialNumberEx==null){ @@ -187,14 +301,22 @@ public class SerialNumberService { User userInfo=userService.getCurrentUser(); serialNumberEx.setCreator(userInfo==null?null:userInfo.getId()); serialNumberEx.setUpdater(userInfo==null?null:userInfo.getId()); - int result=serialNumberMapperEx.addSerialNumber(serialNumberEx); - if(result==1){ + int result=0; + try{ + result = serialNumberMapperEx.addSerialNumber(serialNumberEx); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + if(result>0){ return serialNumberEx; } return null; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public SerialNumberEx updateSerialNumber(SerialNumberEx serialNumberEx) { + public SerialNumberEx updateSerialNumber(SerialNumberEx serialNumberEx)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SERIAL_NUMBER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(serialNumberEx.getId()).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); @@ -207,8 +329,16 @@ public class SerialNumberService { serialNumberEx.setUpdateTime(date); User userInfo=userService.getCurrentUser(); serialNumberEx.setUpdater(userInfo==null?null:userInfo.getId()); - int result = serialNumberMapperEx.updateSerialNumber(serialNumberEx); - if(result==1){ + int result=0; + try{ + result = serialNumberMapperEx.updateSerialNumber(serialNumberEx); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + if(result>0){ return serialNumberEx; } return null; @@ -221,9 +351,17 @@ public class SerialNumberService { * @Param: materialName * @return Long 满足使用条件的商品的id */ - public Long checkMaterialName(String materialName){ + public Long checkMaterialName(String materialName)throws Exception{ if(StringUtil.isNotEmpty(materialName)) { - List mlist = materialMapperEx.findByMaterialName(materialName); + List mlist=null; + try{ + mlist = materialMapperEx.findByMaterialName(materialName); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if (mlist == null || mlist.size() < 1) { //商品名称不存在 throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE, @@ -258,7 +396,7 @@ public class SerialNumberService { * @Param: materialName * @return Long 满足使用条件的商品的id */ - public Long getSerialNumberMaterialIdByMaterialName(String materialName){ + public Long getSerialNumberMaterialIdByMaterialName(String materialName)throws Exception{ if(StringUtil.isNotEmpty(materialName)){ //计算商品库存和目前占用的可用序列号数量关系 //库存=入库-出库 @@ -290,14 +428,22 @@ public class SerialNumberService { public void checkAndUpdateSerialNumber(DepotItem depotItem,User userInfo) throws Exception{ if(depotItem!=null){ //查询商品下已分配的可用序列号数量 - int SerialNumberSum= serialNumberMapperEx.countSerialNumberByMaterialIdAndDepotheadId(depotItem.getMaterialid(),null,BusinessConstants.IS_SELL_HOLD); - //BasicNumber=OperNumber*ratio - if((depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()>SerialNumberSum){ - //获取商品名称 - Material material= materialMapper.selectByPrimaryKey(depotItem.getMaterialid()); - throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_CODE, - String.format(ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_MSG,material==null?"":material.getName())); + try{ + int SerialNumberSum= serialNumberMapperEx.countSerialNumberByMaterialIdAndDepotheadId(depotItem.getMaterialid(),null,BusinessConstants.IS_SELL_HOLD); + //BasicNumber=OperNumber*ratio + if((depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()>SerialNumberSum){ + //获取商品名称 + Material material= materialMapper.selectByPrimaryKey(depotItem.getMaterialid()); + throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_CODE, + String.format(ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_MSG,material==null?"":material.getName())); + } + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); } + //商品下序列号充足,分配序列号 sellSerialNumber(depotItem.getMaterialid(),depotItem.getHeaderid(),(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),userInfo); } @@ -320,7 +466,16 @@ public class SerialNumberService { */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int sellSerialNumber(Long materialId, Long depotheadId,int count,User user) throws Exception{ - return serialNumberMapperEx.sellSerialNumber(materialId,depotheadId,count,new Date(),user==null?null:user.getId()); + int result=0; + try{ + result = serialNumberMapperEx.sellSerialNumber(materialId,depotheadId,count,new Date(),user==null?null:user.getId()); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** @@ -336,7 +491,16 @@ public class SerialNumberService { */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int cancelSerialNumber(Long materialId, Long depotheadId,int count,User user) throws Exception{ - return serialNumberMapperEx.cancelSerialNumber(materialId,depotheadId,count,new Date(),user==null?null:user.getId()); + int result=0; + try{ + result = serialNumberMapperEx.cancelSerialNumber(materialId,depotheadId,count,new Date(),user==null?null:user.getId()); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** @@ -351,7 +515,7 @@ public class SerialNumberService { * @return java.lang.Object */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public void batAddSerialNumber(String materialName, String serialNumberPrefix, Integer batAddTotal, String remark) { + public void batAddSerialNumber(String materialName, String serialNumberPrefix, Integer batAddTotal, String remark)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SERIAL_NUMBER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_BATCH_ADD).append(batAddTotal).append(BusinessConstants.LOG_DATA_UNIT).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); @@ -386,6 +550,15 @@ public class SerialNumberService { each.setSerialNumber(new StringBuffer(prefixBuf.toString()).append(insertNum).toString()); list.add(each); } + int result=0; + try{ + result = serialNumberMapperEx.batAddSerialNumber(list); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } serialNumberMapperEx.batAddSerialNumber(list); batAddTotal -= BusinessConstants.BATCH_INSERT_MAX_NUMBER; }while(batAddTotal>0); @@ -401,13 +574,22 @@ public class SerialNumberService { * @return */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteSerialNumberByIds(String ids) { + public int batchDeleteSerialNumberByIds(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SERIAL_NUMBER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return serialNumberMapperEx.batchDeleteSerialNumberByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result = serialNumberMapperEx.batchDeleteSerialNumberByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } } diff --git a/src/main/java/com/jsh/erp/service/supplier/SupplierComponent.java b/src/main/java/com/jsh/erp/service/supplier/SupplierComponent.java index ec881237..c018e2ac 100644 --- a/src/main/java/com/jsh/erp/service/supplier/SupplierComponent.java +++ b/src/main/java/com/jsh/erp/service/supplier/SupplierComponent.java @@ -21,16 +21,16 @@ public class SupplierComponent implements ICommonQuery { private SupplierService supplierService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getSupplierList(map); } - private List getSupplierList(Map map) { + private List getSupplierList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String supplier = StringUtil.getInfo(search, "supplier"); String type = StringUtil.getInfo(search, "type"); @@ -42,7 +42,7 @@ public class SupplierComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String supplier = StringUtil.getInfo(search, "supplier"); String type = StringUtil.getInfo(search, "type"); @@ -53,27 +53,27 @@ public class SupplierComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return supplierService.insertSupplier(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return supplierService.updateSupplier(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return supplierService.deleteSupplier(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return supplierService.batchDeleteSupplier(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return supplierService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java index 99db9ed6..e40d496f 100644 --- a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java +++ b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java @@ -47,105 +47,236 @@ public class SupplierService { @Resource private DepotHeadMapperEx depotHeadMapperEx; - public Supplier getSupplier(long id) { - return supplierMapper.selectByPrimaryKey(id); + public Supplier getSupplier(long id)throws Exception { + Supplier result=null; + try{ + result=supplierMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getSupplier() { + public List getSupplier()throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list=supplierMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String supplier, String type, String phonenum, String telephone, String description, int offset, int rows) { - return supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows); + public List select(String supplier, String type, String phonenum, + String telephone, String description, int offset, int rows) throws Exception{ + List list=null; + try{ + list=supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countSupplier(String supplier, String type, String phonenum, String telephone, String description) { - return supplierMapperEx.countsBySupplier(supplier, type, phonenum, telephone, description); + public Long countSupplier(String supplier, String type, String phonenum, String telephone, String description) throws Exception{ + Long result=null; + try{ + result=supplierMapperEx.countsBySupplier(supplier, type, phonenum, telephone, description); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertSupplier(String beanJson, HttpServletRequest request) { + public int insertSupplier(String beanJson, HttpServletRequest request)throws Exception { Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class); - return supplierMapper.insertSelective(supplier); + int result=0; + try{ + result=supplierMapper.insertSelective(supplier); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateSupplier(String beanJson, Long id) { + public int updateSupplier(String beanJson, Long id)throws Exception { Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class); supplier.setId(id); - return supplierMapper.updateByPrimaryKeySelective(supplier); + int result=0; + try{ + result=supplierMapper.updateByPrimaryKeySelective(supplier); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteSupplier(Long id) { + public int deleteSupplier(Long id)throws Exception { + int result=0; + try{ + result=supplierMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } return supplierMapper.deleteByPrimaryKey(id); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteSupplier(String ids) { + public int batchDeleteSupplier(String ids) throws Exception{ List idList = StringUtil.strToLongList(ids); SupplierExample example = new SupplierExample(); example.createCriteria().andIdIn(idList); - return supplierMapper.deleteByExample(example); + int result=0; + try{ + result=supplierMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = supplierMapper.selectByExample(example); - return list.size(); + List list=null; + try{ + list= supplierMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return list==null?0:list.size(); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateAdvanceIn(Long supplierId, BigDecimal advanceIn){ + public int updateAdvanceIn(Long supplierId, BigDecimal advanceIn)throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(supplierId).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); - Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId); - if(supplier!=null){ - supplier.setAdvancein(supplier.getAdvancein().add(advanceIn)); //增加预收款的金额,可能增加的是负值 - return supplierMapper.updateByPrimaryKeySelective(supplier); - }else{ - return 0; + Supplier supplier=null; + try{ + supplier = supplierMapper.selectByPrimaryKey(supplierId); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); } - + int result=0; + try{ + if(supplier!=null){ + supplier.setAdvancein(supplier.getAdvancein().add(advanceIn)); //增加预收款的金额,可能增加的是负值 + result=supplierMapper.updateByPrimaryKeySelective(supplier); + } + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public List findBySelectCus() { + public List findBySelectCus()throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List findBySelectSup() { + public List findBySelectSup()throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List findBySelectRetail() { + public List findBySelectRetail()throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List findById(Long supplierId) { + public List findById(Long supplierId)throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andIdEqualTo(supplierId) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchSetEnable(Boolean enabled, String supplierIDs) { + public int batchSetEnable(Boolean enabled, String supplierIDs)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(supplierIDs).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); @@ -154,20 +285,47 @@ public class SupplierService { supplier.setEnabled(enabled); SupplierExample example = new SupplierExample(); example.createCriteria().andIdIn(ids); - return supplierMapper.updateByExampleSelective(supplier, example); + int result=0; + try{ + result = supplierMapper.updateByExampleSelective(supplier, example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public List findUserCustomer(){ + public List findUserCustomer()throws Exception{ SupplierExample example = new SupplierExample(); example.createCriteria().andTypeEqualTo("客户") .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - List list = supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } - public List findByAll(String supplier, String type, String phonenum, String telephone, String description) { - return supplierMapperEx.findByAll(supplier, type, phonenum, telephone, description); + public List findByAll(String supplier, String type, String phonenum, + String telephone, String description) throws Exception{ + List list=null; + try{ + list = supplierMapperEx.findByAll(supplier, type, phonenum, telephone, description); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) public BaseResponseInfo importExcel(List mList) throws Exception { @@ -183,6 +341,8 @@ public class SupplierService { info.code = 200; data.put("message", "成功"); } catch (Exception e) { + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); e.printStackTrace(); info.code = 500; data.put("message", e.getMessage()); @@ -191,13 +351,22 @@ public class SupplierService { return info; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteSupplierByIds(String ids) { + public int batchDeleteSupplierByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return supplierMapperEx.batchDeleteSupplierByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result = supplierMapperEx.batchDeleteSupplierByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: qiankunpingtai @@ -224,7 +393,15 @@ public class SupplierService { /** * 校验财务主表 jsh_accounthead * */ - List accountHeadList=accountHeadMapperEx.getAccountHeadListByOrganIds(idArray); + List accountHeadList=null; + try{ + accountHeadList = accountHeadMapperEx.getAccountHeadListByOrganIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(accountHeadList!=null&&accountHeadList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,OrganIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -234,7 +411,15 @@ public class SupplierService { /** * 校验单据主表 jsh_depothead * */ - List depotHeadList=depotHeadMapperEx.getDepotHeadListByOrganIds(idArray); + List depotHeadList=null; + try{ + depotHeadList = depotHeadMapperEx.getDepotHeadListByOrganIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(depotHeadList!=null&&depotHeadList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,OrganIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); diff --git a/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigComponent.java b/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigComponent.java index 65a6f771..427cd516 100644 --- a/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigComponent.java +++ b/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigComponent.java @@ -21,16 +21,16 @@ public class SystemConfigComponent implements ICommonQuery { private SystemConfigService systemConfigService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getSystemConfigList(map); } - private List getSystemConfigList(Map map) { + private List getSystemConfigList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String companyName = StringUtil.getInfo(search, "companyName"); String order = QueryUtils.order(map); @@ -38,34 +38,34 @@ public class SystemConfigComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String companyName = StringUtil.getInfo(search, "companyName"); return systemConfigService.countSystemConfig(companyName); } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return systemConfigService.insertSystemConfig(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return systemConfigService.updateSystemConfig(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return systemConfigService.deleteSystemConfig(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return systemConfigService.batchDeleteSystemConfig(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return systemConfigService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java b/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java index b4ed6c6f..eb6befdc 100644 --- a/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java +++ b/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java @@ -2,11 +2,14 @@ package com.jsh.erp.service.systemConfig; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; +import com.jsh.erp.datasource.entities.Supplier; import com.jsh.erp.datasource.entities.SystemConfig; import com.jsh.erp.datasource.entities.SystemConfigExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.SystemConfigMapper; import com.jsh.erp.datasource.mappers.SystemConfigMapperEx; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.StringUtil; @@ -36,63 +39,152 @@ public class SystemConfigService { @Resource private LogService logService; - public SystemConfig getSystemConfig(long id) { - return systemConfigMapper.selectByPrimaryKey(id); + public SystemConfig getSystemConfig(long id)throws Exception { + SystemConfig result=null; + try{ + result=systemConfigMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getSystemConfig() { + public List getSystemConfig()throws Exception { SystemConfigExample example = new SystemConfigExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return systemConfigMapper.selectByExample(example); + List list=null; + try{ + list=systemConfigMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String companyName, int offset, int rows) { - return systemConfigMapperEx.selectByConditionSystemConfig(companyName, offset, rows); + public List select(String companyName, int offset, int rows)throws Exception { + List list=null; + try{ + list=systemConfigMapperEx.selectByConditionSystemConfig(companyName, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countSystemConfig(String companyName) { - return systemConfigMapperEx.countsBySystemConfig(companyName); + public Long countSystemConfig(String companyName)throws Exception { + Long result=null; + try{ + result=systemConfigMapperEx.countsBySystemConfig(companyName); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertSystemConfig(String beanJson, HttpServletRequest request) { + public int insertSystemConfig(String beanJson, HttpServletRequest request) throws Exception{ SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class); - return systemConfigMapper.insertSelective(systemConfig); + int result=0; + try{ + result=systemConfigMapper.insertSelective(systemConfig); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateSystemConfig(String beanJson, Long id) { + public int updateSystemConfig(String beanJson, Long id) throws Exception{ SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class); systemConfig.setId(id); - return systemConfigMapper.updateByPrimaryKeySelective(systemConfig); + int result=0; + try{ + result=systemConfigMapper.updateByPrimaryKeySelective(systemConfig); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteSystemConfig(Long id) { - return systemConfigMapper.deleteByPrimaryKey(id); + public int deleteSystemConfig(Long id)throws Exception { + int result=0; + try{ + result=systemConfigMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteSystemConfig(String ids) { + public int batchDeleteSystemConfig(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); SystemConfigExample example = new SystemConfigExample(); example.createCriteria().andIdIn(idList); - return systemConfigMapper.deleteByExample(example); + int result=0; + try{ + result=systemConfigMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name) throws Exception{ SystemConfigExample example = new SystemConfigExample(); example.createCriteria().andIdNotEqualTo(id).andCompanyNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = systemConfigMapper.selectByExample(example); - return list.size(); + List list =null; + try{ + list=systemConfigMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteSystemConfigByIds(String ids) { + public int batchDeleteSystemConfigByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SYSTEM_CONFIG, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return systemConfigMapperEx.batchDeleteSystemConfigByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result=systemConfigMapperEx.batchDeleteSystemConfigByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } } diff --git a/src/main/java/com/jsh/erp/service/unit/UnitComponent.java b/src/main/java/com/jsh/erp/service/unit/UnitComponent.java index 9241190e..98a66249 100644 --- a/src/main/java/com/jsh/erp/service/unit/UnitComponent.java +++ b/src/main/java/com/jsh/erp/service/unit/UnitComponent.java @@ -20,16 +20,16 @@ public class UnitComponent implements ICommonQuery { private UnitService unitService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getUnitList(map); } - private List getUnitList(Map map) { + private List getUnitList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String order = QueryUtils.order(map); @@ -37,34 +37,34 @@ public class UnitComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); return unitService.countUnit(name); } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return unitService.insertUnit(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return unitService.updateUnit(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return unitService.deleteUnit(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return unitService.batchDeleteUnit(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return unitService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/unit/UnitService.java b/src/main/java/com/jsh/erp/service/unit/UnitService.java index d15e49bd..8c160e96 100644 --- a/src/main/java/com/jsh/erp/service/unit/UnitService.java +++ b/src/main/java/com/jsh/erp/service/unit/UnitService.java @@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.ExceptionConstants; -import com.jsh.erp.datasource.entities.Material; -import com.jsh.erp.datasource.entities.Unit; -import com.jsh.erp.datasource.entities.UnitExample; -import com.jsh.erp.datasource.entities.User; +import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.mappers.MaterialMapperEx; import com.jsh.erp.datasource.mappers.UnitMapper; import com.jsh.erp.datasource.mappers.UnitMapperEx; @@ -43,64 +40,153 @@ public class UnitService { @Resource private MaterialMapperEx materialMapperEx; - public Unit getUnit(long id) { - return unitMapper.selectByPrimaryKey(id); + public Unit getUnit(long id)throws Exception { + Unit result=null; + try{ + result=unitMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getUnit() { + public List getUnit()throws Exception { UnitExample example = new UnitExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return unitMapper.selectByExample(example); + List list=null; + try{ + list=unitMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String name, int offset, int rows) { - return unitMapperEx.selectByConditionUnit(name, offset, rows); + public List select(String name, int offset, int rows)throws Exception { + List list=null; + try{ + list=unitMapperEx.selectByConditionUnit(name, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countUnit(String name) { - return unitMapperEx.countsByUnit(name); + public Long countUnit(String name)throws Exception { + Long result=null; + try{ + result=unitMapperEx.countsByUnit(name); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertUnit(String beanJson, HttpServletRequest request) { + public int insertUnit(String beanJson, HttpServletRequest request)throws Exception { Unit unit = JSONObject.parseObject(beanJson, Unit.class); - return unitMapper.insertSelective(unit); + int result=0; + try{ + result=unitMapper.insertSelective(unit); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateUnit(String beanJson, Long id) { + public int updateUnit(String beanJson, Long id)throws Exception { Unit unit = JSONObject.parseObject(beanJson, Unit.class); unit.setId(id); - return unitMapper.updateByPrimaryKeySelective(unit); + int result=0; + try{ + result=unitMapper.updateByPrimaryKeySelective(unit); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteUnit(Long id) { - return unitMapper.deleteByPrimaryKey(id); + public int deleteUnit(Long id)throws Exception { + int result=0; + try{ + result=unitMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteUnit(String ids) { + public int batchDeleteUnit(String ids) throws Exception{ List idList = StringUtil.strToLongList(ids); UnitExample example = new UnitExample(); example.createCriteria().andIdIn(idList); - return unitMapper.deleteByExample(example); + int result=0; + try{ + result=unitMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { UnitExample example = new UnitExample(); example.createCriteria().andIdNotEqualTo(id).andUnameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = unitMapper.selectByExample(example); - return list.size(); + List list=null; + try{ + list=unitMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteUnitByIds(String ids) { + public int batchDeleteUnitByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_UNIT, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return unitMapperEx.batchDeleteUnitByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result=unitMapperEx.batchDeleteUnitByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** @@ -127,7 +213,15 @@ public class UnitService { /** * 校验产品表 jsh_material * */ - List materialList=materialMapperEx.getMaterialListByUnitIds(idArray); + List materialList=null; + try{ + materialList=materialMapperEx.getMaterialListByUnitIds(idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } if(materialList!=null&&materialList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,UnitIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); diff --git a/src/main/java/com/jsh/erp/service/user/UserComponent.java b/src/main/java/com/jsh/erp/service/user/UserComponent.java index 7a4b3b73..3a7bc58d 100644 --- a/src/main/java/com/jsh/erp/service/user/UserComponent.java +++ b/src/main/java/com/jsh/erp/service/user/UserComponent.java @@ -18,16 +18,16 @@ public class UserComponent implements ICommonQuery { private UserService userService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getUserList(map); } - private List getUserList(Map map) { + private List getUserList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String userName = StringUtil.getInfo(search, "userName"); String loginName = StringUtil.getInfo(search, "loginName"); @@ -37,7 +37,7 @@ public class UserComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String userName = StringUtil.getInfo(search, "userName"); String loginName = StringUtil.getInfo(search, "loginName"); @@ -45,27 +45,27 @@ public class UserComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return userService.insertUser(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return userService.updateUser(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return userService.deleteUser(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return userService.batchDeleteUser(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return userService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/user/UserService.java b/src/main/java/com/jsh/erp/service/user/UserService.java index 966a09f6..57aa07a9 100644 --- a/src/main/java/com/jsh/erp/service/user/UserService.java +++ b/src/main/java/com/jsh/erp/service/user/UserService.java @@ -11,16 +11,17 @@ import com.jsh.erp.datasource.entities.UserEx; import com.jsh.erp.datasource.entities.UserExample; import com.jsh.erp.datasource.mappers.UserMapper; import com.jsh.erp.datasource.mappers.UserMapperEx; -import com.jsh.erp.datasource.vo.TreeNode; import com.jsh.erp.datasource.vo.TreeNodeEx; import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.orgaUserRel.OrgaUserRelService; import com.jsh.erp.service.userBusiness.UserBusinessService; -import com.jsh.erp.utils.*; +import com.jsh.erp.utils.ExceptionCodeConstants; +import com.jsh.erp.utils.JshException; +import com.jsh.erp.utils.StringUtil; +import com.jsh.erp.utils.Tools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestContextHolder; @@ -28,9 +29,11 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.net.URLEncoder; import java.security.NoSuchAlgorithmException; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; @Service public class UserService { @@ -51,21 +54,57 @@ public class UserService { private UserBusinessService userBusinessService; - public User getUser(long id) { - return userMapper.selectByPrimaryKey(id); + public User getUser(long id)throws Exception { + User result=null; + try{ + result=userMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getUser() { + public List getUser()throws Exception { UserExample example = new UserExample(); - return userMapper.selectByExample(example); + List list=null; + try{ + list=userMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String userName, String loginName, int offset, int rows) { - return userMapperEx.selectByConditionUser(userName, loginName, offset, rows); + public List select(String userName, String loginName, int offset, int rows)throws Exception { + List list=null; + try{ + list=userMapperEx.selectByConditionUser(userName, loginName, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countUser(String userName, String loginName) { - return userMapperEx.countsByUser(userName, loginName); + public Long countUser(String userName, String loginName)throws Exception { + Long result=null; + try{ + result=userMapperEx.countsByUser(userName, loginName); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } /** * create by: cjl @@ -77,7 +116,7 @@ public class UserService { * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertUser(String beanJson, HttpServletRequest request) { + public int insertUser(String beanJson, HttpServletRequest request)throws Exception { User user = JSONObject.parseObject(beanJson, User.class); String password = "123456"; //因密码用MD5加密,需要对密码进行转化 @@ -88,7 +127,16 @@ public class UserService { e.printStackTrace(); logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 :" + e.getMessage()); } - return userMapper.insertSelective(user); + int result=0; + try{ + result=userMapper.insertSelective(user); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: cjl @@ -100,10 +148,19 @@ public class UserService { * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateUser(String beanJson, Long id) { + public int updateUser(String beanJson, Long id) throws Exception{ User user = JSONObject.parseObject(beanJson, User.class); user.setId(id); - return userMapper.updateByPrimaryKeySelective(user); + int result=0; + try{ + result=userMapper.updateByPrimaryKeySelective(user); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: cjl @@ -114,11 +171,20 @@ public class UserService { * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateUserByObj(User user) { + public int updateUserByObj(User user) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getId()).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); - return userMapper.updateByPrimaryKeySelective(user); + int result=0; + try{ + result=userMapper.updateByPrimaryKeySelective(user); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** * create by: cjl @@ -130,27 +196,54 @@ public class UserService { * @return int */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int resetPwd(String md5Pwd, Long id) { + public int resetPwd(String md5Pwd, Long id) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User user = new User(); user.setId(id); user.setPassword(md5Pwd); - return userMapper.updateByPrimaryKeySelective(user); + int result=0; + try{ + result=userMapper.updateByPrimaryKeySelective(user); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteUser(Long id) { - return userMapper.deleteByPrimaryKey(id); + public int deleteUser(Long id)throws Exception { + int result=0; + try{ + result= userMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteUser(String ids) { + public int batchDeleteUser(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); UserExample example = new UserExample(); example.createCriteria().andIdIn(idList); - return userMapper.deleteByExample(example); + int result=0; + try{ + result= userMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } public int validateUser(String username, String password) throws JshException { @@ -162,6 +255,8 @@ public class UserService { example.createCriteria().andLoginameEqualTo(username); list = userMapper.selectByExample(example); } catch (Exception e) { + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e); return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION; } @@ -188,22 +283,41 @@ public class UserService { } } - public User getUserByUserName(String username) { + public User getUserByUserName(String username)throws Exception { UserExample example = new UserExample(); example.createCriteria().andLoginameEqualTo(username); - List list = userMapper.selectByExample(example); - User user = list.get(0); + List list=null; + try{ + list= userMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + User user =null; + if(list!=null&&list.size()>0){ + user = list.get(0); + } return user; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { UserExample example = new UserExample(); List userStatus=new ArrayList(); userStatus.add(BusinessConstants.USER_STATUS_DELETE); userStatus.add(BusinessConstants.USER_STATUS_BANNED); example.createCriteria().andIdNotEqualTo(id).andLoginameEqualTo(name).andStatusNotIn(userStatus); - List list = userMapper.selectByExample(example); - return list.size(); + List list=null; + try{ + list= userMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } /** * create by: cjl @@ -213,13 +327,22 @@ public class UserService { * @Param: * @return com.jsh.erp.datasource.entities.User */ - public User getCurrentUser(){ + public User getCurrentUser()throws Exception{ HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); return (User)request.getSession().getAttribute("user"); } public List getUserList(Map parameterMap) throws Exception{ - return userMapperEx.getUserList(parameterMap); + List list=null; + try{ + list= userMapperEx.getUserList(parameterMap); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) public void addUserAndOrgUserRel(UserEx ue) throws Exception{ @@ -277,8 +400,16 @@ public class UserService { ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER); } ue.setStatus(BusinessConstants.USER_STATUS_NORMAL); - int i=userMapperEx.addUser(ue); - if(i>0){ + int result=0; + try{ + result= userMapperEx.addUser(ue); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + if(result>0){ return ue; } return null; @@ -303,7 +434,15 @@ public class UserService { ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER); } ue.setStatus(BusinessConstants.USER_STATUS_NORMAL); - int i = userMapperEx.addUser(ue); + int result=0; + try{ + result= userMapperEx.addUser(ue); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } //更新租户id User user = new User(); user.setId(ue.getId()); @@ -317,7 +456,7 @@ public class UserService { ubArr.add(manageRoleId); ubObj.put("value", ubArr.toString()); userBusinessService.insertUserBusiness(ubObj.toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); - if (i > 0) { + if (result > 0) { return ue; } return null; @@ -328,7 +467,14 @@ public class UserService { public void updateUserTenant(User user) throws Exception{ UserExample example = new UserExample(); example.createCriteria().andIdEqualTo(user.getId()); - userMapper.updateByPrimaryKeySelective(user); + try{ + userMapper.updateByPrimaryKeySelective(user); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } } @Transactional(value = "transactionManager", rollbackFor = Exception.class) @@ -380,9 +526,17 @@ public class UserService { } } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public UserEx updateUser(UserEx ue){ - int i=userMapperEx.updateUser(ue); - if(i>0){ + public UserEx updateUser(UserEx ue)throws Exception{ + int result =0; + try{ + result=userMapperEx.updateUser(ue); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + if(result>0){ return ue; } return null; @@ -395,7 +549,7 @@ public class UserService { * @Param: userEx * @return void */ - public void checkUserNameAndLoginName(UserEx userEx){ + public void checkUserNameAndLoginName(UserEx userEx)throws Exception{ List list=null; if(userEx==null){ return; @@ -454,26 +608,52 @@ public class UserService { /** * 通过用户名获取用户列表 * */ - public List getUserListByUserName(String userName){ - return userMapperEx.getUserListByUserNameOrLoginName(userName,null); + public List getUserListByUserName(String userName)throws Exception{ + List list =null; + try{ + list=userMapperEx.getUserListByUserNameOrLoginName(userName,null); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } /** * 通过登录名获取用户列表 * */ public List getUserListByloginName(String loginName){ - return userMapperEx.getUserListByUserNameOrLoginName(null,loginName); + List list =null; + try{ + list=userMapperEx.getUserListByUserNameOrLoginName(null,loginName); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } /** * 批量删除用户 * */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public void batDeleteUser(String ids) { + public void batDeleteUser(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); String idsArray[]=ids.split(","); - int i= userMapperEx.batDeleteOrUpdateUser(idsArray,BusinessConstants.USER_STATUS_DELETE); - if(i<1){ + int result =0; + try{ + result=userMapperEx.batDeleteOrUpdateUser(idsArray,BusinessConstants.USER_STATUS_DELETE); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + if(result<1){ logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]", ExceptionConstants.USER_DELETE_FAILED_CODE,ExceptionConstants.USER_DELETE_FAILED_MSG,ids); throw new BusinessRunTimeException(ExceptionConstants.USER_DELETE_FAILED_CODE, @@ -481,7 +661,16 @@ public class UserService { } } - public List getOrganizationUserTree() { - return userMapperEx.getNodeTree(); + public List getOrganizationUserTree()throws Exception { + List list =null; + try{ + list=userMapperEx.getNodeTree(); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } } diff --git a/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessComponent.java b/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessComponent.java index 26d962a7..04ca587f 100644 --- a/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessComponent.java +++ b/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessComponent.java @@ -22,46 +22,46 @@ public class UserBusinessComponent implements ICommonQuery { private UserBusinessService userBusinessService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getUserBusinessList(map); } - private List getUserBusinessList(Map map) { + private List getUserBusinessList(Map map)throws Exception { return null; } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { return BusinessConstants.DEFAULT_LIST_NULL_NUMBER; } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception { return userBusinessService.insertUserBusiness(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return userBusinessService.updateUserBusiness(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return userBusinessService.deleteUserBusiness(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return userBusinessService.batchDeleteUserBusiness(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return userBusinessService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java b/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java index 9c07a555..d769a6cb 100644 --- a/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java +++ b/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java @@ -2,16 +2,14 @@ package com.jsh.erp.service.userBusiness; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; -import com.jsh.erp.datasource.entities.App; -import com.jsh.erp.datasource.entities.Functions; -import com.jsh.erp.datasource.entities.User; -import com.jsh.erp.datasource.entities.UserBusiness; -import com.jsh.erp.datasource.entities.UserBusinessExample; +import com.jsh.erp.constants.ExceptionConstants; +import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.mappers.UserBusinessMapper; +import com.jsh.erp.datasource.mappers.UserBusinessMapperEx; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.CommonQueryManager; import com.jsh.erp.service.app.AppService; import com.jsh.erp.service.functions.FunctionsService; -import com.jsh.erp.datasource.mappers.UserBusinessMapperEx; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.StringUtil; @@ -25,11 +23,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Date; -import java.util.List; -import java.util.Set; +import java.util.*; @Service public class UserBusinessService { @@ -53,77 +47,145 @@ public class UserBusinessService { @Resource private CommonQueryManager configResourceManager; - public UserBusiness getUserBusiness(long id) { - return userBusinessMapper.selectByPrimaryKey(id); + public UserBusiness getUserBusiness(long id)throws Exception { + UserBusiness result=null; + try{ + result=userBusinessMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getUserBusiness() { + public List getUserBusiness()throws Exception { UserBusinessExample example = new UserBusinessExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return userBusinessMapper.selectByExample(example); - } - - @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertUserBusiness(String beanJson, HttpServletRequest request) { - UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); - int inserts = userBusinessMapper.insertSelective(userBusiness); - // 更新应用权限 - if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && inserts > 0) { - inserts = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue()); + List list=null; + try{ + list=userBusinessMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); } - return inserts; - } - - @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateUserBusiness(String beanJson, Long id) { - UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); - userBusiness.setId(id); - int updates = userBusinessMapper.updateByPrimaryKeySelective(userBusiness); - // 更新应用权限 - if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && updates > 0) { - updates = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue()); - } - return updates; - } - - @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteUserBusiness(Long id) { - return userBusinessMapper.deleteByPrimaryKey(id); - } - - @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteUserBusiness(String ids) { - List idList = StringUtil.strToLongList(ids); - UserBusinessExample example = new UserBusinessExample(); - example.createCriteria().andIdIn(idList); - return userBusinessMapper.deleteByExample(example); - } - - public int checkIsNameExist(Long id, String name) { - return 1; - } - - public List getBasicData(String keyId, String type){ - UserBusinessExample example = new UserBusinessExample(); - example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type) - .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = userBusinessMapper.selectByExample(example); return list; } - public Long checkIsValueExist(String type, String keyId) { + @Transactional(value = "transactionManager", rollbackFor = Exception.class) + public int insertUserBusiness(String beanJson, HttpServletRequest request) throws Exception { + UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); + int result=0; + try{ + result=userBusinessMapper.insertSelective(userBusiness); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + // 更新应用权限 + if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && result > 0) { + result = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue()); + } + return result; + } + + @Transactional(value = "transactionManager", rollbackFor = Exception.class) + public int updateUserBusiness(String beanJson, Long id) throws Exception { + UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); + userBusiness.setId(id); + int result=0; + try{ + result=userBusinessMapper.updateByPrimaryKeySelective(userBusiness); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + // 更新应用权限 + if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && result > 0) { + result = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue()); + } + return result; + } + + @Transactional(value = "transactionManager", rollbackFor = Exception.class) + public int deleteUserBusiness(Long id)throws Exception { + int result=0; + try{ + result=userBusinessMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; + } + + @Transactional(value = "transactionManager", rollbackFor = Exception.class) + public int batchDeleteUserBusiness(String ids)throws Exception { + List idList = StringUtil.strToLongList(ids); + UserBusinessExample example = new UserBusinessExample(); + example.createCriteria().andIdIn(idList); + int result=0; + try{ + result=userBusinessMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; + } + + public int checkIsNameExist(Long id, String name)throws Exception { + return 1; + } + + public List getBasicData(String keyId, String type)throws Exception{ + UserBusinessExample example = new UserBusinessExample(); + example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type) + .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); + List list=null; + try{ + list= userBusinessMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; + } + + public Long checkIsValueExist(String type, String keyId)throws Exception { UserBusinessExample example = new UserBusinessExample(); example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = userBusinessMapper.selectByExample(example); + List list=null; + try{ + list= userBusinessMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } Long id = null; - if(list.size() > 0) { + if(list!=null&&list.size() > 0) { id = list.get(0).getId(); } return id; } - public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue) { + public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue)throws Exception { UserBusinessExample example = new UserBusinessExample(); String newVaule = "%" + UBValue + "%"; if(TypeVale !=null && KeyIdValue !=null) { @@ -133,8 +195,16 @@ public class UserBusinessService { example.createCriteria().andValueLike(newVaule) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); } - List list = userBusinessMapper.selectByExample(example); - if(list.size() > 0) { + List list=null; + try{ + list= userBusinessMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + if(list!=null&&list.size() > 0) { return true; } else { return false; @@ -142,7 +212,7 @@ public class UserBusinessService { } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateBtnStr(Long userBusinessId, String btnStr) { + public int updateBtnStr(Long userBusinessId, String btnStr) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER_BUSINESS, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(userBusinessId).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); @@ -150,34 +220,68 @@ public class UserBusinessService { userBusiness.setBtnstr(btnStr); UserBusinessExample example = new UserBusinessExample(); example.createCriteria().andIdEqualTo(userBusinessId); - return userBusinessMapper.updateByExampleSelective(userBusiness, example); + int result=0; + try{ + result= userBusinessMapper.updateByExampleSelective(userBusiness, example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public List findRoleByUserId(String userId){ + public List findRoleByUserId(String userId)throws Exception{ UserBusinessExample example = new UserBusinessExample(); example.createCriteria().andKeyidEqualTo(userId).andTypeEqualTo("UserRole") .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = userBusinessMapper.selectByExample(example); + List list=null; + try{ + list= userBusinessMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } - public List findAppByRoles(String roles){ + public List findAppByRoles(String roles)throws Exception{ List rolesList = StringUtil.strToStringList(roles); UserBusinessExample example = new UserBusinessExample(); example.createCriteria().andKeyidIn(rolesList).andTypeEqualTo("RoleAPP") .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = userBusinessMapper.selectByExample(example); + List list=null; + try{ + list= userBusinessMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteUserBusinessByIds(String ids) { + public int batchDeleteUserBusinessByIds(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER_BUSINESS, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return userBusinessMapperEx.batchDeleteUserBusinessByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result= userBusinessMapperEx.batchDeleteUserBusinessByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } /** @@ -187,49 +291,46 @@ public class UserBusinessService { * @param functionIds * @return */ - public int insertOrUpdateAppValue(String type, String keyId, String functionIds) { - - int updates = 0; - + public int insertOrUpdateAppValue(String type, String keyId, String functionIds) throws Exception{ + int result=0; functionIds = functionIds.replaceAll("\\]\\[", ","). replaceAll("\\[","").replaceAll("\\]",""); - List functionsList = functionsService.findByIds(functionIds); - if (!CollectionUtils.isEmpty(functionsList)) { - Set appNumbers = new HashSet<>(); String appNumber; for (Functions functions : functionsList) { - appNumber = functions.getNumber().substring(0, 2); appNumbers.add(appNumber); } - List appNumberList = new ArrayList<>(appNumbers); List appList = appService.findAppByNumber(appNumberList); - StringBuilder appIdSb = new StringBuilder(); - if (!CollectionUtils.isEmpty(appList)) { for (App app : appList) { appIdSb.append("[" + app.getId() + "]"); } - List userBusinessList = getBasicData(keyId, type); - if(userBusinessList.size() > 0) { - UserBusiness userBusiness = userBusinessList.get(0); - userBusiness.setValue(appIdSb.toString()); - updates = userBusinessMapper.updateByPrimaryKeySelective(userBusiness); - } else { - UserBusiness userBusiness = new UserBusiness(); - userBusiness.setType(type); - userBusiness.setKeyid(keyId); - userBusiness.setValue(appIdSb.toString()); - updates = userBusinessMapper.insertSelective(userBusiness); + try{ + if(userBusinessList.size() > 0) { + UserBusiness userBusiness = userBusinessList.get(0); + userBusiness.setValue(appIdSb.toString()); + result = userBusinessMapper.updateByPrimaryKeySelective(userBusiness); + } else { + UserBusiness userBusiness = new UserBusiness(); + userBusiness.setType(type); + userBusiness.setKeyid(keyId); + userBusiness.setValue(appIdSb.toString()); + result = userBusinessMapper.insertSelective(userBusiness); + } + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); } } } - return updates; + return result; } }