package com.ld.igds.m.view;
|
|
import java.util.*;
|
import com.bstek.bdf2.core.business.IUser;
|
import com.bstek.bdf2.core.model.DefaultDept;
|
import com.ld.igds.constant.Constant;
|
import com.ld.igds.inout.InoutConstant;
|
import com.ld.igds.m.dto.NoticeDto;
|
import com.ld.igds.m.service.HInoutNoticeService;
|
import com.ld.igds.m.service.InoutCommonService;
|
import com.ld.igds.models.DicTrigger;
|
import com.ld.igds.models.InoutNoticeIn;
|
import com.ld.igds.models.InoutSysConf;
|
import com.ld.igds.sys.service.SysDeptService;
|
import com.ld.igds.util.ContextUtil;
|
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
import com.bstek.dorado.annotation.DataProvider;
|
import com.bstek.dorado.annotation.Expose;
|
import com.bstek.dorado.data.provider.Page;
|
import com.ld.igds.models.InoutNoticeOut;
|
import javax.annotation.Resource;
|
|
/**
|
* 通知单管理
|
*
|
* @author: chen
|
*
|
*/
|
@Component
|
public class InoutNoticePR {
|
|
@Autowired
|
private HInoutNoticeService noticeService;
|
@Autowired
|
private SysDeptService sysDeptService;
|
@Resource(name = InoutCommonService.BEAN_ID)
|
private InoutCommonService inoutManagerService;
|
|
/**
|
* inoutNoticePR#getTitle 根据报表类型,获取默认查询信息,比如表头信息等
|
*
|
* @param
|
* @return
|
*/
|
@DataProvider
|
public Map<String, Object> getTitle(Map<String, Object> param) {
|
Map<String, Object> result = new HashMap<String, Object>();
|
//获取参数中报表类型
|
String type = (String)param.get("type");
|
//获取参数中分库编码
|
String deptId = (String)param.get("deptId");
|
if (StringUtils.isEmpty(deptId)) {
|
deptId = ContextUtil.subDeptId(null);
|
}
|
//获取分库编码对应的分库名称
|
String deptName = "";
|
List<DefaultDept> defaultDepts = sysDeptService.loadUserDepts(ContextUtil.getLoginUserName());
|
for (DefaultDept defaultDept : defaultDepts) {
|
if(defaultDept.getId().equals(deptId)){
|
deptName = defaultDept.getName();
|
}
|
}
|
if ("NOTICE_IN".equals(type)) {
|
result.put("title", "入库通知单");
|
if (StringUtils.isNotEmpty(deptName)) {
|
result.put("title", deptName + "入库通知单");
|
}
|
}
|
if ("NOTICE_OUT".equals(type)) {
|
result.put("title", "出库通知单");
|
if (StringUtils.isNotEmpty(deptName)) {
|
result.put("title", deptName + "出库通知单");
|
}
|
}
|
return result;
|
}
|
|
/**
|
* 通知单状态下拉框
|
*
|
* ${dorado.getDataProvider("inoutNoticePR#triggerNoticeStatus").getResult()}
|
* @return
|
*/
|
@DataProvider
|
public List<DicTrigger> triggerNoticeStatus() throws Exception {
|
List<DicTrigger> list = new ArrayList<DicTrigger>();
|
list.add(new DicTrigger(InoutConstant.COMPLETE_STATUS_NONE, "未完成"));
|
list.add(new DicTrigger(InoutConstant.COMPLETE_STATUS_COMPLETE, "已完成"));
|
return list;
|
}
|
|
/**
|
* inoutNoticePR#getYearQuery 默认年份
|
*
|
* @param
|
* @return
|
*/
|
@DataProvider
|
public Map<String, Object> getYearQuery(Map<String, Object> param) {
|
Map<String, Object> result = new HashMap<String, Object>();
|
//获取参数中分库编码
|
String deptId = (String)param.get("deptId");
|
|
result.put("year", DateFormatUtils.format(new Date(), "yyyy"));
|
result.put("deptId", deptId);
|
return result;
|
}
|
|
|
/**
|
* inoutNoticePR#queryNoticeByKey 根据参数查询出入库通知单,用于手动补单时,选择通知单
|
*
|
* @param
|
* @return
|
*/
|
@DataProvider
|
public List<NoticeDto> queryNoticeByKey(Map<String, Object> param) {
|
|
return noticeService.queryNoticeByKey(param);
|
}
|
|
/*==================== 入库通知单相关业务 ====================*/
|
|
/**
|
* inoutNoticePR#initAddIn 入库通知单新增初始化
|
*
|
* @return
|
*/
|
@Expose
|
public InoutNoticeIn initAddIn() {
|
IUser user = ContextUtil.getLoginUser();
|
InoutNoticeIn data = new InoutNoticeIn();
|
data.setId("RKTZD_" + ContextUtil.getTimeId());
|
data.setName("入库通知单");
|
data.setCompanyId(user.getCompanyId());
|
data.setDeptId(ContextUtil.subDeptId(user));
|
data.setTag(Constant.YN_Y);
|
return data;
|
}
|
|
/**
|
* inoutNoticePR#pageQueryIn 获取入库通知单
|
*
|
* @param parameter
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public void pageQueryIn(Page<InoutNoticeIn> page, Map<String, Object> parameter) throws Exception {
|
if (null == parameter){
|
parameter = new HashMap<String, Object>();
|
}
|
noticeService.pageQueryIn(page, parameter);
|
}
|
|
/**
|
* inoutNoticePR#saveIn 更新入库通知单
|
*/
|
@Expose
|
public String saveIn(InoutNoticeIn data) {
|
return noticeService.saveOrUpdateIn(data);
|
}
|
|
/**
|
* inoutNoticePR#delDataIn
|
*/
|
@Expose
|
public String delDataIn(InoutNoticeIn data) {
|
return noticeService.delDataIn(data);
|
}
|
|
/**
|
* 重新核算入库通知单完成量
|
*
|
* inoutNoticePR#updateSumNoticeIn
|
*
|
* @return
|
*/
|
@Expose
|
public String updateSumNoticeIn() {
|
|
//获取所有未完成状态的入库通知单
|
String companyId = ContextUtil.getCompanyId();
|
String deptId = ContextUtil.subDeptId(null);
|
|
InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(companyId, deptId);
|
|
if(Constant.YN_Y.equals(inoutSysConf.getNoticeTagIn())){
|
List<InoutNoticeIn> noticeInList = inoutManagerService.getUnComNoticeIn(companyId);
|
|
if (noticeInList != null && noticeInList.size() > 0) {
|
inoutManagerService.updateSumNoticeIn(inoutSysConf.getDeptId(), noticeInList);
|
return "success";
|
}
|
}
|
return "fail";
|
}
|
|
|
|
/*==================== 出库通知单相关业务 ====================*/
|
|
/**
|
* inoutNoticePR#initAddOut 出库通知单新增初始化
|
*
|
* @return
|
*/
|
@Expose
|
public InoutNoticeOut initAddOut() {
|
IUser user = ContextUtil.getLoginUser();
|
InoutNoticeOut data = new InoutNoticeOut();
|
data.setId("CKTZD_" + ContextUtil.getTimeId());
|
data.setName("出库通知单");
|
data.setCompanyId(user.getCompanyId());
|
data.setDeptId(ContextUtil.subDeptId(user));
|
data.setTag(Constant.YN_Y);
|
return data;
|
}
|
|
/**
|
* inoutNoticePR#pageQueryOut 获取出库通知单
|
* @param page
|
* @param parameter
|
* @throws Exception
|
*/
|
@DataProvider
|
public void pageQueryOut(Page<InoutNoticeOut> page, Map<String, Object> parameter) throws Exception {
|
if (null == parameter){
|
parameter = new HashMap<String, Object>();
|
}
|
noticeService.pageQueryOut(page, parameter);
|
}
|
|
/**
|
* inoutNoticePR#saveOut 更新出库通知单
|
* @param data
|
* @return
|
*/
|
@Expose
|
public String saveOut(InoutNoticeOut data) {
|
return noticeService.saveOrUpdateOut(data);
|
}
|
|
/**
|
* inoutNoticePR#delDataOut
|
*/
|
@Expose
|
public String delDataOut(InoutNoticeOut data) {
|
return noticeService.delDataOut(data);
|
}
|
|
|
/**
|
* 重新核算出库通知单完成量
|
*
|
* inoutNoticePR#updateSumNoticeOut
|
*
|
* @return
|
*/
|
@Expose
|
public String updateSumNoticeOut() {
|
|
//获取所有未完成状态的入库通知单
|
String companyId = ContextUtil.getCompanyId();
|
String deptId = ContextUtil.subDeptId(null);
|
|
InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(companyId, deptId);
|
|
if(Constant.YN_Y.equals(inoutSysConf.getNoticeTagOut())){
|
List<InoutNoticeOut> noticeOutList = inoutManagerService.getUnComNoticeOut(companyId);
|
|
if (noticeOutList != null && noticeOutList.size() > 0) {
|
inoutManagerService.updateSumNoticeOut(inoutSysConf.getDeptId(), noticeOutList);
|
return "success";
|
}
|
}
|
return "fail";
|
}
|
}
|