给收付款增加对供应商和客户期初收款的接口
This commit is contained in:
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
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.BaseResponseInfo;
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import com.jsh.erp.utils.StringUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -55,7 +56,11 @@ public class AccountItemController {
|
|||||||
item.put("accountName", ai.getAccountName());
|
item.put("accountName", ai.getAccountName());
|
||||||
item.put("inOutItemId", ai.getInOutItemId());
|
item.put("inOutItemId", ai.getInOutItemId());
|
||||||
item.put("inOutItemName", ai.getInOutItemName());
|
item.put("inOutItemName", ai.getInOutItemName());
|
||||||
item.put("billNumber", ai.getBillNumber());
|
if(StringUtil.isNotEmpty(ai.getBillNumber())) {
|
||||||
|
item.put("billNumber", ai.getBillNumber());
|
||||||
|
} else {
|
||||||
|
item.put("billNumber", "QiChu");
|
||||||
|
}
|
||||||
item.put("needDebt", ai.getNeedDebt());
|
item.put("needDebt", ai.getNeedDebt());
|
||||||
item.put("finishDebt", ai.getFinishDebt());
|
item.put("finishDebt", ai.getFinishDebt());
|
||||||
BigDecimal eachAmount = ai.getEachAmount();
|
BigDecimal eachAmount = ai.getEachAmount();
|
||||||
|
|||||||
@@ -512,6 +512,8 @@ public class DepotHeadController {
|
|||||||
@GetMapping(value = "/debtList")
|
@GetMapping(value = "/debtList")
|
||||||
@ApiOperation(value = "查询存在欠款的单据")
|
@ApiOperation(value = "查询存在欠款的单据")
|
||||||
public String debtList(@RequestParam(value = Constants.SEARCH, required = false) String search,
|
public String debtList(@RequestParam(value = Constants.SEARCH, required = false) String search,
|
||||||
|
@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
HttpServletRequest request)throws Exception {
|
HttpServletRequest request)throws Exception {
|
||||||
Map<String, Object> objectMap = new HashMap<>();
|
Map<String, Object> objectMap = new HashMap<>();
|
||||||
String organIdStr = StringUtil.getInfo(search, "organId");
|
String organIdStr = StringUtil.getInfo(search, "organId");
|
||||||
@@ -524,12 +526,17 @@ public class DepotHeadController {
|
|||||||
String subType = StringUtil.getInfo(search, "subType");
|
String subType = StringUtil.getInfo(search, "subType");
|
||||||
String roleType = StringUtil.getInfo(search, "roleType");
|
String roleType = StringUtil.getInfo(search, "roleType");
|
||||||
String status = StringUtil.getInfo(search, "status");
|
String status = StringUtil.getInfo(search, "status");
|
||||||
List<DepotHeadVo4List> list = depotHeadService.debtList(organId, materialParam, number, beginTime, endTime, type, subType, roleType, status);
|
List<DepotHeadVo4List> list = depotHeadService.debtList(organId, materialParam, number, beginTime, endTime, type,
|
||||||
|
subType, roleType, status, (currentPage-1)*pageSize, pageSize);
|
||||||
|
int total = depotHeadService.debtListCount(organId, materialParam, number, beginTime, endTime, type,
|
||||||
|
subType, roleType, status);
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
objectMap.put("rows", list);
|
objectMap.put("rows", list);
|
||||||
|
objectMap.put("total", total);
|
||||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
} else {
|
} else {
|
||||||
objectMap.put("rows", new ArrayList<>());
|
objectMap.put("rows", new ArrayList<>());
|
||||||
|
objectMap.put("total", 0);
|
||||||
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -277,6 +277,30 @@ public class SupplierController {
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据客户或供应商查询期初、期初已收等信息
|
||||||
|
* @param organId
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getBeginNeedByOrganId")
|
||||||
|
@ApiOperation(value = "根据客户或供应商查询期初、期初已收等信息")
|
||||||
|
public BaseResponseInfo getBeginNeedByOrganId(@RequestParam("organId") Long organId,
|
||||||
|
HttpServletRequest request)throws Exception {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
try {
|
||||||
|
Map<String, Object> map = supplierService.getBeginNeedByOrganId(organId);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入供应商
|
* 导入供应商
|
||||||
* @param file
|
* @param file
|
||||||
|
|||||||
@@ -37,4 +37,6 @@ public interface AccountItemMapperEx {
|
|||||||
int batchDeleteAccountItemByHeadIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String[] ids);
|
int batchDeleteAccountItemByHeadIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String[] ids);
|
||||||
|
|
||||||
BigDecimal getEachAmountByBillId(@Param("billId") Long billId);
|
BigDecimal getEachAmountByBillId(@Param("billId") Long billId);
|
||||||
|
|
||||||
|
BigDecimal getFinishDebtByOrganId(@Param("organId") Long organId);
|
||||||
}
|
}
|
||||||
@@ -224,6 +224,20 @@ public interface DepotHeadMapperEx {
|
|||||||
@Param("forceFlag") Boolean forceFlag);
|
@Param("forceFlag") Boolean forceFlag);
|
||||||
|
|
||||||
List<DepotHeadVo4List> debtList(
|
List<DepotHeadVo4List> debtList(
|
||||||
|
@Param("organId") Long organId,
|
||||||
|
@Param("type") String type,
|
||||||
|
@Param("subType") String subType,
|
||||||
|
@Param("creatorArray") String[] creatorArray,
|
||||||
|
@Param("status") String status,
|
||||||
|
@Param("number") String number,
|
||||||
|
@Param("beginTime") String beginTime,
|
||||||
|
@Param("endTime") String endTime,
|
||||||
|
@Param("materialParam") String materialParam,
|
||||||
|
@Param("depotArray") String[] depotArray,
|
||||||
|
@Param("offset") Integer offset,
|
||||||
|
@Param("rows") Integer rows);
|
||||||
|
|
||||||
|
int debtListCount(
|
||||||
@Param("organId") Long organId,
|
@Param("organId") Long organId,
|
||||||
@Param("type") String type,
|
@Param("type") String type,
|
||||||
@Param("subType") String subType,
|
@Param("subType") String subType,
|
||||||
|
|||||||
@@ -1234,7 +1234,7 @@ public class DepotHeadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<DepotHeadVo4List> debtList(Long organId, String materialParam, String number, String beginTime, String endTime,
|
public List<DepotHeadVo4List> debtList(Long organId, String materialParam, String number, String beginTime, String endTime,
|
||||||
String type, String subType, String roleType, String status) {
|
String type, String subType, String roleType, String status, Integer offset, Integer rows) {
|
||||||
List<DepotHeadVo4List> resList = new ArrayList<>();
|
List<DepotHeadVo4List> resList = new ArrayList<>();
|
||||||
try{
|
try{
|
||||||
String depotIds = depotService.findDepotStrByCurrentUser();
|
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||||
@@ -1242,7 +1242,8 @@ public class DepotHeadService {
|
|||||||
String [] creatorArray = getCreatorArray(roleType);
|
String [] creatorArray = getCreatorArray(roleType);
|
||||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||||
List<DepotHeadVo4List> list=depotHeadMapperEx.debtList(organId, type, subType, creatorArray, status, number, beginTime, endTime, materialParam, depotArray);
|
List<DepotHeadVo4List> list=depotHeadMapperEx.debtList(organId, type, subType, creatorArray, status, number,
|
||||||
|
beginTime, endTime, materialParam, depotArray, offset, rows);
|
||||||
if (null != list) {
|
if (null != list) {
|
||||||
List<Long> idList = new ArrayList<>();
|
List<Long> idList = new ArrayList<>();
|
||||||
for (DepotHeadVo4List dh : list) {
|
for (DepotHeadVo4List dh : list) {
|
||||||
@@ -1301,4 +1302,22 @@ public class DepotHeadService {
|
|||||||
}
|
}
|
||||||
return resList;
|
return resList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int debtListCount(Long organId, String materialParam, String number, String beginTime, String endTime,
|
||||||
|
String type, String subType, String roleType, String status) {
|
||||||
|
int total = 0;
|
||||||
|
try {
|
||||||
|
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||||
|
String[] depotArray = depotIds.split(",");
|
||||||
|
String[] creatorArray = getCreatorArray(roleType);
|
||||||
|
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
|
||||||
|
endTime = Tools.parseDayToTime(endTime, BusinessConstants.DAY_LAST_TIME);
|
||||||
|
total = depotHeadMapperEx.debtListCount(organId, type, subType, creatorArray, status, number,
|
||||||
|
beginTime, endTime, materialParam, depotArray);
|
||||||
|
} catch(Exception e){
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|||||||
import com.jsh.erp.constants.BusinessConstants;
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.*;
|
import com.jsh.erp.datasource.entities.*;
|
||||||
import com.jsh.erp.datasource.mappers.AccountHeadMapperEx;
|
import com.jsh.erp.datasource.mappers.*;
|
||||||
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.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.exception.JshException;
|
import com.jsh.erp.exception.JshException;
|
||||||
import com.jsh.erp.service.accountHead.AccountHeadService;
|
import com.jsh.erp.service.accountHead.AccountHeadService;
|
||||||
@@ -56,6 +53,8 @@ public class SupplierService {
|
|||||||
@Resource
|
@Resource
|
||||||
private DepotHeadMapperEx depotHeadMapperEx;
|
private DepotHeadMapperEx depotHeadMapperEx;
|
||||||
@Resource
|
@Resource
|
||||||
|
private AccountItemMapperEx accountItemMapperEx;
|
||||||
|
@Resource
|
||||||
private DepotHeadService depotHeadService;
|
private DepotHeadService depotHeadService;
|
||||||
@Resource
|
@Resource
|
||||||
private AccountHeadService accountHeadService;
|
private AccountHeadService accountHeadService;
|
||||||
@@ -403,6 +402,29 @@ public class SupplierService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getBeginNeedByOrganId(Long organId) throws Exception {
|
||||||
|
Supplier supplier = getSupplier(organId);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
BigDecimal needDebt = BigDecimal.ZERO;
|
||||||
|
if("供应商".equals(supplier.getType())) {
|
||||||
|
needDebt = supplier.getBeginNeedPay();
|
||||||
|
} else if("客户".equals(supplier.getType())) {
|
||||||
|
needDebt = supplier.getBeginNeedGet();
|
||||||
|
}
|
||||||
|
BigDecimal finishDebt = accountItemMapperEx.getFinishDebtByOrganId(organId);
|
||||||
|
BigDecimal eachAmount = BigDecimal.ZERO;
|
||||||
|
if(needDebt != null && finishDebt != null) {
|
||||||
|
eachAmount = needDebt.subtract(finishDebt);
|
||||||
|
}
|
||||||
|
//应收欠款
|
||||||
|
map.put("needDebt", needDebt);
|
||||||
|
//已收欠款
|
||||||
|
map.put("finishDebt", finishDebt);
|
||||||
|
//本次收款
|
||||||
|
map.put("eachAmount", eachAmount);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public void importVendor(MultipartFile file, HttpServletRequest request) throws Exception{
|
public void importVendor(MultipartFile file, HttpServletRequest request) throws Exception{
|
||||||
String type = "供应商";
|
String type = "供应商";
|
||||||
Workbook workbook = Workbook.getWorkbook(file.getInputStream());
|
Workbook workbook = Workbook.getWorkbook(file.getInputStream());
|
||||||
|
|||||||
@@ -59,8 +59,13 @@
|
|||||||
and ah.remark like #{bindRemark}
|
and ah.remark like #{bindRemark}
|
||||||
</if>
|
</if>
|
||||||
<if test="number != null and number !=''">
|
<if test="number != null and number !=''">
|
||||||
<bind name="bindNumber" value="'%'+number+'%'"/>
|
<if test="number == 'QiChu'">
|
||||||
and dh.number like #{bindNumber}
|
and ai.bill_id is null
|
||||||
|
</if>
|
||||||
|
<if test="number != 'QiChu'">
|
||||||
|
<bind name="bindNumber" value="'%'+number+'%'"/>
|
||||||
|
and dh.number like #{bindNumber}
|
||||||
|
</if>
|
||||||
</if>
|
</if>
|
||||||
and ifnull(ah.delete_flag,'0') !='1'
|
and ifnull(ah.delete_flag,'0') !='1'
|
||||||
order by ah.id desc
|
order by ah.id desc
|
||||||
@@ -117,8 +122,13 @@
|
|||||||
and ah.remark like #{bindRemark}
|
and ah.remark like #{bindRemark}
|
||||||
</if>
|
</if>
|
||||||
<if test="number != null and number !=''">
|
<if test="number != null and number !=''">
|
||||||
<bind name="bindNumber" value="'%'+number+'%'"/>
|
<if test="number == 'QiChu'">
|
||||||
and dh.number like #{bindNumber}
|
and ai.bill_id is null
|
||||||
|
</if>
|
||||||
|
<if test="number != 'QiChu'">
|
||||||
|
<bind name="bindNumber" value="'%'+number+'%'"/>
|
||||||
|
and dh.number like #{bindNumber}
|
||||||
|
</if>
|
||||||
</if>
|
</if>
|
||||||
and ifnull(ah.delete_flag,'0') !='1') tb
|
and ifnull(ah.delete_flag,'0') !='1') tb
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -124,4 +124,13 @@
|
|||||||
</if>
|
</if>
|
||||||
and ifnull(delete_flag,'0') !='1'
|
and ifnull(delete_flag,'0') !='1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getFinishDebtByOrganId" resultType="java.math.BigDecimal">
|
||||||
|
select ifnull(sum(ai.each_amount),0) from jsh_account_head ah
|
||||||
|
left join jsh_account_item ai on ah.id = ai.header_id and ifnull(ai.delete_flag,'0') !='1'
|
||||||
|
where ah.organ_id = #{organId}
|
||||||
|
and (ah.type = '收款' or ah.type = '付款')
|
||||||
|
and ai.bill_id is null
|
||||||
|
and ifnull(ah.delete_flag,'0') !='1'
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1002,6 +1002,63 @@
|
|||||||
< (dh.discount_last_money + dh.other_money - ifnull(dh.deposit,0))
|
< (dh.discount_last_money + dh.other_money - ifnull(dh.deposit,0))
|
||||||
and ifnull(dh.delete_flag,'0') !='1'
|
and ifnull(dh.delete_flag,'0') !='1'
|
||||||
order by dh.oper_time desc
|
order by dh.oper_time desc
|
||||||
|
<if test="offset != null and rows != null">
|
||||||
|
limit #{offset},#{rows}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="debtListCount" resultType="java.lang.Integer">
|
||||||
|
select count(1) from (
|
||||||
|
select distinct dh.*, s.supplier OrganName, u.username userName
|
||||||
|
from jsh_depot_head dh
|
||||||
|
left join jsh_supplier s on dh.organ_id=s.id and ifnull(s.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_user u on dh.creator=u.id and ifnull(u.Status,'0') !='1'
|
||||||
|
left join jsh_depot_item di on dh.id = di.header_id and ifnull(di.delete_flag,'0') !='1'
|
||||||
|
left join jsh_material m on di.material_id = m.id and ifnull(m.delete_flag,'0') !='1'
|
||||||
|
where 1=1
|
||||||
|
<if test="organId != null">
|
||||||
|
and dh.organ_id = #{organId}
|
||||||
|
</if>
|
||||||
|
<if test="type != null">
|
||||||
|
and dh.type=#{type}
|
||||||
|
</if>
|
||||||
|
<if test="subType != null">
|
||||||
|
and dh.sub_type=#{subType}
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
and dh.status =#{status}
|
||||||
|
</if>
|
||||||
|
<if test="number != null">
|
||||||
|
<bind name="bindNumber" value="'%'+number+'%'"/>
|
||||||
|
and dh.number like #{bindNumber}
|
||||||
|
</if>
|
||||||
|
<if test="beginTime != null">
|
||||||
|
and dh.oper_time >= #{beginTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null">
|
||||||
|
and dh.oper_time <= #{endTime}
|
||||||
|
</if>
|
||||||
|
<if test="materialParam != null and materialParam !=''">
|
||||||
|
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
||||||
|
and (m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
|
||||||
|
</if>
|
||||||
|
<if test="depotArray != null and depotArray !=''">
|
||||||
|
and di.depot_id in (
|
||||||
|
<foreach collection="depotArray" item="depotId" separator=",">
|
||||||
|
#{depotId}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="creatorArray != null">
|
||||||
|
and dh.creator in (
|
||||||
|
<foreach collection="creatorArray" item="creator" separator=",">
|
||||||
|
#{creator}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
and (abs(dh.change_amount)+(select ifnull(sum(abs(ai.each_amount)),0) from jsh_account_item ai where ai.bill_id=dh.id and ifnull(ai.delete_flag,'0') !='1'))
|
||||||
|
< (dh.discount_last_money + dh.other_money - ifnull(dh.deposit,0))
|
||||||
|
and ifnull(dh.delete_flag,'0') !='1' ) tb
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getFinishDepositByNumberList" resultType="com.jsh.erp.datasource.vo.FinishDepositVo">
|
<select id="getFinishDepositByNumberList" resultType="com.jsh.erp.datasource.vo.FinishDepositVo">
|
||||||
|
|||||||
Reference in New Issue
Block a user