Commit 9550c031 authored by 乾坤平台's avatar 乾坤平台 Committed by 季圣华
Browse files

!16 修复一系列问题

Merge pull request !16 from 乾坤平台/master
parents fc03d050 c4623555
......@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -43,21 +44,25 @@ public class DepotService {
return depotMapper.countsByDepot(name, type, remark);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepot(String beanJson, HttpServletRequest request) {
Depot depot = JSONObject.parseObject(beanJson, Depot.class);
return depotMapper.insertSelective(depot);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepot(String beanJson, Long id) {
Depot depot = JSONObject.parseObject(beanJson, Depot.class);
depot.setId(id);
return depotMapper.updateByPrimaryKeySelective(depot);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepot(Long id) {
return depotMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepot(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
DepotExample example = new DepotExample();
......
......@@ -15,9 +15,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
......@@ -53,10 +55,10 @@ public class DepotHeadService {
dh.setOthermoneyitem(otherMoneyItemStr);
}
if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount()));
dh.setChangeamount(dh.getChangeamount().abs());
}
if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice()));
dh.setTotalprice(dh.getTotalprice().abs());
}
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh);
......@@ -71,6 +73,7 @@ public class DepotHeadService {
return depotHeadMapper.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotHead(String beanJson, HttpServletRequest request) {
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//判断用户是否已经登录过,登录过不再处理
......@@ -85,6 +88,7 @@ public class DepotHeadService {
return depotHeadMapper.insert(depotHead);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotHead(String beanJson, Long id) {
DepotHead dh = depotHeadMapper.selectByPrimaryKey(id);
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
......@@ -95,10 +99,12 @@ public class DepotHeadService {
return depotHeadMapper.updateByPrimaryKey(depotHead);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepotHead(Long id) {
return depotHeadMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotHead(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
DepotHeadExample example = new DepotHeadExample();
......@@ -113,6 +119,7 @@ public class DepotHeadService {
return list.size();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetStatus(Boolean status, String depotHeadIDs) {
List<Long> ids = StringUtil.strToLongList(depotHeadIDs);
DepotHead depotHead = new DepotHead();
......@@ -207,7 +214,7 @@ public class DepotHeadService {
return depotHeadMapper.findStatementAccountCount(beginTime, endTime, organId, supType);
}
public Double findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) {
public BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) {
String modeName = "";
if (mode.equals("实际")) {
modeName = "ChangeAmount";
......@@ -231,10 +238,10 @@ public class DepotHeadService {
dh.setOthermoneyitem(otherMoneyItemStr);
}
if(dh.getChangeamount() != null) {
dh.setChangeamount(Math.abs(dh.getChangeamount()));
dh.setChangeamount(dh.getChangeamount().abs());
}
if(dh.getTotalprice() != null) {
dh.setTotalprice(Math.abs(dh.getTotalprice()));
dh.setTotalprice(dh.getTotalprice().abs());
}
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
resList.add(dh);
......
package com.jsh.erp.service.depotItem;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.DepotItemMapper;
import com.jsh.erp.service.material.MaterialService;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
@Service
public class DepotItemService {
private Logger logger = LoggerFactory.getLogger(DepotItemService.class);
......@@ -25,6 +33,8 @@ public class DepotItemService {
@Resource
private DepotItemMapper depotItemMapper;
@Resource
private MaterialService materialService;
public DepotItem getDepotItem(long id) {
return depotItemMapper.selectByPrimaryKey(id);
......@@ -43,21 +53,25 @@ public class DepotItemService {
return depotItemMapper.countsByDepotItem(name, type, remark);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotItem(String beanJson, HttpServletRequest request) {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
return depotItemMapper.insertSelective(depotItem);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotItem(String beanJson, Long id) {
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
depotItem.setId(id);
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepotItem(Long id) {
return depotItemMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotItem(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
DepotItemExample example = new DepotItemExample();
......@@ -114,10 +128,12 @@ public class DepotItemService {
return depotItemMapper.findStockNumByMaterialIdCounts(mId, monthTime);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotItemWithObj(DepotItem depotItem) {
return depotItemMapper.insertSelective(depotItem);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotItemWithObj(DepotItem depotItem) {
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
}
......@@ -142,7 +158,7 @@ public class DepotItemService {
return depotItemMapper.findByAllCount(headIds, materialIds);
}
public Double findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
public BigDecimal findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapper.findByTypeInIsPrev(ProjectId, MId, MonthTime);
......@@ -158,7 +174,7 @@ public class DepotItemService {
}
}
public Double findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
public BigDecimal findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
if (TYPE.equals(type)) {
if (isPrev) {
return depotItemMapper.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime);
......@@ -174,7 +190,7 @@ public class DepotItemService {
}
}
public Double buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) {
public BigDecimal 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 {
......@@ -182,7 +198,7 @@ public class DepotItemService {
}
}
public Double findGiftByType(String subType, Integer ProjectId, Long MId, String type) {
public BigDecimal findGiftByType(String subType, Integer ProjectId, Long MId, String type) {
if (IN.equals(type)) {
return depotItemMapper.findGiftByTypeIn(subType, ProjectId, MId);
} else {
......@@ -190,5 +206,184 @@ public class DepotItemService {
}
}
@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.getBigDecimal("OperNumber"));
try {
String Unit = tempInsertedJson.get("Unit").toString();
BigDecimal oNumber = tempInsertedJson.getBigDecimal("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.multiply(new BigDecimal(ratio)) ); //数量乘以比例
}
} else {
depotItem.setBasicnumber(oNumber); //其他情况
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
}
if (!StringUtil.isEmpty(tempInsertedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempInsertedJson.getBigDecimal("UnitPrice"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempInsertedJson.getBigDecimal("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempInsertedJson.getBigDecimal("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.getBigDecimal("TaxRate"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempInsertedJson.getBigDecimal("TaxMoney"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempInsertedJson.getBigDecimal("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.getBigDecimal("OperNumber"));
try {
String Unit = tempUpdatedJson.get("Unit").toString();
BigDecimal oNumber = tempUpdatedJson.getBigDecimal("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.multiply(new BigDecimal(ratio))); //数量乘以比例
}
} else {
depotItem.setBasicnumber(oNumber); //其他情况
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempUpdatedJson.getBigDecimal("UnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempUpdatedJson.getBigDecimal("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempUpdatedJson.getBigDecimal("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.getBigDecimal("TaxRate"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempUpdatedJson.getBigDecimal("TaxMoney"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempUpdatedJson.getBigDecimal("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;
}
}
......@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -37,21 +38,25 @@ public class FunctionsService {
return functionsMapper.countsByFunctions(name, type);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertFunctions(String beanJson, HttpServletRequest request) {
Functions depot = JSONObject.parseObject(beanJson, Functions.class);
return functionsMapper.insertSelective(depot);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateFunctions(String beanJson, Long id) {
Functions depot = JSONObject.parseObject(beanJson, Functions.class);
depot.setId(id);
return functionsMapper.updateByPrimaryKeySelective(depot);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteFunctions(Long id) {
return functionsMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteFunctions(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
FunctionsExample example = new FunctionsExample();
......
......@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -37,21 +38,25 @@ public class InOutItemService {
return inOutItemMapper.countsByInOutItem(name, type, remark);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertInOutItem(String beanJson, HttpServletRequest request) {
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
return inOutItemMapper.insertSelective(depot);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateInOutItem(String beanJson, Long id) {
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
depot.setId(id);
return inOutItemMapper.updateByPrimaryKeySelective(depot);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteInOutItem(Long id) {
return inOutItemMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteInOutItem(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
InOutItemExample example = new InOutItemExample();
......
......@@ -11,6 +11,7 @@ import com.jsh.erp.utils.Tools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -43,21 +44,25 @@ public class LogService {
return logMapper.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertLog(String beanJson, HttpServletRequest request) {
Log log = JSONObject.parseObject(beanJson, Log.class);
return logMapper.insertSelective(log);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateLog(String beanJson, Long id) {
Log log = JSONObject.parseObject(beanJson, Log.class);
log.setId(id);
return logMapper.updateByPrimaryKeySelective(log);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteLog(Long id) {
return logMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteLog(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
LogExample example = new LogExample();
......
......@@ -10,6 +10,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -73,12 +74,14 @@ public class MaterialService {
return materialMapper.countsByMaterial(name, model,categoryId,categoryIds,mpList);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertMaterial(String beanJson, HttpServletRequest request) {
Material material = JSONObject.parseObject(beanJson, Material.class);
material.setEnabled(true);
return materialMapper.insertSelective(material);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateMaterial(String beanJson, Long id) {
Material material = JSONObject.parseObject(beanJson, Material.class);
material.setId(id);
......@@ -92,10 +95,12 @@ public class MaterialService {
return res;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteMaterial(Long id) {
return materialMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterial(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialExample example = new MaterialExample();
......@@ -130,6 +135,7 @@ public class MaterialService {
return list.size();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetEnable(Boolean enabled, String materialIDs) {
List<Long> ids = StringUtil.strToLongList(materialIDs);
Material material = new Material();
......
......@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -44,21 +45,25 @@ public class MaterialCategoryService {
return materialCategoryMapper.countsByMaterialCategory(name, parentId);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertMaterialCategory(String beanJson, HttpServletRequest request) {
MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class);
return materialCategoryMapper.insertSelective(materialCategory);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateMaterialCategory(String beanJson, Long id) {
MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class);
materialCategory.setId(id);
return materialCategoryMapper.updateByPrimaryKeySelective(materialCategory);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteMaterialCategory(Long id) {
return materialCategoryMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialCategory(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialCategoryExample example = new MaterialCategoryExample();
......
......@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -36,21 +37,25 @@ public class MaterialPropertyService {
return materialPropertyMapper.countsByMaterialProperty(name);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertMaterialProperty(String beanJson, HttpServletRequest request) {
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
return materialPropertyMapper.insertSelective(materialProperty);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateMaterialProperty(String beanJson, Long id) {
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
materialProperty.setId(id);
return materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteMaterialProperty(Long id) {
return materialPropertyMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialProperty(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialPropertyExample example = new MaterialPropertyExample();
......
......@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -37,21 +38,25 @@ public class PersonService {
return personMapper.countsByPerson(name, type);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertPerson(String beanJson, HttpServletRequest request) {
Person person = JSONObject.parseObject(beanJson, Person.class);
return personMapper.insertSelective(person);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updatePerson(String beanJson, Long id) {
Person person = JSONObject.parseObject(beanJson, Person.class);
person.setId(id);
return personMapper.updateByPrimaryKeySelective(person);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deletePerson(Long id) {
return personMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeletePerson(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
PersonExample example = new PersonExample();
......
......@@ -40,21 +40,25 @@ public class RoleService {
return roleMapper.countsByRole(name);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertRole(String beanJson, HttpServletRequest request) {
Role role = JSONObject.parseObject(beanJson, Role.class);
return roleMapper.insertSelective(role);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateRole(String beanJson, Long id) {
Role role = JSONObject.parseObject(beanJson, Role.class);
role.setId(id);
return roleMapper.updateByPrimaryKeySelective(role);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteRole(Long id) {
return roleMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteRole(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
RoleExample example = new RoleExample();
......
......@@ -9,9 +9,11 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -40,21 +42,25 @@ public class SupplierService {
return supplierMapper.countsBySupplier(supplier, type, phonenum, telephone, description);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertSupplier(String beanJson, HttpServletRequest request) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
return supplierMapper.insertSelective(supplier);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateSupplier(String beanJson, Long id) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
supplier.setId(id);
return supplierMapper.updateByPrimaryKeySelective(supplier);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteSupplier(Long id) {
return supplierMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSupplier(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
SupplierExample example = new SupplierExample();
......@@ -69,9 +75,10 @@ public class SupplierService {
return list.size();
}
public int updateAdvanceIn(Long supplierId, Double advanceIn){
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAdvanceIn(Long supplierId, BigDecimal advanceIn){
Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId);
supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额,可能增加的是负值
supplier.setAdvancein(supplier.getAdvancein().add(advanceIn)); //增加预收款的金额,可能增加的是负值
return supplierMapper.updateByPrimaryKeySelective(supplier);
}
......@@ -103,6 +110,7 @@ public class SupplierService {
return supplierMapper.selectByExample(example);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetEnable(Boolean enabled, String supplierIDs) {
List<Long> ids = StringUtil.strToLongList(supplierIDs);
Supplier supplier = new Supplier();
......
......@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -36,21 +37,25 @@ public class SystemConfigService {
return systemConfigMapper.countsBySystemConfig();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertSystemConfig(String beanJson, HttpServletRequest request) {
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
return systemConfigMapper.insertSelective(systemConfig);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateSystemConfig(String beanJson, Long id) {
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
systemConfig.setId(id);
return systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteSystemConfig(Long id) {
return systemConfigMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSystemConfig(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
SystemConfigExample example = new SystemConfigExample();
......
......@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -37,21 +38,25 @@ public class UnitService {
return unitMapper.countsByUnit(name);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUnit(String beanJson, HttpServletRequest request) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
return unitMapper.insertSelective(unit);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUnit(String beanJson, Long id) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
unit.setId(id);
return unitMapper.updateByPrimaryKeySelective(unit);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUnit(Long id) {
return unitMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUnit(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UnitExample example = new UnitExample();
......
......@@ -9,6 +9,7 @@ import com.jsh.erp.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -38,7 +39,16 @@ public class UserService {
public int countUser(String userName, String loginName) {
return userMapper.countsByUser(userName, loginName);
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:30
* @Param: beanJson
 * @Param: request
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUser(String beanJson, HttpServletRequest request) {
User user = JSONObject.parseObject(beanJson, User.class);
String password = "123456";
......@@ -52,17 +62,43 @@ public class UserService {
}
return userMapper.insertSelective(user);
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:31
* @Param: beanJson
 * @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUser(String beanJson, Long id) {
User user = JSONObject.parseObject(beanJson, User.class);
user.setId(id);
return userMapper.updateByPrimaryKeySelective(user);
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:32
* @Param: user
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserByObj(User user) {
return userMapper.updateByPrimaryKeySelective(user);
}
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:33
* @Param: md5Pwd
 * @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int resetPwd(String md5Pwd, Long id) {
User user = new User();
user.setId(id);
......@@ -70,10 +106,12 @@ public class UserService {
return userMapper.updateByPrimaryKeySelective(user);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUser(Long id) {
return userMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUser(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UserExample example = new UserExample();
......
......@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
......@@ -29,21 +30,25 @@ public class UserBusinessService {
return userBusinessMapper.selectByExample(example);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUserBusiness(String beanJson, HttpServletRequest request) {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
return userBusinessMapper.insertSelective(userBusiness);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserBusiness(String beanJson, Long id) {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
userBusiness.setId(id);
return userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUserBusiness(Long id) {
return userBusinessMapper.deleteByPrimaryKey(id);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUserBusiness(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UserBusinessExample example = new UserBusinessExample();
......@@ -89,6 +94,7 @@ public class UserBusinessService {
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateBtnStr(Long userBusinessId, String btnStr) {
UserBusiness userBusiness = new UserBusiness();
userBusiness.setBtnstr(btnStr);
......
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/jsh_erp?useUnicode=true&characterEncoding=utf8&useCursorFetch=true&defaultFetchSize=500&allowMultiQueries=true&rewriteBatchedStatements=true&useSSL=false
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=123456
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment