更新后端,采用Springboot+mybatis
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package com.jsh.erp.service.accountHead;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service(value = "accountHead_component")
|
||||
@AccountHeadResource
|
||||
public class AccountHeadComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private AccountHeadService accountHeadService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getAccountHeadList(map);
|
||||
}
|
||||
|
||||
private List<?> getAccountHeadList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String billNo = StringUtil.getInfo(search, "billNo");
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String order = QueryUtils.order(map);
|
||||
return accountHeadService.select(type, billNo, beginTime, endTime, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String billNo = StringUtil.getInfo(search, "billNo");
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
return accountHeadService.countAccountHead(type, billNo, beginTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return accountHeadService.insertAccountHead(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return accountHeadService.updateAccountHead(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return accountHeadService.deleteAccountHead(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return accountHeadService.batchDeleteAccountHead(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return accountHeadService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.accountHead;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "accountHead", type = 95)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AccountHeadResource {
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.jsh.erp.service.accountHead;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.AccountHead;
|
||||
import com.jsh.erp.datasource.entities.AccountHeadExample;
|
||||
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
|
||||
import com.jsh.erp.datasource.mappers.AccountHeadMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import com.jsh.erp.utils.Tools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AccountHeadService {
|
||||
private Logger logger = LoggerFactory.getLogger(AccountHeadService.class);
|
||||
|
||||
@Resource
|
||||
private AccountHeadMapper accountHeadMapper;
|
||||
|
||||
public AccountHead getAccountHead(long id) {
|
||||
return accountHeadMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<AccountHead> getAccountHead() {
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
return accountHeadMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<AccountHeadVo4ListEx> select(String type, String billNo, String beginTime, String endTime, int offset, int rows) {
|
||||
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
|
||||
List<AccountHeadVo4ListEx> list = accountHeadMapper.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows);
|
||||
if (null != list) {
|
||||
for (AccountHeadVo4ListEx ah : list) {
|
||||
if(ah.getChangeamount() != null) {
|
||||
ah.setChangeamount(Math.abs(ah.getChangeamount()));
|
||||
}
|
||||
if(ah.getTotalprice() != null) {
|
||||
ah.setTotalprice(Math.abs(ah.getTotalprice()));
|
||||
}
|
||||
resList.add(ah);
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
public int countAccountHead(String type, String billNo, String beginTime, String endTime) {
|
||||
return accountHeadMapper.countsByAccountHead(type, billNo, beginTime, endTime);
|
||||
}
|
||||
|
||||
public int insertAccountHead(String beanJson, HttpServletRequest request) {
|
||||
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
|
||||
return accountHeadMapper.insertSelective(accountHead);
|
||||
}
|
||||
|
||||
public int updateAccountHead(String beanJson, Long id) {
|
||||
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
|
||||
accountHead.setId(id);
|
||||
return accountHeadMapper.updateByPrimaryKeySelective(accountHead);
|
||||
}
|
||||
|
||||
public int deleteAccountHead(Long id) {
|
||||
return accountHeadMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteAccountHead(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return accountHeadMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
example.createCriteria().andIdNotEqualTo(id);
|
||||
List<AccountHead> list = accountHeadMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public Long getMaxId() {
|
||||
return accountHeadMapper.getMaxId();
|
||||
}
|
||||
|
||||
public Double findAllMoney(Integer supplierId, String type, String mode, String endTime) {
|
||||
String modeName = "";
|
||||
if (mode.equals("实际")) {
|
||||
modeName = "ChangeAmount";
|
||||
} else if (mode.equals("合计")) {
|
||||
modeName = "TotalPrice";
|
||||
}
|
||||
return accountHeadMapper.findAllMoney(supplierId, type, modeName, endTime);
|
||||
}
|
||||
|
||||
public List<AccountHeadVo4ListEx> getDetailByNumber(String billNo) {
|
||||
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
|
||||
List<AccountHeadVo4ListEx> list = accountHeadMapper.getDetailByNumber(billNo);
|
||||
if (null != list) {
|
||||
for (AccountHeadVo4ListEx ah : list) {
|
||||
if(ah.getChangeamount() != null) {
|
||||
ah.setChangeamount(Math.abs(ah.getChangeamount()));
|
||||
}
|
||||
if(ah.getTotalprice() != null) {
|
||||
ah.setTotalprice(Math.abs(ah.getTotalprice()));
|
||||
}
|
||||
resList.add(ah);
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user