添加事务控制

This commit is contained in:
cjl 2019-01-11 16:07:43 +08:00
parent 5df1748c79
commit 85d96bb226
25 changed files with 3856 additions and 3671 deletions

View File

@ -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;

View File

@ -1,149 +1,149 @@
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;
}
}

View File

@ -1,150 +1,106 @@
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;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,127 +1,132 @@
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;
}
}

View File

@ -1,307 +1,313 @@
package com.jsh.erp.service.account;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.AccountHeadMapper;
import com.jsh.erp.datasource.mappers.AccountItemMapper;
import com.jsh.erp.datasource.mappers.AccountMapper;
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
import com.jsh.erp.datasource.vo.AccountVo4List;
import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class AccountService {
private Logger logger = LoggerFactory.getLogger(AccountService.class);
@Resource
private AccountMapper accountMapper;
@Resource
private DepotHeadMapper depotHeadMapper;
@Resource
private AccountHeadMapper accountHeadMapper;
@Resource
private AccountItemMapper accountItemMapper;
public Account getAccount(long id) {
return accountMapper.selectByPrimaryKey(id);
}
public List<Account> getAccount() {
AccountExample example = new AccountExample();
return accountMapper.selectByExample(example);
}
public List<AccountVo4List> select(String name, String serialNo, String remark, int offset, int rows) {
List<AccountVo4List> resList = new ArrayList<AccountVo4List>();
List<AccountVo4List> list = accountMapper.selectByConditionAccount(name, serialNo, remark, offset, rows);
String timeStr = Tools.getCurrentMonth();
if (null != list && null !=timeStr) {
for (AccountVo4List al : list) {
DecimalFormat df = new DecimalFormat(".##");
Double thisMonthAmount = getAccountSum(al.getId(), timeStr, "month") + getAccountSumByHead(al.getId(), timeStr, "month") + getAccountSumByDetail(al.getId(), timeStr, "month") + getManyAccountSum(al.getId(), timeStr, "month");
String thisMonthAmountFmt = "0";
if (thisMonthAmount != 0) {
thisMonthAmountFmt = df.format(thisMonthAmount);
}
al.setThismonthamount(thisMonthAmountFmt); //本月发生额
Double currentAmount = getAccountSum(al.getId(), "", "month") + getAccountSumByHead(al.getId(), "", "month") + getAccountSumByDetail(al.getId(), "", "month") + getManyAccountSum(al.getId(), "", "month") + al.getInitialamount();
al.setCurrentamount(currentAmount);
resList.add(al);
}
}
return resList;
}
public int countAccount(String name, String serialNo, String remark) {
return accountMapper.countsByAccount(name, serialNo, remark);
}
public int insertAccount(String beanJson, HttpServletRequest request) {
Account account = JSONObject.parseObject(beanJson, Account.class);
if(account.getInitialamount() == null) {
account.setInitialamount(0d);
}
account.setIsdefault(false);
return accountMapper.insertSelective(account);
}
public int updateAccount(String beanJson, Long id) {
Account account = JSONObject.parseObject(beanJson, Account.class);
account.setId(id);
return accountMapper.updateByPrimaryKeySelective(account);
}
public int deleteAccount(Long id) {
return accountMapper.deleteByPrimaryKey(id);
}
public int batchDeleteAccount(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
AccountExample example = new AccountExample();
example.createCriteria().andIdIn(idList);
return accountMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
AccountExample example = new AccountExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
List<Account> list = accountMapper.selectByExample(example);
return list.size();
}
public List<Account> findBySelect() {
AccountExample example = new AccountExample();
example.setOrderByClause("id desc");
return accountMapper.selectByExample(example);
}
/**
* 单个账户的金额求和-入库和出库
*
* @param id
* @return
*/
public Double getAccountSum(Long id, String timeStr, String type) {
Double accountSum = 0.0;
try {
DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
if (type.equals("month")) {
example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款")
.andOpertimeGreaterThanOrEqualTo(bTime).andOpertimeLessThanOrEqualTo(eTime);
} else if (type.equals("date")) {
example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款")
.andOpertimeLessThanOrEqualTo(mTime);
}
} else {
example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款");
}
List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
if (dataList != null) {
for (DepotHead depotHead : dataList) {
if(depotHead.getChangeamount()!=null) {
accountSum = accountSum + depotHead.getChangeamount();
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-收入支出转账的单据表头的合计
*
* @param id
* @return
*/
public Double getAccountSumByHead(Long id, String timeStr, String type) {
Double accountSum = 0.0;
try {
AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
if (type.equals("month")) {
example.createCriteria().andAccountidEqualTo(id)
.andBilltimeGreaterThanOrEqualTo(bTime).andBilltimeLessThanOrEqualTo(eTime);
} else if (type.equals("date")) {
example.createCriteria().andAccountidEqualTo(id)
.andBilltimeLessThanOrEqualTo(mTime);
}
} else {
example.createCriteria().andAccountidEqualTo(id);
}
List<AccountHead> dataList = accountHeadMapper.selectByExample(example);
if (dataList != null) {
for (AccountHead accountHead : dataList) {
if(accountHead.getChangeamount()!=null) {
accountSum = accountSum + accountHead.getChangeamount();
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-收款付款转账收预付款的单据明细的合计
*
* @param id
* @return
*/
public Double getAccountSumByDetail(Long id, String timeStr, String type) {
Double accountSum = 0.0;
try {
AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
if (type.equals("month")) {
example.createCriteria().andBilltimeGreaterThanOrEqualTo(bTime).andBilltimeLessThanOrEqualTo(eTime);
} else if (type.equals("date")) {
example.createCriteria().andBilltimeLessThanOrEqualTo(mTime);
}
}
List<AccountHead> dataList = accountHeadMapper.selectByExample(example);
if (dataList != null) {
String ids = "";
for (AccountHead accountHead : dataList) {
ids = ids + accountHead.getId() + ",";
}
if (!ids.equals("")) {
ids = ids.substring(0, ids.length() - 1);
}
AccountItemExample exampleAi = new AccountItemExample();
if (!ids.equals("")) {
List<Long> idList = StringUtil.strToLongList(ids);
exampleAi.createCriteria().andAccountidEqualTo(id).andHeaderidIn(idList);
} else {
exampleAi.createCriteria().andAccountidEqualTo(id);
}
List<AccountItem> dataListOne = accountItemMapper.selectByExample(exampleAi);
if (dataListOne != null) {
for (AccountItem accountItem : dataListOne) {
if(accountItem.getEachamount()!=null) {
accountSum = accountSum + accountItem.getEachamount();
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
} catch (Exception e) {
logger.error(">>>>>>>>>异常信息:", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-多账户的明细合计
*
* @param id
* @return
*/
public Double getManyAccountSum(Long id, String timeStr, String type) {
Double accountSum = 0.0;
try {
DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
if (type.equals("month")) {
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%")
.andOpertimeGreaterThanOrEqualTo(bTime).andOpertimeLessThanOrEqualTo(eTime);
} else if (type.equals("date")) {
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%")
.andOpertimeLessThanOrEqualTo(mTime);
}
} else {
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%");
}
List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
if (dataList != null) {
for (DepotHead depotHead : dataList) {
String accountIdList = depotHead.getAccountidlist();
String accountMoneyList = depotHead.getAccountmoneylist();
accountIdList = accountIdList.replace("[", "").replace("]", "").replace("\"", "");
accountMoneyList = accountMoneyList.replace("[", "").replace("]", "").replace("\"", "");
String[] aList = accountIdList.split(",");
String[] amList = accountMoneyList.split(",");
for (int i = 0; i < aList.length; i++) {
if (aList[i].toString().equals(id.toString())) {
accountSum = accountSum + Double.parseDouble(amList[i].toString());
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找信息异常", e);
}
return accountSum;
}
public List<AccountVo4InOutList> findAccountInOutList(Long accountId, Integer offset, Integer rows) {
return accountMapper.findAccountInOutList(accountId, offset, rows);
}
public int findAccountInOutListCount(Long accountId) {
return accountMapper.findAccountInOutListCount(accountId);
}
public int updateAmountIsDefault(Boolean isDefault, Long accountId) {
Account account = new Account();
account.setIsdefault(isDefault);
AccountExample example = new AccountExample();
example.createCriteria().andIdEqualTo(accountId);
return accountMapper.updateByExampleSelective(account, example);
}
}
package com.jsh.erp.service.account;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.AccountHeadMapper;
import com.jsh.erp.datasource.mappers.AccountItemMapper;
import com.jsh.erp.datasource.mappers.AccountMapper;
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
import com.jsh.erp.datasource.vo.AccountVo4List;
import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
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.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class AccountService {
private Logger logger = LoggerFactory.getLogger(AccountService.class);
@Resource
private AccountMapper accountMapper;
@Resource
private DepotHeadMapper depotHeadMapper;
@Resource
private AccountHeadMapper accountHeadMapper;
@Resource
private AccountItemMapper accountItemMapper;
public Account getAccount(long id) {
return accountMapper.selectByPrimaryKey(id);
}
public List<Account> getAccount() {
AccountExample example = new AccountExample();
return accountMapper.selectByExample(example);
}
public List<AccountVo4List> select(String name, String serialNo, String remark, int offset, int rows) {
List<AccountVo4List> resList = new ArrayList<AccountVo4List>();
List<AccountVo4List> list = accountMapper.selectByConditionAccount(name, serialNo, remark, offset, rows);
String timeStr = Tools.getCurrentMonth();
if (null != list && null !=timeStr) {
for (AccountVo4List al : list) {
DecimalFormat df = new DecimalFormat(".##");
Double thisMonthAmount = getAccountSum(al.getId(), timeStr, "month") + getAccountSumByHead(al.getId(), timeStr, "month") + getAccountSumByDetail(al.getId(), timeStr, "month") + getManyAccountSum(al.getId(), timeStr, "month");
String thisMonthAmountFmt = "0";
if (thisMonthAmount != 0) {
thisMonthAmountFmt = df.format(thisMonthAmount);
}
al.setThismonthamount(thisMonthAmountFmt); //本月发生额
Double currentAmount = getAccountSum(al.getId(), "", "month") + getAccountSumByHead(al.getId(), "", "month") + getAccountSumByDetail(al.getId(), "", "month") + getManyAccountSum(al.getId(), "", "month") + al.getInitialamount();
al.setCurrentamount(currentAmount);
resList.add(al);
}
}
return resList;
}
public int countAccount(String name, String serialNo, String remark) {
return accountMapper.countsByAccount(name, serialNo, remark);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertAccount(String beanJson, HttpServletRequest request) {
Account account = JSONObject.parseObject(beanJson, Account.class);
if(account.getInitialamount() == null) {
account.setInitialamount(0d);
}
account.setIsdefault(false);
return accountMapper.insertSelective(account);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAccount(String beanJson, Long id) {
Account account = JSONObject.parseObject(beanJson, Account.class);
account.setId(id);
return accountMapper.updateByPrimaryKeySelective(account);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteAccount(Long id) {
return accountMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccount(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
AccountExample example = new AccountExample();
example.createCriteria().andIdIn(idList);
return accountMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
AccountExample example = new AccountExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
List<Account> list = accountMapper.selectByExample(example);
return list.size();
}
public List<Account> findBySelect() {
AccountExample example = new AccountExample();
example.setOrderByClause("id desc");
return accountMapper.selectByExample(example);
}
/**
* 单个账户的金额求和-入库和出库
*
* @param id
* @return
*/
public Double getAccountSum(Long id, String timeStr, String type) {
Double accountSum = 0.0;
try {
DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
if (type.equals("month")) {
example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款")
.andOpertimeGreaterThanOrEqualTo(bTime).andOpertimeLessThanOrEqualTo(eTime);
} else if (type.equals("date")) {
example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款")
.andOpertimeLessThanOrEqualTo(mTime);
}
} else {
example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款");
}
List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
if (dataList != null) {
for (DepotHead depotHead : dataList) {
if(depotHead.getChangeamount()!=null) {
accountSum = accountSum + depotHead.getChangeamount();
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-收入支出转账的单据表头的合计
*
* @param id
* @return
*/
public Double getAccountSumByHead(Long id, String timeStr, String type) {
Double accountSum = 0.0;
try {
AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
if (type.equals("month")) {
example.createCriteria().andAccountidEqualTo(id)
.andBilltimeGreaterThanOrEqualTo(bTime).andBilltimeLessThanOrEqualTo(eTime);
} else if (type.equals("date")) {
example.createCriteria().andAccountidEqualTo(id)
.andBilltimeLessThanOrEqualTo(mTime);
}
} else {
example.createCriteria().andAccountidEqualTo(id);
}
List<AccountHead> dataList = accountHeadMapper.selectByExample(example);
if (dataList != null) {
for (AccountHead accountHead : dataList) {
if(accountHead.getChangeamount()!=null) {
accountSum = accountSum + accountHead.getChangeamount();
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-收款付款转账收预付款的单据明细的合计
*
* @param id
* @return
*/
public Double getAccountSumByDetail(Long id, String timeStr, String type) {
Double accountSum = 0.0;
try {
AccountHeadExample example = new AccountHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
if (type.equals("month")) {
example.createCriteria().andBilltimeGreaterThanOrEqualTo(bTime).andBilltimeLessThanOrEqualTo(eTime);
} else if (type.equals("date")) {
example.createCriteria().andBilltimeLessThanOrEqualTo(mTime);
}
}
List<AccountHead> dataList = accountHeadMapper.selectByExample(example);
if (dataList != null) {
String ids = "";
for (AccountHead accountHead : dataList) {
ids = ids + accountHead.getId() + ",";
}
if (!ids.equals("")) {
ids = ids.substring(0, ids.length() - 1);
}
AccountItemExample exampleAi = new AccountItemExample();
if (!ids.equals("")) {
List<Long> idList = StringUtil.strToLongList(ids);
exampleAi.createCriteria().andAccountidEqualTo(id).andHeaderidIn(idList);
} else {
exampleAi.createCriteria().andAccountidEqualTo(id);
}
List<AccountItem> dataListOne = accountItemMapper.selectByExample(exampleAi);
if (dataListOne != null) {
for (AccountItem accountItem : dataListOne) {
if(accountItem.getEachamount()!=null) {
accountSum = accountSum + accountItem.getEachamount();
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
} catch (Exception e) {
logger.error(">>>>>>>>>异常信息:", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-多账户的明细合计
*
* @param id
* @return
*/
public Double getManyAccountSum(Long id, String timeStr, String type) {
Double accountSum = 0.0;
try {
DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
if (type.equals("month")) {
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%")
.andOpertimeGreaterThanOrEqualTo(bTime).andOpertimeLessThanOrEqualTo(eTime);
} else if (type.equals("date")) {
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%")
.andOpertimeLessThanOrEqualTo(mTime);
}
} else {
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%");
}
List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
if (dataList != null) {
for (DepotHead depotHead : dataList) {
String accountIdList = depotHead.getAccountidlist();
String accountMoneyList = depotHead.getAccountmoneylist();
accountIdList = accountIdList.replace("[", "").replace("]", "").replace("\"", "");
accountMoneyList = accountMoneyList.replace("[", "").replace("]", "").replace("\"", "");
String[] aList = accountIdList.split(",");
String[] amList = accountMoneyList.split(",");
for (int i = 0; i < aList.length; i++) {
if (aList[i].toString().equals(id.toString())) {
accountSum = accountSum + Double.parseDouble(amList[i].toString());
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找信息异常", e);
}
return accountSum;
}
public List<AccountVo4InOutList> findAccountInOutList(Long accountId, Integer offset, Integer rows) {
return accountMapper.findAccountInOutList(accountId, offset, rows);
}
public int findAccountInOutListCount(Long accountId) {
return accountMapper.findAccountInOutListCount(accountId);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAmountIsDefault(Boolean isDefault, Long accountId) {
Account account = new Account();
account.setIsdefault(isDefault);
AccountExample example = new AccountExample();
example.createCriteria().andIdEqualTo(accountId);
return accountMapper.updateByExampleSelective(account, example);
}
}

View File

@ -1,116 +1,121 @@
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;
}
}

View File

@ -1,81 +1,158 @@
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;
}
}

View File

@ -1,85 +1,90 @@
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;
}
}

View File

@ -1,91 +1,96 @@
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;
}
}

View File

@ -1,242 +1,248 @@
package com.jsh.erp.service.depotHead;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.DepotHead;
import com.jsh.erp.datasource.entities.DepotHeadExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail;
import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount;
import com.jsh.erp.datasource.vo.DepotHeadVo4List;
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class DepotHeadService {
private Logger logger = LoggerFactory.getLogger(DepotHeadService.class);
@Resource
private DepotHeadMapper depotHeadMapper;
public DepotHead getDepotHead(long id) {
return depotHeadMapper.selectByPrimaryKey(id);
}
public List<DepotHead> getDepotHead() {
DepotHeadExample example = new DepotHeadExample();
return depotHeadMapper.selectByExample(example);
}
public List<DepotHeadVo4List> select(String type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows) {
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
List<DepotHeadVo4List> list = depotHeadMapper.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows);
if (null != list) {
for (DepotHeadVo4List dh : list) {
if(dh.getOthermoneylist() != null) {
String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setOthermoneylist(otherMoneyListStr);
}
if(dh.getOthermoneyitem() != null) {
String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setOthermoneyitem(otherMoneyItemStr);
}
if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount()));
}
if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice()));
}
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh);
}
}
return resList;
}
public int countDepotHead(String type, String subType, String number, String beginTime, String endTime, String dhIds) {
return depotHeadMapper.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds);
}
public int insertDepotHead(String beanJson, HttpServletRequest request) {
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//判断用户是否已经登录过登录过不再处理
Object userInfo = request.getSession().getAttribute("user");
if (userInfo != null) {
User sessionUser = (User) userInfo;
String uName = sessionUser.getUsername();
depotHead.setOperpersonname(uName);
}
depotHead.setCreatetime(new Timestamp(System.currentTimeMillis()));
depotHead.setStatus(false);
return depotHeadMapper.insertSelective(depotHead);
}
public int updateDepotHead(String beanJson, Long id) {
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
depotHead.setId(id);
return depotHeadMapper.updateByPrimaryKeySelective(depotHead);
}
public int deleteDepotHead(Long id) {
return depotHeadMapper.deleteByPrimaryKey(id);
}
public int batchDeleteDepotHead(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(idList);
return depotHeadMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdNotEqualTo(id);
List<DepotHead> list = depotHeadMapper.selectByExample(example);
return list.size();
}
public int batchSetStatus(Boolean status, String depotHeadIDs) {
List<Long> ids = StringUtil.strToLongList(depotHeadIDs);
DepotHead depotHead = new DepotHead();
depotHead.setStatus(status);
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(ids);
return depotHeadMapper.updateByExampleSelective(depotHead, example);
}
public String buildNumber(String type, String subType, String beginTime, String endTime) {
String newNumber = "0001"; //新编号
try {
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andTypeEqualTo(type).andSubtypeEqualTo(subType)
.andOpertimeGreaterThanOrEqualTo(StringUtil.getDateByString(beginTime,null))
.andOpertimeLessThanOrEqualTo(StringUtil.getDateByString(endTime,null));
example.setOrderByClause("Id desc");
List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
//存放数据json数组
if (null != dataList && dataList.size() > 0) {
DepotHead depotHead = dataList.get(0);
if (depotHead != null) {
String number = depotHead.getDefaultnumber(); //最大的单据编号
if (number != null) {
Integer lastNumber = Integer.parseInt(number.substring(12, 16)); //末四尾
lastNumber = lastNumber + 1;
Integer nLen = lastNumber.toString().length();
if (nLen == 1) {
newNumber = "000" + lastNumber.toString();
} else if (nLen == 2) {
newNumber = "00" + lastNumber.toString();
} else if (nLen == 3) {
newNumber = "0" + lastNumber.toString();
} else if (nLen == 4) {
newNumber = lastNumber.toString();
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e);
}
return newNumber;
}
public Long getMaxId() {
return depotHeadMapper.getMaxId();
}
public String findMaterialsListByHeaderId(Long id) {
String allReturn = depotHeadMapper.findMaterialsListByHeaderId(id);
return allReturn;
}
public List<DepotHead> findByMonth(String monthTime) {
DepotHeadExample example = new DepotHeadExample();
monthTime = monthTime + "-31 00:00:00";
Date month = StringUtil.getDateByString(monthTime, null);
example.createCriteria().andOpertimeLessThanOrEqualTo(month);
return depotHeadMapper.selectByExample(example);
}
public List<DepotHead> getDepotHeadGiftOut(String projectId) {
DepotHeadExample example = new DepotHeadExample();
if (projectId != null) {
example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId));
}
return depotHeadMapper.selectByExample(example);
}
public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) {
return depotHeadMapper.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows);
}
public int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) {
return depotHeadMapper.findByAllCount(beginTime, endTime, type, pid, dids, oId);
}
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) {
return depotHeadMapper.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, offset, rows);
}
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) {
return depotHeadMapper.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId);
}
public List<DepotHeadVo4StatementAccount> findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows) {
return depotHeadMapper.findStatementAccount(beginTime, endTime, organId, supType, offset, rows);
}
public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) {
return depotHeadMapper.findStatementAccountCount(beginTime, endTime, organId, supType);
}
public Double findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) {
String modeName = "";
if (mode.equals("实际")) {
modeName = "ChangeAmount";
} else if (mode.equals("合计")) {
modeName = "DiscountLastMoney";
}
return depotHeadMapper.findAllMoney(supplierId, type, subType, modeName, endTime);
}
public List<DepotHeadVo4List> getDetailByNumber(String number) {
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
List<DepotHeadVo4List> list = depotHeadMapper.getDetailByNumber(number);
if (null != list) {
for (DepotHeadVo4List dh : list) {
if(dh.getOthermoneylist() != null) {
String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setOthermoneylist(otherMoneyListStr);
}
if(dh.getOthermoneyitem() != null) {
String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setOthermoneyitem(otherMoneyItemStr);
}
if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount()));
}
if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice()));
}
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh);
}
}
return resList;
}
}
package com.jsh.erp.service.depotHead;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.DepotHead;
import com.jsh.erp.datasource.entities.DepotHeadExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail;
import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount;
import com.jsh.erp.datasource.vo.DepotHeadVo4List;
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.jsh.erp.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.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class DepotHeadService {
private Logger logger = LoggerFactory.getLogger(DepotHeadService.class);
@Resource
private DepotHeadMapper depotHeadMapper;
public DepotHead getDepotHead(long id) {
return depotHeadMapper.selectByPrimaryKey(id);
}
public List<DepotHead> getDepotHead() {
DepotHeadExample example = new DepotHeadExample();
return depotHeadMapper.selectByExample(example);
}
public List<DepotHeadVo4List> select(String type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows) {
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
List<DepotHeadVo4List> list = depotHeadMapper.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows);
if (null != list) {
for (DepotHeadVo4List dh : list) {
if(dh.getOthermoneylist() != null) {
String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setOthermoneylist(otherMoneyListStr);
}
if(dh.getOthermoneyitem() != null) {
String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setOthermoneyitem(otherMoneyItemStr);
}
if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount()));
}
if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice()));
}
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh);
}
}
return resList;
}
public int countDepotHead(String type, String subType, String number, String beginTime, String endTime, String dhIds) {
return depotHeadMapper.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotHead(String beanJson, HttpServletRequest request) {
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//判断用户是否已经登录过登录过不再处理
Object userInfo = request.getSession().getAttribute("user");
if (userInfo != null) {
User sessionUser = (User) userInfo;
String uName = sessionUser.getUsername();
depotHead.setOperpersonname(uName);
}
depotHead.setCreatetime(new Timestamp(System.currentTimeMillis()));
depotHead.setStatus(false);
return depotHeadMapper.insertSelective(depotHead);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotHead(String beanJson, Long id) {
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
depotHead.setId(id);
return depotHeadMapper.updateByPrimaryKeySelective(depotHead);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepotHead(Long id) {
return depotHeadMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotHead(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(idList);
return depotHeadMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdNotEqualTo(id);
List<DepotHead> list = depotHeadMapper.selectByExample(example);
return list.size();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetStatus(Boolean status, String depotHeadIDs) {
List<Long> ids = StringUtil.strToLongList(depotHeadIDs);
DepotHead depotHead = new DepotHead();
depotHead.setStatus(status);
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(ids);
return depotHeadMapper.updateByExampleSelective(depotHead, example);
}
public String buildNumber(String type, String subType, String beginTime, String endTime) {
String newNumber = "0001"; //新编号
try {
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andTypeEqualTo(type).andSubtypeEqualTo(subType)
.andOpertimeGreaterThanOrEqualTo(StringUtil.getDateByString(beginTime,null))
.andOpertimeLessThanOrEqualTo(StringUtil.getDateByString(endTime,null));
example.setOrderByClause("Id desc");
List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
//存放数据json数组
if (null != dataList && dataList.size() > 0) {
DepotHead depotHead = dataList.get(0);
if (depotHead != null) {
String number = depotHead.getDefaultnumber(); //最大的单据编号
if (number != null) {
Integer lastNumber = Integer.parseInt(number.substring(12, 16)); //末四尾
lastNumber = lastNumber + 1;
Integer nLen = lastNumber.toString().length();
if (nLen == 1) {
newNumber = "000" + lastNumber.toString();
} else if (nLen == 2) {
newNumber = "00" + lastNumber.toString();
} else if (nLen == 3) {
newNumber = "0" + lastNumber.toString();
} else if (nLen == 4) {
newNumber = lastNumber.toString();
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e);
}
return newNumber;
}
public Long getMaxId() {
return depotHeadMapper.getMaxId();
}
public String findMaterialsListByHeaderId(Long id) {
String allReturn = depotHeadMapper.findMaterialsListByHeaderId(id);
return allReturn;
}
public List<DepotHead> findByMonth(String monthTime) {
DepotHeadExample example = new DepotHeadExample();
monthTime = monthTime + "-31 00:00:00";
Date month = StringUtil.getDateByString(monthTime, null);
example.createCriteria().andOpertimeLessThanOrEqualTo(month);
return depotHeadMapper.selectByExample(example);
}
public List<DepotHead> getDepotHeadGiftOut(String projectId) {
DepotHeadExample example = new DepotHeadExample();
if (projectId != null) {
example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId));
}
return depotHeadMapper.selectByExample(example);
}
public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) {
return depotHeadMapper.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows);
}
public int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) {
return depotHeadMapper.findByAllCount(beginTime, endTime, type, pid, dids, oId);
}
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) {
return depotHeadMapper.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, offset, rows);
}
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) {
return depotHeadMapper.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId);
}
public List<DepotHeadVo4StatementAccount> findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows) {
return depotHeadMapper.findStatementAccount(beginTime, endTime, organId, supType, offset, rows);
}
public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) {
return depotHeadMapper.findStatementAccountCount(beginTime, endTime, organId, supType);
}
public Double findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) {
String modeName = "";
if (mode.equals("实际")) {
modeName = "ChangeAmount";
} else if (mode.equals("合计")) {
modeName = "DiscountLastMoney";
}
return depotHeadMapper.findAllMoney(supplierId, type, subType, modeName, endTime);
}
public List<DepotHeadVo4List> getDetailByNumber(String number) {
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
List<DepotHeadVo4List> list = depotHeadMapper.getDetailByNumber(number);
if (null != list) {
for (DepotHeadVo4List dh : list) {
if(dh.getOthermoneylist() != null) {
String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setOthermoneylist(otherMoneyListStr);
}
if(dh.getOthermoneyitem() != null) {
String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setOthermoneyitem(otherMoneyItemStr);
}
if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount()));
}
if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice()));
}
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh);
}
}
return resList;
}
}

View File

@ -1,194 +1,388 @@
package com.jsh.erp.service.depotItem;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.DepotItemMapper;
import com.jsh.erp.utils.QueryUtils;
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;
import java.util.Map;
@Service
public class DepotItemService {
private Logger logger = LoggerFactory.getLogger(DepotItemService.class);
private final static String TYPE = "入库";
private final static String SUM_TYPE = "Number";
private final static String IN = "in";
private final static String OUT = "out";
@Resource
private DepotItemMapper depotItemMapper;
public DepotItem getDepotItem(long id) {
return depotItemMapper.selectByPrimaryKey(id);
}
public List<DepotItem> getDepotItem() {
DepotItemExample example = new DepotItemExample();
return depotItemMapper.selectByExample(example);
}
public List<DepotItem> select(String name, Integer type, String remark, int offset, int rows) {
return depotItemMapper.selectByConditionDepotItem(name, type, remark, offset, rows);
}
public int countDepotItem(String name, Integer type, String remark) {
return depotItemMapper.countsByDepotItem(name, type, remark);
}
public int insertDepotItem(String beanJson, HttpServletRequest request) {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
return depotItemMapper.insertSelective(depotItem);
}
public int updateDepotItem(String beanJson, Long id) {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
depotItem.setId(id);
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
}
public int deleteDepotItem(Long id) {
return depotItemMapper.deleteByPrimaryKey(id);
}
public int batchDeleteDepotItem(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
DepotItemExample example = new DepotItemExample();
example.createCriteria().andIdIn(idList);
return depotItemMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
DepotItemExample example = new DepotItemExample();
example.createCriteria().andIdNotEqualTo(id);
List<DepotItem> list = depotItemMapper.selectByExample(example);
return list.size();
}
public List<DepotItemVo4HeaderId> getHeaderIdByMaterial(String materialParam, String depotIds) {
return depotItemMapper.getHeaderIdByMaterial(materialParam, depotIds);
}
public List<DepotItemVo4DetailByTypeAndMId> findDetailByTypeAndMaterialIdList(Map<String, String> map) {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
return depotItemMapper.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map));
}
public int findDetailByTypeAndMaterialIdCounts(Map<String, String> map) {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
return depotItemMapper.findDetailByTypeAndMaterialIdCounts(mId);
}
public List<DepotItemVo4Material> findStockNumByMaterialIdList(Map<String, String> map) {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
String monthTime = map.get("monthTime");
return depotItemMapper.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map));
}
public int findStockNumByMaterialIdCounts(Map<String, String> map) {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
String monthTime = map.get("monthTime");
return depotItemMapper.findStockNumByMaterialIdCounts(mId, monthTime);
}
public int insertDepotItemWithObj(DepotItem depotItem) {
return depotItemMapper.insertSelective(depotItem);
}
public int updateDepotItemWithObj(DepotItem depotItem) {
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
}
public int findByTypeAndMaterialId(String type, Long mId) {
if(type.equals(TYPE)) {
return depotItemMapper.findByTypeAndMaterialIdIn(mId);
} else {
return depotItemMapper.findByTypeAndMaterialIdOut(mId);
}
}
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId) {
return depotItemMapper.getDetailList(headerId);
}
public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows) {
return depotItemMapper.findByAll(headIds, materialIds, offset, rows);
}
public int findByAllCount(String headIds, String materialIds) {
return depotItemMapper.findByAllCount(headIds, materialIds);
}
public Double findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapper.findByTypeInIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapper.findByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
return depotItemMapper.findByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapper.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
}
}
}
public Double findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapper.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapper.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
return depotItemMapper.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapper.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
}
}
}
public Double buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) {
if (SUM_TYPE.equals(sumType)) {
return depotItemMapper.buyOrSaleNumber(type, subType, MId, MonthTime, sumType);
} else {
return depotItemMapper.buyOrSalePrice(type, subType, MId, MonthTime, sumType);
}
}
public Double findGiftByType(String subType, Integer ProjectId, Long MId, String type) {
if (IN.equals(type)) {
return depotItemMapper.findGiftByTypeIn(subType, ProjectId, MId);
} else {
return depotItemMapper.findGiftByTypeOut(subType, ProjectId, MId);
}
}
}
package com.jsh.erp.service.depotItem;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.DepotItemMapper;
import com.jsh.erp.service.material.MaterialService;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.QueryUtils;
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 java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
@Service
public class DepotItemService {
private Logger logger = LoggerFactory.getLogger(DepotItemService.class);
private final static String TYPE = "入库";
private final static String SUM_TYPE = "Number";
private final static String IN = "in";
private final static String OUT = "out";
@Resource
private DepotItemMapper depotItemMapper;
@Resource
private MaterialService materialService;
public DepotItem getDepotItem(long id) {
return depotItemMapper.selectByPrimaryKey(id);
}
public List<DepotItem> getDepotItem() {
DepotItemExample example = new DepotItemExample();
return depotItemMapper.selectByExample(example);
}
public List<DepotItem> select(String name, Integer type, String remark, int offset, int rows) {
return depotItemMapper.selectByConditionDepotItem(name, type, remark, offset, rows);
}
public int countDepotItem(String name, Integer type, String remark) {
return depotItemMapper.countsByDepotItem(name, type, remark);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotItem(String beanJson, HttpServletRequest request) {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
return depotItemMapper.insertSelective(depotItem);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotItem(String beanJson, Long id) {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
depotItem.setId(id);
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepotItem(Long id) {
return depotItemMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotItem(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
DepotItemExample example = new DepotItemExample();
example.createCriteria().andIdIn(idList);
return depotItemMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
DepotItemExample example = new DepotItemExample();
example.createCriteria().andIdNotEqualTo(id);
List<DepotItem> list = depotItemMapper.selectByExample(example);
return list.size();
}
public List<DepotItemVo4HeaderId> getHeaderIdByMaterial(String materialParam, String depotIds) {
return depotItemMapper.getHeaderIdByMaterial(materialParam, depotIds);
}
public List<DepotItemVo4DetailByTypeAndMId> findDetailByTypeAndMaterialIdList(Map<String, String> map) {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
return depotItemMapper.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map));
}
public int findDetailByTypeAndMaterialIdCounts(Map<String, String> map) {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
return depotItemMapper.findDetailByTypeAndMaterialIdCounts(mId);
}
public List<DepotItemVo4Material> findStockNumByMaterialIdList(Map<String, String> map) {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
String monthTime = map.get("monthTime");
return depotItemMapper.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map));
}
public int findStockNumByMaterialIdCounts(Map<String, String> map) {
String mIdStr = map.get("mId");
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
}
String monthTime = map.get("monthTime");
return depotItemMapper.findStockNumByMaterialIdCounts(mId, monthTime);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotItemWithObj(DepotItem depotItem) {
return depotItemMapper.insertSelective(depotItem);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotItemWithObj(DepotItem depotItem) {
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
}
public int findByTypeAndMaterialId(String type, Long mId) {
if(type.equals(TYPE)) {
return depotItemMapper.findByTypeAndMaterialIdIn(mId);
} else {
return depotItemMapper.findByTypeAndMaterialIdOut(mId);
}
}
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId) {
return depotItemMapper.getDetailList(headerId);
}
public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows) {
return depotItemMapper.findByAll(headIds, materialIds, offset, rows);
}
public int findByAllCount(String headIds, String materialIds) {
return depotItemMapper.findByAllCount(headIds, materialIds);
}
public Double findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapper.findByTypeInIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapper.findByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
return depotItemMapper.findByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapper.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
}
}
}
public Double findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapper.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapper.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime);
}
} else {
if (isPrev) {
return depotItemMapper.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime);
} else {
return depotItemMapper.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
}
}
}
public Double buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) {
if (SUM_TYPE.equals(sumType)) {
return depotItemMapper.buyOrSaleNumber(type, subType, MId, MonthTime, sumType);
} else {
return depotItemMapper.buyOrSalePrice(type, subType, MId, MonthTime, sumType);
}
}
public Double findGiftByType(String subType, Integer ProjectId, Long MId, String type) {
if (IN.equals(type)) {
return depotItemMapper.findGiftByTypeIn(subType, ProjectId, MId);
} else {
return depotItemMapper.findGiftByTypeOut(subType, ProjectId, MId);
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String saveDetials(String inserted, String deleted, String updated, Long headerId) 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++) {
DepotItem depotItem = new DepotItem();
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
depotItem.setHeaderid(headerId);
depotItem.setMaterialid(tempInsertedJson.getLong("MaterialId"));
depotItem.setMunit(tempInsertedJson.getString("Unit"));
if (!StringUtil.isEmpty(tempInsertedJson.get("OperNumber").toString())) {
depotItem.setOpernumber(tempInsertedJson.getDouble("OperNumber"));
try {
String Unit = tempInsertedJson.get("Unit").toString();
Double oNumber = tempInsertedJson.getDouble("OperNumber");
Long mId = Long.parseLong(tempInsertedJson.get("MaterialId").toString());
//以下进行单位换算
String UnitName = findUnitName(mId); //查询计量单位名称
if (!StringUtil.isEmpty(UnitName)) {
String UnitList = UnitName.substring(0, UnitName.indexOf("("));
String RatioList = UnitName.substring(UnitName.indexOf("("));
String basicUnit = UnitList.substring(0, UnitList.indexOf(",")); //基本单位
String otherUnit = UnitList.substring(UnitList.indexOf(",") + 1); //副单位
Integer ratio = Integer.parseInt(RatioList.substring(RatioList.indexOf(":") + 1).replace(")", "")); //比例
if (Unit.equals(basicUnit)) { //如果等于基础单位
depotItem.setBasicnumber(oNumber); //数量一致
} else if (Unit.equals(otherUnit)) { //如果等于副单位
depotItem.setBasicnumber(oNumber * ratio); //数量乘以比例
}
} else {
depotItem.setBasicnumber(oNumber); //其他情况
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
}
if (!StringUtil.isEmpty(tempInsertedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempInsertedJson.getDouble("UnitPrice"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempInsertedJson.getDouble("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempInsertedJson.getDouble("AllPrice"));
}
depotItem.setRemark(tempInsertedJson.getString("Remark"));
if (tempInsertedJson.get("DepotId") != null && !StringUtil.isEmpty(tempInsertedJson.get("DepotId").toString())) {
depotItem.setDepotid(tempInsertedJson.getLong("DepotId"));
}
if (tempInsertedJson.get("AnotherDepotId") != null && !StringUtil.isEmpty(tempInsertedJson.get("AnotherDepotId").toString())) {
depotItem.setAnotherdepotid(tempInsertedJson.getLong("AnotherDepotId"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxRate").toString())) {
depotItem.setTaxrate(tempInsertedJson.getDouble("TaxRate"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempInsertedJson.getDouble("TaxMoney"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempInsertedJson.getDouble("TaxLastMoney"));
}
if (tempInsertedJson.get("OtherField1") != null) {
depotItem.setOtherfield1(tempInsertedJson.getString("OtherField1"));
}
if (tempInsertedJson.get("OtherField2") != null) {
depotItem.setOtherfield2(tempInsertedJson.getString("OtherField2"));
}
if (tempInsertedJson.get("OtherField3") != null) {
depotItem.setOtherfield3(tempInsertedJson.getString("OtherField3"));
}
if (tempInsertedJson.get("OtherField4") != null) {
depotItem.setOtherfield4(tempInsertedJson.getString("OtherField4"));
}
if (tempInsertedJson.get("OtherField5") != null) {
depotItem.setOtherfield5(tempInsertedJson.getString("OtherField5"));
}
if (tempInsertedJson.get("MType") != null) {
depotItem.setMtype(tempInsertedJson.getString("MType"));
}
this.insertDepotItemWithObj(depotItem);
}
}
if (null != deletedJson) {
for (int i = 0; i < deletedJson.size(); i++) {
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
this.deleteDepotItem(tempDeletedJson.getLong("Id"));
}
}
if (null != updatedJson) {
for (int i = 0; i < updatedJson.size(); i++) {
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
DepotItem depotItem = this.getDepotItem(tempUpdatedJson.getLong("Id"));
depotItem.setId(tempUpdatedJson.getLong("Id"));
depotItem.setMaterialid(tempUpdatedJson.getLong("MaterialId"));
depotItem.setMunit(tempUpdatedJson.getString("Unit"));
if (!StringUtil.isEmpty(tempUpdatedJson.get("OperNumber").toString())) {
depotItem.setOpernumber(tempUpdatedJson.getDouble("OperNumber"));
try {
String Unit = tempUpdatedJson.get("Unit").toString();
Double oNumber = tempUpdatedJson.getDouble("OperNumber");
Long mId = Long.parseLong(tempUpdatedJson.get("MaterialId").toString());
//以下进行单位换算
String UnitName = findUnitName(mId); //查询计量单位名称
if (!StringUtil.isEmpty(UnitName)) {
String UnitList = UnitName.substring(0, UnitName.indexOf("("));
String RatioList = UnitName.substring(UnitName.indexOf("("));
String basicUnit = UnitList.substring(0, UnitList.indexOf(",")); //基本单位
String otherUnit = UnitList.substring(UnitList.indexOf(",") + 1); //副单位
Integer ratio = Integer.parseInt(RatioList.substring(RatioList.indexOf(":") + 1).replace(")", "")); //比例
if (Unit.equals(basicUnit)) { //如果等于基础单位
depotItem.setBasicnumber(oNumber); //数量一致
} else if (Unit.equals(otherUnit)) { //如果等于副单位
depotItem.setBasicnumber(oNumber * ratio); //数量乘以比例
}
} else {
depotItem.setBasicnumber(oNumber); //其他情况
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempUpdatedJson.getDouble("UnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempUpdatedJson.getDouble("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempUpdatedJson.getDouble("AllPrice"));
}
depotItem.setRemark(tempUpdatedJson.getString("Remark"));
if (tempUpdatedJson.get("DepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("DepotId").toString())) {
depotItem.setDepotid(tempUpdatedJson.getLong("DepotId"));
}
if (tempUpdatedJson.get("AnotherDepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("AnotherDepotId").toString())) {
depotItem.setAnotherdepotid(tempUpdatedJson.getLong("AnotherDepotId"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxRate").toString())) {
depotItem.setTaxrate(tempUpdatedJson.getDouble("TaxRate"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempUpdatedJson.getDouble("TaxMoney"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempUpdatedJson.getDouble("TaxLastMoney"));
}
depotItem.setOtherfield1(tempUpdatedJson.getString("OtherField1"));
depotItem.setOtherfield2(tempUpdatedJson.getString("OtherField2"));
depotItem.setOtherfield3(tempUpdatedJson.getString("OtherField3"));
depotItem.setOtherfield4(tempUpdatedJson.getString("OtherField4"));
depotItem.setOtherfield5(tempUpdatedJson.getString("OtherField5"));
depotItem.setMtype(tempUpdatedJson.getString("MType"));
this.updateDepotItemWithObj(depotItem);
}
}
return null;
}
/**
* 查询计量单位信息
*
* @return
*/
public String findUnitName(Long mId) {
String unitName = "";
try {
unitName = materialService.findUnitName(mId);
if (unitName != null) {
unitName = unitName.substring(1, unitName.length() - 1);
if (unitName.equals("null")) {
unitName = "";
}
}
} catch (Exception e) {
e.printStackTrace();
}
return unitName;
}
}

View File

@ -1,93 +1,98 @@
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;
}
}

View File

@ -1,79 +1,84 @@
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);
}
}

View File

@ -1,68 +1,73 @@
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);
}
}

View File

@ -1,157 +1,163 @@
package com.jsh.erp.service.material;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Material;
import com.jsh.erp.datasource.entities.MaterialExample;
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
import com.jsh.erp.datasource.mappers.MaterialMapper;
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.ArrayList;
import java.util.List;
@Service
public class MaterialService {
private Logger logger = LoggerFactory.getLogger(MaterialService.class);
@Resource
private MaterialMapper materialMapper;
public Material getMaterial(long id) {
return materialMapper.selectByPrimaryKey(id);
}
public List<Material> getMaterial() {
MaterialExample example = new MaterialExample();
return materialMapper.selectByExample(example);
}
public List<MaterialVo4Unit> select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows) {
String[] mpArr = mpList.split(",");
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
List<MaterialVo4Unit> list = materialMapper.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows);
if (null != list) {
for (MaterialVo4Unit m : list) {
//扩展信息
String materialOther = "";
for (int i = 0; i < mpArr.length; i++) {
if (mpArr[i].equals("颜色")) {
materialOther = materialOther + ((m.getColor() == null || m.getColor().equals("")) ? "" : "(" + m.getColor() + ")");
}
if (mpArr[i].equals("规格")) {
materialOther = materialOther + ((m.getStandard() == null || m.getStandard().equals("")) ? "" : "(" + m.getStandard() + ")");
}
if (mpArr[i].equals("制造商")) {
materialOther = materialOther + ((m.getMfrs() == null || m.getMfrs().equals("")) ? "" : "(" + m.getMfrs() + ")");
}
if (mpArr[i].equals("自定义1")) {
materialOther = materialOther + ((m.getOtherfield1() == null || m.getOtherfield1().equals("")) ? "" : "(" + m.getOtherfield1() + ")");
}
if (mpArr[i].equals("自定义2")) {
materialOther = materialOther + ((m.getOtherfield2() == null || m.getOtherfield2().equals("")) ? "" : "(" + m.getOtherfield2() + ")");
}
if (mpArr[i].equals("自定义3")) {
materialOther = materialOther + ((m.getOtherfield3() == null || m.getOtherfield3().equals("")) ? "" : "(" + m.getOtherfield3() + ")");
}
}
m.setMaterialOther(materialOther);
resList.add(m);
}
}
return resList;
}
public int countMaterial(String name, String model,Long categoryId, String categoryIds,String mpList) {
return materialMapper.countsByMaterial(name, model,categoryId,categoryIds,mpList);
}
public int insertMaterial(String beanJson, HttpServletRequest request) {
Material material = JSONObject.parseObject(beanJson, Material.class);
material.setEnabled(true);
return materialMapper.insertSelective(material);
}
public int updateMaterial(String beanJson, Long id) {
Material material = JSONObject.parseObject(beanJson, Material.class);
material.setId(id);
int res = materialMapper.updateByPrimaryKeySelective(material);
Long unitId = material.getUnitid();
if(unitId != null) {
materialMapper.updatePriceNullByPrimaryKey(id); //将价格置空
} else {
materialMapper.updateUnitIdNullByPrimaryKey(id); //将多单位置空
}
return res;
}
public int deleteMaterial(Long id) {
return materialMapper.deleteByPrimaryKey(id);
}
public int batchDeleteMaterial(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialExample example = new MaterialExample();
example.createCriteria().andIdIn(idList);
return materialMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
MaterialExample example = new MaterialExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
List<Material> list = materialMapper.selectByExample(example);
return list.size();
}
public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs,
String otherField1, String otherField2, String otherField3, String unit, Long unitId) {
MaterialExample example = new MaterialExample();
MaterialExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color)
.andStandardEqualTo(standard).andMfrsEqualTo(mfrs)
.andOtherfield1EqualTo(otherField1).andOtherfield2EqualTo(otherField2).andOtherfield2EqualTo(otherField3);
if (id > 0) {
criteria.andIdNotEqualTo(id);
}
if (!StringUtil.isEmpty(unit)) {
criteria.andUnitEqualTo(unit);
}
if (unitId !=null) {
criteria.andUnitidEqualTo(unitId);
}
List<Material> list = materialMapper.selectByExample(example);
return list.size();
}
public int batchSetEnable(Boolean enabled, String materialIDs) {
List<Long> ids = StringUtil.strToLongList(materialIDs);
Material material = new Material();
material.setEnabled(enabled);
MaterialExample example = new MaterialExample();
example.createCriteria().andIdIn(ids);
return materialMapper.updateByExampleSelective(material, example);
}
public String findUnitName(Long mId){
return materialMapper.findUnitName(mId);
}
public List<MaterialVo4Unit> findById(Long id){
return materialMapper.findById(id);
}
public List<MaterialVo4Unit> findBySelect(){
return materialMapper.findBySelect();
}
public List<Material> findByOrder(){
MaterialExample example = new MaterialExample();
example.setOrderByClause("Name,Model asc");
return materialMapper.selectByExample(example);
}
}
package com.jsh.erp.service.material;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Material;
import com.jsh.erp.datasource.entities.MaterialExample;
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
import com.jsh.erp.datasource.mappers.MaterialMapper;
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.ArrayList;
import java.util.List;
@Service
public class MaterialService {
private Logger logger = LoggerFactory.getLogger(MaterialService.class);
@Resource
private MaterialMapper materialMapper;
public Material getMaterial(long id) {
return materialMapper.selectByPrimaryKey(id);
}
public List<Material> getMaterial() {
MaterialExample example = new MaterialExample();
return materialMapper.selectByExample(example);
}
public List<MaterialVo4Unit> select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows) {
String[] mpArr = mpList.split(",");
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
List<MaterialVo4Unit> list = materialMapper.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows);
if (null != list) {
for (MaterialVo4Unit m : list) {
//扩展信息
String materialOther = "";
for (int i = 0; i < mpArr.length; i++) {
if (mpArr[i].equals("颜色")) {
materialOther = materialOther + ((m.getColor() == null || m.getColor().equals("")) ? "" : "(" + m.getColor() + ")");
}
if (mpArr[i].equals("规格")) {
materialOther = materialOther + ((m.getStandard() == null || m.getStandard().equals("")) ? "" : "(" + m.getStandard() + ")");
}
if (mpArr[i].equals("制造商")) {
materialOther = materialOther + ((m.getMfrs() == null || m.getMfrs().equals("")) ? "" : "(" + m.getMfrs() + ")");
}
if (mpArr[i].equals("自定义1")) {
materialOther = materialOther + ((m.getOtherfield1() == null || m.getOtherfield1().equals("")) ? "" : "(" + m.getOtherfield1() + ")");
}
if (mpArr[i].equals("自定义2")) {
materialOther = materialOther + ((m.getOtherfield2() == null || m.getOtherfield2().equals("")) ? "" : "(" + m.getOtherfield2() + ")");
}
if (mpArr[i].equals("自定义3")) {
materialOther = materialOther + ((m.getOtherfield3() == null || m.getOtherfield3().equals("")) ? "" : "(" + m.getOtherfield3() + ")");
}
}
m.setMaterialOther(materialOther);
resList.add(m);
}
}
return resList;
}
public int countMaterial(String name, String model,Long categoryId, String categoryIds,String mpList) {
return materialMapper.countsByMaterial(name, model,categoryId,categoryIds,mpList);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertMaterial(String beanJson, HttpServletRequest request) {
Material material = JSONObject.parseObject(beanJson, Material.class);
material.setEnabled(true);
return materialMapper.insertSelective(material);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateMaterial(String beanJson, Long id) {
Material material = JSONObject.parseObject(beanJson, Material.class);
material.setId(id);
int res = materialMapper.updateByPrimaryKeySelective(material);
Long unitId = material.getUnitid();
if(unitId != null) {
materialMapper.updatePriceNullByPrimaryKey(id); //将价格置空
} else {
materialMapper.updateUnitIdNullByPrimaryKey(id); //将多单位置空
}
return res;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteMaterial(Long id) {
return materialMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterial(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialExample example = new MaterialExample();
example.createCriteria().andIdIn(idList);
return materialMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
MaterialExample example = new MaterialExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
List<Material> list = materialMapper.selectByExample(example);
return list.size();
}
public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs,
String otherField1, String otherField2, String otherField3, String unit, Long unitId) {
MaterialExample example = new MaterialExample();
MaterialExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color)
.andStandardEqualTo(standard).andMfrsEqualTo(mfrs)
.andOtherfield1EqualTo(otherField1).andOtherfield2EqualTo(otherField2).andOtherfield2EqualTo(otherField3);
if (id > 0) {
criteria.andIdNotEqualTo(id);
}
if (!StringUtil.isEmpty(unit)) {
criteria.andUnitEqualTo(unit);
}
if (unitId !=null) {
criteria.andUnitidEqualTo(unitId);
}
List<Material> list = materialMapper.selectByExample(example);
return list.size();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetEnable(Boolean enabled, String materialIDs) {
List<Long> ids = StringUtil.strToLongList(materialIDs);
Material material = new Material();
material.setEnabled(enabled);
MaterialExample example = new MaterialExample();
example.createCriteria().andIdIn(ids);
return materialMapper.updateByExampleSelective(material, example);
}
public String findUnitName(Long mId){
return materialMapper.findUnitName(mId);
}
public List<MaterialVo4Unit> findById(Long id){
return materialMapper.findById(id);
}
public List<MaterialVo4Unit> findBySelect(){
return materialMapper.findBySelect();
}
public List<Material> findByOrder(){
MaterialExample example = new MaterialExample();
example.setOrderByClause("Name,Model asc");
return materialMapper.selectByExample(example);
}
}

View File

@ -1,78 +1,83 @@
package com.jsh.erp.service.materialCategory;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.MaterialCategory;
import com.jsh.erp.datasource.entities.MaterialCategoryExample;
import com.jsh.erp.datasource.mappers.MaterialCategoryMapper;
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 MaterialCategoryService {
private Logger logger = LoggerFactory.getLogger(MaterialCategoryService.class);
@Resource
private MaterialCategoryMapper materialCategoryMapper;
public MaterialCategory getMaterialCategory(long id) {
return materialCategoryMapper.selectByPrimaryKey(id);
}
public List<MaterialCategory> getMaterialCategory() {
MaterialCategoryExample example = new MaterialCategoryExample();
return materialCategoryMapper.selectByExample(example);
}
public List<MaterialCategory> getAllList(Long parentId) {
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
example.setOrderByClause("id");
return materialCategoryMapper.selectByExample(example);
}
public List<MaterialCategory> select(String name, Integer parentId, int offset, int rows) {
return materialCategoryMapper.selectByConditionMaterialCategory(name, parentId, offset, rows);
}
public int countMaterialCategory(String name, Integer parentId) {
return materialCategoryMapper.countsByMaterialCategory(name, parentId);
}
public int insertMaterialCategory(String beanJson, HttpServletRequest request) {
MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class);
return materialCategoryMapper.insertSelective(materialCategory);
}
public int updateMaterialCategory(String beanJson, Long id) {
MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class);
materialCategory.setId(id);
return materialCategoryMapper.updateByPrimaryKeySelective(materialCategory);
}
public int deleteMaterialCategory(Long id) {
return materialCategoryMapper.deleteByPrimaryKey(id);
}
public int batchDeleteMaterialCategory(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andIdIn(idList);
return materialCategoryMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
return 0;
}
public List<MaterialCategory> findById(Long id) {
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andIdEqualTo(id);
return materialCategoryMapper.selectByExample(example);
}
}
package com.jsh.erp.service.materialCategory;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.MaterialCategory;
import com.jsh.erp.datasource.entities.MaterialCategoryExample;
import com.jsh.erp.datasource.mappers.MaterialCategoryMapper;
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 MaterialCategoryService {
private Logger logger = LoggerFactory.getLogger(MaterialCategoryService.class);
@Resource
private MaterialCategoryMapper materialCategoryMapper;
public MaterialCategory getMaterialCategory(long id) {
return materialCategoryMapper.selectByPrimaryKey(id);
}
public List<MaterialCategory> getMaterialCategory() {
MaterialCategoryExample example = new MaterialCategoryExample();
return materialCategoryMapper.selectByExample(example);
}
public List<MaterialCategory> getAllList(Long parentId) {
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
example.setOrderByClause("id");
return materialCategoryMapper.selectByExample(example);
}
public List<MaterialCategory> select(String name, Integer parentId, int offset, int rows) {
return materialCategoryMapper.selectByConditionMaterialCategory(name, parentId, offset, rows);
}
public int countMaterialCategory(String name, Integer parentId) {
return materialCategoryMapper.countsByMaterialCategory(name, parentId);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertMaterialCategory(String beanJson, HttpServletRequest request) {
MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class);
return materialCategoryMapper.insertSelective(materialCategory);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateMaterialCategory(String beanJson, Long id) {
MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class);
materialCategory.setId(id);
return materialCategoryMapper.updateByPrimaryKeySelective(materialCategory);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteMaterialCategory(Long id) {
return materialCategoryMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialCategory(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andIdIn(idList);
return materialCategoryMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
return 0;
}
public List<MaterialCategory> findById(Long id) {
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andIdEqualTo(id);
return materialCategoryMapper.selectByExample(example);
}
}

View File

@ -1,64 +1,69 @@
package com.jsh.erp.service.materialProperty;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.MaterialProperty;
import com.jsh.erp.datasource.entities.MaterialPropertyExample;
import com.jsh.erp.datasource.mappers.MaterialPropertyMapper;
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 MaterialPropertyService {
private Logger logger = LoggerFactory.getLogger(MaterialPropertyService.class);
@Resource
private MaterialPropertyMapper materialPropertyMapper;
public MaterialProperty getMaterialProperty(long id) {
return materialPropertyMapper.selectByPrimaryKey(id);
}
public List<MaterialProperty> getMaterialProperty() {
MaterialPropertyExample example = new MaterialPropertyExample();
return materialPropertyMapper.selectByExample(example);
}
public List<MaterialProperty> select(String name, int offset, int rows) {
return materialPropertyMapper.selectByConditionMaterialProperty(name, offset, rows);
}
public int countMaterialProperty(String name) {
return materialPropertyMapper.countsByMaterialProperty(name);
}
public int insertMaterialProperty(String beanJson, HttpServletRequest request) {
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
return materialPropertyMapper.insertSelective(materialProperty);
}
public int updateMaterialProperty(String beanJson, Long id) {
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
materialProperty.setId(id);
return materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
}
public int deleteMaterialProperty(Long id) {
return materialPropertyMapper.deleteByPrimaryKey(id);
}
public int batchDeleteMaterialProperty(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialPropertyExample example = new MaterialPropertyExample();
example.createCriteria().andIdIn(idList);
return materialPropertyMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
return 0;
}
}
package com.jsh.erp.service.materialProperty;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.MaterialProperty;
import com.jsh.erp.datasource.entities.MaterialPropertyExample;
import com.jsh.erp.datasource.mappers.MaterialPropertyMapper;
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 MaterialPropertyService {
private Logger logger = LoggerFactory.getLogger(MaterialPropertyService.class);
@Resource
private MaterialPropertyMapper materialPropertyMapper;
public MaterialProperty getMaterialProperty(long id) {
return materialPropertyMapper.selectByPrimaryKey(id);
}
public List<MaterialProperty> getMaterialProperty() {
MaterialPropertyExample example = new MaterialPropertyExample();
return materialPropertyMapper.selectByExample(example);
}
public List<MaterialProperty> select(String name, int offset, int rows) {
return materialPropertyMapper.selectByConditionMaterialProperty(name, offset, rows);
}
public int countMaterialProperty(String name) {
return materialPropertyMapper.countsByMaterialProperty(name);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertMaterialProperty(String beanJson, HttpServletRequest request) {
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
return materialPropertyMapper.insertSelective(materialProperty);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateMaterialProperty(String beanJson, Long id) {
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
materialProperty.setId(id);
return materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteMaterialProperty(Long id) {
return materialPropertyMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialProperty(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialPropertyExample example = new MaterialPropertyExample();
example.createCriteria().andIdIn(idList);
return materialPropertyMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
return 0;
}
}

View File

@ -1,93 +1,98 @@
package com.jsh.erp.service.person;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Person;
import com.jsh.erp.datasource.entities.PersonExample;
import com.jsh.erp.datasource.mappers.PersonMapper;
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 PersonService {
private Logger logger = LoggerFactory.getLogger(PersonService.class);
@Resource
private PersonMapper personMapper;
public Person getPerson(long id) {
return personMapper.selectByPrimaryKey(id);
}
public List<Person> getPerson() {
PersonExample example = new PersonExample();
return personMapper.selectByExample(example);
}
public List<Person> select(String name, String type, int offset, int rows) {
return personMapper.selectByConditionPerson(name, type, offset, rows);
}
public int countPerson(String name, String type) {
return personMapper.countsByPerson(name, type);
}
public int insertPerson(String beanJson, HttpServletRequest request) {
Person person = JSONObject.parseObject(beanJson, Person.class);
return personMapper.insertSelective(person);
}
public int updatePerson(String beanJson, Long id) {
Person person = JSONObject.parseObject(beanJson, Person.class);
person.setId(id);
return personMapper.updateByPrimaryKeySelective(person);
}
public int deletePerson(Long id) {
return personMapper.deleteByPrimaryKey(id);
}
public int batchDeletePerson(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
PersonExample example = new PersonExample();
example.createCriteria().andIdIn(idList);
return personMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
PersonExample example = new PersonExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
List<Person> list = personMapper.selectByExample(example);
return list.size();
}
public String getPersonByIds(String personIDs) {
List<Long> ids = StringUtil.strToLongList(personIDs);
PersonExample example = new PersonExample();
example.createCriteria().andIdIn(ids);
example.setOrderByClause("Id asc");
List<Person> list = personMapper.selectByExample(example);
StringBuffer sb = new StringBuffer();
if (null != list) {
for (Person person : list) {
sb.append(person.getName() + " ");
}
}
return sb.toString();
}
public List<Person> getPersonByType(String type) {
PersonExample example = new PersonExample();
example.createCriteria().andTypeEqualTo(type);
example.setOrderByClause("Id asc");
return personMapper.selectByExample(example);
}
}
package com.jsh.erp.service.person;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Person;
import com.jsh.erp.datasource.entities.PersonExample;
import com.jsh.erp.datasource.mappers.PersonMapper;
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 PersonService {
private Logger logger = LoggerFactory.getLogger(PersonService.class);
@Resource
private PersonMapper personMapper;
public Person getPerson(long id) {
return personMapper.selectByPrimaryKey(id);
}
public List<Person> getPerson() {
PersonExample example = new PersonExample();
return personMapper.selectByExample(example);
}
public List<Person> select(String name, String type, int offset, int rows) {
return personMapper.selectByConditionPerson(name, type, offset, rows);
}
public int countPerson(String name, String type) {
return personMapper.countsByPerson(name, type);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertPerson(String beanJson, HttpServletRequest request) {
Person person = JSONObject.parseObject(beanJson, Person.class);
return personMapper.insertSelective(person);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updatePerson(String beanJson, Long id) {
Person person = JSONObject.parseObject(beanJson, Person.class);
person.setId(id);
return personMapper.updateByPrimaryKeySelective(person);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deletePerson(Long id) {
return personMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeletePerson(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
PersonExample example = new PersonExample();
example.createCriteria().andIdIn(idList);
return personMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
PersonExample example = new PersonExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
List<Person> list = personMapper.selectByExample(example);
return list.size();
}
public String getPersonByIds(String personIDs) {
List<Long> ids = StringUtil.strToLongList(personIDs);
PersonExample example = new PersonExample();
example.createCriteria().andIdIn(ids);
example.setOrderByClause("Id asc");
List<Person> list = personMapper.selectByExample(example);
StringBuffer sb = new StringBuffer();
if (null != list) {
for (Person person : list) {
sb.append(person.getName() + " ");
}
}
return sb.toString();
}
public List<Person> getPersonByType(String type) {
PersonExample example = new PersonExample();
example.createCriteria().andTypeEqualTo(type);
example.setOrderByClause("Id asc");
return personMapper.selectByExample(example);
}
}

View File

@ -1,71 +1,75 @@
package com.jsh.erp.service.role;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Role;
import com.jsh.erp.datasource.entities.RoleExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.mappers.RoleMapper;
import com.jsh.erp.datasource.mappers.UserMapper;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.RegExpTools;
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.List;
import java.util.Map;
@Service
public class RoleService {
@Resource
private RoleMapper roleMapper;
public Role getRole(long id) {
return roleMapper.selectByPrimaryKey(id);
}
public List<Role> getRole() {
RoleExample example = new RoleExample();
return roleMapper.selectByExample(example);
}
public List<Role> select(String name, int offset, int rows) {
return roleMapper.selectByConditionRole(name, offset, rows);
}
public int countRole(String name) {
return roleMapper.countsByRole(name);
}
public int insertRole(String beanJson, HttpServletRequest request) {
Role role = JSONObject.parseObject(beanJson, Role.class);
return roleMapper.insertSelective(role);
}
public int updateRole(String beanJson, Long id) {
Role role = JSONObject.parseObject(beanJson, Role.class);
role.setId(id);
return roleMapper.updateByPrimaryKeySelective(role);
}
public int deleteRole(Long id) {
return roleMapper.deleteByPrimaryKey(id);
}
public int batchDeleteRole(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
RoleExample example = new RoleExample();
example.createCriteria().andIdIn(idList);
return roleMapper.deleteByExample(example);
}
public List<Role> findUserRole(){
RoleExample example = new RoleExample();
example.setOrderByClause("Id");
List<Role> list = roleMapper.selectByExample(example);
return list;
}
}
package com.jsh.erp.service.role;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Role;
import com.jsh.erp.datasource.entities.RoleExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.mappers.RoleMapper;
import com.jsh.erp.datasource.mappers.UserMapper;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.RegExpTools;
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.List;
import java.util.Map;
@Service
public class RoleService {
@Resource
private RoleMapper roleMapper;
public Role getRole(long id) {
return roleMapper.selectByPrimaryKey(id);
}
public List<Role> getRole() {
RoleExample example = new RoleExample();
return roleMapper.selectByExample(example);
}
public List<Role> select(String name, int offset, int rows) {
return roleMapper.selectByConditionRole(name, offset, rows);
}
public int countRole(String name) {
return roleMapper.countsByRole(name);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertRole(String beanJson, HttpServletRequest request) {
Role role = JSONObject.parseObject(beanJson, Role.class);
return roleMapper.insertSelective(role);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateRole(String beanJson, Long id) {
Role role = JSONObject.parseObject(beanJson, Role.class);
role.setId(id);
return roleMapper.updateByPrimaryKeySelective(role);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteRole(Long id) {
return roleMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteRole(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
RoleExample example = new RoleExample();
example.createCriteria().andIdIn(idList);
return roleMapper.deleteByExample(example);
}
public List<Role> findUserRole(){
RoleExample example = new RoleExample();
example.setOrderByClause("Id");
List<Role> list = roleMapper.selectByExample(example);
return list;
}
}

View File

@ -1,119 +1,126 @@
package com.jsh.erp.service.supplier;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Supplier;
import com.jsh.erp.datasource.entities.SupplierExample;
import com.jsh.erp.datasource.mappers.SupplierMapper;
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 SupplierService {
private Logger logger = LoggerFactory.getLogger(SupplierService.class);
@Resource
private SupplierMapper supplierMapper;
public Supplier getSupplier(long id) {
return supplierMapper.selectByPrimaryKey(id);
}
public List<Supplier> getSupplier() {
SupplierExample example = new SupplierExample();
return supplierMapper.selectByExample(example);
}
public List<Supplier> select(String supplier, String type, String phonenum, String telephone, String description, int offset, int rows) {
return supplierMapper.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows);
}
public int countSupplier(String supplier, String type, String phonenum, String telephone, String description) {
return supplierMapper.countsBySupplier(supplier, type, phonenum, telephone, description);
}
public int insertSupplier(String beanJson, HttpServletRequest request) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
return supplierMapper.insertSelective(supplier);
}
public int updateSupplier(String beanJson, Long id) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
supplier.setId(id);
return supplierMapper.updateByPrimaryKeySelective(supplier);
}
public int deleteSupplier(Long id) {
return supplierMapper.deleteByPrimaryKey(id);
}
public int batchDeleteSupplier(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
SupplierExample example = new SupplierExample();
example.createCriteria().andIdIn(idList);
return supplierMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
SupplierExample example = new SupplierExample();
example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name);
List<Supplier> list = supplierMapper.selectByExample(example);
return list.size();
}
public int updateAdvanceIn(Long supplierId, Double advanceIn){
Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId);
supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额可能增加的是负值
return supplierMapper.updateByPrimaryKeySelective(supplier);
}
public List<Supplier> findBySelectCus() {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public List<Supplier> findBySelectSup() {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public List<Supplier> findBySelectRetail() {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public List<Supplier> findById(Long supplierId) {
SupplierExample example = new SupplierExample();
example.createCriteria().andIdEqualTo(supplierId);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public int batchSetEnable(Boolean enabled, String supplierIDs) {
List<Long> ids = StringUtil.strToLongList(supplierIDs);
Supplier supplier = new Supplier();
supplier.setEnabled(enabled);
SupplierExample example = new SupplierExample();
example.createCriteria().andIdIn(ids);
return supplierMapper.updateByExampleSelective(supplier, example);
}
public List<Supplier> findUserCustomer(){
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeEqualTo("客户");
example.setOrderByClause("id desc");
List<Supplier> list = supplierMapper.selectByExample(example);
return list;
}
}
package com.jsh.erp.service.supplier;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Supplier;
import com.jsh.erp.datasource.entities.SupplierExample;
import com.jsh.erp.datasource.mappers.SupplierMapper;
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 SupplierService {
private Logger logger = LoggerFactory.getLogger(SupplierService.class);
@Resource
private SupplierMapper supplierMapper;
public Supplier getSupplier(long id) {
return supplierMapper.selectByPrimaryKey(id);
}
public List<Supplier> getSupplier() {
SupplierExample example = new SupplierExample();
return supplierMapper.selectByExample(example);
}
public List<Supplier> select(String supplier, String type, String phonenum, String telephone, String description, int offset, int rows) {
return supplierMapper.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows);
}
public int countSupplier(String supplier, String type, String phonenum, String telephone, String description) {
return supplierMapper.countsBySupplier(supplier, type, phonenum, telephone, description);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertSupplier(String beanJson, HttpServletRequest request) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
return supplierMapper.insertSelective(supplier);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateSupplier(String beanJson, Long id) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
supplier.setId(id);
return supplierMapper.updateByPrimaryKeySelective(supplier);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteSupplier(Long id) {
return supplierMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSupplier(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
SupplierExample example = new SupplierExample();
example.createCriteria().andIdIn(idList);
return supplierMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
SupplierExample example = new SupplierExample();
example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name);
List<Supplier> list = supplierMapper.selectByExample(example);
return list.size();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAdvanceIn(Long supplierId, Double advanceIn){
Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId);
supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额可能增加的是负值
return supplierMapper.updateByPrimaryKeySelective(supplier);
}
public List<Supplier> findBySelectCus() {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public List<Supplier> findBySelectSup() {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public List<Supplier> findBySelectRetail() {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public List<Supplier> findById(Long supplierId) {
SupplierExample example = new SupplierExample();
example.createCriteria().andIdEqualTo(supplierId);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetEnable(Boolean enabled, String supplierIDs) {
List<Long> ids = StringUtil.strToLongList(supplierIDs);
Supplier supplier = new Supplier();
supplier.setEnabled(enabled);
SupplierExample example = new SupplierExample();
example.createCriteria().andIdIn(ids);
return supplierMapper.updateByExampleSelective(supplier, example);
}
public List<Supplier> findUserCustomer(){
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeEqualTo("客户");
example.setOrderByClause("id desc");
List<Supplier> list = supplierMapper.selectByExample(example);
return list;
}
}

View File

@ -1,67 +1,72 @@
package com.jsh.erp.service.systemConfig;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.SystemConfig;
import com.jsh.erp.datasource.entities.SystemConfigExample;
import com.jsh.erp.datasource.mappers.SystemConfigMapper;
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 SystemConfigService {
private Logger logger = LoggerFactory.getLogger(SystemConfigService.class);
@Resource
private SystemConfigMapper systemConfigMapper;
public SystemConfig getSystemConfig(long id) {
return systemConfigMapper.selectByPrimaryKey(id);
}
public List<SystemConfig> getSystemConfig() {
SystemConfigExample example = new SystemConfigExample();
return systemConfigMapper.selectByExample(example);
}
public List<SystemConfig> select(int offset, int rows) {
return systemConfigMapper.selectByConditionSystemConfig(offset, rows);
}
public int countSystemConfig() {
return systemConfigMapper.countsBySystemConfig();
}
public int insertSystemConfig(String beanJson, HttpServletRequest request) {
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
return systemConfigMapper.insertSelective(systemConfig);
}
public int updateSystemConfig(String beanJson, Long id) {
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
systemConfig.setId(id);
return systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
}
public int deleteSystemConfig(Long id) {
return systemConfigMapper.deleteByPrimaryKey(id);
}
public int batchDeleteSystemConfig(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
SystemConfigExample example = new SystemConfigExample();
example.createCriteria().andIdIn(idList);
return systemConfigMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
SystemConfigExample example = new SystemConfigExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
List<SystemConfig> list = systemConfigMapper.selectByExample(example);
return list.size();
}
}
package com.jsh.erp.service.systemConfig;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.SystemConfig;
import com.jsh.erp.datasource.entities.SystemConfigExample;
import com.jsh.erp.datasource.mappers.SystemConfigMapper;
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 SystemConfigService {
private Logger logger = LoggerFactory.getLogger(SystemConfigService.class);
@Resource
private SystemConfigMapper systemConfigMapper;
public SystemConfig getSystemConfig(long id) {
return systemConfigMapper.selectByPrimaryKey(id);
}
public List<SystemConfig> getSystemConfig() {
SystemConfigExample example = new SystemConfigExample();
return systemConfigMapper.selectByExample(example);
}
public List<SystemConfig> select(int offset, int rows) {
return systemConfigMapper.selectByConditionSystemConfig(offset, rows);
}
public int countSystemConfig() {
return systemConfigMapper.countsBySystemConfig();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertSystemConfig(String beanJson, HttpServletRequest request) {
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
return systemConfigMapper.insertSelective(systemConfig);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateSystemConfig(String beanJson, Long id) {
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
systemConfig.setId(id);
return systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteSystemConfig(Long id) {
return systemConfigMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSystemConfig(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
SystemConfigExample example = new SystemConfigExample();
example.createCriteria().andIdIn(idList);
return systemConfigMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
SystemConfigExample example = new SystemConfigExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
List<SystemConfig> list = systemConfigMapper.selectByExample(example);
return list.size();
}
}

View File

@ -1,68 +1,73 @@
package com.jsh.erp.service.unit;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Unit;
import com.jsh.erp.datasource.entities.UnitExample;
import com.jsh.erp.datasource.mappers.UnitMapper;
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 UnitService {
private Logger logger = LoggerFactory.getLogger(UnitService.class);
@Resource
private UnitMapper unitMapper;
public Unit getUnit(long id) {
return unitMapper.selectByPrimaryKey(id);
}
public List<Unit> getUnit() {
UnitExample example = new UnitExample();
return unitMapper.selectByExample(example);
}
public List<Unit> select(String name, int offset, int rows) {
return unitMapper.selectByConditionUnit(name, offset, rows);
}
public int countUnit(String name) {
return unitMapper.countsByUnit(name);
}
public int insertUnit(String beanJson, HttpServletRequest request) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
return unitMapper.insertSelective(unit);
}
public int updateUnit(String beanJson, Long id) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
unit.setId(id);
return unitMapper.updateByPrimaryKeySelective(unit);
}
public int deleteUnit(Long id) {
return unitMapper.deleteByPrimaryKey(id);
}
public int batchDeleteUnit(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UnitExample example = new UnitExample();
example.createCriteria().andIdIn(idList);
return unitMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
UnitExample example = new UnitExample();
example.createCriteria().andIdNotEqualTo(id).andUnameEqualTo(name);
List<Unit> list = unitMapper.selectByExample(example);
return list.size();
}
}
package com.jsh.erp.service.unit;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Unit;
import com.jsh.erp.datasource.entities.UnitExample;
import com.jsh.erp.datasource.mappers.UnitMapper;
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 UnitService {
private Logger logger = LoggerFactory.getLogger(UnitService.class);
@Resource
private UnitMapper unitMapper;
public Unit getUnit(long id) {
return unitMapper.selectByPrimaryKey(id);
}
public List<Unit> getUnit() {
UnitExample example = new UnitExample();
return unitMapper.selectByExample(example);
}
public List<Unit> select(String name, int offset, int rows) {
return unitMapper.selectByConditionUnit(name, offset, rows);
}
public int countUnit(String name) {
return unitMapper.countsByUnit(name);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUnit(String beanJson, HttpServletRequest request) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
return unitMapper.insertSelective(unit);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUnit(String beanJson, Long id) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
unit.setId(id);
return unitMapper.updateByPrimaryKeySelective(unit);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUnit(Long id) {
return unitMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUnit(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UnitExample example = new UnitExample();
example.createCriteria().andIdIn(idList);
return unitMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
UnitExample example = new UnitExample();
example.createCriteria().andIdNotEqualTo(id).andUnameEqualTo(name);
List<Unit> list = unitMapper.selectByExample(example);
return list.size();
}
}

View File

@ -1,133 +1,171 @@
package com.jsh.erp.service.user;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.mappers.UserMapper;
import com.jsh.erp.utils.*;
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;
import java.util.Map;
@Service
public class UserService {
private Logger logger = LoggerFactory.getLogger(UserService.class);
@Resource
private UserMapper userMapper;
public User getUser(long id) {
return userMapper.selectByPrimaryKey(id);
}
public List<User> getUser() {
UserExample example = new UserExample();
return userMapper.selectByExample(example);
}
public List<User> select(String userName, String loginName, int offset, int rows) {
return userMapper.selectByConditionUser(userName, loginName, offset, rows);
}
public int countUser(String userName, String loginName) {
return userMapper.countsByUser(userName, loginName);
}
public int insertUser(String beanJson, HttpServletRequest request) {
User user = JSONObject.parseObject(beanJson, User.class);
String password = "123456";
//因密码用MD5加密需要对密码进行转化
try {
password = Tools.md5Encryp(password);
user.setPassword(password);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 " + e.getMessage());
}
return userMapper.insertSelective(user);
}
public int updateUser(String beanJson, Long id) {
User user = JSONObject.parseObject(beanJson, User.class);
user.setId(id);
return userMapper.updateByPrimaryKeySelective(user);
}
public int updateUserByObj(User user) {
return userMapper.updateByPrimaryKeySelective(user);
}
public int resetPwd(String md5Pwd, Long id) {
User user = new User();
user.setId(id);
user.setPassword(md5Pwd);
return userMapper.updateByPrimaryKeySelective(user);
}
public int deleteUser(Long id) {
return userMapper.deleteByPrimaryKey(id);
}
public int batchDeleteUser(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UserExample example = new UserExample();
example.createCriteria().andIdIn(idList);
return userMapper.deleteByExample(example);
}
public int validateUser(String username, String password) throws JshException {
try {
/**默认是可以登录的*/
List<User> list = null;
try {
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username);
list = userMapper.selectByExample(example);
} catch (Exception e) {
logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
}
if (null != list && list.size() == 0) {
return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST;
}
try {
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username).andPasswordEqualTo(password);
list = userMapper.selectByExample(example);
} catch (Exception e) {
logger.error(">>>>>>>>>>访问验证用户密码后台信息异常", e);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
}
if (null != list && list.size() == 0) {
return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR;
}
return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT;
} catch (Exception e) {
throw new JshException("unknown exception", e);
}
}
public User getUserByUserName(String username) {
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username);
List<User> list = userMapper.selectByExample(example);
User user = list.get(0);
return user;
}
public int checkIsNameExist(Long id, String name) {
UserExample example = new UserExample();
example.createCriteria().andIdNotEqualTo(id).andLoginameEqualTo(name);
List<User> list = userMapper.selectByExample(example);
return list.size();
}
}
package com.jsh.erp.service.user;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.mappers.UserMapper;
import com.jsh.erp.utils.*;
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;
import java.util.Map;
@Service
public class UserService {
private Logger logger = LoggerFactory.getLogger(UserService.class);
@Resource
private UserMapper userMapper;
public User getUser(long id) {
return userMapper.selectByPrimaryKey(id);
}
public List<User> getUser() {
UserExample example = new UserExample();
return userMapper.selectByExample(example);
}
public List<User> select(String userName, String loginName, int offset, int rows) {
return userMapper.selectByConditionUser(userName, loginName, offset, rows);
}
public int countUser(String userName, String loginName) {
return userMapper.countsByUser(userName, loginName);
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:30
* @Param: beanJson
 * @Param: request
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUser(String beanJson, HttpServletRequest request) {
User user = JSONObject.parseObject(beanJson, User.class);
String password = "123456";
//因密码用MD5加密需要对密码进行转化
try {
password = Tools.md5Encryp(password);
user.setPassword(password);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 " + e.getMessage());
}
return userMapper.insertSelective(user);
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:31
* @Param: beanJson
 * @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUser(String beanJson, Long id) {
User user = JSONObject.parseObject(beanJson, User.class);
user.setId(id);
return userMapper.updateByPrimaryKeySelective(user);
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:32
* @Param: user
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserByObj(User user) {
return userMapper.updateByPrimaryKeySelective(user);
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:33
* @Param: md5Pwd
 * @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int resetPwd(String md5Pwd, Long id) {
User user = new User();
user.setId(id);
user.setPassword(md5Pwd);
return userMapper.updateByPrimaryKeySelective(user);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUser(Long id) {
return userMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUser(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UserExample example = new UserExample();
example.createCriteria().andIdIn(idList);
return userMapper.deleteByExample(example);
}
public int validateUser(String username, String password) throws JshException {
try {
/**默认是可以登录的*/
List<User> list = null;
try {
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username);
list = userMapper.selectByExample(example);
} catch (Exception e) {
logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
}
if (null != list && list.size() == 0) {
return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST;
}
try {
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username).andPasswordEqualTo(password);
list = userMapper.selectByExample(example);
} catch (Exception e) {
logger.error(">>>>>>>>>>访问验证用户密码后台信息异常", e);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
}
if (null != list && list.size() == 0) {
return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR;
}
return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT;
} catch (Exception e) {
throw new JshException("unknown exception", e);
}
}
public User getUserByUserName(String username) {
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username);
List<User> list = userMapper.selectByExample(example);
User user = list.get(0);
return user;
}
public int checkIsNameExist(Long id, String name) {
UserExample example = new UserExample();
example.createCriteria().andIdNotEqualTo(id).andLoginameEqualTo(name);
List<User> list = userMapper.selectByExample(example);
return list.size();
}
}

View File

@ -1,100 +1,106 @@
package com.jsh.erp.service.userBusiness;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.UserBusiness;
import com.jsh.erp.datasource.entities.UserBusinessExample;
import com.jsh.erp.datasource.mappers.UserBusinessMapper;
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 UserBusinessService {
private Logger logger = LoggerFactory.getLogger(UserBusinessService.class);
@Resource
private UserBusinessMapper userBusinessMapper;
public UserBusiness getUserBusiness(long id) {
return userBusinessMapper.selectByPrimaryKey(id);
}
public List<UserBusiness> getUserBusiness() {
UserBusinessExample example = new UserBusinessExample();
return userBusinessMapper.selectByExample(example);
}
public int insertUserBusiness(String beanJson, HttpServletRequest request) {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
return userBusinessMapper.insertSelective(userBusiness);
}
public int updateUserBusiness(String beanJson, Long id) {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
userBusiness.setId(id);
return userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
}
public int deleteUserBusiness(Long id) {
return userBusinessMapper.deleteByPrimaryKey(id);
}
public int batchDeleteUserBusiness(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andIdIn(idList);
return userBusinessMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
return 1;
}
public List<UserBusiness> getBasicData(String keyId, String type){
UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type);
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
return list;
}
public Long checkIsValueExist(String type, String keyId) {
UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId);
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
Long id = null;
if(list.size() > 0) {
id = list.get(0).getId();
}
return id;
}
public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue) {
UserBusinessExample example = new UserBusinessExample();
String newVaule = "%" + UBValue + "%";
if(TypeVale !=null && KeyIdValue !=null) {
example.createCriteria().andTypeEqualTo(TypeVale).andKeyidEqualTo(KeyIdValue).andValueLike(newVaule);
} else {
example.createCriteria().andValueLike(newVaule);
}
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
if(list.size() > 0) {
return true;
} else {
return false;
}
}
public int updateBtnStr(Long userBusinessId, String btnStr) {
UserBusiness userBusiness = new UserBusiness();
userBusiness.setBtnstr(btnStr);
UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andIdEqualTo(userBusinessId);
return userBusinessMapper.updateByExampleSelective(userBusiness, example);
}
}
package com.jsh.erp.service.userBusiness;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.UserBusiness;
import com.jsh.erp.datasource.entities.UserBusinessExample;
import com.jsh.erp.datasource.mappers.UserBusinessMapper;
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 UserBusinessService {
private Logger logger = LoggerFactory.getLogger(UserBusinessService.class);
@Resource
private UserBusinessMapper userBusinessMapper;
public UserBusiness getUserBusiness(long id) {
return userBusinessMapper.selectByPrimaryKey(id);
}
public List<UserBusiness> getUserBusiness() {
UserBusinessExample example = new UserBusinessExample();
return userBusinessMapper.selectByExample(example);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUserBusiness(String beanJson, HttpServletRequest request) {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
return userBusinessMapper.insertSelective(userBusiness);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserBusiness(String beanJson, Long id) {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
userBusiness.setId(id);
return userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUserBusiness(Long id) {
return userBusinessMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUserBusiness(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andIdIn(idList);
return userBusinessMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
return 1;
}
public List<UserBusiness> getBasicData(String keyId, String type){
UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type);
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
return list;
}
public Long checkIsValueExist(String type, String keyId) {
UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId);
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
Long id = null;
if(list.size() > 0) {
id = list.get(0).getId();
}
return id;
}
public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue) {
UserBusinessExample example = new UserBusinessExample();
String newVaule = "%" + UBValue + "%";
if(TypeVale !=null && KeyIdValue !=null) {
example.createCriteria().andTypeEqualTo(TypeVale).andKeyidEqualTo(KeyIdValue).andValueLike(newVaule);
} else {
example.createCriteria().andValueLike(newVaule);
}
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
if(list.size() > 0) {
return true;
} else {
return false;
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateBtnStr(Long userBusinessId, String btnStr) {
UserBusiness userBusiness = new UserBusiness();
userBusiness.setBtnstr(btnStr);
UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andIdEqualTo(userBusinessId);
return userBusinessMapper.updateByExampleSelective(userBusiness, example);
}
}