从源更新
This commit is contained in:
@@ -24,6 +24,10 @@ import java.lang.annotation.*;
|
||||
* depotItem-90
|
||||
* accountHead-95
|
||||
* accountItem-100
|
||||
* serialNumber-105
|
||||
* organization-110
|
||||
* orgaUserRel-115
|
||||
* tenant-120
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -208,6 +208,56 @@ public class AccountHeadService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计总金额
|
||||
* @param getS
|
||||
* @param type
|
||||
* @param mode 合计或者金额
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal allMoney(String getS, String type, String mode, String endTime) {
|
||||
BigDecimal allMoney = BigDecimal.ZERO;
|
||||
try {
|
||||
Integer supplierId = Integer.valueOf(getS);
|
||||
BigDecimal sum = findAllMoney(supplierId, type, mode, endTime);
|
||||
if(sum != null) {
|
||||
allMoney = sum;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//返回正数,如果负数也转为正数
|
||||
if ((allMoney.compareTo(BigDecimal.ZERO))==-1) {
|
||||
allMoney = allMoney.abs();
|
||||
}
|
||||
return allMoney;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单位的累计应收和累计应付,收预付款不计入此处
|
||||
* @param supplierId
|
||||
* @param endTime
|
||||
* @param supType
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal findTotalPay(Integer supplierId, String endTime, String supType) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
String getS = supplierId.toString();
|
||||
int i = 1;
|
||||
if (("customer").equals(supType)) { //客户
|
||||
i = 1;
|
||||
} else if (("vendor").equals(supType)) { //供应商
|
||||
i = -1;
|
||||
}
|
||||
//收付款部分
|
||||
sum = sum.add((allMoney(getS, "付款", "合计",endTime).add(allMoney(getS, "付款", "实际",endTime))).multiply(new BigDecimal(i)));
|
||||
sum = sum.subtract((allMoney(getS, "收款", "合计",endTime).add(allMoney(getS, "收款", "实际",endTime))).multiply(new BigDecimal(i)));
|
||||
sum = sum.add((allMoney(getS, "收入", "合计",endTime).subtract(allMoney(getS, "收入", "实际",endTime))).multiply(new BigDecimal(i)));
|
||||
sum = sum.subtract((allMoney(getS, "支出", "合计",endTime).subtract(allMoney(getS, "支出", "实际",endTime))).multiply(new BigDecimal(i)));
|
||||
return sum;
|
||||
}
|
||||
|
||||
public List<AccountHeadVo4ListEx> getDetailByNumber(String billNo)throws Exception {
|
||||
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
|
||||
List<AccountHeadVo4ListEx> list = null;
|
||||
|
||||
@@ -264,10 +264,12 @@ public class DepotHeadService {
|
||||
/**
|
||||
* 创建一个唯一的序列号
|
||||
* */
|
||||
public String buildOnlyNumber()throws Exception{
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public String buildOnlyNumber()throws Exception{
|
||||
Long buildOnlyNumber=null;
|
||||
synchronized (this){
|
||||
try{
|
||||
depotHeadMapperEx.updateBuildOnlyNumber(); //编号+1
|
||||
buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ);
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
@@ -275,7 +277,6 @@ public class DepotHeadService {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||
}
|
||||
|
||||
}
|
||||
if(buildOnlyNumber<BusinessConstants.SEQ_TO_STRING_MIN_LENGTH){
|
||||
StringBuffer sb=new StringBuffer(buildOnlyNumber.toString());
|
||||
@@ -434,6 +435,56 @@ public class DepotHeadService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计总金额
|
||||
* @param getS
|
||||
* @param type
|
||||
* @param subType
|
||||
* @param mode 合计或者金额
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal allMoney(String getS, String type, String subType, String mode, String endTime) {
|
||||
BigDecimal allMoney = BigDecimal.ZERO;
|
||||
try {
|
||||
Integer supplierId = Integer.valueOf(getS);
|
||||
BigDecimal sum = findAllMoney(supplierId, type, subType, mode, endTime);
|
||||
if(sum != null) {
|
||||
allMoney = sum;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//返回正数,如果负数也转为正数
|
||||
if ((allMoney.compareTo(BigDecimal.ZERO))==-1) {
|
||||
allMoney = allMoney.abs();
|
||||
}
|
||||
return allMoney;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单位的累计应收和累计应付,零售不能计入
|
||||
* @param supplierId
|
||||
* @param endTime
|
||||
* @param supType
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal findTotalPay(Integer supplierId, String endTime, String supType) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
String getS = supplierId.toString();
|
||||
int i = 1;
|
||||
if (("customer").equals(supType)) { //客户
|
||||
i = 1;
|
||||
} else if (("vendor").equals(supType)) { //供应商
|
||||
i = -1;
|
||||
}
|
||||
//进销部分
|
||||
sum = sum.subtract((allMoney(getS, "入库", "采购", "合计",endTime).subtract(allMoney(getS, "入库", "采购", "实际",endTime))).multiply(new BigDecimal(i)));
|
||||
sum = sum.subtract((allMoney(getS, "入库", "销售退货", "合计",endTime).subtract(allMoney(getS, "入库", "销售退货", "实际",endTime))).multiply(new BigDecimal(i)));
|
||||
sum = sum.add((allMoney(getS, "出库", "销售", "合计",endTime).subtract(allMoney(getS, "出库", "销售", "实际",endTime))).multiply(new BigDecimal(i)));
|
||||
sum = sum.add((allMoney(getS, "出库", "采购退货", "合计",endTime).subtract(allMoney(getS, "出库", "采购退货", "实际",endTime))).multiply(new BigDecimal(i)));
|
||||
return sum;
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4List> getDetailByNumber(String number)throws Exception {
|
||||
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
|
||||
List<DepotHeadVo4List> list = null;
|
||||
|
||||
@@ -291,8 +291,8 @@ public class DepotItemService {
|
||||
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
|
||||
}
|
||||
|
||||
public int findByTypeAndMaterialId(String type, Long mId) throws Exception{
|
||||
int result =0;
|
||||
public Long findByTypeAndMaterialId(String type, Long mId) throws Exception{
|
||||
Long result = 0l;
|
||||
try{
|
||||
if(type.equals(TYPE)) {
|
||||
result= depotItemMapperEx.findByTypeAndMaterialIdIn(mId);
|
||||
|
||||
@@ -34,11 +34,10 @@ public class MaterialComponent implements ICommonQuery {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String model = StringUtil.getInfo(search, "model");
|
||||
Long categoryId = Long.parseLong(StringUtil.getInfo(search, "categoryId"));
|
||||
String categoryIds = StringUtil.getInfo(search, "categoryIds");
|
||||
String mpList = StringUtil.getInfo(search, "mpList");
|
||||
String order = QueryUtils.order(map);
|
||||
return materialService.select(name, model,categoryId,categoryIds,mpList, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
return materialService.select(name, model,categoryIds,mpList, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,10 +45,9 @@ public class MaterialComponent implements ICommonQuery {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String model = StringUtil.getInfo(search, "model");
|
||||
Long categoryId = Long.parseLong(StringUtil.getInfo(search, "categoryId"));
|
||||
String categoryIds = StringUtil.getInfo(search, "categoryIds");
|
||||
String mpList = StringUtil.getInfo(search, "mpList");
|
||||
return materialService.countMaterial(name, model,categoryId,categoryIds,mpList);
|
||||
return materialService.countMaterial(name, model,categoryIds,mpList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
|
||||
import com.jsh.erp.datasource.mappers.MaterialMapper;
|
||||
import com.jsh.erp.datasource.mappers.MaterialMapperEx;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
@@ -38,6 +39,8 @@ public class MaterialService {
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private DepotItemMapperEx depotItemMapperEx;
|
||||
@Resource
|
||||
private DepotItemService depotItemService;
|
||||
|
||||
public Material getMaterial(long id)throws Exception {
|
||||
Material result=null;
|
||||
@@ -67,13 +70,13 @@ public class MaterialService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows)
|
||||
public List<MaterialVo4Unit> select(String name, String model, String categoryIds,String mpList, int offset, int rows)
|
||||
throws Exception{
|
||||
String[] mpArr = mpList.split(",");
|
||||
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
|
||||
List<MaterialVo4Unit> list =null;
|
||||
try{
|
||||
list= materialMapperEx.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows);
|
||||
list= materialMapperEx.selectByConditionMaterial(name, model,categoryIds,mpList, offset, rows);
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||
@@ -105,16 +108,19 @@ public class MaterialService {
|
||||
}
|
||||
}
|
||||
m.setMaterialOther(materialOther);
|
||||
Long InSum = depotItemService.findByTypeAndMaterialId("入库", m.getId());
|
||||
Long OutSum = depotItemService.findByTypeAndMaterialId("出库", m.getId());
|
||||
m.setStock(InSum - OutSum);
|
||||
resList.add(m);
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
public Long countMaterial(String name, String model,Long categoryId, String categoryIds,String mpList)throws Exception {
|
||||
public Long countMaterial(String name, String model, String categoryIds,String mpList)throws Exception {
|
||||
Long result =null;
|
||||
try{
|
||||
result= materialMapperEx.countsByMaterial(name, model,categoryId,categoryIds,mpList);
|
||||
result= materialMapperEx.countsByMaterial(name, model,categoryIds,mpList);
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||
@@ -314,11 +320,11 @@ public class MaterialService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> findByAll(String name, String model, Long categoryId, String categoryIds)throws Exception {
|
||||
public List<MaterialVo4Unit> findByAll(String name, String model, String categoryIds)throws Exception {
|
||||
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
|
||||
List<MaterialVo4Unit> list =null;
|
||||
try{
|
||||
list= materialMapperEx.findByAll(name, model, categoryId, categoryIds);
|
||||
list= materialMapperEx.findByAll(name, model, categoryIds);
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -68,12 +69,9 @@ public class MaterialCategoryService {
|
||||
}
|
||||
|
||||
public List<MaterialCategory> getAllList(Long parentId)throws Exception {
|
||||
MaterialCategoryExample example = new MaterialCategoryExample();
|
||||
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
|
||||
example.setOrderByClause("id");
|
||||
List<MaterialCategory> list=null;
|
||||
try{
|
||||
list=materialCategoryMapper.selectByExample(example);
|
||||
list = getMCList(parentId);
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||
@@ -83,6 +81,25 @@ public class MaterialCategoryService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<MaterialCategory> getMCList(Long parentId)throws Exception {
|
||||
List<MaterialCategory> res= new ArrayList<MaterialCategory>();
|
||||
List<MaterialCategory> list=null;
|
||||
MaterialCategoryExample example = new MaterialCategoryExample();
|
||||
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
|
||||
example.setOrderByClause("id");
|
||||
list=materialCategoryMapper.selectByExample(example);
|
||||
if(list!=null && list.size()>0) {
|
||||
res.addAll(list);
|
||||
for(MaterialCategory mc : list) {
|
||||
List<MaterialCategory> mcList = getMCList(mc.getId());
|
||||
if(mcList!=null && mcList.size()>0) {
|
||||
res.addAll(mcList);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<MaterialCategory> select(String name, Integer parentId, int offset, int rows) throws Exception{
|
||||
List<MaterialCategory> list=null;
|
||||
try{
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
|
||||
import com.jsh.erp.datasource.mappers.SupplierMapper;
|
||||
import com.jsh.erp.datasource.mappers.SupplierMapperEx;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.accountHead.AccountHeadService;
|
||||
import com.jsh.erp.service.depotHead.DepotHeadService;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
@@ -24,10 +26,9 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static com.jsh.erp.utils.Tools.getNow3;
|
||||
|
||||
@Service
|
||||
public class SupplierService {
|
||||
@@ -46,6 +47,10 @@ public class SupplierService {
|
||||
private AccountHeadMapperEx accountHeadMapperEx;
|
||||
@Resource
|
||||
private DepotHeadMapperEx depotHeadMapperEx;
|
||||
@Resource
|
||||
private DepotHeadService depotHeadService;
|
||||
@Resource
|
||||
private AccountHeadService accountHeadService;
|
||||
|
||||
public Supplier getSupplier(long id)throws Exception {
|
||||
Supplier result=null;
|
||||
@@ -77,16 +82,47 @@ public class SupplierService {
|
||||
|
||||
public List<Supplier> select(String supplier, String type, String phonenum,
|
||||
String telephone, String description, int offset, int rows) throws Exception{
|
||||
List<Supplier> list=null;
|
||||
List<Supplier> resList = new ArrayList<Supplier>();
|
||||
try{
|
||||
list=supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows);
|
||||
List<Supplier> list = supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows);
|
||||
for(Supplier s : list) {
|
||||
Integer supplierId = s.getId().intValue();
|
||||
String endTime = getNow3();
|
||||
String supType = null;
|
||||
if(("客户").equals(s.getType())) {
|
||||
supType = "customer";
|
||||
} else if(("供应商").equals(s.getType())) {
|
||||
supType = "vendor";
|
||||
}
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
BigDecimal beginNeedGet = s.getBeginneedget();
|
||||
if(beginNeedGet==null) {
|
||||
beginNeedGet = BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal beginNeedPay = s.getBeginneedpay();
|
||||
if(beginNeedPay==null) {
|
||||
beginNeedPay = BigDecimal.ZERO;
|
||||
}
|
||||
sum = sum.add(depotHeadService.findTotalPay(supplierId, endTime, supType));
|
||||
sum = sum.add(accountHeadService.findTotalPay(supplierId, endTime, supType));
|
||||
if(("客户").equals(s.getType())) {
|
||||
sum = sum.add(beginNeedGet).subtract(beginNeedPay);
|
||||
s.setAllneedget(sum);
|
||||
s.setAllneedpay(BigDecimal.ZERO);
|
||||
} else if(("供应商").equals(s.getType())) {
|
||||
sum = sum.add(beginNeedPay).subtract(beginNeedGet);
|
||||
s.setAllneedget(BigDecimal.ZERO);
|
||||
s.setAllneedpay(sum);
|
||||
}
|
||||
resList.add(s);
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||
}
|
||||
return list;
|
||||
return resList;
|
||||
}
|
||||
|
||||
public Long countSupplier(String supplier, String type, String phonenum, String telephone, String description) throws Exception{
|
||||
|
||||
Reference in New Issue
Block a user