package com.ld.igds.inout.view;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
import com.bstek.bdf2.core.business.IUser;
|
import com.bstek.dorado.annotation.DataProvider;
|
import com.bstek.dorado.annotation.DataResolver;
|
import com.bstek.dorado.annotation.Expose;
|
import com.bstek.dorado.data.provider.Page;
|
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.InoutManager;
|
import com.ld.igds.inout.manager.InoutReportManager;
|
import com.ld.igds.inout.service.InoutService;
|
import com.ld.igds.models.DicTrigger;
|
import com.ld.igds.util.ContextUtil;
|
|
import org.apache.commons.lang.StringUtils;
|
import org.springframework.stereotype.Component;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
|
/**
|
* 出入库详单页面管理
|
*
|
* @author: andy.jia
|
* @description:
|
* @version:
|
* @data:2020年3月30日
|
*/
|
@Component
|
public class InoutDataPR {
|
|
@Resource
|
private InoutService inoutService;
|
@Resource
|
private InoutReportManager inoutReportManager;
|
@Resource
|
private InoutManager inoutManager;
|
|
|
|
// ${dorado.getDataProvider("inoutDataPR#triggerRecordStatus1").getResult()}
|
@DataProvider
|
public List<DicTrigger> triggerRecordStatus1() {
|
List<DicTrigger> list = new ArrayList<DicTrigger>();
|
list.add(new DicTrigger(InoutConstant.RECORD_STATUS_DEL, "作废单"));
|
list.add(new DicTrigger(InoutConstant.RECORD_STATUS_NORMAL, "正常单"));
|
return list;
|
}
|
|
/**
|
* inoutDataPR#pageInoutData
|
*
|
* @param page
|
* @param param
|
* @throws Exception
|
*/
|
@DataProvider
|
public void pageInoutData(Page<InoutData> page, InoutParam param) throws Exception {
|
// 调用核心包中方法,需要做对象转换
|
param.setPage(page.getPageNo());
|
param.setLimit(page.getPageSize());
|
param.setCustomerName(null);
|
|
com.baomidou.mybatisplus.plugins.Page<InoutData> batisPage = inoutService.pageRecordData(param);
|
|
// 封装转换
|
page.setEntities(batisPage.getRecords());
|
page.setEntityCount(Integer.valueOf(batisPage.getTotal() + ""));
|
}
|
|
/**
|
* 保存出入库数据 inoutDataPR#saveInoutData
|
*/
|
@DataResolver
|
public String saveInoutData(InoutData data) throws Exception {
|
if (StringUtils.isEmpty(data.getId())) {
|
return inoutManager.addInoutData(data);
|
} else {
|
return inoutManager.updateInoutData(data);
|
}
|
}
|
|
/**
|
* inoutDataPR#errorInoutData 出入库数据执行 异常终止
|
*
|
* @param data
|
* @return
|
* @throws Exception
|
*/
|
@DataResolver
|
@Transactional
|
public String errorInoutData(InoutData data) throws Exception {
|
return inoutManager.errorInoutData(data);
|
}
|
|
/**
|
* inoutDataPR#completeInoutData 出入库数据执行 正常结束
|
* <p>
|
* 执行逻辑:先判断页面数据与实际数据状态是否相符,如果不相符说明页面数据有延迟
|
*
|
* @param data
|
* @return
|
* @throws Exception
|
*/
|
@DataResolver
|
@Transactional
|
public String completeInoutData(InoutData data) throws Exception {
|
return inoutManager.completeInoutData(data);
|
}
|
|
/**
|
* inoutDataPR#printWeightBill 获取打印单信息
|
*
|
* @param data
|
* @return
|
* @throws Exception
|
*/
|
@Expose
|
public String printWeightBill(InoutData data) throws Exception {
|
if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
|
return "删除的数据不支持打印!";
|
}
|
if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
|
return "未完成的数据不支持打印!";
|
}
|
|
if (InoutConstant.TYPE_IN.equals(data.getType())) {
|
return inoutReportManager.inWeightBill(data);
|
} else {
|
return inoutReportManager.outWeightBill(data);
|
}
|
}
|
|
/**
|
* inoutDataPR#printShipBill 获取打印单信息
|
*
|
* @param data
|
* @return
|
* @throws Exception
|
*/
|
@Expose
|
public List<String> printShipBill(InoutData data) throws Exception {
|
if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
|
return null;
|
}
|
if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
|
return null;
|
}
|
//打印船运过磅单
|
return inoutReportManager.shipWeightBill2(data);
|
}
|
|
/**
|
* inoutDataPR#printCheckBill 打印化验单
|
*
|
* @param data
|
* @return
|
* @throws Exception
|
*/
|
@Expose
|
public String printCheckBill(InoutData data) throws Exception {
|
if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) {
|
return "删除的数据不支持打印!";
|
}
|
return inoutReportManager.inCheckBill(data);
|
}
|
|
/**
|
* inoutDataPR#initAddData 新增
|
*
|
* @return
|
*/
|
@Expose
|
public InoutData initAddData(String type) {
|
IUser user = ContextUtil.getLoginUser();
|
InoutData data = new InoutData();
|
data.setCompanyId(user.getCompanyId());
|
data.setRegisterTime(new Date());
|
data.setCompleteTime(new Date());
|
data.setType(type);
|
data.setIntelCard("0000");
|
data.setRegisterUser(user.getCname());
|
data.setDeptId(ContextUtil.subDeptId(user));
|
data.setCheckUser(user.getCname());
|
data.setProgress(InoutConstant.PROGRESS_RECORD);
|
data.setRecordStatus(InoutConstant.RECORD_STATUS_ADD);
|
return data;
|
}
|
|
/**
|
* inoutDataPR#initDataByHand 新增
|
*
|
* @return
|
*/
|
@DataProvider
|
public InoutData initDataByHand(String type) {
|
IUser user = ContextUtil.getLoginUser();
|
InoutData data = new InoutData();
|
data.setCompanyId(user.getCompanyId());
|
data.setRegisterTime(new Date());
|
data.setType(type);
|
data.setRegisterUser(user.getCname());
|
data.setDeptId(ContextUtil.subDeptId(user));
|
data.setCheckUser(user.getCname());
|
data.setProgress(InoutConstant.PROGRESS_RECORD);
|
data.setRecordStatus(InoutConstant.RECORD_STATUS_ADD);
|
return data;
|
}
|
|
}
|