优化客户对账和供应商对账的导出excel功能
This commit is contained in:
@@ -29,6 +29,7 @@ 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 javax.servlet.http.HttpServletResponse;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@@ -547,4 +548,41 @@ public class DepotHeadController {
|
|||||||
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出存在欠款的单据
|
||||||
|
* @param organId
|
||||||
|
* @param materialParam
|
||||||
|
* @param number
|
||||||
|
* @param type
|
||||||
|
* @param subType
|
||||||
|
* @param beginTime
|
||||||
|
* @param endTime
|
||||||
|
* @param roleType
|
||||||
|
* @param status
|
||||||
|
* @param mpList
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/debtExport")
|
||||||
|
@ApiOperation(value = "导出存在欠款的单据")
|
||||||
|
public void debtExport(@RequestParam(value = "organId", required = false) Long organId,
|
||||||
|
@RequestParam(value = "materialParam", required = false) String materialParam,
|
||||||
|
@RequestParam(value = "number", required = false) String number,
|
||||||
|
@RequestParam(value = "type", required = false) String type,
|
||||||
|
@RequestParam(value = "subType", required = false) String subType,
|
||||||
|
@RequestParam(value = "beginTime", required = false) String beginTime,
|
||||||
|
@RequestParam(value = "endTime", required = false) String endTime,
|
||||||
|
@RequestParam(value = "roleType", required = false) String roleType,
|
||||||
|
@RequestParam(value = "status", required = false) String status,
|
||||||
|
@RequestParam(value = "mpList", required = false) String mpList,
|
||||||
|
HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||||
|
try {
|
||||||
|
depotHeadService.debtExport(organId, materialParam, number, type, subType, beginTime, endTime, roleType,
|
||||||
|
status, mpList, request, response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public class DepotItemController {
|
|||||||
item.put("standard", diEx.getMStandard());
|
item.put("standard", diEx.getMStandard());
|
||||||
item.put("model", diEx.getMModel());
|
item.put("model", diEx.getMModel());
|
||||||
item.put("color", diEx.getMColor());
|
item.put("color", diEx.getMColor());
|
||||||
item.put("materialOther", getOtherInfo(mpArr, diEx));
|
item.put("materialOther", depotItemService.getOtherInfo(mpArr, diEx));
|
||||||
BigDecimal stock;
|
BigDecimal stock;
|
||||||
Unit unitInfo = materialService.findUnit(diEx.getMaterialId()); //查询计量单位信息
|
Unit unitInfo = materialService.findUnit(diEx.getMaterialId()); //查询计量单位信息
|
||||||
String materialUnit = diEx.getMaterialUnit();
|
String materialUnit = diEx.getMaterialUnit();
|
||||||
@@ -302,30 +302,6 @@ public class DepotItemController {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取扩展信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx)throws Exception {
|
|
||||||
String materialOther = "";
|
|
||||||
for (int i = 0; i < mpArr.length; i++) {
|
|
||||||
if (mpArr[i].equals("制造商")) {
|
|
||||||
materialOther = materialOther + ((diEx.getMMfrs() == null || diEx.getMMfrs().equals("")) ? "" : "(" + diEx.getMMfrs() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("自定义1")) {
|
|
||||||
materialOther = materialOther + ((diEx.getMOtherField1() == null || diEx.getMOtherField1().equals("")) ? "" : "(" + diEx.getMOtherField1() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("自定义2")) {
|
|
||||||
materialOther = materialOther + ((diEx.getMOtherField2() == null || diEx.getMOtherField2().equals("")) ? "" : "(" + diEx.getMOtherField2() + ")");
|
|
||||||
}
|
|
||||||
if (mpArr[i].equals("自定义3")) {
|
|
||||||
materialOther = materialOther + ((diEx.getMOtherField3() == null || diEx.getMOtherField3().equals("")) ? "" : "(" + diEx.getMOtherField3() + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return materialOther;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进销存统计
|
* 进销存统计
|
||||||
* @param currentPage
|
* @param currentPage
|
||||||
@@ -374,7 +350,7 @@ public class DepotItemController {
|
|||||||
item.put("materialModel", diEx.getMModel());
|
item.put("materialModel", diEx.getMModel());
|
||||||
item.put("materialStandard", diEx.getMStandard());
|
item.put("materialStandard", diEx.getMStandard());
|
||||||
//扩展信息
|
//扩展信息
|
||||||
String materialOther = getOtherInfo(mpArr, diEx);
|
String materialOther = depotItemService.getOtherInfo(mpArr, diEx);
|
||||||
item.put("materialOther", materialOther);
|
item.put("materialOther", materialOther);
|
||||||
item.put("materialColor", diEx.getMColor());
|
item.put("materialColor", diEx.getMColor());
|
||||||
item.put("unitId", diEx.getUnitId());
|
item.put("unitId", diEx.getUnitId());
|
||||||
@@ -537,7 +513,7 @@ public class DepotItemController {
|
|||||||
item.put("materialModel", diEx.getMModel());
|
item.put("materialModel", diEx.getMModel());
|
||||||
item.put("materialStandard", diEx.getMStandard());
|
item.put("materialStandard", diEx.getMStandard());
|
||||||
//扩展信息
|
//扩展信息
|
||||||
String materialOther = getOtherInfo(mpArr, diEx);
|
String materialOther = depotItemService.getOtherInfo(mpArr, diEx);
|
||||||
item.put("materialOther", materialOther);
|
item.put("materialOther", materialOther);
|
||||||
item.put("materialColor", diEx.getMColor());
|
item.put("materialColor", diEx.getMColor());
|
||||||
item.put("materialUnit", diEx.getMaterialUnit());
|
item.put("materialUnit", diEx.getMaterialUnit());
|
||||||
@@ -618,7 +594,7 @@ public class DepotItemController {
|
|||||||
item.put("materialModel", diEx.getMModel());
|
item.put("materialModel", diEx.getMModel());
|
||||||
item.put("materialStandard", diEx.getMStandard());
|
item.put("materialStandard", diEx.getMStandard());
|
||||||
//扩展信息
|
//扩展信息
|
||||||
String materialOther = getOtherInfo(mpArr, diEx);
|
String materialOther = depotItemService.getOtherInfo(mpArr, diEx);
|
||||||
item.put("materialOther", materialOther);
|
item.put("materialOther", materialOther);
|
||||||
item.put("materialColor", diEx.getMColor());
|
item.put("materialColor", diEx.getMColor());
|
||||||
item.put("materialUnit", diEx.getMaterialUnit());
|
item.put("materialUnit", diEx.getMaterialUnit());
|
||||||
@@ -700,7 +676,7 @@ public class DepotItemController {
|
|||||||
item.put("materialModel", diEx.getMModel());
|
item.put("materialModel", diEx.getMModel());
|
||||||
item.put("materialStandard", diEx.getMStandard());
|
item.put("materialStandard", diEx.getMStandard());
|
||||||
//扩展信息
|
//扩展信息
|
||||||
String materialOther = getOtherInfo(mpArr, diEx);
|
String materialOther = depotItemService.getOtherInfo(mpArr, diEx);
|
||||||
item.put("materialOther", materialOther);
|
item.put("materialOther", materialOther);
|
||||||
item.put("materialColor", diEx.getMColor());
|
item.put("materialColor", diEx.getMColor());
|
||||||
item.put("materialUnit", diEx.getMaterialUnit());
|
item.put("materialUnit", diEx.getMaterialUnit());
|
||||||
@@ -781,7 +757,7 @@ public class DepotItemController {
|
|||||||
diEx.setMOtherField1(disw.getMOtherField1());
|
diEx.setMOtherField1(disw.getMOtherField1());
|
||||||
diEx.setMOtherField2(disw.getMOtherField2());
|
diEx.setMOtherField2(disw.getMOtherField2());
|
||||||
diEx.setMOtherField3(disw.getMOtherField3());
|
diEx.setMOtherField3(disw.getMOtherField3());
|
||||||
disw.setMaterialOther(getOtherInfo(mpArr, diEx));
|
disw.setMaterialOther(depotItemService.getOtherInfo(mpArr, diEx));
|
||||||
disw.setMaterialUnit(getUName(disw.getMaterialUnit(), disw.getUnitName()));
|
disw.setMaterialUnit(getUName(disw.getMaterialUnit(), disw.getUnitName()));
|
||||||
if(null!=disw.getLowSafeStock() && disw.getCurrentNumber().compareTo(disw.getLowSafeStock())<0) {
|
if(null!=disw.getLowSafeStock() && disw.getCurrentNumber().compareTo(disw.getLowSafeStock())<0) {
|
||||||
disw.setLowCritical(disw.getLowSafeStock().subtract(disw.getCurrentNumber()));
|
disw.setLowCritical(disw.getLowSafeStock().subtract(disw.getCurrentNumber()));
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ public interface DepotItemMapperEx {
|
|||||||
List<DepotItemVo4WithInfoEx> getDetailList(
|
List<DepotItemVo4WithInfoEx> getDetailList(
|
||||||
@Param("headerId") Long headerId);
|
@Param("headerId") Long headerId);
|
||||||
|
|
||||||
|
List<DepotItemVo4WithInfoEx> getBillDetailListByIds(
|
||||||
|
@Param("idList") List<Long> idList);
|
||||||
|
|
||||||
List<DepotItemVo4WithInfoEx> findByAll(
|
List<DepotItemVo4WithInfoEx> findByAll(
|
||||||
@Param("materialParam") String materialParam,
|
@Param("materialParam") String materialParam,
|
||||||
@Param("categoryIdList") List<Long> categoryIdList,
|
@Param("categoryIdList") List<Long> categoryIdList,
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.jsh.erp.datasource.vo;
|
||||||
|
|
||||||
|
public class BillListCacheVo {
|
||||||
|
|
||||||
|
private String number;
|
||||||
|
|
||||||
|
private String organName;
|
||||||
|
|
||||||
|
private String operTimeStr;
|
||||||
|
|
||||||
|
public String getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber(String number) {
|
||||||
|
this.number = number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrganName() {
|
||||||
|
return organName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrganName(String organName) {
|
||||||
|
this.organName = organName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperTimeStr() {
|
||||||
|
return operTimeStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperTimeStr(String operTimeStr) {
|
||||||
|
this.operTimeStr = operTimeStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jsh.erp.service.depotHead;
|
package com.jsh.erp.service.depotHead;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jsh.erp.constants.BusinessConstants;
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
@@ -24,8 +25,11 @@ import com.jsh.erp.service.supplier.SupplierService;
|
|||||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||||
import com.jsh.erp.service.user.UserService;
|
import com.jsh.erp.service.user.UserService;
|
||||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
|
import com.jsh.erp.utils.ExcelUtils;
|
||||||
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 jxl.Workbook;
|
||||||
|
import jxl.write.WritableWorkbook;
|
||||||
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;
|
||||||
@@ -35,6 +39,8 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.File;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -1229,47 +1235,7 @@ public class DepotHeadService {
|
|||||||
List<DepotHeadVo4List> list=depotHeadMapperEx.debtList(organId, creatorArray, status, number,
|
List<DepotHeadVo4List> list=depotHeadMapperEx.debtList(organId, creatorArray, status, number,
|
||||||
beginTime, endTime, materialParam, depotArray, offset, rows);
|
beginTime, endTime, materialParam, depotArray, offset, rows);
|
||||||
if (null != list) {
|
if (null != list) {
|
||||||
List<Long> idList = new ArrayList<>();
|
resList = parseDebtBillList(list);
|
||||||
for (DepotHeadVo4List dh : list) {
|
|
||||||
idList.add(dh.getId());
|
|
||||||
}
|
|
||||||
//通过批量查询去构造map
|
|
||||||
Map<Long,String> materialsListMap = findMaterialsListMapByHeaderIdList(idList);
|
|
||||||
for (DepotHeadVo4List dh : list) {
|
|
||||||
if(dh.getChangeAmount() != null) {
|
|
||||||
dh.setChangeAmount(dh.getChangeAmount().abs());
|
|
||||||
}
|
|
||||||
if(dh.getTotalPrice() != null) {
|
|
||||||
dh.setTotalPrice(dh.getTotalPrice().abs());
|
|
||||||
}
|
|
||||||
if(dh.getDeposit() == null) {
|
|
||||||
dh.setDeposit(BigDecimal.ZERO);
|
|
||||||
}
|
|
||||||
if(dh.getOperTime() != null) {
|
|
||||||
dh.setOperTimeStr(getCenternTime(dh.getOperTime()));
|
|
||||||
}
|
|
||||||
BigDecimal discountLastMoney = dh.getDiscountLastMoney()!=null?dh.getDiscountLastMoney():BigDecimal.ZERO;
|
|
||||||
BigDecimal otherMoney = dh.getOtherMoney()!=null?dh.getOtherMoney():BigDecimal.ZERO;
|
|
||||||
BigDecimal deposit = dh.getDeposit()!=null?dh.getDeposit():BigDecimal.ZERO;
|
|
||||||
BigDecimal changeAmount = dh.getChangeAmount()!=null?dh.getChangeAmount().abs():BigDecimal.ZERO;
|
|
||||||
//本单欠款(如果退货则为负数)
|
|
||||||
dh.setNeedDebt(discountLastMoney.add(otherMoney).subtract(deposit.add(changeAmount)));
|
|
||||||
if(BusinessConstants.SUB_TYPE_PURCHASE_RETURN.equals(dh.getSubType()) || BusinessConstants.SUB_TYPE_SALES_RETURN.equals(dh.getSubType())) {
|
|
||||||
dh.setNeedDebt(BigDecimal.ZERO.subtract(dh.getNeedDebt()));
|
|
||||||
}
|
|
||||||
BigDecimal needDebt = dh.getNeedDebt()!=null?dh.getNeedDebt():BigDecimal.ZERO;
|
|
||||||
BigDecimal finishDebt = accountItemService.getEachAmountByBillId(dh.getId());
|
|
||||||
finishDebt = finishDebt!=null?finishDebt:BigDecimal.ZERO;
|
|
||||||
//已收欠款
|
|
||||||
dh.setFinishDebt(finishDebt);
|
|
||||||
//待收欠款
|
|
||||||
dh.setDebt(needDebt.subtract(finishDebt));
|
|
||||||
//商品信息简述
|
|
||||||
if(materialsListMap!=null) {
|
|
||||||
dh.setMaterialsList(materialsListMap.get(dh.getId()));
|
|
||||||
}
|
|
||||||
resList.add(dh);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
JshException.readFail(logger, e);
|
JshException.readFail(logger, e);
|
||||||
@@ -1294,6 +1260,175 @@ public class DepotHeadService {
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void debtExport(Long organId, String materialParam, String number, String type, String subType,
|
||||||
|
String beginTime, String endTime, String roleType, String status, String mpList,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
Long userId = userService.getUserId(request);
|
||||||
|
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
||||||
|
String billCategory = getBillCategory(subType);
|
||||||
|
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||||
|
String[] depotArray = depotIds.split(",");
|
||||||
|
String[] creatorArray = getCreatorArray(roleType);
|
||||||
|
status = StringUtil.isNotEmpty(status) ? status : null;
|
||||||
|
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
|
||||||
|
endTime = Tools.parseDayToTime(endTime, BusinessConstants.DAY_LAST_TIME);
|
||||||
|
List<DepotHeadVo4List> dhList = new ArrayList<>();
|
||||||
|
List<DepotHeadVo4List> list = depotHeadMapperEx.debtList(organId, creatorArray, status, number,
|
||||||
|
beginTime, endTime, materialParam, depotArray, null, null);
|
||||||
|
if (null != list) {
|
||||||
|
dhList = parseDebtBillList(list);
|
||||||
|
}
|
||||||
|
//生成Excel文件
|
||||||
|
String fileName = "单据信息";
|
||||||
|
File file = new File("/opt/"+ fileName);
|
||||||
|
WritableWorkbook wtwb = Workbook.createWorkbook(file);
|
||||||
|
String oneTip = "";
|
||||||
|
String sheetOneStr = "";
|
||||||
|
if("采购".equals(subType)) {
|
||||||
|
oneTip = "供应商对账列表";
|
||||||
|
sheetOneStr = "供应商,单据编号,关联单据,商品信息,单据日期,操作员,单据金额,本单欠款,已付欠款,待付欠款,备注";
|
||||||
|
} else if("出库".equals(type) && "销售".equals(subType)) {
|
||||||
|
oneTip = "客户对账列表";
|
||||||
|
sheetOneStr = "客户,单据编号,关联单据,商品信息,单据日期,操作员,单据金额,本单欠款,已收欠款,待收欠款,备注";
|
||||||
|
}
|
||||||
|
if(StringUtil.isNotEmpty(beginTime) && StringUtil.isNotEmpty(endTime)) {
|
||||||
|
oneTip = oneTip + "(" + beginTime + "至" + endTime + ")";
|
||||||
|
}
|
||||||
|
List<String> sheetOneList = StringUtil.strToStringList(sheetOneStr);
|
||||||
|
String[] sheetOneArr = StringUtil.listToStringArray(sheetOneList);
|
||||||
|
List<Long> idList = new ArrayList<>();
|
||||||
|
List<String[]> billList = new ArrayList<>();
|
||||||
|
Map<Long, BillListCacheVo> billListCacheVoMap = new HashMap<>();
|
||||||
|
for (DepotHeadVo4List dh : dhList) {
|
||||||
|
idList.add(dh.getId());
|
||||||
|
BillListCacheVo billListCacheVo = new BillListCacheVo();
|
||||||
|
billListCacheVo.setNumber(dh.getNumber());
|
||||||
|
billListCacheVo.setOrganName(dh.getOrganName());
|
||||||
|
billListCacheVo.setOperTimeStr(getCenternTime(dh.getOperTime()));
|
||||||
|
billListCacheVoMap.put(dh.getId(), billListCacheVo);
|
||||||
|
String[] objs = new String[100];
|
||||||
|
objs[0] = dh.getOrganName();
|
||||||
|
objs[1] = dh.getNumber();
|
||||||
|
objs[2] = dh.getLinkNumber();
|
||||||
|
objs[3] = dh.getMaterialsList();
|
||||||
|
objs[4] = dh.getOperTimeStr();
|
||||||
|
objs[5] = dh.getUserName();
|
||||||
|
BigDecimal discountLastMoney = dh.getDiscountLastMoney() == null ? BigDecimal.ZERO : dh.getDiscountLastMoney();
|
||||||
|
BigDecimal otherMoney = dh.getOtherMoney() == null ? BigDecimal.ZERO : dh.getOtherMoney();
|
||||||
|
BigDecimal deposit = dh.getDeposit() == null ? BigDecimal.ZERO : dh.getDeposit();
|
||||||
|
objs[6] = parseDecimalToStr(discountLastMoney.add(otherMoney).subtract(deposit), 2);
|
||||||
|
objs[7] = parseDecimalToStr(dh.getNeedDebt(), 2);
|
||||||
|
objs[8] = parseDecimalToStr(dh.getFinishDebt(), 2);
|
||||||
|
objs[9] = parseDecimalToStr(dh.getDebt(), 2);
|
||||||
|
objs[10] = dh.getRemark();
|
||||||
|
billList.add(objs);
|
||||||
|
}
|
||||||
|
ExcelUtils.exportObjectsWithTitle(wtwb, oneTip, sheetOneArr, "单据列表", 0, billList);
|
||||||
|
//导出明细数据
|
||||||
|
if(idList.size()>0) {
|
||||||
|
List<DepotItemVo4WithInfoEx> dataList = depotItemMapperEx.getBillDetailListByIds(idList);
|
||||||
|
String[] mpArr = mpList.split(",");
|
||||||
|
String twoTip = "";
|
||||||
|
String sheetTwoStr = "";
|
||||||
|
if ("采购".equals(subType)) {
|
||||||
|
twoTip = "供应商单据明细";
|
||||||
|
sheetTwoStr = "供应商,单据编号,单据日期,仓库名称,条码,名称,规格,型号,颜色,扩展信息,单位,序列号,批号,有效期,多属性,数量,单价,金额,税率(%),税额,价税合计,重量,备注";
|
||||||
|
} else if ("销售".equals(subType)) {
|
||||||
|
twoTip = "客户单据明细";
|
||||||
|
sheetTwoStr = "客户,单据编号,单据日期,仓库名称,条码,名称,规格,型号,颜色,扩展信息,单位,序列号,批号,有效期,多属性,数量,单价,金额,税率(%),税额,价税合计,重量,备注";
|
||||||
|
}
|
||||||
|
if (StringUtil.isNotEmpty(beginTime) && StringUtil.isNotEmpty(endTime)) {
|
||||||
|
twoTip = twoTip + "(" + beginTime + "至" + endTime + ")";
|
||||||
|
}
|
||||||
|
List<String> sheetTwoList = StringUtil.strToStringList(sheetTwoStr);
|
||||||
|
String[] sheetTwoArr = StringUtil.listToStringArray(sheetTwoList);
|
||||||
|
List<String[]> billDetail = new ArrayList<>();
|
||||||
|
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||||
|
String[] objs = new String[100];
|
||||||
|
BillListCacheVo billListCacheVo = billListCacheVoMap.get(diEx.getHeaderId());
|
||||||
|
objs[0] = billListCacheVo != null ? billListCacheVo.getOrganName() : "";
|
||||||
|
objs[1] = billListCacheVo != null ? billListCacheVo.getNumber() : "";
|
||||||
|
objs[2] = billListCacheVo != null ? billListCacheVo.getOperTimeStr() : "";
|
||||||
|
objs[3] = diEx.getDepotId() == null ? "" : diEx.getDepotName();
|
||||||
|
objs[4] = diEx.getBarCode();
|
||||||
|
objs[5] = diEx.getMName();
|
||||||
|
objs[6] = diEx.getMStandard();
|
||||||
|
objs[7] = diEx.getMModel();
|
||||||
|
objs[8] = diEx.getMColor();
|
||||||
|
objs[9] = depotItemService.getOtherInfo(mpArr, diEx);
|
||||||
|
objs[10] = diEx.getMaterialUnit();
|
||||||
|
objs[11] = diEx.getSnList();
|
||||||
|
objs[12] = diEx.getBatchNumber();
|
||||||
|
objs[13] = Tools.parseDateToStr(diEx.getExpirationDate());
|
||||||
|
objs[14] = diEx.getSku();
|
||||||
|
objs[15] = parseDecimalToStr(diEx.getOperNumber(), 2);
|
||||||
|
objs[16] = parseDecimalToStr(roleService.parseBillPriceByLimit(diEx.getUnitPrice(), billCategory, priceLimit, request), 2);
|
||||||
|
objs[17] = parseDecimalToStr(roleService.parseBillPriceByLimit(diEx.getAllPrice(), billCategory, priceLimit, request), 2);
|
||||||
|
objs[18] = parseDecimalToStr(roleService.parseBillPriceByLimit(diEx.getTaxRate(), billCategory, priceLimit, request), 2);
|
||||||
|
objs[19] = parseDecimalToStr(roleService.parseBillPriceByLimit(diEx.getTaxMoney(), billCategory, priceLimit, request), 2);
|
||||||
|
objs[20] = parseDecimalToStr(roleService.parseBillPriceByLimit(diEx.getTaxLastMoney(), billCategory, priceLimit, request), 2);
|
||||||
|
BigDecimal allWeight = diEx.getBasicNumber() == null || diEx.getWeight() == null ? BigDecimal.ZERO : diEx.getBasicNumber().multiply(diEx.getWeight());
|
||||||
|
objs[21] = parseDecimalToStr(allWeight, 2);
|
||||||
|
objs[22] = diEx.getRemark();
|
||||||
|
billDetail.add(objs);
|
||||||
|
}
|
||||||
|
ExcelUtils.exportObjectsWithTitle(wtwb, twoTip, sheetTwoArr, "单据明细", 1, billDetail);
|
||||||
|
}
|
||||||
|
wtwb.write();
|
||||||
|
wtwb.close();
|
||||||
|
ExcelUtils.downloadExcel(file, file.getName(), response);
|
||||||
|
} catch(Exception e){
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DepotHeadVo4List> parseDebtBillList(List<DepotHeadVo4List> list) throws Exception {
|
||||||
|
List<Long> idList = new ArrayList<>();
|
||||||
|
List<DepotHeadVo4List> dhList = new ArrayList<>();
|
||||||
|
for (DepotHeadVo4List dh : list) {
|
||||||
|
idList.add(dh.getId());
|
||||||
|
}
|
||||||
|
//通过批量查询去构造map
|
||||||
|
Map<Long,String> materialsListMap = findMaterialsListMapByHeaderIdList(idList);
|
||||||
|
for (DepotHeadVo4List dh : list) {
|
||||||
|
if(dh.getChangeAmount() != null) {
|
||||||
|
dh.setChangeAmount(dh.getChangeAmount().abs());
|
||||||
|
}
|
||||||
|
if(dh.getTotalPrice() != null) {
|
||||||
|
dh.setTotalPrice(dh.getTotalPrice().abs());
|
||||||
|
}
|
||||||
|
if(dh.getDeposit() == null) {
|
||||||
|
dh.setDeposit(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
if(dh.getOperTime() != null) {
|
||||||
|
dh.setOperTimeStr(getCenternTime(dh.getOperTime()));
|
||||||
|
}
|
||||||
|
BigDecimal discountLastMoney = dh.getDiscountLastMoney()!=null?dh.getDiscountLastMoney():BigDecimal.ZERO;
|
||||||
|
BigDecimal otherMoney = dh.getOtherMoney()!=null?dh.getOtherMoney():BigDecimal.ZERO;
|
||||||
|
BigDecimal deposit = dh.getDeposit()!=null?dh.getDeposit():BigDecimal.ZERO;
|
||||||
|
BigDecimal changeAmount = dh.getChangeAmount()!=null?dh.getChangeAmount().abs():BigDecimal.ZERO;
|
||||||
|
//本单欠款(如果退货则为负数)
|
||||||
|
dh.setNeedDebt(discountLastMoney.add(otherMoney).subtract(deposit.add(changeAmount)));
|
||||||
|
if(BusinessConstants.SUB_TYPE_PURCHASE_RETURN.equals(dh.getSubType()) || BusinessConstants.SUB_TYPE_SALES_RETURN.equals(dh.getSubType())) {
|
||||||
|
dh.setNeedDebt(BigDecimal.ZERO.subtract(dh.getNeedDebt()));
|
||||||
|
}
|
||||||
|
BigDecimal needDebt = dh.getNeedDebt()!=null?dh.getNeedDebt():BigDecimal.ZERO;
|
||||||
|
BigDecimal finishDebt = accountItemService.getEachAmountByBillId(dh.getId());
|
||||||
|
finishDebt = finishDebt!=null?finishDebt:BigDecimal.ZERO;
|
||||||
|
//已收欠款
|
||||||
|
dh.setFinishDebt(finishDebt);
|
||||||
|
//待收欠款
|
||||||
|
dh.setDebt(needDebt.subtract(finishDebt));
|
||||||
|
//商品信息简述
|
||||||
|
if(materialsListMap!=null) {
|
||||||
|
dh.setMaterialsList(materialsListMap.get(dh.getId()));
|
||||||
|
}
|
||||||
|
dhList.add(dh);
|
||||||
|
}
|
||||||
|
return dhList;
|
||||||
|
}
|
||||||
|
|
||||||
public String getBillCategory(String subType) {
|
public String getBillCategory(String subType) {
|
||||||
if(subType.equals("零售") || subType.equals("零售退货")) {
|
if(subType.equals("零售") || subType.equals("零售退货")) {
|
||||||
return "retail";
|
return "retail";
|
||||||
@@ -1303,4 +1438,43 @@ public class DepotHeadService {
|
|||||||
return "buy";
|
return "buy";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化金额样式
|
||||||
|
* @param decimal
|
||||||
|
* @param num
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String parseDecimalToStr(BigDecimal decimal, Integer num) {
|
||||||
|
return decimal == null ? "" : decimal.setScale(num, BigDecimal.ROUND_HALF_UP).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String parseStatusToStr(String status, String type) {
|
||||||
|
if(StringUtil.isNotEmpty(status)) {
|
||||||
|
if("purchase".equals(type)) {
|
||||||
|
switch (status) {
|
||||||
|
case "2":
|
||||||
|
return "完成采购";
|
||||||
|
case "3":
|
||||||
|
return "部分采购";
|
||||||
|
}
|
||||||
|
} else if("sale".equals(type)) {
|
||||||
|
switch (status) {
|
||||||
|
case "2":
|
||||||
|
return "完成销售";
|
||||||
|
case "3":
|
||||||
|
return "部分销售";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (status) {
|
||||||
|
case "0":
|
||||||
|
return "未审核";
|
||||||
|
case "1":
|
||||||
|
return "已审核";
|
||||||
|
case "9":
|
||||||
|
return "审核中";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1224,4 +1224,27 @@ public class DepotItemService {
|
|||||||
return stock!=null? stock: BigDecimal.ZERO;
|
return stock!=null? stock: BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取扩展信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx)throws Exception {
|
||||||
|
String materialOther = "";
|
||||||
|
for (int i = 0; i < mpArr.length; i++) {
|
||||||
|
if (mpArr[i].equals("制造商")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMMfrs() == null || diEx.getMMfrs().equals("")) ? "" : "(" + diEx.getMMfrs() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("自定义1")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMOtherField1() == null || diEx.getMOtherField1().equals("")) ? "" : "(" + diEx.getMOtherField1() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("自定义2")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMOtherField2() == null || diEx.getMOtherField2().equals("")) ? "" : "(" + diEx.getMOtherField2() + ")");
|
||||||
|
}
|
||||||
|
if (mpArr[i].equals("自定义3")) {
|
||||||
|
materialOther = materialOther + ((diEx.getMOtherField3() == null || diEx.getMOtherField3().equals("")) ? "" : "(" + diEx.getMOtherField3() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return materialOther;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,73 @@ public class ExcelUtils {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel,带多sheet
|
||||||
|
*
|
||||||
|
* @param wtwb
|
||||||
|
* @param tip
|
||||||
|
* @param names
|
||||||
|
* @param title
|
||||||
|
* @param index
|
||||||
|
* @param objects
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void exportObjectsWithTitle(WritableWorkbook wtwb, String tip,
|
||||||
|
String[] names, String title, int index, List<String[]> objects)
|
||||||
|
throws Exception {
|
||||||
|
WritableSheet sheet = wtwb.createSheet(title, index);
|
||||||
|
sheet.getSettings().setDefaultColumnWidth(12);
|
||||||
|
|
||||||
|
// 标题的格式-红色
|
||||||
|
WritableFont redWF = new WritableFont(WritableFont.ARIAL, 12,
|
||||||
|
WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
|
||||||
|
Colour.RED);
|
||||||
|
WritableCellFormat redWFFC = new WritableCellFormat(redWF);
|
||||||
|
redWFFC.setVerticalAlignment(VerticalAlignment.CENTRE);
|
||||||
|
redWFFC.setBorder(Border.ALL, BorderLineStyle.THIN);
|
||||||
|
|
||||||
|
// 标题的格式-黑色
|
||||||
|
WritableFont blackWF = new WritableFont(WritableFont.ARIAL, 12,
|
||||||
|
WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
|
||||||
|
Colour.BLACK);
|
||||||
|
WritableCellFormat blackWFFC = new WritableCellFormat(blackWF);
|
||||||
|
blackWFFC.setVerticalAlignment(VerticalAlignment.CENTRE);
|
||||||
|
blackWFFC.setBorder(Border.ALL, BorderLineStyle.THIN);
|
||||||
|
|
||||||
|
// 设置字体以及单元格格式
|
||||||
|
WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 12);
|
||||||
|
WritableCellFormat format = new WritableCellFormat(wfont);
|
||||||
|
format.setAlignment(Alignment.LEFT);
|
||||||
|
format.setVerticalAlignment(VerticalAlignment.TOP);
|
||||||
|
|
||||||
|
// 第一行写入提示
|
||||||
|
if(com.jsh.erp.utils.StringUtil.isNotEmpty(tip) && tip.contains("*")) {
|
||||||
|
sheet.addCell(new Label(0, 0, tip, redWFFC));
|
||||||
|
} else {
|
||||||
|
sheet.addCell(new Label(0, 0, tip, blackWFFC));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第二行写入标题
|
||||||
|
for (int i = 0; i < names.length; i++) {
|
||||||
|
if(StringUtil.isNotEmpty(names[i]) && names[i].contains("*")) {
|
||||||
|
sheet.addCell(new Label(i, 1, names[i], redWFFC));
|
||||||
|
} else {
|
||||||
|
sheet.addCell(new Label(i, 1, names[i], blackWFFC));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其余行依次写入数据
|
||||||
|
int rowNum = 2;
|
||||||
|
for (int j = 0; j < objects.size(); j++) {
|
||||||
|
String[] obj = objects.get(j);
|
||||||
|
for (int h = 0; h < obj.length; h++) {
|
||||||
|
sheet.addCell(new Label(h, rowNum, obj[h], format));
|
||||||
|
}
|
||||||
|
rowNum = rowNum + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出excel,不需要第一行的title
|
* 导出excel,不需要第一行的title
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -315,6 +315,23 @@
|
|||||||
order by di.id asc
|
order by di.id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getBillDetailListByIds" resultType="com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx">
|
||||||
|
select di.*,m.name MName,m.model MModel,m.unit MaterialUnit,m.color MColor,m.standard MStandard,m.mfrs MMfrs,m.weight, m.img_name,
|
||||||
|
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,m.enable_serial_number, m.enable_batch_number,
|
||||||
|
dp1.name DepotName,dp2.name AnotherDepotName, me.bar_code barCode, me.purchase_decimal
|
||||||
|
from jsh_depot_item di
|
||||||
|
left join jsh_material m on di.material_id=m.id and ifnull(m.delete_flag,'0') !='1'
|
||||||
|
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_depot dp1 on di.depot_id=dp1.id and ifnull(dp1.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_depot dp2 on di.another_depot_id=dp2.id and ifnull(dp2.delete_Flag,'0') !='1'
|
||||||
|
where ifnull(di.delete_flag,'0') !='1'
|
||||||
|
and di.header_id in
|
||||||
|
<foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
order by di.header_id desc, di.id asc
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial">
|
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial">
|
||||||
select m.id MId, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,
|
select m.id MId, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,
|
||||||
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
|
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
|
||||||
|
|||||||
Reference in New Issue
Block a user