添加事务控制

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"/> <link href="/js/HoorayOS_mini/img/ui/index.css" rel="stylesheet"/>
<style> <style>
#user-name-span{ #user-name-span{
text-align:left; text-align:center;
color:white; color:white;
position:absolute; position:absolute;
top:435px; top:435px;

View File

@ -1,149 +1,149 @@
package com.jsh.erp.controller; package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.AccountHead; import com.jsh.erp.datasource.entities.AccountHead;
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx; import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
import com.jsh.erp.service.accountHead.AccountHeadService; import com.jsh.erp.service.accountHead.AccountHeadService;
import com.jsh.erp.utils.BaseResponseInfo; import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo; import com.jsh.erp.utils.ErpInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson; import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
/** /**
* @author jishenghua 752*718*920 * @author jishenghua 752*718*920
*/ */
@RestController @RestController
@RequestMapping(value = "/accountHead") @RequestMapping(value = "/accountHead")
public class AccountHeadController { public class AccountHeadController {
private Logger logger = LoggerFactory.getLogger(AccountHeadController.class); private Logger logger = LoggerFactory.getLogger(AccountHeadController.class);
@Resource @Resource
private AccountHeadService accountHeadService; private AccountHeadService accountHeadService;
/** /**
* 获取最大的id * 获取最大的id
* @param request * @param request
* @return * @return
*/ */
@GetMapping(value = "/getMaxId") @GetMapping(value = "/getMaxId")
public BaseResponseInfo getMaxId(HttpServletRequest request) { public BaseResponseInfo getMaxId(HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
Long maxId = accountHeadService.getMaxId(); Long maxId = accountHeadService.getMaxId();
map.put("maxId", maxId); map.put("maxId", maxId);
res.code = 200; res.code = 200;
res.data = map; res.data = map;
} catch(Exception e){ } catch(Exception e){
e.printStackTrace(); e.printStackTrace();
res.code = 500; res.code = 500;
res.data = "获取数据失败"; res.data = "获取数据失败";
} }
return res; return res;
} }
/** /**
* 查询单位的累计应收和累计应付收预付款不计入此处 * 查询单位的累计应收和累计应付收预付款不计入此处
* @param supplierId * @param supplierId
* @param endTime * @param endTime
* @param supType * @param supType
* @param request * @param request
* @return * @return
*/ */
@GetMapping(value = "/findTotalPay") @GetMapping(value = "/findTotalPay")
public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId, public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId,
@RequestParam("endTime") String endTime, @RequestParam("endTime") String endTime,
@RequestParam("supType") String supType, @RequestParam("supType") String supType,
HttpServletRequest request) { HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
JSONObject outer = new JSONObject(); JSONObject outer = new JSONObject();
Double sum = 0.0; Double sum = 0.0;
String getS = supplierId.toString(); String getS = supplierId.toString();
int i = 1; int i = 1;
if (supType.equals("customer")) { //客户 if (supType.equals("customer")) { //客户
i = 1; i = 1;
} else if (supType.equals("vendor")) { //供应商 } else if (supType.equals("vendor")) { //供应商
i = -1; i = -1;
} }
//收付款部分 //收付款部分
sum = sum + (allMoney(getS, "付款", "合计",endTime) + allMoney(getS, "付款", "实际",endTime)) * i; sum = sum + (allMoney(getS, "付款", "合计",endTime) + allMoney(getS, "付款", "实际",endTime)) * i;
sum = sum - (allMoney(getS, "收款", "合计",endTime) + allMoney(getS, "收款", "实际",endTime)) * i; sum = sum - (allMoney(getS, "收款", "合计",endTime) + allMoney(getS, "收款", "实际",endTime)) * i;
sum = sum + (allMoney(getS, "收入", "合计",endTime) - allMoney(getS, "收入", "实际",endTime)) * i; sum = sum + (allMoney(getS, "收入", "合计",endTime) - allMoney(getS, "收入", "实际",endTime)) * i;
sum = sum - (allMoney(getS, "支出", "合计",endTime) - allMoney(getS, "支出", "实际",endTime)) * i; sum = sum - (allMoney(getS, "支出", "合计",endTime) - allMoney(getS, "支出", "实际",endTime)) * i;
outer.put("getAllMoney", sum); outer.put("getAllMoney", sum);
map.put("rows", outer); map.put("rows", outer);
res.code = 200; res.code = 200;
res.data = map; res.data = map;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
res.code = 500; res.code = 500;
res.data = "获取数据失败"; res.data = "获取数据失败";
} }
return res; return res;
} }
/** /**
* 根据编号查询单据信息 * 根据编号查询单据信息
* @param number * @param billNo
* @param request * @param request
* @return * @return
*/ */
@GetMapping(value = "/getDetailByNumber") @GetMapping(value = "/getDetailByNumber")
public BaseResponseInfo getDetailByNumber(@RequestParam("billNo") String billNo, public BaseResponseInfo getDetailByNumber(@RequestParam("billNo") String billNo,
HttpServletRequest request) { HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx(); AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx();
try { try {
List<AccountHeadVo4ListEx> list = accountHeadService.getDetailByNumber(billNo); List<AccountHeadVo4ListEx> list = accountHeadService.getDetailByNumber(billNo);
if(list.size() == 1) { if(list.size() == 1) {
ahl = list.get(0); ahl = list.get(0);
} }
res.code = 200; res.code = 200;
res.data = ahl; res.data = ahl;
} catch(Exception e){ } catch(Exception e){
e.printStackTrace(); e.printStackTrace();
res.code = 500; res.code = 500;
res.data = "获取数据失败"; res.data = "获取数据失败";
} }
return res; return res;
} }
/** /**
* 统计总金额 * 统计总金额
* @param getS * @param getS
* @param type * @param type
* @param subType * @param mode 合计或者金额
* @param mode 合计或者金额 * @param endTime
* @return * @return
*/ */
public Double allMoney(String getS, String type, String mode, String endTime) { public Double allMoney(String getS, String type, String mode, String endTime) {
Double allMoney = 0.0; Double allMoney = 0.0;
try { try {
Integer supplierId = Integer.valueOf(getS); Integer supplierId = Integer.valueOf(getS);
Double sum = accountHeadService.findAllMoney(supplierId, type, mode, endTime); Double sum = accountHeadService.findAllMoney(supplierId, type, mode, endTime);
if(sum != null) { if(sum != null) {
allMoney = sum; allMoney = sum;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
//返回正数如果负数也转为正数 //返回正数如果负数也转为正数
if (allMoney < 0) { if (allMoney < 0) {
allMoney = -allMoney; allMoney = -allMoney;
} }
return allMoney; return allMoney;
} }
} }

View File

@ -1,150 +1,106 @@
package com.jsh.erp.controller; package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.AccountItem; import com.jsh.erp.datasource.entities.AccountItem;
import com.jsh.erp.datasource.vo.AccountItemVo4List; import com.jsh.erp.datasource.vo.AccountItemVo4List;
import com.jsh.erp.service.accountItem.AccountItemService; import com.jsh.erp.service.accountItem.AccountItemService;
import com.jsh.erp.utils.*; import com.jsh.erp.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.web.bind.annotation.*; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.io.IOException; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.io.IOException;
import java.util.HashMap; import java.util.ArrayList;
import java.util.List; import java.util.HashMap;
import java.util.Map; import java.util.List;
import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
/**
* @author ji sheng hua 752*718*920 /**
*/ * @author ji sheng hua 752*718*920
@RestController */
@RequestMapping(value = "/accountItem") @RestController
public class AccountItemController { @RequestMapping(value = "/accountItem")
private Logger logger = LoggerFactory.getLogger(AccountItemController.class); public class AccountItemController {
private Logger logger = LoggerFactory.getLogger(AccountItemController.class);
@Resource
private AccountItemService accountItemService; @Resource
private AccountItemService accountItemService;
@PostMapping(value = "/saveDetials") /**
public String saveDetials(@RequestParam("inserted") String inserted, * create by: cjl
@RequestParam("deleted") String deleted, * description:
@RequestParam("updated") String updated, * 业务逻辑操作放在service层controller只做参数解析和视图封装
@RequestParam("headerId") Long headerId, * create time: 2019/1/11 15:08
@RequestParam("listType") String listType, * @Param: inserted
HttpServletRequest request) {  * @Param: deleted
Map<String, Object> objectMap = new HashMap<String, Object>();  * @Param: updated
try {  * @Param: headerId
//转为json  * @Param: listType
JSONArray insertedJson = JSONArray.parseArray(inserted);  * @Param: request
JSONArray deletedJson = JSONArray.parseArray(deleted); * @return java.lang.String
JSONArray updatedJson = JSONArray.parseArray(updated); */
if (null != insertedJson) { @PostMapping(value = "/saveDetials")
for (int i = 0; i < insertedJson.size(); i++) { public String saveDetials(@RequestParam("inserted") String inserted,
AccountItem accountItem = new AccountItem(); @RequestParam("deleted") String deleted,
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i)); @RequestParam("updated") String updated,
accountItem.setHeaderid(headerId); @RequestParam("headerId") Long headerId,
if (tempInsertedJson.get("AccountId") != null && !tempInsertedJson.get("AccountId").equals("")) { @RequestParam("listType") String listType,
accountItem.setAccountid(tempInsertedJson.getLong("AccountId")); HttpServletRequest request) {
}
if (tempInsertedJson.get("InOutItemId") != null && !tempInsertedJson.get("InOutItemId").equals("")) { Map<String, Object> objectMap = new HashMap<String, Object>();
accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId")); try {
} accountItemService.saveDetials(inserted,deleted,updated,headerId,listType);
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) { return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
Double eachAmount = tempInsertedJson.getDouble("EachAmount"); } catch (DataAccessException e) {
if (listType.equals("付款")) { e.printStackTrace();
eachAmount = 0 - eachAmount; logger.error(">>>>>>>>>>>>>>>>>>>保存明细信息异常", e);
} return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
accountItem.setEachamount(eachAmount); }
} else { }
accountItem.setEachamount(0.0);
} @GetMapping(value = "/getDetailList")
accountItem.setRemark(tempInsertedJson.getString("Remark")); public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
accountItemService.insertAccountItemWithObj(accountItem); HttpServletRequest request) {
} BaseResponseInfo res = new BaseResponseInfo();
} Map<String, Object> map = new HashMap<String, Object>();
if (null != deletedJson) { try {
for (int i = 0; i < deletedJson.size(); i++) { List<AccountItemVo4List> dataList = new ArrayList<AccountItemVo4List>();
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i)); if(headerId != 0) {
accountItemService.deleteAccountItem(tempDeletedJson.getLong("Id")); dataList = accountItemService.getDetailList(headerId);
} }
} JSONObject outer = new JSONObject();
if (null != updatedJson) { outer.put("total", dataList.size());
for (int i = 0; i < updatedJson.size(); i++) { //存放数据json数组
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i)); JSONArray dataArray = new JSONArray();
AccountItem accountItem = accountItemService.getAccountItem(tempUpdatedJson.getLong("Id")); if (null != dataList) {
accountItem.setId(tempUpdatedJson.getLong("Id")); for (AccountItemVo4List ai : dataList) {
accountItem.setHeaderid(headerId); JSONObject item = new JSONObject();
if (tempUpdatedJson.get("AccountId") != null && !tempUpdatedJson.get("AccountId").equals("")) { item.put("Id", ai.getId());
accountItem.setAccountid(tempUpdatedJson.getLong("AccountId")); item.put("AccountId", ai.getAccountid());
} item.put("AccountName", ai.getAccountName());
if (tempUpdatedJson.get("InOutItemId") != null && !tempUpdatedJson.get("InOutItemId").equals("")) { item.put("InOutItemId", ai.getInoutitemid());
accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId")); item.put("InOutItemName", ai.getInOutItemName());
} Double eachAmount = ai.getEachamount();
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) { item.put("EachAmount", eachAmount < 0 ? 0 - eachAmount : eachAmount);
Double eachAmount = tempUpdatedJson.getDouble("EachAmount"); item.put("Remark", ai.getRemark());
if (listType.equals("付款")) { dataArray.add(item);
eachAmount = 0 - eachAmount; }
} }
accountItem.setEachamount(eachAmount); outer.put("rows", dataArray);
} else { res.code = 200;
accountItem.setEachamount(0.0); res.data = outer;
} } catch (Exception e) {
accountItem.setRemark(tempUpdatedJson.getString("Remark")); e.printStackTrace();
accountItemService.updateAccountItemWithObj(accountItem); res.code = 500;
} res.data = "获取数据失败";
} }
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); return res;
} catch (DataAccessException e) { }
e.printStackTrace();
logger.error(">>>>>>>>>>>>>>>>>>>保存明细信息异常", e); }
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
@GetMapping(value = "/getDetailList")
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<AccountItemVo4List> dataList = new ArrayList<AccountItemVo4List>();
if(headerId != 0) {
dataList = accountItemService.getDetailList(headerId);
}
JSONObject outer = new JSONObject();
outer.put("total", dataList.size());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (AccountItemVo4List ai : dataList) {
JSONObject item = new JSONObject();
item.put("Id", ai.getId());
item.put("AccountId", ai.getAccountid());
item.put("AccountName", ai.getAccountName());
item.put("InOutItemId", ai.getInoutitemid());
item.put("InOutItemName", ai.getInOutItemName());
Double eachAmount = ai.getEachamount();
item.put("EachAmount", eachAmount < 0 ? 0 - eachAmount : eachAmount);
item.put("Remark", ai.getRemark());
dataArray.add(item);
}
}
outer.put("rows", dataArray);
res.code = 200;
res.data = outer;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,127 +1,132 @@
package com.jsh.erp.service; package com.jsh.erp.service;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.ArrayList; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.ArrayList;
import java.util.Map; import java.util.List;
import java.util.Map;
/**
* @author jishenghua 752718920 2018-10-7 15:25:58 /**
*/ * @author jishenghua 752718920 2018-10-7 15:25:58
@Service */
public class CommonQueryManager { @Service
public class CommonQueryManager {
@Resource
private InterfaceContainer container; @Resource
private InterfaceContainer container;
/**
* 查询单条 /**
* * 查询单条
* @param apiName 接口名称 *
* @param id ID * @param apiName 接口名称
*/ * @param id ID
public Object selectOne(String apiName, String id) { */
if (StringUtil.isNotEmpty(apiName) && StringUtil.isNotEmpty(id)) { public Object selectOne(String apiName, String id) {
return container.getCommonQuery(apiName).selectOne(id); if (StringUtil.isNotEmpty(apiName) && StringUtil.isNotEmpty(id)) {
} return container.getCommonQuery(apiName).selectOne(id);
return null; }
} return null;
}
/**
* 查询 /**
* @param apiName * 查询
* @param parameterMap * @param apiName
* @return * @param parameterMap
*/ * @return
public List<?> select(String apiName, Map<String, String> parameterMap) { */
if (StringUtil.isNotEmpty(apiName)) { public List<?> select(String apiName, Map<String, String> parameterMap) {
return container.getCommonQuery(apiName).select(parameterMap); if (StringUtil.isNotEmpty(apiName)) {
} return container.getCommonQuery(apiName).select(parameterMap);
return new ArrayList<Object>(); }
} return new ArrayList<Object>();
}
/**
* 计数 /**
* @param apiName * 计数
* @param parameterMap * @param apiName
* @return * @param parameterMap
*/ * @return
public int counts(String apiName, Map<String, String> parameterMap) { */
if (StringUtil.isNotEmpty(apiName)) { public int counts(String apiName, Map<String, String> parameterMap) {
return container.getCommonQuery(apiName).counts(parameterMap); if (StringUtil.isNotEmpty(apiName)) {
} return container.getCommonQuery(apiName).counts(parameterMap);
return 0; }
} return 0;
}
/**
* 插入 /**
* @param apiName * 插入
* @param beanJson * @param apiName
* @return * @param beanJson
*/ * @return
public int insert(String apiName, String beanJson, HttpServletRequest request) { */
if (StringUtil.isNotEmpty(apiName)) { @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return container.getCommonQuery(apiName).insert(beanJson, request); public int insert(String apiName, String beanJson, HttpServletRequest request) {
} if (StringUtil.isNotEmpty(apiName)) {
return 0; return container.getCommonQuery(apiName).insert(beanJson, request);
} }
return 0;
/** }
* 更新
* @param apiName /**
* @param beanJson * 更新
* @param id * @param apiName
* @return * @param beanJson
*/ * @param id
public int update(String apiName, String beanJson, Long id) { * @return
if (StringUtil.isNotEmpty(apiName)) { */
return container.getCommonQuery(apiName).update(beanJson, id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int update(String apiName, String beanJson, Long id) {
return 0; if (StringUtil.isNotEmpty(apiName)) {
} return container.getCommonQuery(apiName).update(beanJson, id);
}
/** return 0;
* 删除 }
* @param apiName
* @param id /**
* @return * 删除
*/ * @param apiName
public int delete(String apiName, Long id) { * @param id
if (StringUtil.isNotEmpty(apiName)) { * @return
return container.getCommonQuery(apiName).delete(id); */
} @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return 0; public int delete(String apiName, Long id) {
} if (StringUtil.isNotEmpty(apiName)) {
return container.getCommonQuery(apiName).delete(id);
/** }
* 批量删除 return 0;
* @param apiName }
* @param ids
* @return /**
*/ * 批量删除
public int batchDelete(String apiName, String ids) { * @param apiName
if (StringUtil.isNotEmpty(apiName)) { * @param ids
return container.getCommonQuery(apiName).batchDelete(ids); * @return
} */
return 0; @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDelete(String apiName, String ids) {
if (StringUtil.isNotEmpty(apiName)) {
/** return container.getCommonQuery(apiName).batchDelete(ids);
* 判断是否存在 }
* @param apiName return 0;
* @param id }
* @param name
* @return /**
*/ * 判断是否存在
public int checkIsNameExist(String apiName, Long id, String name) { * @param apiName
if (StringUtil.isNotEmpty(apiName)) { * @param id
return container.getCommonQuery(apiName).checkIsNameExist(id, name); * @param name
} * @return
return 0; */
} public int checkIsNameExist(String apiName, Long id, String name) {
if (StringUtil.isNotEmpty(apiName)) {
return container.getCommonQuery(apiName).checkIsNameExist(id, name);
}
return 0;
}
} }

View File

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

View File

@ -1,81 +1,158 @@
package com.jsh.erp.service.accountItem; package com.jsh.erp.service.accountItem;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONArray;
import com.jsh.erp.datasource.entities.AccountItem; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.AccountItemExample; import com.jsh.erp.datasource.entities.AccountItem;
import com.jsh.erp.datasource.mappers.AccountItemMapper; import com.jsh.erp.datasource.entities.AccountItemExample;
import com.jsh.erp.datasource.vo.AccountItemVo4List; import com.jsh.erp.datasource.mappers.AccountItemMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.datasource.vo.AccountItemVo4List;
import org.slf4j.Logger; import com.jsh.erp.utils.ErpInfo;
import org.slf4j.LoggerFactory; import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource; import org.springframework.dao.DataAccessException;
import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Service;
import java.util.List; import org.springframework.transaction.annotation.Transactional;
@Service import javax.annotation.Resource;
public class AccountItemService { import javax.servlet.http.HttpServletRequest;
private Logger logger = LoggerFactory.getLogger(AccountItemService.class); import java.util.List;
@Resource import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
private AccountItemMapper accountItemMapper;
@Service
public AccountItem getAccountItem(long id) { public class AccountItemService {
return accountItemMapper.selectByPrimaryKey(id); private Logger logger = LoggerFactory.getLogger(AccountItemService.class);
}
@Resource
public List<AccountItem> getAccountItem() { private AccountItemMapper accountItemMapper;
AccountItemExample example = new AccountItemExample();
return accountItemMapper.selectByExample(example); public AccountItem getAccountItem(long id) {
} return accountItemMapper.selectByPrimaryKey(id);
}
public List<AccountItem> select(String name, Integer type, String remark, int offset, int rows) {
return accountItemMapper.selectByConditionAccountItem(name, type, remark, offset, rows); public List<AccountItem> getAccountItem() {
} AccountItemExample example = new AccountItemExample();
return accountItemMapper.selectByExample(example);
public int countAccountItem(String name, Integer type, String remark) { }
return accountItemMapper.countsByAccountItem(name, type, remark);
} public List<AccountItem> select(String name, Integer type, String remark, int offset, int rows) {
return accountItemMapper.selectByConditionAccountItem(name, type, remark, offset, rows);
public int insertAccountItem(String beanJson, HttpServletRequest request) { }
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
return accountItemMapper.insertSelective(accountItem); public int countAccountItem(String name, Integer type, String remark) {
} return accountItemMapper.countsByAccountItem(name, type, remark);
}
public int updateAccountItem(String beanJson, Long id) {
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
accountItem.setId(id); public int insertAccountItem(String beanJson, HttpServletRequest request) {
return accountItemMapper.updateByPrimaryKeySelective(accountItem); AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
} return accountItemMapper.insertSelective(accountItem);
}
public int deleteAccountItem(Long id) {
return accountItemMapper.deleteByPrimaryKey(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int updateAccountItem(String beanJson, Long id) {
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
public int batchDeleteAccountItem(String ids) { accountItem.setId(id);
List<Long> idList = StringUtil.strToLongList(ids); return accountItemMapper.updateByPrimaryKeySelective(accountItem);
AccountItemExample example = new AccountItemExample(); }
example.createCriteria().andIdIn(idList);
return accountItemMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int deleteAccountItem(Long id) {
return accountItemMapper.deleteByPrimaryKey(id);
public int checkIsNameExist(Long id, String name) { }
AccountItemExample example = new AccountItemExample();
example.createCriteria().andIdNotEqualTo(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
List<AccountItem> list = accountItemMapper.selectByExample(example); public int batchDeleteAccountItem(String ids) {
return list.size(); List<Long> idList = StringUtil.strToLongList(ids);
} AccountItemExample example = new AccountItemExample();
example.createCriteria().andIdIn(idList);
public int insertAccountItemWithObj(AccountItem accountItem) { return accountItemMapper.deleteByExample(example);
return accountItemMapper.insertSelective(accountItem); }
}
public int checkIsNameExist(Long id, String name) {
public int updateAccountItemWithObj(AccountItem accountItem) { AccountItemExample example = new AccountItemExample();
return accountItemMapper.updateByPrimaryKeySelective(accountItem); example.createCriteria().andIdNotEqualTo(id);
} List<AccountItem> list = accountItemMapper.selectByExample(example);
return list.size();
public List<AccountItemVo4List> getDetailList(Long headerId) { }
return accountItemMapper.getDetailList(headerId);
} @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int insertAccountItemWithObj(AccountItem accountItem) {
return accountItemMapper.insertSelective(accountItem);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAccountItemWithObj(AccountItem accountItem) {
return accountItemMapper.updateByPrimaryKeySelective(accountItem);
}
public List<AccountItemVo4List> getDetailList(Long headerId) {
return accountItemMapper.getDetailList(headerId);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String saveDetials(String inserted, String deleted, String updated, Long headerId, String listType) throws DataAccessException {
//转为json
JSONArray insertedJson = JSONArray.parseArray(inserted);
JSONArray deletedJson = JSONArray.parseArray(deleted);
JSONArray updatedJson = JSONArray.parseArray(updated);
if (null != insertedJson) {
for (int i = 0; i < insertedJson.size(); i++) {
AccountItem accountItem = new AccountItem();
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
accountItem.setHeaderid(headerId);
if (tempInsertedJson.get("AccountId") != null && !tempInsertedJson.get("AccountId").equals("")) {
accountItem.setAccountid(tempInsertedJson.getLong("AccountId"));
}
if (tempInsertedJson.get("InOutItemId") != null && !tempInsertedJson.get("InOutItemId").equals("")) {
accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId"));
}
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) {
Double eachAmount = tempInsertedJson.getDouble("EachAmount");
if (listType.equals("付款")) {
eachAmount = 0 - eachAmount;
}
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(0.0);
}
accountItem.setRemark(tempInsertedJson.getString("Remark"));
this.insertAccountItemWithObj(accountItem);
}
}
if (null != deletedJson) {
for (int i = 0; i < deletedJson.size(); i++) {
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
this.deleteAccountItem(tempDeletedJson.getLong("Id"));
}
}
if (null != updatedJson) {
for (int i = 0; i < updatedJson.size(); i++) {
JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
AccountItem accountItem = this.getAccountItem(tempUpdatedJson.getLong("Id"));
accountItem.setId(tempUpdatedJson.getLong("Id"));
accountItem.setHeaderid(headerId);
if (tempUpdatedJson.get("AccountId") != null && !tempUpdatedJson.get("AccountId").equals("")) {
accountItem.setAccountid(tempUpdatedJson.getLong("AccountId"));
}
if (tempUpdatedJson.get("InOutItemId") != null && !tempUpdatedJson.get("InOutItemId").equals("")) {
accountItem.setInoutitemid(tempUpdatedJson.getLong("InOutItemId"));
}
if (tempUpdatedJson.get("EachAmount") != null && !tempUpdatedJson.get("EachAmount").equals("")) {
Double eachAmount = tempUpdatedJson.getDouble("EachAmount");
if (listType.equals("付款")) {
eachAmount = 0 - eachAmount;
}
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(0.0);
}
accountItem.setRemark(tempUpdatedJson.getString("Remark"));
this.updateAccountItemWithObj(accountItem);
}
}
return null;
}
}

View File

@ -1,85 +1,90 @@
package com.jsh.erp.service.app; package com.jsh.erp.service.app;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.App; import com.jsh.erp.datasource.entities.App;
import com.jsh.erp.datasource.entities.AppExample; import com.jsh.erp.datasource.entities.AppExample;
import com.jsh.erp.datasource.mappers.AppMapper; import com.jsh.erp.datasource.mappers.AppMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class AppService { @Service
private Logger logger = LoggerFactory.getLogger(AppService.class); public class AppService {
private Logger logger = LoggerFactory.getLogger(AppService.class);
@Resource
private AppMapper appMapper; @Resource
private AppMapper appMapper;
public List<App> findDock(){
AppExample example = new AppExample(); public List<App> findDock(){
example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true); AppExample example = new AppExample();
example.setOrderByClause("Sort"); example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true);
List<App> list = appMapper.selectByExample(example); example.setOrderByClause("Sort");
return list; List<App> list = appMapper.selectByExample(example);
} return list;
}
public List<App> findDesk(){
AppExample example = new AppExample(); public List<App> findDesk(){
example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true); AppExample example = new AppExample();
example.setOrderByClause("Sort"); example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true);
List<App> list = appMapper.selectByExample(example); example.setOrderByClause("Sort");
return list; List<App> list = appMapper.selectByExample(example);
} return list;
}
public App getApp(long id) {
return appMapper.selectByPrimaryKey(id); public App getApp(long id) {
} return appMapper.selectByPrimaryKey(id);
}
public List<App> getApp() {
AppExample example = new AppExample(); public List<App> getApp() {
return appMapper.selectByExample(example); AppExample example = new AppExample();
} return appMapper.selectByExample(example);
}
public List<App> select(String name, String type, int offset, int rows) {
return appMapper.selectByConditionApp(name, type, offset, rows); public List<App> select(String name, String type, int offset, int rows) {
} return appMapper.selectByConditionApp(name, type, offset, rows);
}
public int countApp(String name, String type) {
return appMapper.countsByApp(name, type); public int countApp(String name, String type) {
} return appMapper.countsByApp(name, type);
}
public int insertApp(String beanJson, HttpServletRequest request) {
App app = JSONObject.parseObject(beanJson, App.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return appMapper.insertSelective(app); public int insertApp(String beanJson, HttpServletRequest request) {
} App app = JSONObject.parseObject(beanJson, App.class);
return appMapper.insertSelective(app);
public int updateApp(String beanJson, Long id) { }
App app = JSONObject.parseObject(beanJson, App.class);
app.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return appMapper.updateByPrimaryKeySelective(app); public int updateApp(String beanJson, Long id) {
} App app = JSONObject.parseObject(beanJson, App.class);
app.setId(id);
public int deleteApp(Long id) { return appMapper.updateByPrimaryKeySelective(app);
return appMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteApp(String ids) { public int deleteApp(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return appMapper.deleteByPrimaryKey(id);
AppExample example = new AppExample(); }
example.createCriteria().andIdIn(idList);
return appMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteApp(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public List<App> findRoleAPP(){ AppExample example = new AppExample();
AppExample example = new AppExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andEnabledEqualTo(true); return appMapper.deleteByExample(example);
example.setOrderByClause("Sort"); }
List<App> list = appMapper.selectByExample(example);
return list; public List<App> findRoleAPP(){
} AppExample example = new AppExample();
} example.createCriteria().andEnabledEqualTo(true);
example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example);
return list;
}
}

View File

@ -1,91 +1,96 @@
package com.jsh.erp.service.depot; package com.jsh.erp.service.depot;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Depot; import com.jsh.erp.datasource.entities.Depot;
import com.jsh.erp.datasource.entities.DepotExample; import com.jsh.erp.datasource.entities.DepotExample;
import com.jsh.erp.datasource.mappers.DepotMapper; import com.jsh.erp.datasource.mappers.DepotMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class DepotService { @Service
private Logger logger = LoggerFactory.getLogger(DepotService.class); public class DepotService {
private Logger logger = LoggerFactory.getLogger(DepotService.class);
@Resource
private DepotMapper depotMapper; @Resource
private DepotMapper depotMapper;
public Depot getDepot(long id) {
return depotMapper.selectByPrimaryKey(id); public Depot getDepot(long id) {
} return depotMapper.selectByPrimaryKey(id);
}
public List<Depot> getDepot() {
DepotExample example = new DepotExample(); public List<Depot> getDepot() {
return depotMapper.selectByExample(example); DepotExample example = new DepotExample();
} return depotMapper.selectByExample(example);
}
public List<Depot> getAllList() {
DepotExample example = new DepotExample(); public List<Depot> getAllList() {
example.setOrderByClause("sort"); DepotExample example = new DepotExample();
return depotMapper.selectByExample(example); example.setOrderByClause("sort");
} return depotMapper.selectByExample(example);
}
public List<Depot> select(String name, Integer type, String remark, int offset, int rows) {
return depotMapper.selectByConditionDepot(name, type, remark, offset, rows); public List<Depot> select(String name, Integer type, String remark, int offset, int rows) {
} return depotMapper.selectByConditionDepot(name, type, remark, offset, rows);
}
public int countDepot(String name, Integer type, String remark) {
return depotMapper.countsByDepot(name, type, remark); public int countDepot(String name, Integer type, String remark) {
} return depotMapper.countsByDepot(name, type, remark);
}
public int insertDepot(String beanJson, HttpServletRequest request) {
Depot depot = JSONObject.parseObject(beanJson, Depot.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return depotMapper.insertSelective(depot); public int insertDepot(String beanJson, HttpServletRequest request) {
} Depot depot = JSONObject.parseObject(beanJson, Depot.class);
return depotMapper.insertSelective(depot);
public int updateDepot(String beanJson, Long id) { }
Depot depot = JSONObject.parseObject(beanJson, Depot.class);
depot.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return depotMapper.updateByPrimaryKeySelective(depot); public int updateDepot(String beanJson, Long id) {
} Depot depot = JSONObject.parseObject(beanJson, Depot.class);
depot.setId(id);
public int deleteDepot(Long id) { return depotMapper.updateByPrimaryKeySelective(depot);
return depotMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepot(String ids) { public int deleteDepot(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return depotMapper.deleteByPrimaryKey(id);
DepotExample example = new DepotExample(); }
example.createCriteria().andIdIn(idList);
return depotMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteDepot(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { DepotExample example = new DepotExample();
DepotExample example = new DepotExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name); return depotMapper.deleteByExample(example);
List<Depot> list = depotMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
DepotExample example = new DepotExample();
public List<Depot> findUserDepot(){ example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
DepotExample example = new DepotExample(); List<Depot> list = depotMapper.selectByExample(example);
example.createCriteria().andTypeEqualTo(0); return list.size();
example.setOrderByClause("Sort"); }
List<Depot> list = depotMapper.selectByExample(example);
return list; public List<Depot> findUserDepot(){
} DepotExample example = new DepotExample();
example.createCriteria().andTypeEqualTo(0);
public List<Depot> findGiftByType(Integer type){ example.setOrderByClause("Sort");
DepotExample example = new DepotExample(); List<Depot> list = depotMapper.selectByExample(example);
example.createCriteria().andTypeEqualTo(type); return list;
example.setOrderByClause("Sort"); }
List<Depot> list = depotMapper.selectByExample(example);
return list; public List<Depot> findGiftByType(Integer type){
} DepotExample example = new DepotExample();
example.createCriteria().andTypeEqualTo(type);
} example.setOrderByClause("Sort");
List<Depot> list = depotMapper.selectByExample(example);
return list;
}
}

View File

@ -1,242 +1,248 @@
package com.jsh.erp.service.depotHead; package com.jsh.erp.service.depotHead;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.DepotHead; import com.jsh.erp.datasource.entities.DepotHead;
import com.jsh.erp.datasource.entities.DepotHeadExample; import com.jsh.erp.datasource.entities.DepotHeadExample;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.DepotHeadMapper; import com.jsh.erp.datasource.mappers.DepotHeadMapper;
import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail; import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail;
import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount; import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount;
import com.jsh.erp.datasource.vo.DepotHeadVo4List; import com.jsh.erp.datasource.vo.DepotHeadVo4List;
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount; import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.sql.Timestamp; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.sql.Timestamp;
import java.util.Date; import java.util.ArrayList;
import java.util.List; import java.util.Date;
import java.util.List;
@Service
public class DepotHeadService { @Service
private Logger logger = LoggerFactory.getLogger(DepotHeadService.class); public class DepotHeadService {
private Logger logger = LoggerFactory.getLogger(DepotHeadService.class);
@Resource
private DepotHeadMapper depotHeadMapper; @Resource
private DepotHeadMapper depotHeadMapper;
public DepotHead getDepotHead(long id) {
return depotHeadMapper.selectByPrimaryKey(id); public DepotHead getDepotHead(long id) {
} return depotHeadMapper.selectByPrimaryKey(id);
}
public List<DepotHead> getDepotHead() {
DepotHeadExample example = new DepotHeadExample(); public List<DepotHead> getDepotHead() {
return depotHeadMapper.selectByExample(example); 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>(); public List<DepotHeadVo4List> select(String type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows) {
List<DepotHeadVo4List> list = depotHeadMapper.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows); List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
if (null != list) { List<DepotHeadVo4List> list = depotHeadMapper.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows);
for (DepotHeadVo4List dh : list) { if (null != list) {
if(dh.getOthermoneylist() != null) { for (DepotHeadVo4List dh : list) {
String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", ""); if(dh.getOthermoneylist() != null) {
dh.setOthermoneylist(otherMoneyListStr); String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", "");
} dh.setOthermoneylist(otherMoneyListStr);
if(dh.getOthermoneyitem() != null) { }
String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", ""); if(dh.getOthermoneyitem() != null) {
dh.setOthermoneyitem(otherMoneyItemStr); String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", "");
} dh.setOthermoneyitem(otherMoneyItemStr);
if(dh.getChangeamount() != null) { }
dh.setChangeamount(Math.abs(dh.getChangeamount())); if(dh.getChangeamount() != null) {
} dh.setChangeamount(Math.abs(dh.getChangeamount()));
if(dh.getTotalprice() != null) { }
dh.setTotalprice(Math.abs(dh.getTotalprice())); if(dh.getTotalprice() != null) {
} dh.setTotalprice(Math.abs(dh.getTotalprice()));
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId())); }
resList.add(dh); dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
} resList.add(dh);
} }
return resList; }
} 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 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
//判断用户是否已经登录过登录过不再处理 public int insertDepotHead(String beanJson, HttpServletRequest request) {
Object userInfo = request.getSession().getAttribute("user"); DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
if (userInfo != null) { //判断用户是否已经登录过登录过不再处理
User sessionUser = (User) userInfo; Object userInfo = request.getSession().getAttribute("user");
String uName = sessionUser.getUsername(); if (userInfo != null) {
depotHead.setOperpersonname(uName); User sessionUser = (User) userInfo;
} String uName = sessionUser.getUsername();
depotHead.setCreatetime(new Timestamp(System.currentTimeMillis())); depotHead.setOperpersonname(uName);
depotHead.setStatus(false); }
return depotHeadMapper.insertSelective(depotHead); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return depotHeadMapper.updateByPrimaryKeySelective(depotHead); public int updateDepotHead(String beanJson, Long id) {
} DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
depotHead.setId(id);
public int deleteDepotHead(Long id) { return depotHeadMapper.updateByPrimaryKeySelective(depotHead);
return depotHeadMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotHead(String ids) { public int deleteDepotHead(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return depotHeadMapper.deleteByPrimaryKey(id);
DepotHeadExample example = new DepotHeadExample(); }
example.createCriteria().andIdIn(idList);
return depotHeadMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteDepotHead(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { DepotHeadExample example = new DepotHeadExample();
DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id); return depotHeadMapper.deleteByExample(example);
List<DepotHead> list = depotHeadMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
DepotHeadExample example = new DepotHeadExample();
public int batchSetStatus(Boolean status, String depotHeadIDs) { example.createCriteria().andIdNotEqualTo(id);
List<Long> ids = StringUtil.strToLongList(depotHeadIDs); List<DepotHead> list = depotHeadMapper.selectByExample(example);
DepotHead depotHead = new DepotHead(); return list.size();
depotHead.setStatus(status); }
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(ids); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return depotHeadMapper.updateByExampleSelective(depotHead, example); public int batchSetStatus(Boolean status, String depotHeadIDs) {
} List<Long> ids = StringUtil.strToLongList(depotHeadIDs);
DepotHead depotHead = new DepotHead();
public String buildNumber(String type, String subType, String beginTime, String endTime) { depotHead.setStatus(status);
String newNumber = "0001"; //新编号 DepotHeadExample example = new DepotHeadExample();
try { example.createCriteria().andIdIn(ids);
DepotHeadExample example = new DepotHeadExample(); return depotHeadMapper.updateByExampleSelective(depotHead, example);
example.createCriteria().andTypeEqualTo(type).andSubtypeEqualTo(subType) }
.andOpertimeGreaterThanOrEqualTo(StringUtil.getDateByString(beginTime,null))
.andOpertimeLessThanOrEqualTo(StringUtil.getDateByString(endTime,null)); public String buildNumber(String type, String subType, String beginTime, String endTime) {
example.setOrderByClause("Id desc"); String newNumber = "0001"; //新编号
List<DepotHead> dataList = depotHeadMapper.selectByExample(example); try {
//存放数据json数组 DepotHeadExample example = new DepotHeadExample();
if (null != dataList && dataList.size() > 0) { example.createCriteria().andTypeEqualTo(type).andSubtypeEqualTo(subType)
DepotHead depotHead = dataList.get(0); .andOpertimeGreaterThanOrEqualTo(StringUtil.getDateByString(beginTime,null))
if (depotHead != null) { .andOpertimeLessThanOrEqualTo(StringUtil.getDateByString(endTime,null));
String number = depotHead.getDefaultnumber(); //最大的单据编号 example.setOrderByClause("Id desc");
if (number != null) { List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
Integer lastNumber = Integer.parseInt(number.substring(12, 16)); //末四尾 //存放数据json数组
lastNumber = lastNumber + 1; if (null != dataList && dataList.size() > 0) {
Integer nLen = lastNumber.toString().length(); DepotHead depotHead = dataList.get(0);
if (nLen == 1) { if (depotHead != null) {
newNumber = "000" + lastNumber.toString(); String number = depotHead.getDefaultnumber(); //最大的单据编号
} else if (nLen == 2) { if (number != null) {
newNumber = "00" + lastNumber.toString(); Integer lastNumber = Integer.parseInt(number.substring(12, 16)); //末四尾
} else if (nLen == 3) { lastNumber = lastNumber + 1;
newNumber = "0" + lastNumber.toString(); Integer nLen = lastNumber.toString().length();
} else if (nLen == 4) { if (nLen == 1) {
newNumber = lastNumber.toString(); newNumber = "000" + lastNumber.toString();
} } else if (nLen == 2) {
} newNumber = "00" + lastNumber.toString();
} } else if (nLen == 3) {
} newNumber = "0" + lastNumber.toString();
} catch (DataAccessException e) { } else if (nLen == 4) {
logger.error(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e); newNumber = lastNumber.toString();
} }
return newNumber; }
} }
}
public Long getMaxId() { } catch (DataAccessException e) {
return depotHeadMapper.getMaxId(); logger.error(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e);
} }
return newNumber;
public String findMaterialsListByHeaderId(Long id) { }
String allReturn = depotHeadMapper.findMaterialsListByHeaderId(id);
return allReturn; public Long getMaxId() {
} return depotHeadMapper.getMaxId();
}
public List<DepotHead> findByMonth(String monthTime) {
DepotHeadExample example = new DepotHeadExample(); public String findMaterialsListByHeaderId(Long id) {
monthTime = monthTime + "-31 00:00:00"; String allReturn = depotHeadMapper.findMaterialsListByHeaderId(id);
Date month = StringUtil.getDateByString(monthTime, null); return allReturn;
example.createCriteria().andOpertimeLessThanOrEqualTo(month); }
return depotHeadMapper.selectByExample(example);
} public List<DepotHead> findByMonth(String monthTime) {
DepotHeadExample example = new DepotHeadExample();
public List<DepotHead> getDepotHeadGiftOut(String projectId) { monthTime = monthTime + "-31 00:00:00";
DepotHeadExample example = new DepotHeadExample(); Date month = StringUtil.getDateByString(monthTime, null);
if (projectId != null) { example.createCriteria().andOpertimeLessThanOrEqualTo(month);
example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId)); return depotHeadMapper.selectByExample(example);
} }
return depotHeadMapper.selectByExample(example);
} public List<DepotHead> getDepotHeadGiftOut(String projectId) {
DepotHeadExample example = new DepotHeadExample();
public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) { if (projectId != null) {
return depotHeadMapper.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows); example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId));
} }
return depotHeadMapper.selectByExample(example);
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<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 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 findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) {
return depotHeadMapper.findByAllCount(beginTime, endTime, type, pid, dids, oId);
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<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 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 findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) {
return depotHeadMapper.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId);
public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) { }
return depotHeadMapper.findStatementAccountCount(beginTime, endTime, organId, supType);
} 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 Double findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) { }
String modeName = "";
if (mode.equals("实际")) { public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) {
modeName = "ChangeAmount"; return depotHeadMapper.findStatementAccountCount(beginTime, endTime, organId, supType);
} else if (mode.equals("合计")) { }
modeName = "DiscountLastMoney";
} public Double findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) {
return depotHeadMapper.findAllMoney(supplierId, type, subType, modeName, endTime); String modeName = "";
} if (mode.equals("实际")) {
modeName = "ChangeAmount";
public List<DepotHeadVo4List> getDetailByNumber(String number) { } else if (mode.equals("合计")) {
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>(); modeName = "DiscountLastMoney";
List<DepotHeadVo4List> list = depotHeadMapper.getDetailByNumber(number); }
if (null != list) { return depotHeadMapper.findAllMoney(supplierId, type, subType, modeName, endTime);
for (DepotHeadVo4List dh : list) { }
if(dh.getOthermoneylist() != null) {
String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", ""); public List<DepotHeadVo4List> getDetailByNumber(String number) {
dh.setOthermoneylist(otherMoneyListStr); List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
} List<DepotHeadVo4List> list = depotHeadMapper.getDetailByNumber(number);
if(dh.getOthermoneyitem() != null) { if (null != list) {
String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", ""); for (DepotHeadVo4List dh : list) {
dh.setOthermoneyitem(otherMoneyItemStr); if(dh.getOthermoneylist() != null) {
} String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", "");
if(dh.getChangeamount() != null) { dh.setOthermoneylist(otherMoneyListStr);
dh.setChangeamount(Math.abs(dh.getChangeamount())); }
} if(dh.getOthermoneyitem() != null) {
if(dh.getTotalprice() != null) { String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", "");
dh.setTotalprice(Math.abs(dh.getTotalprice())); dh.setOthermoneyitem(otherMoneyItemStr);
} }
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId())); if(dh.getChangeamount() != null) {
resList.add(dh); dh.setChangeamount(Math.abs(dh.getChangeamount()));
} }
} if(dh.getTotalprice() != null) {
return resList; 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; package com.jsh.erp.service.depotItem;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONArray;
import com.jsh.erp.datasource.entities.*; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.mappers.DepotItemMapper; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.utils.QueryUtils; import com.jsh.erp.datasource.mappers.DepotItemMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.service.material.MaterialService;
import org.slf4j.Logger; import com.jsh.erp.utils.ErpInfo;
import org.slf4j.LoggerFactory; import com.jsh.erp.utils.QueryUtils;
import org.springframework.stereotype.Service; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import javax.annotation.Resource; import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest; import org.springframework.dao.DataAccessException;
import java.util.List; import org.springframework.stereotype.Service;
import java.util.Map; import org.springframework.transaction.annotation.Transactional;
@Service import javax.annotation.Resource;
public class DepotItemService { import javax.servlet.http.HttpServletRequest;
private Logger logger = LoggerFactory.getLogger(DepotItemService.class); import java.util.List;
import java.util.Map;
private final static String TYPE = "入库";
private final static String SUM_TYPE = "Number"; import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
private final static String IN = "in";
private final static String OUT = "out"; @Service
public class DepotItemService {
@Resource private Logger logger = LoggerFactory.getLogger(DepotItemService.class);
private DepotItemMapper depotItemMapper;
private final static String TYPE = "入库";
public DepotItem getDepotItem(long id) { private final static String SUM_TYPE = "Number";
return depotItemMapper.selectByPrimaryKey(id); private final static String IN = "in";
} private final static String OUT = "out";
public List<DepotItem> getDepotItem() { @Resource
DepotItemExample example = new DepotItemExample(); private DepotItemMapper depotItemMapper;
return depotItemMapper.selectByExample(example); @Resource
} private MaterialService materialService;
public List<DepotItem> select(String name, Integer type, String remark, int offset, int rows) { public DepotItem getDepotItem(long id) {
return depotItemMapper.selectByConditionDepotItem(name, type, remark, offset, rows); return depotItemMapper.selectByPrimaryKey(id);
} }
public int countDepotItem(String name, Integer type, String remark) { public List<DepotItem> getDepotItem() {
return depotItemMapper.countsByDepotItem(name, type, remark); DepotItemExample example = new DepotItemExample();
} return depotItemMapper.selectByExample(example);
}
public int insertDepotItem(String beanJson, HttpServletRequest request) {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class); public List<DepotItem> select(String name, Integer type, String remark, int offset, int rows) {
return depotItemMapper.insertSelective(depotItem); return depotItemMapper.selectByConditionDepotItem(name, type, remark, offset, rows);
} }
public int updateDepotItem(String beanJson, Long id) { public int countDepotItem(String name, Integer type, String remark) {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class); return depotItemMapper.countsByDepotItem(name, type, remark);
depotItem.setId(id); }
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
} @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotItem(String beanJson, HttpServletRequest request) {
public int deleteDepotItem(Long id) { DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
return depotItemMapper.deleteByPrimaryKey(id); return depotItemMapper.insertSelective(depotItem);
} }
public int batchDeleteDepotItem(String ids) { @Transactional(value = "transactionManager", rollbackFor = Exception.class)
List<Long> idList = StringUtil.strToLongList(ids); public int updateDepotItem(String beanJson, Long id) {
DepotItemExample example = new DepotItemExample(); DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
example.createCriteria().andIdIn(idList); depotItem.setId(id);
return depotItemMapper.deleteByExample(example); return depotItemMapper.updateByPrimaryKeySelective(depotItem);
} }
public int checkIsNameExist(Long id, String name) { @Transactional(value = "transactionManager", rollbackFor = Exception.class)
DepotItemExample example = new DepotItemExample(); public int deleteDepotItem(Long id) {
example.createCriteria().andIdNotEqualTo(id); return depotItemMapper.deleteByPrimaryKey(id);
List<DepotItem> list = depotItemMapper.selectByExample(example); }
return list.size();
} @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotItem(String ids) {
public List<DepotItemVo4HeaderId> getHeaderIdByMaterial(String materialParam, String depotIds) { List<Long> idList = StringUtil.strToLongList(ids);
return depotItemMapper.getHeaderIdByMaterial(materialParam, depotIds); DepotItemExample example = new DepotItemExample();
} example.createCriteria().andIdIn(idList);
return depotItemMapper.deleteByExample(example);
public List<DepotItemVo4DetailByTypeAndMId> findDetailByTypeAndMaterialIdList(Map<String, String> map) { }
String mIdStr = map.get("mId");
Long mId = null; public int checkIsNameExist(Long id, String name) {
if(!StringUtil.isEmpty(mIdStr)) { DepotItemExample example = new DepotItemExample();
mId = Long.parseLong(mIdStr); example.createCriteria().andIdNotEqualTo(id);
} List<DepotItem> list = depotItemMapper.selectByExample(example);
return depotItemMapper.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map)); return list.size();
} }
public int findDetailByTypeAndMaterialIdCounts(Map<String, String> map) { public List<DepotItemVo4HeaderId> getHeaderIdByMaterial(String materialParam, String depotIds) {
String mIdStr = map.get("mId"); return depotItemMapper.getHeaderIdByMaterial(materialParam, depotIds);
Long mId = null; }
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr); public List<DepotItemVo4DetailByTypeAndMId> findDetailByTypeAndMaterialIdList(Map<String, String> map) {
} String mIdStr = map.get("mId");
return depotItemMapper.findDetailByTypeAndMaterialIdCounts(mId); Long mId = null;
} if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
public List<DepotItemVo4Material> findStockNumByMaterialIdList(Map<String, String> map) { }
String mIdStr = map.get("mId"); return depotItemMapper.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map));
Long mId = null; }
if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr); public int findDetailByTypeAndMaterialIdCounts(Map<String, String> map) {
} String mIdStr = map.get("mId");
String monthTime = map.get("monthTime"); Long mId = null;
return depotItemMapper.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map)); if(!StringUtil.isEmpty(mIdStr)) {
} mId = Long.parseLong(mIdStr);
}
public int findStockNumByMaterialIdCounts(Map<String, String> map) { return depotItemMapper.findDetailByTypeAndMaterialIdCounts(mId);
String mIdStr = map.get("mId"); }
Long mId = null;
if(!StringUtil.isEmpty(mIdStr)) { public List<DepotItemVo4Material> findStockNumByMaterialIdList(Map<String, String> map) {
mId = Long.parseLong(mIdStr); String mIdStr = map.get("mId");
} Long mId = null;
String monthTime = map.get("monthTime"); if(!StringUtil.isEmpty(mIdStr)) {
return depotItemMapper.findStockNumByMaterialIdCounts(mId, monthTime); mId = Long.parseLong(mIdStr);
} }
String monthTime = map.get("monthTime");
public int insertDepotItemWithObj(DepotItem depotItem) { return depotItemMapper.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map));
return depotItemMapper.insertSelective(depotItem); }
}
public int findStockNumByMaterialIdCounts(Map<String, String> map) {
public int updateDepotItemWithObj(DepotItem depotItem) { String mIdStr = map.get("mId");
return depotItemMapper.updateByPrimaryKeySelective(depotItem); Long mId = null;
} if(!StringUtil.isEmpty(mIdStr)) {
mId = Long.parseLong(mIdStr);
public int findByTypeAndMaterialId(String type, Long mId) { }
if(type.equals(TYPE)) { String monthTime = map.get("monthTime");
return depotItemMapper.findByTypeAndMaterialIdIn(mId); return depotItemMapper.findStockNumByMaterialIdCounts(mId, monthTime);
} else { }
return depotItemMapper.findByTypeAndMaterialIdOut(mId);
} @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int insertDepotItemWithObj(DepotItem depotItem) {
return depotItemMapper.insertSelective(depotItem);
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId) { }
return depotItemMapper.getDetailList(headerId);
} @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotItemWithObj(DepotItem depotItem) {
public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows) { return depotItemMapper.updateByPrimaryKeySelective(depotItem);
return depotItemMapper.findByAll(headIds, materialIds, offset, rows); }
}
public int findByTypeAndMaterialId(String type, Long mId) {
public int findByAllCount(String headIds, String materialIds) { if(type.equals(TYPE)) {
return depotItemMapper.findByAllCount(headIds, materialIds); return depotItemMapper.findByTypeAndMaterialIdIn(mId);
} } else {
return depotItemMapper.findByTypeAndMaterialIdOut(mId);
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); public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId) {
} else { return depotItemMapper.getDetailList(headerId);
return depotItemMapper.findByTypeInIsNotPrev(ProjectId, MId, MonthTime); }
}
} else { public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows) {
if (isPrev) { return depotItemMapper.findByAll(headIds, materialIds, offset, rows);
return depotItemMapper.findByTypeOutIsPrev(ProjectId, MId, MonthTime); }
} else {
return depotItemMapper.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime); 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) {
public Double findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) { if (TYPE.equals(type)) {
if (TYPE.equals(type)) { if (isPrev) {
if (isPrev) { return depotItemMapper.findByTypeInIsPrev(ProjectId, MId, MonthTime);
return depotItemMapper.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime); } else {
} else { return depotItemMapper.findByTypeInIsNotPrev(ProjectId, MId, MonthTime);
return depotItemMapper.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime); }
} } else {
} else { if (isPrev) {
if (isPrev) { return depotItemMapper.findByTypeOutIsPrev(ProjectId, MId, MonthTime);
return depotItemMapper.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime); } else {
} else { return depotItemMapper.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
return depotItemMapper.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime); }
} }
} }
}
public Double findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
public Double buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) { if (TYPE.equals(type)) {
if (SUM_TYPE.equals(sumType)) { if (isPrev) {
return depotItemMapper.buyOrSaleNumber(type, subType, MId, MonthTime, sumType); return depotItemMapper.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime);
} else { } else {
return depotItemMapper.buyOrSalePrice(type, subType, MId, MonthTime, sumType); return depotItemMapper.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime);
} }
} } else {
if (isPrev) {
public Double findGiftByType(String subType, Integer ProjectId, Long MId, String type) { return depotItemMapper.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime);
if (IN.equals(type)) { } else {
return depotItemMapper.findGiftByTypeIn(subType, ProjectId, MId); return depotItemMapper.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
} else { }
return depotItemMapper.findGiftByTypeOut(subType, ProjectId, MId); }
} }
}
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; package com.jsh.erp.service.functions;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Functions; import com.jsh.erp.datasource.entities.Functions;
import com.jsh.erp.datasource.entities.FunctionsExample; import com.jsh.erp.datasource.entities.FunctionsExample;
import com.jsh.erp.datasource.mappers.FunctionsMapper; import com.jsh.erp.datasource.mappers.FunctionsMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class FunctionsService { @Service
private Logger logger = LoggerFactory.getLogger(FunctionsService.class); public class FunctionsService {
private Logger logger = LoggerFactory.getLogger(FunctionsService.class);
@Resource
private FunctionsMapper functionsMapper; @Resource
private FunctionsMapper functionsMapper;
public Functions getFunctions(long id) {
return functionsMapper.selectByPrimaryKey(id); public Functions getFunctions(long id) {
} return functionsMapper.selectByPrimaryKey(id);
}
public List<Functions> getFunctions() {
FunctionsExample example = new FunctionsExample(); public List<Functions> getFunctions() {
return functionsMapper.selectByExample(example); FunctionsExample example = new FunctionsExample();
} return functionsMapper.selectByExample(example);
}
public List<Functions> select(String name, String type, int offset, int rows) {
return functionsMapper.selectByConditionFunctions(name, type, offset, rows); public List<Functions> select(String name, String type, int offset, int rows) {
} return functionsMapper.selectByConditionFunctions(name, type, offset, rows);
}
public int countFunctions(String name, String type) {
return functionsMapper.countsByFunctions(name, type); public int countFunctions(String name, String type) {
} return functionsMapper.countsByFunctions(name, type);
}
public int insertFunctions(String beanJson, HttpServletRequest request) {
Functions depot = JSONObject.parseObject(beanJson, Functions.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return functionsMapper.insertSelective(depot); public int insertFunctions(String beanJson, HttpServletRequest request) {
} Functions depot = JSONObject.parseObject(beanJson, Functions.class);
return functionsMapper.insertSelective(depot);
public int updateFunctions(String beanJson, Long id) { }
Functions depot = JSONObject.parseObject(beanJson, Functions.class);
depot.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return functionsMapper.updateByPrimaryKeySelective(depot); public int updateFunctions(String beanJson, Long id) {
} Functions depot = JSONObject.parseObject(beanJson, Functions.class);
depot.setId(id);
public int deleteFunctions(Long id) { return functionsMapper.updateByPrimaryKeySelective(depot);
return functionsMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteFunctions(String ids) { public int deleteFunctions(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return functionsMapper.deleteByPrimaryKey(id);
FunctionsExample example = new FunctionsExample(); }
example.createCriteria().andIdIn(idList);
return functionsMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteFunctions(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { FunctionsExample example = new FunctionsExample();
FunctionsExample example = new FunctionsExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name); return functionsMapper.deleteByExample(example);
List<Functions> list = functionsMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
FunctionsExample example = new FunctionsExample();
public List<Functions> getRoleFunctions(String pNumber) { example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
FunctionsExample example = new FunctionsExample(); List<Functions> list = functionsMapper.selectByExample(example);
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pNumber); return list.size();
example.setOrderByClause("Sort"); }
List<Functions> list = functionsMapper.selectByExample(example);
return list; public List<Functions> getRoleFunctions(String pNumber) {
} FunctionsExample example = new FunctionsExample();
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pNumber);
public List<Functions> findRoleFunctions(String pnumber){ example.setOrderByClause("Sort");
FunctionsExample example = new FunctionsExample(); List<Functions> list = functionsMapper.selectByExample(example);
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pnumber); return list;
example.setOrderByClause("Sort"); }
List<Functions> list = functionsMapper.selectByExample(example);
return list; public List<Functions> findRoleFunctions(String pnumber){
} FunctionsExample example = new FunctionsExample();
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pnumber);
public List<Functions> findByIds(String functionsIds){ example.setOrderByClause("Sort");
List<Long> idList = StringUtil.strToLongList(functionsIds); List<Functions> list = functionsMapper.selectByExample(example);
FunctionsExample example = new FunctionsExample(); return list;
example.createCriteria().andEnabledEqualTo(true).andIdIn(idList); }
example.setOrderByClause("Sort asc");
List<Functions> list = functionsMapper.selectByExample(example); public List<Functions> findByIds(String functionsIds){
return list; List<Long> idList = StringUtil.strToLongList(functionsIds);
} FunctionsExample example = new FunctionsExample();
} example.createCriteria().andEnabledEqualTo(true).andIdIn(idList);
example.setOrderByClause("Sort asc");
List<Functions> list = functionsMapper.selectByExample(example);
return list;
}
}

View File

@ -1,79 +1,84 @@
package com.jsh.erp.service.inOutItem; package com.jsh.erp.service.inOutItem;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.InOutItem; import com.jsh.erp.datasource.entities.InOutItem;
import com.jsh.erp.datasource.entities.InOutItemExample; import com.jsh.erp.datasource.entities.InOutItemExample;
import com.jsh.erp.datasource.mappers.InOutItemMapper; import com.jsh.erp.datasource.mappers.InOutItemMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class InOutItemService { @Service
private Logger logger = LoggerFactory.getLogger(InOutItemService.class); public class InOutItemService {
private Logger logger = LoggerFactory.getLogger(InOutItemService.class);
@Resource
private InOutItemMapper inOutItemMapper; @Resource
private InOutItemMapper inOutItemMapper;
public InOutItem getInOutItem(long id) {
return inOutItemMapper.selectByPrimaryKey(id); public InOutItem getInOutItem(long id) {
} return inOutItemMapper.selectByPrimaryKey(id);
}
public List<InOutItem> getInOutItem() {
InOutItemExample example = new InOutItemExample(); public List<InOutItem> getInOutItem() {
return inOutItemMapper.selectByExample(example); InOutItemExample example = new InOutItemExample();
} return inOutItemMapper.selectByExample(example);
}
public List<InOutItem> select(String name, String type, String remark, int offset, int rows) {
return inOutItemMapper.selectByConditionInOutItem(name, type, remark, offset, rows); public List<InOutItem> select(String name, String type, String remark, int offset, int rows) {
} return inOutItemMapper.selectByConditionInOutItem(name, type, remark, offset, rows);
}
public int countInOutItem(String name, String type, String remark) {
return inOutItemMapper.countsByInOutItem(name, type, remark); public int countInOutItem(String name, String type, String remark) {
} return inOutItemMapper.countsByInOutItem(name, type, remark);
}
public int insertInOutItem(String beanJson, HttpServletRequest request) {
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return inOutItemMapper.insertSelective(depot); public int insertInOutItem(String beanJson, HttpServletRequest request) {
} InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
return inOutItemMapper.insertSelective(depot);
public int updateInOutItem(String beanJson, Long id) { }
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
depot.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return inOutItemMapper.updateByPrimaryKeySelective(depot); public int updateInOutItem(String beanJson, Long id) {
} InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
depot.setId(id);
public int deleteInOutItem(Long id) { return inOutItemMapper.updateByPrimaryKeySelective(depot);
return inOutItemMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteInOutItem(String ids) { public int deleteInOutItem(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return inOutItemMapper.deleteByPrimaryKey(id);
InOutItemExample example = new InOutItemExample(); }
example.createCriteria().andIdIn(idList);
return inOutItemMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteInOutItem(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { InOutItemExample example = new InOutItemExample();
InOutItemExample example = new InOutItemExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name); return inOutItemMapper.deleteByExample(example);
List<InOutItem> list = inOutItemMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
InOutItemExample example = new InOutItemExample();
public List<InOutItem> findBySelect(String type) { example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
InOutItemExample example = new InOutItemExample(); List<InOutItem> list = inOutItemMapper.selectByExample(example);
if (type.equals("in")) { return list.size();
example.createCriteria().andTypeEqualTo("收入"); }
} else if (type.equals("out")) {
example.createCriteria().andTypeEqualTo("支出"); public List<InOutItem> findBySelect(String type) {
} InOutItemExample example = new InOutItemExample();
example.setOrderByClause("id desc"); if (type.equals("in")) {
return inOutItemMapper.selectByExample(example); example.createCriteria().andTypeEqualTo("收入");
} } else if (type.equals("out")) {
} example.createCriteria().andTypeEqualTo("支出");
}
example.setOrderByClause("id desc");
return inOutItemMapper.selectByExample(example);
}
}

View File

@ -1,68 +1,73 @@
package com.jsh.erp.service.log; package com.jsh.erp.service.log;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Log; import com.jsh.erp.datasource.entities.Log;
import com.jsh.erp.datasource.entities.LogExample; import com.jsh.erp.datasource.entities.LogExample;
import com.jsh.erp.datasource.mappers.LogMapper; import com.jsh.erp.datasource.mappers.LogMapper;
import com.jsh.erp.utils.ExceptionCodeConstants; import com.jsh.erp.utils.ExceptionCodeConstants;
import com.jsh.erp.utils.JshException; import com.jsh.erp.utils.JshException;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools; import com.jsh.erp.utils.Tools;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.security.NoSuchAlgorithmException; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.security.NoSuchAlgorithmException;
import java.util.List;
@Service
public class LogService { @Service
private Logger logger = LoggerFactory.getLogger(LogService.class); public class LogService {
@Resource private Logger logger = LoggerFactory.getLogger(LogService.class);
private LogMapper logMapper; @Resource
private LogMapper logMapper;
public Log getLog(long id) {
return logMapper.selectByPrimaryKey(id); public Log getLog(long id) {
} return logMapper.selectByPrimaryKey(id);
}
public List<Log> getLog() {
LogExample example = new LogExample(); public List<Log> getLog() {
return logMapper.selectByExample(example); LogExample example = new LogExample();
} return logMapper.selectByExample(example);
}
public List<Log> select(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
String contentdetails, int offset, int rows) { public List<Log> select(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
return logMapper.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime, String contentdetails, int offset, int rows) {
contentdetails, offset, rows); return logMapper.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime,
} contentdetails, offset, rows);
}
public int countLog(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
String contentdetails) { public int countLog(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
return logMapper.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails); String contentdetails) {
} return logMapper.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails);
}
public int insertLog(String beanJson, HttpServletRequest request) {
Log log = JSONObject.parseObject(beanJson, Log.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return logMapper.insertSelective(log); public int insertLog(String beanJson, HttpServletRequest request) {
} Log log = JSONObject.parseObject(beanJson, Log.class);
return logMapper.insertSelective(log);
public int updateLog(String beanJson, Long id) { }
Log log = JSONObject.parseObject(beanJson, Log.class);
log.setId(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return logMapper.updateByPrimaryKeySelective(log); public int updateLog(String beanJson, Long id) {
} Log log = JSONObject.parseObject(beanJson, Log.class);
log.setId(id);
public int deleteLog(Long id) { return logMapper.updateByPrimaryKeySelective(log);
return logMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteLog(String ids) { public int deleteLog(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return logMapper.deleteByPrimaryKey(id);
LogExample example = new LogExample(); }
example.createCriteria().andIdIn(idList);
return logMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteLog(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
} LogExample example = new LogExample();
example.createCriteria().andIdIn(idList);
return logMapper.deleteByExample(example);
}
}

View File

@ -1,157 +1,163 @@
package com.jsh.erp.service.material; package com.jsh.erp.service.material;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Material; import com.jsh.erp.datasource.entities.Material;
import com.jsh.erp.datasource.entities.MaterialExample; import com.jsh.erp.datasource.entities.MaterialExample;
import com.jsh.erp.datasource.entities.MaterialVo4Unit; import com.jsh.erp.datasource.entities.MaterialVo4Unit;
import com.jsh.erp.datasource.mappers.MaterialMapper; import com.jsh.erp.datasource.mappers.MaterialMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.ArrayList; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.ArrayList;
import java.util.List;
@Service
public class MaterialService { @Service
private Logger logger = LoggerFactory.getLogger(MaterialService.class); public class MaterialService {
private Logger logger = LoggerFactory.getLogger(MaterialService.class);
@Resource
private MaterialMapper materialMapper; @Resource
private MaterialMapper materialMapper;
public Material getMaterial(long id) {
return materialMapper.selectByPrimaryKey(id); public Material getMaterial(long id) {
} return materialMapper.selectByPrimaryKey(id);
}
public List<Material> getMaterial() {
MaterialExample example = new MaterialExample(); public List<Material> getMaterial() {
return materialMapper.selectByExample(example); 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(","); public List<MaterialVo4Unit> select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows) {
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>(); String[] mpArr = mpList.split(",");
List<MaterialVo4Unit> list = materialMapper.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows); List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
if (null != list) { List<MaterialVo4Unit> list = materialMapper.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows);
for (MaterialVo4Unit m : list) { if (null != list) {
//扩展信息 for (MaterialVo4Unit m : list) {
String materialOther = ""; //扩展信息
for (int i = 0; i < mpArr.length; i++) { String materialOther = "";
if (mpArr[i].equals("颜色")) { for (int i = 0; i < mpArr.length; i++) {
materialOther = materialOther + ((m.getColor() == null || m.getColor().equals("")) ? "" : "(" + m.getColor() + ")"); 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.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("制造商")) {
} 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("自定义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("自定义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() + ")"); if (mpArr[i].equals("自定义3")) {
} materialOther = materialOther + ((m.getOtherfield3() == null || m.getOtherfield3().equals("")) ? "" : "(" + m.getOtherfield3() + ")");
} }
m.setMaterialOther(materialOther); }
resList.add(m); m.setMaterialOther(materialOther);
} resList.add(m);
} }
return resList; }
} 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 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
material.setEnabled(true); public int insertMaterial(String beanJson, HttpServletRequest request) {
return materialMapper.insertSelective(material); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
int res = materialMapper.updateByPrimaryKeySelective(material); public int updateMaterial(String beanJson, Long id) {
Long unitId = material.getUnitid(); Material material = JSONObject.parseObject(beanJson, Material.class);
if(unitId != null) { material.setId(id);
materialMapper.updatePriceNullByPrimaryKey(id); //将价格置空 int res = materialMapper.updateByPrimaryKeySelective(material);
} else { Long unitId = material.getUnitid();
materialMapper.updateUnitIdNullByPrimaryKey(id); //将多单位置空 if(unitId != null) {
} materialMapper.updatePriceNullByPrimaryKey(id); //将价格置空
return res; } else {
} materialMapper.updateUnitIdNullByPrimaryKey(id); //将多单位置空
}
public int deleteMaterial(Long id) { return res;
return materialMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterial(String ids) { public int deleteMaterial(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return materialMapper.deleteByPrimaryKey(id);
MaterialExample example = new MaterialExample(); }
example.createCriteria().andIdIn(idList);
return materialMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteMaterial(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { MaterialExample example = new MaterialExample();
MaterialExample example = new MaterialExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name); return materialMapper.deleteByExample(example);
List<Material> list = materialMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
MaterialExample example = new MaterialExample();
public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs, example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
String otherField1, String otherField2, String otherField3, String unit, Long unitId) { List<Material> list = materialMapper.selectByExample(example);
MaterialExample example = new MaterialExample(); return list.size();
MaterialExample.Criteria criteria = example.createCriteria(); }
criteria.andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color)
.andStandardEqualTo(standard).andMfrsEqualTo(mfrs) public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs,
.andOtherfield1EqualTo(otherField1).andOtherfield2EqualTo(otherField2).andOtherfield2EqualTo(otherField3); String otherField1, String otherField2, String otherField3, String unit, Long unitId) {
if (id > 0) { MaterialExample example = new MaterialExample();
criteria.andIdNotEqualTo(id); MaterialExample.Criteria criteria = example.createCriteria();
} criteria.andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color)
if (!StringUtil.isEmpty(unit)) { .andStandardEqualTo(standard).andMfrsEqualTo(mfrs)
criteria.andUnitEqualTo(unit); .andOtherfield1EqualTo(otherField1).andOtherfield2EqualTo(otherField2).andOtherfield2EqualTo(otherField3);
} if (id > 0) {
if (unitId !=null) { criteria.andIdNotEqualTo(id);
criteria.andUnitidEqualTo(unitId); }
} if (!StringUtil.isEmpty(unit)) {
List<Material> list = materialMapper.selectByExample(example); criteria.andUnitEqualTo(unit);
return list.size(); }
} if (unitId !=null) {
criteria.andUnitidEqualTo(unitId);
public int batchSetEnable(Boolean enabled, String materialIDs) { }
List<Long> ids = StringUtil.strToLongList(materialIDs); List<Material> list = materialMapper.selectByExample(example);
Material material = new Material(); return list.size();
material.setEnabled(enabled); }
MaterialExample example = new MaterialExample();
example.createCriteria().andIdIn(ids); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return materialMapper.updateByExampleSelective(material, example); public int batchSetEnable(Boolean enabled, String materialIDs) {
} List<Long> ids = StringUtil.strToLongList(materialIDs);
Material material = new Material();
public String findUnitName(Long mId){ material.setEnabled(enabled);
return materialMapper.findUnitName(mId); MaterialExample example = new MaterialExample();
} example.createCriteria().andIdIn(ids);
return materialMapper.updateByExampleSelective(material, example);
public List<MaterialVo4Unit> findById(Long id){ }
return materialMapper.findById(id);
} public String findUnitName(Long mId){
return materialMapper.findUnitName(mId);
public List<MaterialVo4Unit> findBySelect(){ }
return materialMapper.findBySelect();
} public List<MaterialVo4Unit> findById(Long id){
return materialMapper.findById(id);
public List<Material> findByOrder(){ }
MaterialExample example = new MaterialExample();
example.setOrderByClause("Name,Model asc"); public List<MaterialVo4Unit> findBySelect(){
return materialMapper.selectByExample(example); 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; package com.jsh.erp.service.materialCategory;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.MaterialCategory; import com.jsh.erp.datasource.entities.MaterialCategory;
import com.jsh.erp.datasource.entities.MaterialCategoryExample; import com.jsh.erp.datasource.entities.MaterialCategoryExample;
import com.jsh.erp.datasource.mappers.MaterialCategoryMapper; import com.jsh.erp.datasource.mappers.MaterialCategoryMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class MaterialCategoryService { @Service
private Logger logger = LoggerFactory.getLogger(MaterialCategoryService.class); public class MaterialCategoryService {
private Logger logger = LoggerFactory.getLogger(MaterialCategoryService.class);
@Resource
private MaterialCategoryMapper materialCategoryMapper; @Resource
private MaterialCategoryMapper materialCategoryMapper;
public MaterialCategory getMaterialCategory(long id) {
return materialCategoryMapper.selectByPrimaryKey(id); public MaterialCategory getMaterialCategory(long id) {
} return materialCategoryMapper.selectByPrimaryKey(id);
}
public List<MaterialCategory> getMaterialCategory() {
MaterialCategoryExample example = new MaterialCategoryExample(); public List<MaterialCategory> getMaterialCategory() {
return materialCategoryMapper.selectByExample(example); MaterialCategoryExample example = new MaterialCategoryExample();
} return materialCategoryMapper.selectByExample(example);
}
public List<MaterialCategory> getAllList(Long parentId) {
MaterialCategoryExample example = new MaterialCategoryExample(); public List<MaterialCategory> getAllList(Long parentId) {
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l); MaterialCategoryExample example = new MaterialCategoryExample();
example.setOrderByClause("id"); example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
return materialCategoryMapper.selectByExample(example); 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 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 countMaterialCategory(String name, Integer parentId) {
} return materialCategoryMapper.countsByMaterialCategory(name, parentId);
}
public int insertMaterialCategory(String beanJson, HttpServletRequest request) {
MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return materialCategoryMapper.insertSelective(materialCategory); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return materialCategoryMapper.updateByPrimaryKeySelective(materialCategory); public int updateMaterialCategory(String beanJson, Long id) {
} MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class);
materialCategory.setId(id);
public int deleteMaterialCategory(Long id) { return materialCategoryMapper.updateByPrimaryKeySelective(materialCategory);
return materialCategoryMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialCategory(String ids) { public int deleteMaterialCategory(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return materialCategoryMapper.deleteByPrimaryKey(id);
MaterialCategoryExample example = new MaterialCategoryExample(); }
example.createCriteria().andIdIn(idList);
return materialCategoryMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteMaterialCategory(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { MaterialCategoryExample example = new MaterialCategoryExample();
return 0; example.createCriteria().andIdIn(idList);
} return materialCategoryMapper.deleteByExample(example);
}
public List<MaterialCategory> findById(Long id) {
MaterialCategoryExample example = new MaterialCategoryExample(); public int checkIsNameExist(Long id, String name) {
example.createCriteria().andIdEqualTo(id); return 0;
return materialCategoryMapper.selectByExample(example); }
}
} 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; package com.jsh.erp.service.materialProperty;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.MaterialProperty; import com.jsh.erp.datasource.entities.MaterialProperty;
import com.jsh.erp.datasource.entities.MaterialPropertyExample; import com.jsh.erp.datasource.entities.MaterialPropertyExample;
import com.jsh.erp.datasource.mappers.MaterialPropertyMapper; import com.jsh.erp.datasource.mappers.MaterialPropertyMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class MaterialPropertyService { @Service
private Logger logger = LoggerFactory.getLogger(MaterialPropertyService.class); public class MaterialPropertyService {
private Logger logger = LoggerFactory.getLogger(MaterialPropertyService.class);
@Resource
private MaterialPropertyMapper materialPropertyMapper; @Resource
private MaterialPropertyMapper materialPropertyMapper;
public MaterialProperty getMaterialProperty(long id) {
return materialPropertyMapper.selectByPrimaryKey(id); public MaterialProperty getMaterialProperty(long id) {
} return materialPropertyMapper.selectByPrimaryKey(id);
}
public List<MaterialProperty> getMaterialProperty() {
MaterialPropertyExample example = new MaterialPropertyExample(); public List<MaterialProperty> getMaterialProperty() {
return materialPropertyMapper.selectByExample(example); 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 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 countMaterialProperty(String name) {
} return materialPropertyMapper.countsByMaterialProperty(name);
}
public int insertMaterialProperty(String beanJson, HttpServletRequest request) {
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return materialPropertyMapper.insertSelective(materialProperty); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return materialPropertyMapper.updateByPrimaryKeySelective(materialProperty); public int updateMaterialProperty(String beanJson, Long id) {
} MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
materialProperty.setId(id);
public int deleteMaterialProperty(Long id) { return materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
return materialPropertyMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialProperty(String ids) { public int deleteMaterialProperty(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return materialPropertyMapper.deleteByPrimaryKey(id);
MaterialPropertyExample example = new MaterialPropertyExample(); }
example.createCriteria().andIdIn(idList);
return materialPropertyMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteMaterialProperty(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { MaterialPropertyExample example = new MaterialPropertyExample();
return 0; 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; package com.jsh.erp.service.person;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Person; import com.jsh.erp.datasource.entities.Person;
import com.jsh.erp.datasource.entities.PersonExample; import com.jsh.erp.datasource.entities.PersonExample;
import com.jsh.erp.datasource.mappers.PersonMapper; import com.jsh.erp.datasource.mappers.PersonMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class PersonService { @Service
private Logger logger = LoggerFactory.getLogger(PersonService.class); public class PersonService {
private Logger logger = LoggerFactory.getLogger(PersonService.class);
@Resource
private PersonMapper personMapper; @Resource
private PersonMapper personMapper;
public Person getPerson(long id) {
return personMapper.selectByPrimaryKey(id); public Person getPerson(long id) {
} return personMapper.selectByPrimaryKey(id);
}
public List<Person> getPerson() {
PersonExample example = new PersonExample(); public List<Person> getPerson() {
return personMapper.selectByExample(example); 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 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 countPerson(String name, String type) {
} return personMapper.countsByPerson(name, type);
}
public int insertPerson(String beanJson, HttpServletRequest request) {
Person person = JSONObject.parseObject(beanJson, Person.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return personMapper.insertSelective(person); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return personMapper.updateByPrimaryKeySelective(person); public int updatePerson(String beanJson, Long id) {
} Person person = JSONObject.parseObject(beanJson, Person.class);
person.setId(id);
public int deletePerson(Long id) { return personMapper.updateByPrimaryKeySelective(person);
return personMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeletePerson(String ids) { public int deletePerson(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return personMapper.deleteByPrimaryKey(id);
PersonExample example = new PersonExample(); }
example.createCriteria().andIdIn(idList);
return personMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeletePerson(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { PersonExample example = new PersonExample();
PersonExample example = new PersonExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name); return personMapper.deleteByExample(example);
List<Person> list = personMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
PersonExample example = new PersonExample();
public String getPersonByIds(String personIDs) { example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
List<Long> ids = StringUtil.strToLongList(personIDs); List<Person> list = personMapper.selectByExample(example);
PersonExample example = new PersonExample(); return list.size();
example.createCriteria().andIdIn(ids); }
example.setOrderByClause("Id asc");
List<Person> list = personMapper.selectByExample(example); public String getPersonByIds(String personIDs) {
StringBuffer sb = new StringBuffer(); List<Long> ids = StringUtil.strToLongList(personIDs);
if (null != list) { PersonExample example = new PersonExample();
for (Person person : list) { example.createCriteria().andIdIn(ids);
sb.append(person.getName() + " "); example.setOrderByClause("Id asc");
} List<Person> list = personMapper.selectByExample(example);
} StringBuffer sb = new StringBuffer();
return sb.toString(); if (null != list) {
} for (Person person : list) {
sb.append(person.getName() + " ");
public List<Person> getPersonByType(String type) { }
PersonExample example = new PersonExample(); }
example.createCriteria().andTypeEqualTo(type); return sb.toString();
example.setOrderByClause("Id asc"); }
return personMapper.selectByExample(example);
} 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; package com.jsh.erp.service.role;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Role; import com.jsh.erp.datasource.entities.Role;
import com.jsh.erp.datasource.entities.RoleExample; import com.jsh.erp.datasource.entities.RoleExample;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserExample; import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.mappers.RoleMapper; import com.jsh.erp.datasource.mappers.RoleMapper;
import com.jsh.erp.datasource.mappers.UserMapper; import com.jsh.erp.datasource.mappers.UserMapper;
import com.jsh.erp.utils.QueryUtils; import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.RegExpTools; import com.jsh.erp.utils.RegExpTools;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Service @Service
public class RoleService { public class RoleService {
@Resource @Resource
private RoleMapper roleMapper; private RoleMapper roleMapper;
public Role getRole(long id) { public Role getRole(long id) {
return roleMapper.selectByPrimaryKey(id); return roleMapper.selectByPrimaryKey(id);
} }
public List<Role> getRole() { public List<Role> getRole() {
RoleExample example = new RoleExample(); RoleExample example = new RoleExample();
return roleMapper.selectByExample(example); return roleMapper.selectByExample(example);
} }
public List<Role> select(String name, int offset, int rows) { public List<Role> select(String name, int offset, int rows) {
return roleMapper.selectByConditionRole(name, offset, rows); return roleMapper.selectByConditionRole(name, offset, rows);
} }
public int countRole(String name) { public int countRole(String name) {
return roleMapper.countsByRole(name); return roleMapper.countsByRole(name);
} }
public int insertRole(String beanJson, HttpServletRequest request) { @Transactional(value = "transactionManager", rollbackFor = Exception.class)
Role role = JSONObject.parseObject(beanJson, Role.class); public int insertRole(String beanJson, HttpServletRequest request) {
return roleMapper.insertSelective(role); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
role.setId(id); public int updateRole(String beanJson, Long id) {
return roleMapper.updateByPrimaryKeySelective(role); Role role = JSONObject.parseObject(beanJson, Role.class);
} role.setId(id);
return roleMapper.updateByPrimaryKeySelective(role);
public int deleteRole(Long id) { }
return roleMapper.deleteByPrimaryKey(id);
} @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteRole(Long id) {
public int batchDeleteRole(String ids) { return roleMapper.deleteByPrimaryKey(id);
List<Long> idList = StringUtil.strToLongList(ids); }
RoleExample example = new RoleExample();
example.createCriteria().andIdIn(idList); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return roleMapper.deleteByExample(example); public int batchDeleteRole(String ids) {
} List<Long> idList = StringUtil.strToLongList(ids);
RoleExample example = new RoleExample();
public List<Role> findUserRole(){ example.createCriteria().andIdIn(idList);
RoleExample example = new RoleExample(); return roleMapper.deleteByExample(example);
example.setOrderByClause("Id"); }
List<Role> list = roleMapper.selectByExample(example);
return list; 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; package com.jsh.erp.service.supplier;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Supplier; import com.jsh.erp.datasource.entities.Supplier;
import com.jsh.erp.datasource.entities.SupplierExample; import com.jsh.erp.datasource.entities.SupplierExample;
import com.jsh.erp.datasource.mappers.SupplierMapper; import com.jsh.erp.datasource.mappers.SupplierMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class SupplierService { @Service
private Logger logger = LoggerFactory.getLogger(SupplierService.class); public class SupplierService {
private Logger logger = LoggerFactory.getLogger(SupplierService.class);
@Resource
private SupplierMapper supplierMapper; @Resource
private SupplierMapper supplierMapper;
public Supplier getSupplier(long id) {
return supplierMapper.selectByPrimaryKey(id); public Supplier getSupplier(long id) {
} return supplierMapper.selectByPrimaryKey(id);
}
public List<Supplier> getSupplier() {
SupplierExample example = new SupplierExample(); public List<Supplier> getSupplier() {
return supplierMapper.selectByExample(example); 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 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 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return supplierMapper.insertSelective(supplier); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return supplierMapper.updateByPrimaryKeySelective(supplier); public int updateSupplier(String beanJson, Long id) {
} Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
supplier.setId(id);
public int deleteSupplier(Long id) { return supplierMapper.updateByPrimaryKeySelective(supplier);
return supplierMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSupplier(String ids) { public int deleteSupplier(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return supplierMapper.deleteByPrimaryKey(id);
SupplierExample example = new SupplierExample(); }
example.createCriteria().andIdIn(idList);
return supplierMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteSupplier(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { SupplierExample example = new SupplierExample();
SupplierExample example = new SupplierExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name); return supplierMapper.deleteByExample(example);
List<Supplier> list = supplierMapper.selectByExample(example); }
return list.size();
} public int checkIsNameExist(Long id, String name) {
SupplierExample example = new SupplierExample();
public int updateAdvanceIn(Long supplierId, Double advanceIn){ example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name);
Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId); List<Supplier> list = supplierMapper.selectByExample(example);
supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额可能增加的是负值 return list.size();
return supplierMapper.updateByPrimaryKeySelective(supplier); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public List<Supplier> findBySelectCus() { public int updateAdvanceIn(Long supplierId, Double advanceIn){
SupplierExample example = new SupplierExample(); Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId);
example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true); supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额可能增加的是负值
example.setOrderByClause("id desc"); return supplierMapper.updateByPrimaryKeySelective(supplier);
return supplierMapper.selectByExample(example); }
}
public List<Supplier> findBySelectCus() {
public List<Supplier> findBySelectSup() { SupplierExample example = new SupplierExample();
SupplierExample example = new SupplierExample(); example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true);
example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true); example.setOrderByClause("id desc");
example.setOrderByClause("id desc"); return supplierMapper.selectByExample(example);
return supplierMapper.selectByExample(example); }
}
public List<Supplier> findBySelectSup() {
public List<Supplier> findBySelectRetail() { SupplierExample example = new SupplierExample();
SupplierExample example = new SupplierExample(); example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true);
example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true); example.setOrderByClause("id desc");
example.setOrderByClause("id desc"); return supplierMapper.selectByExample(example);
return supplierMapper.selectByExample(example); }
}
public List<Supplier> findBySelectRetail() {
public List<Supplier> findById(Long supplierId) { SupplierExample example = new SupplierExample();
SupplierExample example = new SupplierExample(); example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true);
example.createCriteria().andIdEqualTo(supplierId); example.setOrderByClause("id desc");
example.setOrderByClause("id desc"); return supplierMapper.selectByExample(example);
return supplierMapper.selectByExample(example); }
}
public List<Supplier> findById(Long supplierId) {
public int batchSetEnable(Boolean enabled, String supplierIDs) { SupplierExample example = new SupplierExample();
List<Long> ids = StringUtil.strToLongList(supplierIDs); example.createCriteria().andIdEqualTo(supplierId);
Supplier supplier = new Supplier(); example.setOrderByClause("id desc");
supplier.setEnabled(enabled); return supplierMapper.selectByExample(example);
SupplierExample example = new SupplierExample(); }
example.createCriteria().andIdIn(ids);
return supplierMapper.updateByExampleSelective(supplier, example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchSetEnable(Boolean enabled, String supplierIDs) {
List<Long> ids = StringUtil.strToLongList(supplierIDs);
public List<Supplier> findUserCustomer(){ Supplier supplier = new Supplier();
SupplierExample example = new SupplierExample(); supplier.setEnabled(enabled);
example.createCriteria().andTypeEqualTo("客户"); SupplierExample example = new SupplierExample();
example.setOrderByClause("id desc"); example.createCriteria().andIdIn(ids);
List<Supplier> list = supplierMapper.selectByExample(example); return supplierMapper.updateByExampleSelective(supplier, example);
return list; }
}
} 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; package com.jsh.erp.service.systemConfig;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.SystemConfig; import com.jsh.erp.datasource.entities.SystemConfig;
import com.jsh.erp.datasource.entities.SystemConfigExample; import com.jsh.erp.datasource.entities.SystemConfigExample;
import com.jsh.erp.datasource.mappers.SystemConfigMapper; import com.jsh.erp.datasource.mappers.SystemConfigMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class SystemConfigService { @Service
private Logger logger = LoggerFactory.getLogger(SystemConfigService.class); public class SystemConfigService {
private Logger logger = LoggerFactory.getLogger(SystemConfigService.class);
@Resource
private SystemConfigMapper systemConfigMapper; @Resource
private SystemConfigMapper systemConfigMapper;
public SystemConfig getSystemConfig(long id) {
return systemConfigMapper.selectByPrimaryKey(id); public SystemConfig getSystemConfig(long id) {
} return systemConfigMapper.selectByPrimaryKey(id);
}
public List<SystemConfig> getSystemConfig() {
SystemConfigExample example = new SystemConfigExample(); public List<SystemConfig> getSystemConfig() {
return systemConfigMapper.selectByExample(example); SystemConfigExample example = new SystemConfigExample();
} return systemConfigMapper.selectByExample(example);
public List<SystemConfig> select(int offset, int rows) { }
return systemConfigMapper.selectByConditionSystemConfig(offset, rows); public List<SystemConfig> select(int offset, int rows) {
} return systemConfigMapper.selectByConditionSystemConfig(offset, rows);
}
public int countSystemConfig() {
return systemConfigMapper.countsBySystemConfig(); public int countSystemConfig() {
} return systemConfigMapper.countsBySystemConfig();
}
public int insertSystemConfig(String beanJson, HttpServletRequest request) {
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return systemConfigMapper.insertSelective(systemConfig); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return systemConfigMapper.updateByPrimaryKeySelective(systemConfig); public int updateSystemConfig(String beanJson, Long id) {
} SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
systemConfig.setId(id);
public int deleteSystemConfig(Long id) { return systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
return systemConfigMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSystemConfig(String ids) { public int deleteSystemConfig(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return systemConfigMapper.deleteByPrimaryKey(id);
SystemConfigExample example = new SystemConfigExample(); }
example.createCriteria().andIdIn(idList);
return systemConfigMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteSystemConfig(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { SystemConfigExample example = new SystemConfigExample();
SystemConfigExample example = new SystemConfigExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name); return systemConfigMapper.deleteByExample(example);
List<SystemConfig> list = systemConfigMapper.selectByExample(example); }
return list.size();
} 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; package com.jsh.erp.service.unit;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Unit; import com.jsh.erp.datasource.entities.Unit;
import com.jsh.erp.datasource.entities.UnitExample; import com.jsh.erp.datasource.entities.UnitExample;
import com.jsh.erp.datasource.mappers.UnitMapper; import com.jsh.erp.datasource.mappers.UnitMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class UnitService { @Service
private Logger logger = LoggerFactory.getLogger(UnitService.class); public class UnitService {
private Logger logger = LoggerFactory.getLogger(UnitService.class);
@Resource
private UnitMapper unitMapper; @Resource
private UnitMapper unitMapper;
public Unit getUnit(long id) {
return unitMapper.selectByPrimaryKey(id); public Unit getUnit(long id) {
} return unitMapper.selectByPrimaryKey(id);
}
public List<Unit> getUnit() {
UnitExample example = new UnitExample(); public List<Unit> getUnit() {
return unitMapper.selectByExample(example); 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 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 countUnit(String name) {
} return unitMapper.countsByUnit(name);
}
public int insertUnit(String beanJson, HttpServletRequest request) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return unitMapper.insertSelective(unit); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return unitMapper.updateByPrimaryKeySelective(unit); public int updateUnit(String beanJson, Long id) {
} Unit unit = JSONObject.parseObject(beanJson, Unit.class);
unit.setId(id);
public int deleteUnit(Long id) { return unitMapper.updateByPrimaryKeySelective(unit);
return unitMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUnit(String ids) { public int deleteUnit(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return unitMapper.deleteByPrimaryKey(id);
UnitExample example = new UnitExample(); }
example.createCriteria().andIdIn(idList);
return unitMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteUnit(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { UnitExample example = new UnitExample();
UnitExample example = new UnitExample(); example.createCriteria().andIdIn(idList);
example.createCriteria().andIdNotEqualTo(id).andUnameEqualTo(name); return unitMapper.deleteByExample(example);
List<Unit> list = unitMapper.selectByExample(example); }
return list.size();
} 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; package com.jsh.erp.service.user;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserExample; import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.mappers.UserMapper; import com.jsh.erp.datasource.mappers.UserMapper;
import com.jsh.erp.utils.*; import com.jsh.erp.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.security.NoSuchAlgorithmException; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.security.NoSuchAlgorithmException;
import java.util.Map; import java.util.List;
import java.util.Map;
@Service
public class UserService { @Service
private Logger logger = LoggerFactory.getLogger(UserService.class); public class UserService {
@Resource private Logger logger = LoggerFactory.getLogger(UserService.class);
private UserMapper userMapper; @Resource
private UserMapper userMapper;
public User getUser(long id) {
return userMapper.selectByPrimaryKey(id); public User getUser(long id) {
} return userMapper.selectByPrimaryKey(id);
}
public List<User> getUser() {
UserExample example = new UserExample(); public List<User> getUser() {
return userMapper.selectByExample(example); 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 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 countUser(String userName, String loginName) {
} return userMapper.countsByUser(userName, loginName);
}
public int insertUser(String beanJson, HttpServletRequest request) { /**
User user = JSONObject.parseObject(beanJson, User.class); * create by: cjl
String password = "123456"; * description:
//因密码用MD5加密需要对密码进行转化 * 添加事务控制
try { * create time: 2019/1/11 14:30
password = Tools.md5Encryp(password); * @Param: beanJson
user.setPassword(password);  * @Param: request
} catch (NoSuchAlgorithmException e) { * @return int
e.printStackTrace(); */
logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 " + e.getMessage()); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int insertUser(String beanJson, HttpServletRequest request) {
return userMapper.insertSelective(user); User user = JSONObject.parseObject(beanJson, User.class);
} String password = "123456";
//因密码用MD5加密需要对密码进行转化
public int updateUser(String beanJson, Long id) { try {
User user = JSONObject.parseObject(beanJson, User.class); password = Tools.md5Encryp(password);
user.setId(id); user.setPassword(password);
return userMapper.updateByPrimaryKeySelective(user); } catch (NoSuchAlgorithmException e) {
} e.printStackTrace();
logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 " + e.getMessage());
public int updateUserByObj(User user) { }
return userMapper.updateByPrimaryKeySelective(user); return userMapper.insertSelective(user);
} }
/**
public int resetPwd(String md5Pwd, Long id) { * create by: cjl
User user = new User(); * description:
user.setId(id); * 添加事务控制
user.setPassword(md5Pwd); * create time: 2019/1/11 14:31
return userMapper.updateByPrimaryKeySelective(user); * @Param: beanJson
}  * @Param: id
* @return int
public int deleteUser(Long id) { */
return userMapper.deleteByPrimaryKey(id); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int updateUser(String beanJson, Long id) {
User user = JSONObject.parseObject(beanJson, User.class);
public int batchDeleteUser(String ids) { user.setId(id);
List<Long> idList = StringUtil.strToLongList(ids); return userMapper.updateByPrimaryKeySelective(user);
UserExample example = new UserExample(); }
example.createCriteria().andIdIn(idList); /**
return userMapper.deleteByExample(example); * create by: cjl
} * description:
* 添加事务控制
public int validateUser(String username, String password) throws JshException { * create time: 2019/1/11 14:32
try { * @Param: user
/**默认是可以登录的*/ * @return int
List<User> list = null; */
try { @Transactional(value = "transactionManager", rollbackFor = Exception.class)
UserExample example = new UserExample(); public int updateUserByObj(User user) {
example.createCriteria().andLoginameEqualTo(username); return userMapper.updateByPrimaryKeySelective(user);
list = userMapper.selectByExample(example); }
} catch (Exception e) { /**
logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e); * create by: cjl
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION; * description:
} * 添加事务控制
* create time: 2019/1/11 14:33
if (null != list && list.size() == 0) { * @Param: md5Pwd
return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST;  * @Param: id
} * @return int
*/
try { @Transactional(value = "transactionManager", rollbackFor = Exception.class)
UserExample example = new UserExample(); public int resetPwd(String md5Pwd, Long id) {
example.createCriteria().andLoginameEqualTo(username).andPasswordEqualTo(password); User user = new User();
list = userMapper.selectByExample(example); user.setId(id);
} catch (Exception e) { user.setPassword(md5Pwd);
logger.error(">>>>>>>>>>访问验证用户密码后台信息异常", e); return userMapper.updateByPrimaryKeySelective(user);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION; }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
if (null != list && list.size() == 0) { public int deleteUser(Long id) {
return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR; return userMapper.deleteByPrimaryKey(id);
} }
return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT;
} catch (Exception e) { @Transactional(value = "transactionManager", rollbackFor = Exception.class)
throw new JshException("unknown exception", e); public int batchDeleteUser(String ids) {
} List<Long> idList = StringUtil.strToLongList(ids);
} UserExample example = new UserExample();
example.createCriteria().andIdIn(idList);
public User getUserByUserName(String username) { return userMapper.deleteByExample(example);
UserExample example = new UserExample(); }
example.createCriteria().andLoginameEqualTo(username);
List<User> list = userMapper.selectByExample(example); public int validateUser(String username, String password) throws JshException {
User user = list.get(0); try {
return user; /**默认是可以登录的*/
} List<User> list = null;
try {
public int checkIsNameExist(Long id, String name) { UserExample example = new UserExample();
UserExample example = new UserExample(); example.createCriteria().andLoginameEqualTo(username);
example.createCriteria().andIdNotEqualTo(id).andLoginameEqualTo(name); list = userMapper.selectByExample(example);
List<User> list = userMapper.selectByExample(example); } catch (Exception e) {
return list.size(); 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; package com.jsh.erp.service.userBusiness;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.UserBusiness; import com.jsh.erp.datasource.entities.UserBusiness;
import com.jsh.erp.datasource.entities.UserBusinessExample; import com.jsh.erp.datasource.entities.UserBusinessExample;
import com.jsh.erp.datasource.mappers.UserBusinessMapper; import com.jsh.erp.datasource.mappers.UserBusinessMapper;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.annotation.Resource;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class UserBusinessService { @Service
private Logger logger = LoggerFactory.getLogger(UserBusinessService.class); public class UserBusinessService {
private Logger logger = LoggerFactory.getLogger(UserBusinessService.class);
@Resource
private UserBusinessMapper userBusinessMapper; @Resource
private UserBusinessMapper userBusinessMapper;
public UserBusiness getUserBusiness(long id) {
return userBusinessMapper.selectByPrimaryKey(id); public UserBusiness getUserBusiness(long id) {
} return userBusinessMapper.selectByPrimaryKey(id);
}
public List<UserBusiness> getUserBusiness() {
UserBusinessExample example = new UserBusinessExample(); public List<UserBusiness> getUserBusiness() {
return userBusinessMapper.selectByExample(example); UserBusinessExample example = new UserBusinessExample();
} return userBusinessMapper.selectByExample(example);
}
public int insertUserBusiness(String beanJson, HttpServletRequest request) {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return userBusinessMapper.insertSelective(userBusiness); 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); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
return userBusinessMapper.updateByPrimaryKeySelective(userBusiness); public int updateUserBusiness(String beanJson, Long id) {
} UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
userBusiness.setId(id);
public int deleteUserBusiness(Long id) { return userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
return userBusinessMapper.deleteByPrimaryKey(id); }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUserBusiness(String ids) { public int deleteUserBusiness(Long id) {
List<Long> idList = StringUtil.strToLongList(ids); return userBusinessMapper.deleteByPrimaryKey(id);
UserBusinessExample example = new UserBusinessExample(); }
example.createCriteria().andIdIn(idList);
return userBusinessMapper.deleteByExample(example); @Transactional(value = "transactionManager", rollbackFor = Exception.class)
} public int batchDeleteUserBusiness(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
public int checkIsNameExist(Long id, String name) { UserBusinessExample example = new UserBusinessExample();
return 1; example.createCriteria().andIdIn(idList);
} return userBusinessMapper.deleteByExample(example);
}
public List<UserBusiness> getBasicData(String keyId, String type){
UserBusinessExample example = new UserBusinessExample(); public int checkIsNameExist(Long id, String name) {
example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type); return 1;
List<UserBusiness> list = userBusinessMapper.selectByExample(example); }
return list;
} public List<UserBusiness> getBasicData(String keyId, String type){
UserBusinessExample example = new UserBusinessExample();
public Long checkIsValueExist(String type, String keyId) { example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type);
UserBusinessExample example = new UserBusinessExample(); List<UserBusiness> list = userBusinessMapper.selectByExample(example);
example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId); return list;
List<UserBusiness> list = userBusinessMapper.selectByExample(example); }
Long id = null;
if(list.size() > 0) { public Long checkIsValueExist(String type, String keyId) {
id = list.get(0).getId(); UserBusinessExample example = new UserBusinessExample();
} example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId);
return id; List<UserBusiness> list = userBusinessMapper.selectByExample(example);
} Long id = null;
if(list.size() > 0) {
public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue) { id = list.get(0).getId();
UserBusinessExample example = new UserBusinessExample(); }
String newVaule = "%" + UBValue + "%"; return id;
if(TypeVale !=null && KeyIdValue !=null) { }
example.createCriteria().andTypeEqualTo(TypeVale).andKeyidEqualTo(KeyIdValue).andValueLike(newVaule);
} else { public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue) {
example.createCriteria().andValueLike(newVaule); UserBusinessExample example = new UserBusinessExample();
} String newVaule = "%" + UBValue + "%";
List<UserBusiness> list = userBusinessMapper.selectByExample(example); if(TypeVale !=null && KeyIdValue !=null) {
if(list.size() > 0) { example.createCriteria().andTypeEqualTo(TypeVale).andKeyidEqualTo(KeyIdValue).andValueLike(newVaule);
return true; } else {
} else { example.createCriteria().andValueLike(newVaule);
return false; }
} List<UserBusiness> list = userBusinessMapper.selectByExample(example);
} if(list.size() > 0) {
return true;
public int updateBtnStr(Long userBusinessId, String btnStr) { } else {
UserBusiness userBusiness = new UserBusiness(); return false;
userBusiness.setBtnstr(btnStr); }
UserBusinessExample example = new UserBusinessExample(); }
example.createCriteria().andIdEqualTo(userBusinessId);
return userBusinessMapper.updateByExampleSelective(userBusiness, example); @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);
}
}