package com.ld.igds.inout.view;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import com.bstek.bdf2.core.business.IUser;
|
import com.ld.igds.constant.Constant;
|
import com.ld.igds.inout.InoutConstant;
|
import com.ld.igds.inout.dto.InoutData;
|
import com.ld.igds.inout.dto.InoutParam;
|
import com.ld.igds.inout.manager.InoutReportManager;
|
import com.ld.igds.inout.mapper.InoutSettleServiceMapper;
|
import com.ld.igds.models.DicTrigger;
|
import com.ld.igds.models.InoutRecord;
|
|
import com.ld.igds.util.ContextUtil;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.bstek.dorado.annotation.DataProvider;
|
import com.bstek.dorado.annotation.Expose;
|
import com.bstek.dorado.data.provider.Page;
|
import com.ld.igds.inout.service.HInoutSettleService;
|
import com.ld.igds.models.InoutSettle;
|
|
import javax.annotation.Resource;
|
|
/**
|
* 结算管理
|
*
|
* @author chen
|
*/
|
@Component
|
public class InoutSettlePR {
|
|
@Resource
|
private HInoutSettleService hSettleService;
|
|
@Resource
|
private InoutReportManager inoutReportManager;
|
|
@Resource
|
private InoutSettleServiceMapper inoutSettleServiceMapper;
|
|
/**
|
* 是否结算
|
* ${dorado.getDataProvider("inoutSettlePR#triggerSettleTag").getResult()}
|
*
|
* @return
|
*/
|
@DataProvider
|
public List<DicTrigger> triggerSettleTag() {
|
List<DicTrigger> list = new ArrayList<DicTrigger>();
|
list.add(new DicTrigger(Constant.YN_N, "未结算"));
|
list.add(new DicTrigger(Constant.YN_Y, "已结算"));
|
return list;
|
}
|
|
/**
|
* 结算方式 0:现金,1:转账
|
* ${dorado.getDataProvider("inoutSettlePR#triggerPayType").getResult()}
|
*
|
* @return
|
*/
|
@DataProvider
|
public List<DicTrigger> triggerPayType() {
|
List<DicTrigger> list = new ArrayList<DicTrigger>();
|
list.add(new DicTrigger("0", "现金"));
|
list.add(new DicTrigger("1", "转账"));
|
return list;
|
}
|
|
|
|
/**
|
* 入库结算-合同结算
|
* inoutSettlePR#pageSettleIn1
|
*
|
* @param param
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public void pageSettleIn1(Page<InoutSettle> page, InoutParam param)throws Exception {
|
|
if(null == param)param = new InoutParam();
|
|
IUser u = ContextUtil.getLoginUser();
|
|
param.setCompanyId(u.getCompanyId());
|
|
|
if(null == param.getDeptId()){
|
param.setDeptId(ContextUtil.subDeptId(u));
|
}
|
|
param.setSettleBizType("1");
|
param.setType(InoutConstant.TYPE_IN);
|
|
hSettleService.pageSettle(page, param);
|
}
|
|
/**
|
* 入库结算-单车结算
|
* inoutSettlePR#pageSettleIn0
|
*
|
* @param param
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public void pageSettleIn0(Page<InoutSettle> page, InoutParam param)throws Exception {
|
if(null == param)param = new InoutParam();
|
IUser u = ContextUtil.getLoginUser();
|
|
param.setCompanyId(u.getCompanyId());
|
|
|
if(null == param.getDeptId()){
|
param.setDeptId(ContextUtil.subDeptId(u));
|
}
|
|
param.setSettleBizType("0");
|
param.setType(InoutConstant.TYPE_IN);
|
hSettleService.pageSettle(page, param);
|
}
|
|
/**
|
* 出库结算-合同结算
|
* inoutSettlePR#pageSettleOut1
|
*
|
* @param param
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public void pageSettleOut1(Page<InoutSettle> page, InoutParam param)throws Exception {
|
IUser u = ContextUtil.getLoginUser();
|
|
param.setCompanyId(u.getCompanyId());
|
|
|
if(null == param.getDeptId()){
|
param.setDeptId(ContextUtil.subDeptId(u));
|
}
|
|
param.setSettleBizType("1");
|
param.setType(InoutConstant.TYPE_OUT);
|
hSettleService.pageSettle(page, param);
|
}
|
|
|
/**
|
* inoutSettlePR#pageInoutRecord
|
*
|
* @param param
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public void pageInoutRecord(Page<InoutRecord> page, InoutParam param)
|
throws Exception {
|
hSettleService.pageIoutRecord(page, param);
|
}
|
|
/**
|
* inoutSettlePR#pageSettleData
|
*
|
* @param param
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public void pageSettleData(Page<InoutSettle> page, InoutParam param)
|
throws Exception {
|
|
if (null == param)
|
param = new InoutParam();
|
|
if (StringUtils.isNotEmpty(param.getId())
|
&& param.getId().indexOf("_") == -1) {
|
param.setId("%" + param.getId() + "%");
|
}
|
|
// 转换为Mybatis
|
com.baomidou.mybatisplus.plugins.Page<InoutSettle> myBatisPage = new com.baomidou.mybatisplus.plugins.Page<InoutSettle>(
|
page.getPageNo(), page.getPageSize());
|
|
List<InoutSettle> list = inoutSettleServiceMapper.pageSettleData(
|
myBatisPage, param);
|
|
page.setEntities(list);
|
int total = (int) myBatisPage.getTotal();
|
page.setEntityCount(total);
|
}
|
|
/**
|
* inoutSettlePR#getSettleByInoutData
|
*
|
* @param
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public InoutSettle getSettleByInoutData(InoutData data) throws Exception {
|
return getNewSettle(data);
|
}
|
|
/**
|
* inoutSettlePR#getSettleById
|
*
|
* @param
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public InoutSettle getSettleById(InoutData data) throws Exception {
|
InoutSettle settle = hSettleService.getSettleById(data.getCompanyId(),
|
data.getId());
|
if (settle == null) {
|
return getNewSettle(data);
|
}
|
return settle;
|
}
|
|
/**
|
* 封装计算结算单相关金额
|
*
|
* @param data
|
* @return
|
*/
|
private InoutSettle getNewSettle(InoutData data) {
|
InoutSettle inoutSettle = new InoutSettle();
|
inoutSettle.setId(data.getId());
|
// inoutSettle.setType(data.getType());
|
// inoutSettle.setCustomerId(data.getCustomerId());
|
// inoutSettle.setCustomerName(data.getCustomerName());
|
// inoutSettle.setFullWeight(data.getFullWeight());
|
// inoutSettle.setEmptyWeight(data.getEmptyWeight());
|
// inoutSettle.setNetWeight(data.getNetWeight());
|
inoutSettle.setSettleWeight(data.getSettleWeight());
|
// inoutSettle.setDeSum(data.getDeSum());
|
|
// inoutSettle.setCompleteTime(data.getCompleteTime());
|
inoutSettle.setDepotId(data.getDepotId());
|
inoutSettle.setDeptId(data.getDeptId());
|
// inoutSettle.setUserName(data.getUserName());
|
// inoutSettle.setPlateNum(data.getPlateNum());
|
// inoutSettle.setFoodLevel(data.getFoodLevel());
|
// inoutSettle.setFoodVariety(data.getFoodVariety());
|
|
if (data.getPrice() != null) {
|
inoutSettle.setPayPrice(data.getPrice());
|
}
|
|
return inoutSettle;
|
}
|
|
/**
|
* inoutSettlePR#saveData
|
*/
|
@Expose
|
@Transactional
|
public String saveData(InoutSettle data) {
|
// if (null == data.getType()) {
|
// data.setType(InoutConstant.TYPE_IN);
|
// }
|
|
hSettleService.saveOrUpdateData(data);
|
|
// 更新流水结算状态
|
hSettleService.updateInoutRecordPay(data.getId());
|
|
return null;
|
}
|
|
/**
|
* inoutSettlePR#printSettleBill 打印结算单
|
*
|
* @param data
|
* @return
|
* @throws Exception
|
*/
|
@Expose
|
public String printSettleBill(InoutData data) {
|
InoutSettle settle = hSettleService.getSettleById(data.getCompanyId(),
|
data.getId());
|
if (settle == null) {
|
return "没有获取到结算信息,不打印!";
|
}
|
return inoutReportManager.inSettleBill(data, settle);
|
}
|
|
/**
|
* inoutSettlePR#printSettleBill2 打印结算单
|
*
|
* @param data
|
* @return
|
* @throws Exception
|
*/
|
@Expose
|
public String printSettleBill2(InoutSettle settle) {
|
if (settle == null) {
|
return "没有获取到结算信息,不打印!";
|
}
|
return inoutReportManager.inSettleBill(null, settle);
|
}
|
}
|