Commit 85d96bb2 authored by cjl's avatar cjl
Browse files

添加事务控制

parent 5df1748c
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<link href="/js/HoorayOS_mini/img/ui/index.css" rel="stylesheet"/> <link href="/js/HoorayOS_mini/img/ui/index.css" rel="stylesheet"/>
<style> <style>
#user-name-span{ #user-name-span{
text-align:left; text-align:center;
color:white; color:white;
position:absolute; position:absolute;
top:435px; top:435px;
......
package com.jsh.erp.controller; package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.AccountHead; import com.jsh.erp.datasource.entities.AccountHead;
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx; import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
import com.jsh.erp.service.accountHead.AccountHeadService; import com.jsh.erp.service.accountHead.AccountHeadService;
import com.jsh.erp.utils.BaseResponseInfo; import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo; import com.jsh.erp.utils.ErpInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson; import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
/** /**
* @author jishenghua 752*718*920 * @author jishenghua 752*718*920
*/ */
@RestController @RestController
@RequestMapping(value = "/accountHead") @RequestMapping(value = "/accountHead")
public class AccountHeadController { public class AccountHeadController {
private Logger logger = LoggerFactory.getLogger(AccountHeadController.class); private Logger logger = LoggerFactory.getLogger(AccountHeadController.class);
@Resource @Resource
private AccountHeadService accountHeadService; private AccountHeadService accountHeadService;
/** /**
* 获取最大的id * 获取最大的id
* @param request * @param request
* @return * @return
*/ */
@GetMapping(value = "/getMaxId") @GetMapping(value = "/getMaxId")
public BaseResponseInfo getMaxId(HttpServletRequest request) { public BaseResponseInfo getMaxId(HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
Long maxId = accountHeadService.getMaxId(); Long maxId = accountHeadService.getMaxId();
map.put("maxId", maxId); map.put("maxId", maxId);
res.code = 200; res.code = 200;
res.data = map; res.data = map;
} catch(Exception e){ } catch(Exception e){
e.printStackTrace(); e.printStackTrace();
res.code = 500; res.code = 500;
res.data = "获取数据失败"; res.data = "获取数据失败";
} }
return res; return res;
} }
/** /**
* 查询单位的累计应收和累计应付,收预付款不计入此处 * 查询单位的累计应收和累计应付,收预付款不计入此处
* @param supplierId * @param supplierId
* @param endTime * @param endTime
* @param supType * @param supType
* @param request * @param request
* @return * @return
*/ */
@GetMapping(value = "/findTotalPay") @GetMapping(value = "/findTotalPay")
public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId, public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId,
@RequestParam("endTime") String endTime, @RequestParam("endTime") String endTime,
@RequestParam("supType") String supType, @RequestParam("supType") String supType,
HttpServletRequest request) { HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
JSONObject outer = new JSONObject(); JSONObject outer = new JSONObject();
Double sum = 0.0; Double sum = 0.0;
String getS = supplierId.toString(); String getS = supplierId.toString();
int i = 1; int i = 1;
if (supType.equals("customer")) { //客户 if (supType.equals("customer")) { //客户
i = 1; i = 1;
} else if (supType.equals("vendor")) { //供应商 } else if (supType.equals("vendor")) { //供应商
i = -1; i = -1;
} }
//收付款部分 //收付款部分
sum = sum + (allMoney(getS, "付款", "合计",endTime) + allMoney(getS, "付款", "实际",endTime)) * i; sum = sum + (allMoney(getS, "付款", "合计",endTime) + allMoney(getS, "付款", "实际",endTime)) * i;
sum = sum - (allMoney(getS, "收款", "合计",endTime) + allMoney(getS, "收款", "实际",endTime)) * i; sum = sum - (allMoney(getS, "收款", "合计",endTime) + allMoney(getS, "收款", "实际",endTime)) * i;
sum = sum + (allMoney(getS, "收入", "合计",endTime) - allMoney(getS, "收入", "实际",endTime)) * i; sum = sum + (allMoney(getS, "收入", "合计",endTime) - allMoney(getS, "收入", "实际",endTime)) * i;
sum = sum - (allMoney(getS, "支出", "合计",endTime) - allMoney(getS, "支出", "实际",endTime)) * i; sum = sum - (allMoney(getS, "支出", "合计",endTime) - allMoney(getS, "支出", "实际",endTime)) * i;
outer.put("getAllMoney", sum); outer.put("getAllMoney", sum);
map.put("rows", outer); map.put("rows", outer);
res.code = 200; res.code = 200;
res.data = map; res.data = map;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
res.code = 500; res.code = 500;
res.data = "获取数据失败"; res.data = "获取数据失败";
} }
return res; return res;
} }
/** /**
* 根据编号查询单据信息 * 根据编号查询单据信息
* @param number * @param billNo
* @param request * @param request
* @return * @return
*/ */
@GetMapping(value = "/getDetailByNumber") @GetMapping(value = "/getDetailByNumber")
public BaseResponseInfo getDetailByNumber(@RequestParam("billNo") String billNo, public BaseResponseInfo getDetailByNumber(@RequestParam("billNo") String billNo,
HttpServletRequest request) { HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx(); AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx();
try { try {
List<AccountHeadVo4ListEx> list = accountHeadService.getDetailByNumber(billNo); List<AccountHeadVo4ListEx> list = accountHeadService.getDetailByNumber(billNo);
if(list.size() == 1) { if(list.size() == 1) {
ahl = list.get(0); ahl = list.get(0);
} }
res.code = 200; res.code = 200;
res.data = ahl; res.data = ahl;
} catch(Exception e){ } catch(Exception e){
e.printStackTrace(); e.printStackTrace();
res.code = 500; res.code = 500;
res.data = "获取数据失败"; res.data = "获取数据失败";
} }
return res; return res;
} }
/** /**
* 统计总金额 * 统计总金额
* @param getS * @param getS
* @param type * @param type
* @param subType * @param mode 合计或者金额
* @param mode 合计或者金额 * @param endTime
* @return * @return
*/ */
public Double allMoney(String getS, String type, String mode, String endTime) { public Double allMoney(String getS, String type, String mode, String endTime) {
Double allMoney = 0.0; Double allMoney = 0.0;
try { try {
Integer supplierId = Integer.valueOf(getS); Integer supplierId = Integer.valueOf(getS);
Double sum = accountHeadService.findAllMoney(supplierId, type, mode, endTime); Double sum = accountHeadService.findAllMoney(supplierId, type, mode, endTime);
if(sum != null) { if(sum != null) {
allMoney = sum; allMoney = sum;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//返回正数,如果负数也转为正数 //返回正数,如果负数也转为正数
if (allMoney < 0) { if (allMoney < 0) {
allMoney = -allMoney; allMoney = -allMoney;
} }
return allMoney; return allMoney;
} }
} }
package com.jsh.erp.controller; package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.AccountItem; import com.jsh.erp.datasource.entities.AccountItem;
import com.jsh.erp.datasource.vo.AccountItemVo4List; import com.jsh.erp.datasource.vo.AccountItemVo4List;
import com.jsh.erp.service.accountItem.AccountItemService; import com.jsh.erp.service.accountItem.AccountItemService;
import com.jsh.erp.utils.*; import com.jsh.erp.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.web.bind.annotation.*; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.io.IOException; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.io.IOException;
import java.util.HashMap; import java.util.ArrayList;
import java.util.List; import java.util.HashMap;
import java.util.Map; import java.util.List;
import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
/**
* @author ji sheng hua 752*718*920 /**
*/ * @author ji sheng hua 752*718*920
@RestController */
@RequestMapping(value = "/accountItem") @RestController
public class AccountItemController { @RequestMapping(value = "/accountItem")
private Logger logger = LoggerFactory.getLogger(AccountItemController.class); public class AccountItemController {
private Logger logger = LoggerFactory.getLogger(AccountItemController.class);
@Resource
private AccountItemService accountItemService; @Resource
private AccountItemService accountItemService;
@PostMapping(value = "/saveDetials") /**
public String saveDetials(@RequestParam("inserted") String inserted, * create by: cjl
@RequestParam("deleted") String deleted, * description:
@RequestParam("updated") String updated, * 业务逻辑操作放在service层,controller只做参数解析和视图封装
@RequestParam("headerId") Long headerId, * create time: 2019/1/11 15:08
@RequestParam("listType") String listType, * @Param: inserted
HttpServletRequest request) {  * @Param: deleted
Map<String, Object> objectMap = new HashMap<String, Object>();  * @Param: updated
try {  * @Param: headerId
//转为json  * @Param: listType
JSONArray insertedJson = JSONArray.parseArray(inserted);  * @Param: request
JSONArray deletedJson = JSONArray.parseArray(deleted); * @return java.lang.String
JSONArray updatedJson = JSONArray.parseArray(updated); */
if (null != insertedJson) { @PostMapping(value = "/saveDetials")
for (int i = 0; i < insertedJson.size(); i++) { public String saveDetials(@RequestParam("inserted") String inserted,
AccountItem accountItem = new AccountItem(); @RequestParam("deleted") String deleted,
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i)); @RequestParam("updated") String updated,
accountItem.setHeaderid(headerId); @RequestParam("headerId") Long headerId,
if (tempInsertedJson.get("AccountId") != null && !tempInsertedJson.get("AccountId").equals("")) { @RequestParam("listType") String listType,
accountItem.setAccountid(tempInsertedJson.getLong("AccountId")); HttpServletRequest request) {
}
if (tempInsertedJson.get("InOutItemId") != null && !tempInsertedJson.get("InOutItemId").equals("")) { Map<String, Object> objectMap = new HashMap<String, Object>();
accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId")); try {
} accountItemService.saveDetials(inserted,deleted,updated,headerId,listType);
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) { return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
Double eachAmount = tempInsertedJson.getDouble("EachAmount"); } catch (DataAccessException e) {
if (listType.equals("付款")) { e.printStackTrace();
eachAmount = 0 - eachAmount; logger.error(">>>>>>>>>>>>>>>>>>>保存明细信息异常", e);
} return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
accountItem.setEachamount(eachAmount); }
} else { }
accountItem.setEachamount(0.0);
} @GetMapping(value = "/getDetailList")
accountItem.setRemark(tempInsertedJson.getString("Remark")); public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
accountItemService.insertAccountItemWithObj(accountItem); HttpServletRequest request) {
} BaseResponseInfo res = new BaseResponseInfo();
} Map<String, Object> map = new HashMap<String, Object>();
if (null != deletedJson) { try {
for (int i = 0; i < deletedJson.size(); i++) { List<AccountItemVo4List> dataList = new ArrayList<AccountItemVo4List>();
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i)); if(headerId != 0) {
accountItemService.deleteAccountItem(tempDeletedJson.getLong("Id")); dataList = accountItemService.getDetailList(headerId);
} }
} JSONObject outer = new JSONObject();
if (null != updatedJson) { outer.put("total", dataList.size());
for (int i = 0; i < updatedJson.size(); i++) { //存放数据json数组
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i)); JSONArray dataArray = new JSONArray();
AccountItem accountItem = accountItemService.getAccountItem(tempUpdatedJson.getLong("Id")); if (null != dataList) {
accountItem.setId(tempUpdatedJson.getLong("Id")); for (AccountItemVo4List ai : dataList) {
accountItem.setHeaderid(headerId); JSONObject item = new JSONObject();
if (tempUpdatedJson.get("AccountId") != null && !tempUpdatedJson.get("AccountId").equals("")) { item.put("Id", ai.getId());
accountItem.setAccountid(tempUpdatedJson.getLong("AccountId")); item.put("AccountId", ai.getAccountid());
} item.put("AccountName", ai.getAccountName());
if (tempUpdatedJson.get("InOutItemId") != null && !tempUpdatedJson.get("InOutItemId").equals("")) { item.put("InOutItemId", ai.getInoutitemid());
accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId")); item.put("InOutItemName", ai.getInOutItemName());
} Double eachAmount = ai.getEachamount();
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) { item.put("EachAmount", eachAmount < 0 ? 0 - eachAmount : eachAmount);
Double eachAmount = tempUpdatedJson.getDouble("EachAmount"); item.put("Remark", ai.getRemark());
if (listType.equals("付款")) { dataArray.add(item);
eachAmount = 0 - eachAmount; }
} }
accountItem.setEachamount(eachAmount); outer.put("rows", dataArray);
} else { res.code = 200;
accountItem.setEachamount(0.0); res.data = outer;
} } catch (Exception e) {
accountItem.setRemark(tempUpdatedJson.getString("Remark")); e.printStackTrace();
accountItemService.updateAccountItemWithObj(accountItem); res.code = 500;
} res.data = "获取数据失败";
} }
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); return res;
} catch (DataAccessException e) { }
e.printStackTrace();
logger.error(">>>>>>>>>>>>>>>>>>>保存明细信息异常", e); }
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
@GetMapping(value = "/getDetailList")
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<AccountItemVo4List> dataList = new ArrayList<AccountItemVo4List>();
if(headerId != 0) {
dataList = accountItemService.getDetailList(headerId);
}
JSONObject outer = new JSONObject();
outer.put("total", dataList.size());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (AccountItemVo4List ai : dataList) {
JSONObject item = new JSONObject();
item.put("Id", ai.getId());
item.put("AccountId", ai.getAccountid());
item.put("AccountName", ai.getAccountName());
item.put("InOutItemId", ai.getInoutitemid());
item.put("InOutItemName", ai.getInOutItemName());
Double eachAmount = ai.getEachamount();
item.put("EachAmount", eachAmount < 0 ? 0 - eachAmount : eachAmount);
item.put("Remark", ai.getRemark());
dataArray.add(item);
}
}
outer.put("rows", dataArray);
res.code = 200;
res.data = outer;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}
package com.jsh.erp.service; package com.jsh.erp.service;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.ArrayList; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.ArrayList;
import java.util.Map; import java.util.List;
import java.util.Map;
/**
* @author jishenghua 752718920 2018-10-7 15:25:58 /**
*/ * @author jishenghua 752718920 2018-10-7 15:25:58
@Service */
public class CommonQueryManager { @Service
public class CommonQueryManager {
@Resource
private InterfaceContainer container; @Resource
private InterfaceContainer container;
/**
* 查询单条 /**
* * 查询单条
* @param apiName 接口名称 *
* @param id ID * @param apiName 接口名称
*/ * @param id ID
public Object selectOne(String apiName, String id) { */
if (StringUtil.isNotEmpty(apiName) && StringUtil.isNotEmpty(id)) { public Object selectOne(String apiName, String id) {
return container.getCommonQuery(apiName).selectOne(id); if (StringUtil.isNotEmpty(apiName) && StringUtil.isNotEmpty(id)) {
} return container.getCommonQuery(apiName).selectOne(id);
return null; }
} return null;
}
/**
* 查询 /**
* @param apiName * 查询
* @param parameterMap * @param apiName
* @return * @param parameterMap
*/ * @return
public List<?> select(String apiName, Map<String, String> parameterMap) { */
if (StringUtil.isNotEmpty(apiName)) { public List<?> select(String apiName, Map<String, String> parameterMap) {
return container.getCommonQuery(apiName).select(parameterMap); if (StringUtil.isNotEmpty(apiName)) {
} return container.getCommonQuery(apiName).select(parameterMap);
return new ArrayList<Object>(); }
} return new ArrayList<Object>();
}
/**
* 计数 /**
* @param apiName * 计数
* @param parameterMap * @param apiName
* @return * @param parameterMap
*/ * @return
public int counts(String apiName, Map<String, String> parameterMap) { */
if (StringUtil.isNotEmpty(apiName)) { public int counts(String apiName, Map<String, String> parameterMap) {
return container.getCommonQuery(apiName).counts(parameterMap); if (StringUtil.isNotEmpty(apiName)) {
} return container.getCommonQuery(apiName).counts(parameterMap);
return 0; }
} return 0;
}
/**
* 插入 /**
* @param apiName * 插入
* @param beanJson * @param apiName
* @return * @param beanJson
*/ * @return
public int insert(String apiName, String beanJson, HttpServletRequest request) { */
if (StringUtil.isNotEmpty(apiName)) { @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return container.getCommonQuery(apiName).insert(beanJson, request); public int insert(String apiName, String beanJson, HttpServletRequest request) {
} if (StringUtil.isNotEmpty(apiName)) {
return 0; return container.getCommonQuery(apiName).insert(beanJson, request);
} }
return 0;
/** }
* 更新
* @param apiName /**
* @param beanJson * 更新
* @param id * @param apiName
* @return * @param beanJson
*/ * @param id
public int update(String apiName, String beanJson, Long id) { * @return
if (StringUtil.isNotEmpty(apiName)) { */
return container.getCommonQuery(apiName).update(beanJson, id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int update(String apiName, String beanJson, Long id) {
return 0; if (StringUtil.isNotEmpty(apiName)) {
} return container.getCommonQuery(apiName).update(beanJson, id);
}
/** return 0;
* 删除 }
* @param apiName
* @param id /**
* @return * 删除
*/ * @param apiName
public int delete(String apiName, Long id) { * @param id
if (StringUtil.isNotEmpty(apiName)) { * @return
return container.getCommonQuery(apiName).delete(id); */
} @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return 0; public int delete(String apiName, Long id) {
} if (StringUtil.isNotEmpty(apiName)) {
return container.getCommonQuery(apiName).delete(id);
/** }
* 批量删除 return 0;
* @param apiName }
* @param ids
* @return /**
*/ * 批量删除
public int batchDelete(String apiName, String ids) { * @param apiName
if (StringUtil.isNotEmpty(apiName)) { * @param ids
return container.getCommonQuery(apiName).batchDelete(ids); * @return
} */
return 0; @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDelete(String apiName, String ids) {
if (StringUtil.isNotEmpty(apiName)) {
/** return container.getCommonQuery(apiName).batchDelete(ids);
* 判断是否存在 }
* @param apiName return 0;
* @param id }
* @param name
* @return /**
*/ * 判断是否存在
public int checkIsNameExist(String apiName, Long id, String name) { * @param apiName
if (StringUtil.isNotEmpty(apiName)) { * @param id
return container.getCommonQuery(apiName).checkIsNameExist(id, name); * @param name
} * @return
return 0; */
} public int checkIsNameExist(String apiName, Long id, String name) {
if (StringUtil.isNotEmpty(apiName)) {
return container.getCommonQuery(apiName).checkIsNameExist(id, name);
}
return 0;
}
} }
\ No newline at end of file
package com.jsh.erp.service.accountHead; package com.jsh.erp.service.accountHead;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.AccountHead; import com.jsh.erp.datasource.entities.AccountHead;
import com.jsh.erp.datasource.entities.AccountHeadExample; import com.jsh.erp.datasource.entities.AccountHeadExample;
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx; import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
import com.jsh.erp.datasource.mappers.AccountHeadMapper; import com.jsh.erp.datasource.mappers.AccountHeadMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools; import com.jsh.erp.utils.Tools;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.ArrayList; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.ArrayList;
import java.util.List;
@Service
public class AccountHeadService { @Service
private Logger logger = LoggerFactory.getLogger(AccountHeadService.class); public class AccountHeadService {
private Logger logger = LoggerFactory.getLogger(AccountHeadService.class);
@Resource
private AccountHeadMapper accountHeadMapper; @Resource
private AccountHeadMapper accountHeadMapper;
public AccountHead getAccountHead(long id) {
return accountHeadMapper.selectByPrimaryKey(id); public AccountHead getAccountHead(long id) {
} return accountHeadMapper.selectByPrimaryKey(id);
}
public List<AccountHead> getAccountHead() {
AccountHeadExample example = new AccountHeadExample(); public List<AccountHead> getAccountHead() {
return accountHeadMapper.selectByExample(example); AccountHeadExample example = new AccountHeadExample();
} return accountHeadMapper.selectByExample(example);
}
public List<AccountHeadVo4ListEx> select(String type, String billNo, String beginTime, String endTime, int offset, int rows) {
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>(); public List<AccountHeadVo4ListEx> select(String type, String billNo, String beginTime, String endTime, int offset, int rows) {
List<AccountHeadVo4ListEx> list = accountHeadMapper.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows); List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
if (null != list) { List<AccountHeadVo4ListEx> list = accountHeadMapper.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows);
for (AccountHeadVo4ListEx ah : list) { if (null != list) {
if(ah.getChangeamount() != null) { for (AccountHeadVo4ListEx ah : list) {
ah.setChangeamount(Math.abs(ah.getChangeamount())); if(ah.getChangeamount() != null) {
} ah.setChangeamount(Math.abs(ah.getChangeamount()));
if(ah.getTotalprice() != null) { }
ah.setTotalprice(Math.abs(ah.getTotalprice())); if(ah.getTotalprice() != null) {
} ah.setTotalprice(Math.abs(ah.getTotalprice()));
resList.add(ah); }
} resList.add(ah);
} }
return resList; }
} return resList;
}
public int countAccountHead(String type, String billNo, String beginTime, String endTime) {
return accountHeadMapper.countsByAccountHead(type, billNo, beginTime, endTime); public int countAccountHead(String type, String billNo, String beginTime, String endTime) {
} return accountHeadMapper.countsByAccountHead(type, billNo, beginTime, endTime);
}
public int insertAccountHead(String beanJson, HttpServletRequest request) {
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return accountHeadMapper.insertSelective(accountHead); public int insertAccountHead(String beanJson, HttpServletRequest request) {
} AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
return accountHeadMapper.insertSelective(accountHead);
public int updateAccountHead(String beanJson, Long id) { }
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
accountHead.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return accountHeadMapper.updateByPrimaryKeySelective(accountHead); public int updateAccountHead(String beanJson, Long id) {
} AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
accountHead.setId(id);
public int deleteAccountHead(Long id) { return accountHeadMapper.updateByPrimaryKeySelective(accountHead);
return accountHeadMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountHead(String ids) { public int deleteAccountHead(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return accountHeadMapper.deleteByPrimaryKey(id);
AccountHeadExample example = new AccountHeadExample(); }
example.createCriteria().andIdIn(idList);
return accountHeadMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteAccountHead(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { AccountHeadExample example = new AccountHeadExample();
AccountHeadExample example = new AccountHeadExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id); return accountHeadMapper.deleteByExample(example);
List<AccountHead> list = accountHeadMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
AccountHeadExample example = new AccountHeadExample();
public Long getMaxId() { example.createCriteria().andIdNotEqualTo(id);
return accountHeadMapper.getMaxId(); List<AccountHead> list = accountHeadMapper.selectByExample(example);
} return list.size();
}
public Double findAllMoney(Integer supplierId, String type, String mode, String endTime) {
String modeName = ""; public Long getMaxId() {
if (mode.equals("实际")) { return accountHeadMapper.getMaxId();
modeName = "ChangeAmount"; }
} else if (mode.equals("合计")) {
modeName = "TotalPrice"; public Double findAllMoney(Integer supplierId, String type, String mode, String endTime) {
} String modeName = "";
return accountHeadMapper.findAllMoney(supplierId, type, modeName, endTime); if (mode.equals("实际")) {
} modeName = "ChangeAmount";
} else if (mode.equals("合计")) {
public List<AccountHeadVo4ListEx> getDetailByNumber(String billNo) { modeName = "TotalPrice";
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>(); }
List<AccountHeadVo4ListEx> list = accountHeadMapper.getDetailByNumber(billNo); return accountHeadMapper.findAllMoney(supplierId, type, modeName, endTime);
if (null != list) { }
for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeamount() != null) { public List<AccountHeadVo4ListEx> getDetailByNumber(String billNo) {
ah.setChangeamount(Math.abs(ah.getChangeamount())); List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
} List<AccountHeadVo4ListEx> list = accountHeadMapper.getDetailByNumber(billNo);
if(ah.getTotalprice() != null) { if (null != list) {
ah.setTotalprice(Math.abs(ah.getTotalprice())); for (AccountHeadVo4ListEx ah : list) {
} if(ah.getChangeamount() != null) {
resList.add(ah); ah.setChangeamount(Math.abs(ah.getChangeamount()));
} }
} if(ah.getTotalprice() != null) {
return resList; ah.setTotalprice(Math.abs(ah.getTotalprice()));
} }
resList.add(ah);
} }
}
return resList;
}
}
package com.jsh.erp.service.accountItem; package com.jsh.erp.service.accountItem;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONArray;
import com.jsh.erp.datasource.entities.AccountItem; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.AccountItemExample; import com.jsh.erp.datasource.entities.AccountItem;
import com.jsh.erp.datasource.mappers.AccountItemMapper; import com.jsh.erp.datasource.entities.AccountItemExample;
import com.jsh.erp.datasource.vo.AccountItemVo4List; import com.jsh.erp.datasource.mappers.AccountItemMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.datasource.vo.AccountItemVo4List;
import org.slf4j.Logger; import com.jsh.erp.utils.ErpInfo;
import org.slf4j.LoggerFactory; import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource; import org.springframework.dao.DataAccessException;
import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Service;
import java.util.List; import org.springframework.transaction.annotation.Transactional;
@Service import javax.annotation.Resource;
public class AccountItemService { import javax.servlet.http.HttpServletRequest;
private Logger logger = LoggerFactory.getLogger(AccountItemService.class); import java.util.List;
@Resource import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
private AccountItemMapper accountItemMapper;
@Service
public AccountItem getAccountItem(long id) { public class AccountItemService {
return accountItemMapper.selectByPrimaryKey(id); private Logger logger = LoggerFactory.getLogger(AccountItemService.class);
}
@Resource
public List<AccountItem> getAccountItem() { private AccountItemMapper accountItemMapper;
AccountItemExample example = new AccountItemExample();
return accountItemMapper.selectByExample(example); public AccountItem getAccountItem(long id) {
} return accountItemMapper.selectByPrimaryKey(id);
}
public List<AccountItem> select(String name, Integer type, String remark, int offset, int rows) {
return accountItemMapper.selectByConditionAccountItem(name, type, remark, offset, rows); public List<AccountItem> getAccountItem() {
} AccountItemExample example = new AccountItemExample();
return accountItemMapper.selectByExample(example);
public int countAccountItem(String name, Integer type, String remark) { }
return accountItemMapper.countsByAccountItem(name, type, remark);
} public List<AccountItem> select(String name, Integer type, String remark, int offset, int rows) {
return accountItemMapper.selectByConditionAccountItem(name, type, remark, offset, rows);
public int insertAccountItem(String beanJson, HttpServletRequest request) { }
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
return accountItemMapper.insertSelective(accountItem); public int countAccountItem(String name, Integer type, String remark) {
} return accountItemMapper.countsByAccountItem(name, type, remark);
}
public int updateAccountItem(String beanJson, Long id) {
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
accountItem.setId(id); public int insertAccountItem(String beanJson, HttpServletRequest request) {
return accountItemMapper.updateByPrimaryKeySelective(accountItem); AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
} return accountItemMapper.insertSelective(accountItem);
}
public int deleteAccountItem(Long id) {
return accountItemMapper.deleteByPrimaryKey(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int updateAccountItem(String beanJson, Long id) {
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
public int batchDeleteAccountItem(String ids) { accountItem.setId(id);
List<Long> idList = StringUtil.strToLongList(ids); return accountItemMapper.updateByPrimaryKeySelective(accountItem);
AccountItemExample example = new AccountItemExample(); }
example.createCriteria().andIdIn(idList);
return accountItemMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int deleteAccountItem(Long id) {
return accountItemMapper.deleteByPrimaryKey(id);
public int checkIsNameExist(Long id, String name) { }
AccountItemExample example = new AccountItemExample();
example.createCriteria().andIdNotEqualTo(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
List<AccountItem> list = accountItemMapper.selectByExample(example); public int batchDeleteAccountItem(String ids) {
return list.size(); List<Long> idList = StringUtil.strToLongList(ids);
} AccountItemExample example = new AccountItemExample();
example.createCriteria().andIdIn(idList);
public int insertAccountItemWithObj(AccountItem accountItem) { return accountItemMapper.deleteByExample(example);
return accountItemMapper.insertSelective(accountItem); }
}
public int checkIsNameExist(Long id, String name) {
public int updateAccountItemWithObj(AccountItem accountItem) { AccountItemExample example = new AccountItemExample();
return accountItemMapper.updateByPrimaryKeySelective(accountItem); example.createCriteria().andIdNotEqualTo(id);
} List<AccountItem> list = accountItemMapper.selectByExample(example);
return list.size();
public List<AccountItemVo4List> getDetailList(Long headerId) { }
return accountItemMapper.getDetailList(headerId);
} @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int insertAccountItemWithObj(AccountItem accountItem) {
return accountItemMapper.insertSelective(accountItem);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAccountItemWithObj(AccountItem accountItem) {
return accountItemMapper.updateByPrimaryKeySelective(accountItem);
}
public List<AccountItemVo4List> getDetailList(Long headerId) {
return accountItemMapper.getDetailList(headerId);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String saveDetials(String inserted, String deleted, String updated, Long headerId, String listType) throws DataAccessException {
//转为json
JSONArray insertedJson = JSONArray.parseArray(inserted);
JSONArray deletedJson = JSONArray.parseArray(deleted);
JSONArray updatedJson = JSONArray.parseArray(updated);
if (null != insertedJson) {
for (int i = 0; i < insertedJson.size(); i++) {
AccountItem accountItem = new AccountItem();
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
accountItem.setHeaderid(headerId);
if (tempInsertedJson.get("AccountId") != null && !tempInsertedJson.get("AccountId").equals("")) {
accountItem.setAccountid(tempInsertedJson.getLong("AccountId"));
}
if (tempInsertedJson.get("InOutItemId") != null && !tempInsertedJson.get("InOutItemId").equals("")) {
accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId"));
}
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) {
Double eachAmount = tempInsertedJson.getDouble("EachAmount");
if (listType.equals("付款")) {
eachAmount = 0 - eachAmount;
}
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(0.0);
}
accountItem.setRemark(tempInsertedJson.getString("Remark"));
this.insertAccountItemWithObj(accountItem);
}
}
if (null != deletedJson) {
for (int i = 0; i < deletedJson.size(); i++) {
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
this.deleteAccountItem(tempDeletedJson.getLong("Id"));
}
}
if (null != updatedJson) {
for (int i = 0; i < updatedJson.size(); i++) {
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
AccountItem accountItem = this.getAccountItem(tempUpdatedJson.getLong("Id"));
accountItem.setId(tempUpdatedJson.getLong("Id"));
accountItem.setHeaderid(headerId);
if (tempUpdatedJson.get("AccountId") != null && !tempUpdatedJson.get("AccountId").equals("")) {
accountItem.setAccountid(tempUpdatedJson.getLong("AccountId"));
}
if (tempUpdatedJson.get("InOutItemId") != null && !tempUpdatedJson.get("InOutItemId").equals("")) {
accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId"));
}
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) {
Double eachAmount = tempUpdatedJson.getDouble("EachAmount");
if (listType.equals("付款")) {
eachAmount = 0 - eachAmount;
}
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(0.0);
}
accountItem.setRemark(tempUpdatedJson.getString("Remark"));
this.updateAccountItemWithObj(accountItem);
}
}
return null;
}
}
package com.jsh.erp.service.app; package com.jsh.erp.service.app;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.App; import com.jsh.erp.datasource.entities.App;
import com.jsh.erp.datasource.entities.AppExample; import com.jsh.erp.datasource.entities.AppExample;
import com.jsh.erp.datasource.mappers.AppMapper; import com.jsh.erp.datasource.mappers.AppMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class AppService { @Service
private Logger logger = LoggerFactory.getLogger(AppService.class); public class AppService {
private Logger logger = LoggerFactory.getLogger(AppService.class);
@Resource
private AppMapper appMapper; @Resource
private AppMapper appMapper;
public List<App> findDock(){
AppExample example = new AppExample(); public List<App> findDock(){
example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true); AppExample example = new AppExample();
example.setOrderByClause("Sort"); example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true);
List<App> list = appMapper.selectByExample(example); example.setOrderByClause("Sort");
return list; List<App> list = appMapper.selectByExample(example);
} return list;
}
public List<App> findDesk(){
AppExample example = new AppExample(); public List<App> findDesk(){
example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true); AppExample example = new AppExample();
example.setOrderByClause("Sort"); example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true);
List<App> list = appMapper.selectByExample(example); example.setOrderByClause("Sort");
return list; List<App> list = appMapper.selectByExample(example);
} return list;
}
public App getApp(long id) {
return appMapper.selectByPrimaryKey(id); public App getApp(long id) {
} return appMapper.selectByPrimaryKey(id);
}
public List<App> getApp() {
AppExample example = new AppExample(); public List<App> getApp() {
return appMapper.selectByExample(example); AppExample example = new AppExample();
} return appMapper.selectByExample(example);
}
public List<App> select(String name, String type, int offset, int rows) {
return appMapper.selectByConditionApp(name, type, offset, rows); public List<App> select(String name, String type, int offset, int rows) {
} return appMapper.selectByConditionApp(name, type, offset, rows);
}
public int countApp(String name, String type) {
return appMapper.countsByApp(name, type); public int countApp(String name, String type) {
} return appMapper.countsByApp(name, type);
}
public int insertApp(String beanJson, HttpServletRequest request) {
App app = JSONObject.parseObject(beanJson, App.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return appMapper.insertSelective(app); public int insertApp(String beanJson, HttpServletRequest request) {
} App app = JSONObject.parseObject(beanJson, App.class);
return appMapper.insertSelective(app);
public int updateApp(String beanJson, Long id) { }
App app = JSONObject.parseObject(beanJson, App.class);
app.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return appMapper.updateByPrimaryKeySelective(app); public int updateApp(String beanJson, Long id) {
} App app = JSONObject.parseObject(beanJson, App.class);
app.setId(id);
public int deleteApp(Long id) { return appMapper.updateByPrimaryKeySelective(app);
return appMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteApp(String ids) { public int deleteApp(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return appMapper.deleteByPrimaryKey(id);
AppExample example = new AppExample(); }
example.createCriteria().andIdIn(idList);
return appMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteApp(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public List<App> findRoleAPP(){ AppExample example = new AppExample();
AppExample example = new AppExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andEnabledEqualTo(true); return appMapper.deleteByExample(example);
example.setOrderByClause("Sort"); }
List<App> list = appMapper.selectByExample(example);
return list; public List<App> findRoleAPP(){
} AppExample example = new AppExample();
} example.createCriteria().andEnabledEqualTo(true);
example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example);
return list;
}
}
package com.jsh.erp.service.depot; package com.jsh.erp.service.depot;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Depot; import com.jsh.erp.datasource.entities.Depot;
import com.jsh.erp.datasource.entities.DepotExample; import com.jsh.erp.datasource.entities.DepotExample;
import com.jsh.erp.datasource.mappers.DepotMapper; import com.jsh.erp.datasource.mappers.DepotMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class DepotService { @Service
private Logger logger = LoggerFactory.getLogger(DepotService.class); public class DepotService {
private Logger logger = LoggerFactory.getLogger(DepotService.class);
@Resource
private DepotMapper depotMapper; @Resource
private DepotMapper depotMapper;
public Depot getDepot(long id) {
return depotMapper.selectByPrimaryKey(id); public Depot getDepot(long id) {
} return depotMapper.selectByPrimaryKey(id);
}
public List<Depot> getDepot() {
DepotExample example = new DepotExample(); public List<Depot> getDepot() {
return depotMapper.selectByExample(example); DepotExample example = new DepotExample();
} return depotMapper.selectByExample(example);
}
public List<Depot> getAllList() {
DepotExample example = new DepotExample(); public List<Depot> getAllList() {
example.setOrderByClause("sort"); DepotExample example = new DepotExample();
return depotMapper.selectByExample(example); example.setOrderByClause("sort");
} return depotMapper.selectByExample(example);
}
public List<Depot> select(String name, Integer type, String remark, int offset, int rows) {
return depotMapper.selectByConditionDepot(name, type, remark, offset, rows); public List<Depot> select(String name, Integer type, String remark, int offset, int rows) {
} return depotMapper.selectByConditionDepot(name, type, remark, offset, rows);
}
public int countDepot(String name, Integer type, String remark) {
return depotMapper.countsByDepot(name, type, remark); public int countDepot(String name, Integer type, String remark) {
} return depotMapper.countsByDepot(name, type, remark);
}
public int insertDepot(String beanJson, HttpServletRequest request) {
Depot depot = JSONObject.parseObject(beanJson, Depot.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return depotMapper.insertSelective(depot); public int insertDepot(String beanJson, HttpServletRequest request) {
} Depot depot = JSONObject.parseObject(beanJson, Depot.class);
return depotMapper.insertSelective(depot);
public int updateDepot(String beanJson, Long id) { }
Depot depot = JSONObject.parseObject(beanJson, Depot.class);
depot.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return depotMapper.updateByPrimaryKeySelective(depot); public int updateDepot(String beanJson, Long id) {
} Depot depot = JSONObject.parseObject(beanJson, Depot.class);
depot.setId(id);
public int deleteDepot(Long id) { return depotMapper.updateByPrimaryKeySelective(depot);
return depotMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepot(String ids) { public int deleteDepot(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return depotMapper.deleteByPrimaryKey(id);
DepotExample example = new DepotExample(); }
example.createCriteria().andIdIn(idList);
return depotMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteDepot(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { DepotExample example = new DepotExample();
DepotExample example = new DepotExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name); return depotMapper.deleteByExample(example);
List<Depot> list = depotMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
DepotExample example = new DepotExample();
public List<Depot> findUserDepot(){ example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
DepotExample example = new DepotExample(); List<Depot> list = depotMapper.selectByExample(example);
example.createCriteria().andTypeEqualTo(0); return list.size();
example.setOrderByClause("Sort"); }
List<Depot> list = depotMapper.selectByExample(example);
return list; public List<Depot> findUserDepot(){
} DepotExample example = new DepotExample();
example.createCriteria().andTypeEqualTo(0);
public List<Depot> findGiftByType(Integer type){ example.setOrderByClause("Sort");
DepotExample example = new DepotExample(); List<Depot> list = depotMapper.selectByExample(example);
example.createCriteria().andTypeEqualTo(type); return list;
example.setOrderByClause("Sort"); }
List<Depot> list = depotMapper.selectByExample(example);
return list; public List<Depot> findGiftByType(Integer type){
} DepotExample example = new DepotExample();
example.createCriteria().andTypeEqualTo(type);
} example.setOrderByClause("Sort");
List<Depot> list = depotMapper.selectByExample(example);
return list;
}
}
package com.jsh.erp.service.functions; package com.jsh.erp.service.functions;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Functions; import com.jsh.erp.datasource.entities.Functions;
import com.jsh.erp.datasource.entities.FunctionsExample; import com.jsh.erp.datasource.entities.FunctionsExample;
import com.jsh.erp.datasource.mappers.FunctionsMapper; import com.jsh.erp.datasource.mappers.FunctionsMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class FunctionsService { @Service
private Logger logger = LoggerFactory.getLogger(FunctionsService.class); public class FunctionsService {
private Logger logger = LoggerFactory.getLogger(FunctionsService.class);
@Resource
private FunctionsMapper functionsMapper; @Resource
private FunctionsMapper functionsMapper;
public Functions getFunctions(long id) {
return functionsMapper.selectByPrimaryKey(id); public Functions getFunctions(long id) {
} return functionsMapper.selectByPrimaryKey(id);
}
public List<Functions> getFunctions() {
FunctionsExample example = new FunctionsExample(); public List<Functions> getFunctions() {
return functionsMapper.selectByExample(example); FunctionsExample example = new FunctionsExample();
} return functionsMapper.selectByExample(example);
}
public List<Functions> select(String name, String type, int offset, int rows) {
return functionsMapper.selectByConditionFunctions(name, type, offset, rows); public List<Functions> select(String name, String type, int offset, int rows) {
} return functionsMapper.selectByConditionFunctions(name, type, offset, rows);
}
public int countFunctions(String name, String type) {
return functionsMapper.countsByFunctions(name, type); public int countFunctions(String name, String type) {
} return functionsMapper.countsByFunctions(name, type);
}
public int insertFunctions(String beanJson, HttpServletRequest request) {
Functions depot = JSONObject.parseObject(beanJson, Functions.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return functionsMapper.insertSelective(depot); public int insertFunctions(String beanJson, HttpServletRequest request) {
} Functions depot = JSONObject.parseObject(beanJson, Functions.class);
return functionsMapper.insertSelective(depot);
public int updateFunctions(String beanJson, Long id) { }
Functions depot = JSONObject.parseObject(beanJson, Functions.class);
depot.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return functionsMapper.updateByPrimaryKeySelective(depot); public int updateFunctions(String beanJson, Long id) {
} Functions depot = JSONObject.parseObject(beanJson, Functions.class);
depot.setId(id);
public int deleteFunctions(Long id) { return functionsMapper.updateByPrimaryKeySelective(depot);
return functionsMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteFunctions(String ids) { public int deleteFunctions(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return functionsMapper.deleteByPrimaryKey(id);
FunctionsExample example = new FunctionsExample(); }
example.createCriteria().andIdIn(idList);
return functionsMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteFunctions(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { FunctionsExample example = new FunctionsExample();
FunctionsExample example = new FunctionsExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name); return functionsMapper.deleteByExample(example);
List<Functions> list = functionsMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
FunctionsExample example = new FunctionsExample();
public List<Functions> getRoleFunctions(String pNumber) { example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
FunctionsExample example = new FunctionsExample(); List<Functions> list = functionsMapper.selectByExample(example);
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pNumber); return list.size();
example.setOrderByClause("Sort"); }
List<Functions> list = functionsMapper.selectByExample(example);
return list; public List<Functions> getRoleFunctions(String pNumber) {
} FunctionsExample example = new FunctionsExample();
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pNumber);
public List<Functions> findRoleFunctions(String pnumber){ example.setOrderByClause("Sort");
FunctionsExample example = new FunctionsExample(); List<Functions> list = functionsMapper.selectByExample(example);
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pnumber); return list;
example.setOrderByClause("Sort"); }
List<Functions> list = functionsMapper.selectByExample(example);
return list; public List<Functions> findRoleFunctions(String pnumber){
} FunctionsExample example = new FunctionsExample();
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pnumber);
public List<Functions> findByIds(String functionsIds){ example.setOrderByClause("Sort");
List<Long> idList = StringUtil.strToLongList(functionsIds); List<Functions> list = functionsMapper.selectByExample(example);
FunctionsExample example = new FunctionsExample(); return list;
example.createCriteria().andEnabledEqualTo(true).andIdIn(idList); }
example.setOrderByClause("Sort asc");
List<Functions> list = functionsMapper.selectByExample(example); public List<Functions> findByIds(String functionsIds){
return list; List<Long> idList = StringUtil.strToLongList(functionsIds);
} FunctionsExample example = new FunctionsExample();
} example.createCriteria().andEnabledEqualTo(true).andIdIn(idList);
example.setOrderByClause("Sort asc");
List<Functions> list = functionsMapper.selectByExample(example);
return list;
}
}
package com.jsh.erp.service.inOutItem; package com.jsh.erp.service.inOutItem;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.InOutItem; import com.jsh.erp.datasource.entities.InOutItem;
import com.jsh.erp.datasource.entities.InOutItemExample; import com.jsh.erp.datasource.entities.InOutItemExample;
import com.jsh.erp.datasource.mappers.InOutItemMapper; import com.jsh.erp.datasource.mappers.InOutItemMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class InOutItemService { @Service
private Logger logger = LoggerFactory.getLogger(InOutItemService.class); public class InOutItemService {
private Logger logger = LoggerFactory.getLogger(InOutItemService.class);
@Resource
private InOutItemMapper inOutItemMapper; @Resource
private InOutItemMapper inOutItemMapper;
public InOutItem getInOutItem(long id) {
return inOutItemMapper.selectByPrimaryKey(id); public InOutItem getInOutItem(long id) {
} return inOutItemMapper.selectByPrimaryKey(id);
}
public List<InOutItem> getInOutItem() {
InOutItemExample example = new InOutItemExample(); public List<InOutItem> getInOutItem() {
return inOutItemMapper.selectByExample(example); InOutItemExample example = new InOutItemExample();
} return inOutItemMapper.selectByExample(example);
}
public List<InOutItem> select(String name, String type, String remark, int offset, int rows) {
return inOutItemMapper.selectByConditionInOutItem(name, type, remark, offset, rows); public List<InOutItem> select(String name, String type, String remark, int offset, int rows) {
} return inOutItemMapper.selectByConditionInOutItem(name, type, remark, offset, rows);
}
public int countInOutItem(String name, String type, String remark) {
return inOutItemMapper.countsByInOutItem(name, type, remark); public int countInOutItem(String name, String type, String remark) {
} return inOutItemMapper.countsByInOutItem(name, type, remark);
}
public int insertInOutItem(String beanJson, HttpServletRequest request) {
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return inOutItemMapper.insertSelective(depot); public int insertInOutItem(String beanJson, HttpServletRequest request) {
} InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
return inOutItemMapper.insertSelective(depot);
public int updateInOutItem(String beanJson, Long id) { }
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
depot.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return inOutItemMapper.updateByPrimaryKeySelective(depot); public int updateInOutItem(String beanJson, Long id) {
} InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
depot.setId(id);
public int deleteInOutItem(Long id) { return inOutItemMapper.updateByPrimaryKeySelective(depot);
return inOutItemMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteInOutItem(String ids) { public int deleteInOutItem(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return inOutItemMapper.deleteByPrimaryKey(id);
InOutItemExample example = new InOutItemExample(); }
example.createCriteria().andIdIn(idList);
return inOutItemMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteInOutItem(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { InOutItemExample example = new InOutItemExample();
InOutItemExample example = new InOutItemExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name); return inOutItemMapper.deleteByExample(example);
List<InOutItem> list = inOutItemMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
InOutItemExample example = new InOutItemExample();
public List<InOutItem> findBySelect(String type) { example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
InOutItemExample example = new InOutItemExample(); List<InOutItem> list = inOutItemMapper.selectByExample(example);
if (type.equals("in")) { return list.size();
example.createCriteria().andTypeEqualTo("收入"); }
} else if (type.equals("out")) {
example.createCriteria().andTypeEqualTo("支出"); public List<InOutItem> findBySelect(String type) {
} InOutItemExample example = new InOutItemExample();
example.setOrderByClause("id desc"); if (type.equals("in")) {
return inOutItemMapper.selectByExample(example); example.createCriteria().andTypeEqualTo("收入");
} } else if (type.equals("out")) {
} example.createCriteria().andTypeEqualTo("支出");
}
example.setOrderByClause("id desc");
return inOutItemMapper.selectByExample(example);
}
}
package com.jsh.erp.service.log; package com.jsh.erp.service.log;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Log; import com.jsh.erp.datasource.entities.Log;
import com.jsh.erp.datasource.entities.LogExample; import com.jsh.erp.datasource.entities.LogExample;
import com.jsh.erp.datasource.mappers.LogMapper; import com.jsh.erp.datasource.mappers.LogMapper;
import com.jsh.erp.utils.ExceptionCodeConstants; import com.jsh.erp.utils.ExceptionCodeConstants;
import com.jsh.erp.utils.JshException; import com.jsh.erp.utils.JshException;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools; import com.jsh.erp.utils.Tools;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.security.NoSuchAlgorithmException; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.security.NoSuchAlgorithmException;
import java.util.List;
@Service
public class LogService { @Service
private Logger logger = LoggerFactory.getLogger(LogService.class); public class LogService {
@Resource private Logger logger = LoggerFactory.getLogger(LogService.class);
private LogMapper logMapper; @Resource
private LogMapper logMapper;
public Log getLog(long id) {
return logMapper.selectByPrimaryKey(id); public Log getLog(long id) {
} return logMapper.selectByPrimaryKey(id);
}
public List<Log> getLog() {
LogExample example = new LogExample(); public List<Log> getLog() {
return logMapper.selectByExample(example); LogExample example = new LogExample();
} return logMapper.selectByExample(example);
}
public List<Log> select(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
String contentdetails, int offset, int rows) { public List<Log> select(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
return logMapper.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime, String contentdetails, int offset, int rows) {
contentdetails, offset, rows); return logMapper.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime,
} contentdetails, offset, rows);
}
public int countLog(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
String contentdetails) { public int countLog(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
return logMapper.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails); String contentdetails) {
} return logMapper.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails);
}
public int insertLog(String beanJson, HttpServletRequest request) {
Log log = JSONObject.parseObject(beanJson, Log.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return logMapper.insertSelective(log); public int insertLog(String beanJson, HttpServletRequest request) {
} Log log = JSONObject.parseObject(beanJson, Log.class);
return logMapper.insertSelective(log);
public int updateLog(String beanJson, Long id) { }
Log log = JSONObject.parseObject(beanJson, Log.class);
log.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return logMapper.updateByPrimaryKeySelective(log); public int updateLog(String beanJson, Long id) {
} Log log = JSONObject.parseObject(beanJson, Log.class);
log.setId(id);
public int deleteLog(Long id) { return logMapper.updateByPrimaryKeySelective(log);
return logMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteLog(String ids) { public int deleteLog(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return logMapper.deleteByPrimaryKey(id);
LogExample example = new LogExample(); }
example.createCriteria().andIdIn(idList);
return logMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteLog(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
} LogExample example = new LogExample();
example.createCriteria().andIdIn(idList);
return logMapper.deleteByExample(example);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment