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

添加事务控制

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