package com.ld.igds.sec.view;
|
|
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.models.SecSnapConf;
|
import com.ld.igds.models.SecSnapDepot;
|
import com.ld.igds.sec.service.SecSnapDepotService;
|
import com.ld.igds.util.ContextUtil;
|
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
import java.util.Collection;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @author: andy.jia
|
* @description: 仓内抓拍信息获取管理
|
* @version:
|
*/
|
@Component
|
public class SecSnapDepotPR {
|
|
@Resource
|
private SecSnapDepotService snapDepotService;
|
|
|
/**
|
* secSnapDepotPR#pageSnapDepot
|
*
|
* @param param
|
* @throws Exception
|
*/
|
@DataProvider
|
public void pageSnapDepot(Page<SecSnapDepot> page, Map<String, Object> param)
|
throws Exception {
|
|
if (null == param) param = new HashMap<>();
|
param.put("companyId", ContextUtil.getCompanyId());
|
param.put("deptId", ContextUtil.subDeptId(null));
|
|
snapDepotService.pageSnapDepot(page, param);
|
|
//添加4条测试数据
|
if (null == page.getEntities() || page.getEntities().isEmpty()) {
|
Collection<SecSnapDepot> list = new ArrayList<>();
|
list.add(new SecSnapDepot("TEST"));
|
list.add(new SecSnapDepot("TEST"));
|
list.add(new SecSnapDepot("TEST"));
|
list.add(new SecSnapDepot("TEST"));
|
|
page.setEntities(list);
|
}
|
}
|
|
|
|
/**
|
* secSnapDepotPR#getConfActHour
|
*
|
* 默认获取第一条数据的配置信息,如果没有就返回一个空的对象
|
* @param page
|
* @param param
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public SecSnapConf getConfActHour()throws Exception {
|
List<SecSnapConf> list = snapDepotService.listSnapConf(ContextUtil.getCompanyId(), ContextUtil.subDeptId(null));
|
if(null == list || list.isEmpty()) return new SecSnapConf();
|
return list.get(0);
|
}
|
|
|
/**
|
* secSnapDepotPR#listConf
|
*
|
* 默认获取第一条数据的配置信息,如果没有就返回一个空的对象
|
* @param page
|
* @param param
|
* @return
|
* @throws Exception
|
*/
|
@DataProvider
|
public List<SecSnapConf> listConf()throws Exception {
|
return snapDepotService.listSnapConf(ContextUtil.getCompanyId(), ContextUtil.subDeptId(null));
|
}
|
|
|
/**
|
* secSnapDepotPR#updateConf
|
* @param items
|
* @throws Exception
|
*/
|
@DataResolver
|
public void updateConf(List<SecSnapConf> items)throws Exception {
|
if(null ==items || items.isEmpty() ) return;
|
for(SecSnapConf conf:items){
|
if(null == conf.getId()){
|
if(null == conf.getCompanyId()){
|
conf.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if(null == conf.getDeptId()){
|
conf.setDeptId(ContextUtil.subDeptId(null));
|
}
|
|
snapDepotService.addConf(conf);
|
}else{
|
snapDepotService.updateConf(conf);
|
}
|
}
|
|
}
|
|
|
/**
|
* secSnapDepotPR#updateActHour
|
* @param items
|
* @throws Exception
|
*/
|
@Expose
|
public void updateActHour(SecSnapConf conf)throws Exception {
|
|
if(null == conf.getCompanyId()){
|
conf.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if(null == conf.getDeptId()){
|
conf.setDeptId(ContextUtil.subDeptId(null));
|
}
|
|
//同步更新所有的执行时间一致
|
snapDepotService.updateActHour(conf);
|
|
}
|
}
|