Commit dba1dcd3 LN

Merge remote-tracking branch 'origin/master'

2 个父辈 9ce49e21 71c7891a
......@@ -196,7 +196,8 @@ public class MenuInit {
Menu pMenuLog = Menu.CreatePMenu("日志管理", 8, "log","log",null);
addDefaultFunctionMenu(61, pMenuLog, "物料日志", "taskLog", "neolight/taskLog/index", "education",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(62, pMenuLog, "消息查询", "message", "neolight/message/index", "messagefind",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(63, pMenuLog, "日志监控", "logMonitor", "neolight/logMonitor/index", "messagefind");
addDefaultFunctionMenu(63, pMenuLog, "日志监控", "logMonitor", "neolight/logMonitor/index", "logMonitor");
addDefaultFunctionMenu(64, pMenuLog, "物料追溯", "materialTrace", "neolight/materialTrace/index", "trace");
//暂未找到页面
// addDefaultFunctionMenu(63, pMenuLog, "接口异常", "interfaceException", "neolight/interfaceException/index", "messagefind");
......
package com.neotel.smfcore.core.system.rest;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.base.IExcelDownLoad;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.system.rest.bean.dto.MaterialTraceDto;
import com.neotel.smfcore.core.system.rest.bean.mapstruct.MaterialTraceMapper;
import com.neotel.smfcore.core.system.rest.bean.query.MaterialTraceQueryCondition;
import com.neotel.smfcore.core.system.service.manager.IMaterialTraceManager;
import com.neotel.smfcore.core.system.service.po.MaterialTrace;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@Slf4j
@Api(tags = "物料追溯管理")
@RestController
@RequestMapping("/api/materialTrace")
@RequiredArgsConstructor
public class MaterialTraceController {
@Autowired
private IMaterialTraceManager materialTraceManager;
@Autowired
private MaterialTraceMapper materialTraceMapper;
@ApiOperation("查询物料追溯信息")
@GetMapping("/history")
@PreAuthorize("@el.check('materialTrace')")
@AnonymousAccess
public PageData<MaterialTraceDto> query(MaterialTraceQueryCondition criteria, Pageable pageable) {
Query query = getQuery(criteria);
PageData<MaterialTrace> materialTraceList = materialTraceManager.findByPage(query, pageable);
PageData<MaterialTraceDto> result = materialTraceMapper.toDto(materialTraceList);
return result;
}
@ApiOperation("导出物料追溯日志")
@GetMapping(value = "/history/download")
@PreAuthorize("@el.check('taskLog')")
@AnonymousAccess
public void download(HttpServletResponse response, MaterialTraceQueryCondition criteria, Pageable pageable, HttpServletRequest request) throws IOException {
Query query = getQuery(criteria);
Locale locale = request.getLocale();
log.info("开始导出物料追溯日志");
FileUtil.downloadExcel(query, pageable, response, new IExcelDownLoad() {
@Override
public List<List<String>> getHeader() {
List<List<String>> header = new ArrayList<>();
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.barcode",locale,"条码编号")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.partNumber",locale,"料件编号")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.posName",locale,"料仓名称")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.amount",locale,"数量")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.type",locale,"类型")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.orderSource",locale,"来源")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.status",locale,"状态")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.operator",locale,"操作人")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.createDate",locale,"创建时间")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.NeoLight.updateDate",locale,"更新时间")));
return header;
}
@Override
public List<List<Object>> getPageData(Query query, Pageable pageable) {
List<List<Object>> dataList = new ArrayList<>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<MaterialTrace> materialTraceList = materialTraceManager.findByQuery(query,pageable);
for (MaterialTrace materialTrace : materialTraceList) {
String createDate = dateFormat.format(materialTrace.getCreateDate());
String updateDate = dateFormat.format(materialTrace.getUpdateDate());
List<Object> data = new ArrayList<>();
data.add(materialTrace.getBarcode());
data.add(materialTrace.getPartNumber());
data.add(materialTrace.getPosName() + " " + materialTrace.getStorageName());
data.add(materialTrace.getNum());
String typeKey = "NeoLight.logType." + materialTrace.getType();
String typeMsg = MessageUtils.getSmfClientMsg(typeKey,locale,typeKey);
data.add(typeMsg);
data.add(materialTrace.getSourceName());
String status = materialTrace.getStatus().toLowerCase();
String statusKey = "NeoLight.logStatus." + status;
String statusMsg = MessageUtils.getSmfClientMsg(statusKey,locale,statusKey);
data.add(statusMsg);
data.add(materialTrace.getOperator());
data.add(createDate);
data.add(updateDate);
dataList.add(data);
}
return dataList;
}
});
log.info("物料追溯日志导出完成");
}
private Query getQuery(MaterialTraceQueryCondition criteria){
String un_End = "UN_END";
boolean unEnd = false;
boolean finished=false;
if (criteria.getStatus()!=null&& criteria.getStatus().equals(un_End)) {
criteria.setStatus(null);
unEnd = true;
}else if(criteria.getStatus()!=null&&criteria.getStatus().equals(OP_STATUS.FINISHED.name())){
criteria.setStatus(null);
finished=true;
}
/*if (StringUtils.isBlank(criteria.getStorageId())){
criteria.setStorageIdList(SecurityUtils.getUserGroupStorageId());
}*/
Query query = QueryHelp.getQuery(criteria);
if (unEnd) {
query.addCriteria(Criteria.where("status").nin(OP_STATUS.END.name(), OP_STATUS.FINISHED.name()));
}else if(finished){
query.addCriteria(Criteria.where("status").in(OP_STATUS.END.name(), OP_STATUS.FINISHED.name()));
}
return query;
}
}
package com.neotel.smfcore.core.system.rest.bean.dto;
import lombok.Data;
@Data
public class MaterialTraceDto extends TaskDto {
}
package com.neotel.smfcore.core.system.rest.bean.mapstruct;
import com.neotel.smfcore.common.base.BaseMapper;
import com.neotel.smfcore.core.system.rest.bean.dto.MaterialTraceDto;
import com.neotel.smfcore.core.system.service.po.MaterialTrace;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MaterialTraceMapper extends BaseMapper<MaterialTraceDto, MaterialTrace> {
}
package com.neotel.smfcore.core.system.rest.bean.query;
import com.neotel.smfcore.common.annotation.QueryCondition;
import com.neotel.smfcore.common.bean.BetweenData;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
@Data
@ApiModel("查询条件")
public class MaterialTraceQueryCondition {
@QueryCondition(blurry = "barcode,partNumber,posName,sourceName,subSourceInfo,memo")
@ApiModelProperty("模糊搜索")
private String blurry;
@QueryCondition
@ApiModelProperty("条码编号")
private String barcode;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "updateDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> updateDate;
@QueryCondition
@ApiModelProperty("來源ID")
private String sourceId;
@QueryCondition
@ApiModelProperty("任务状态")
private String status;
@QueryCondition(isDBId =true)
@ApiModelProperty("料仓Id")
private String storageId;
@QueryCondition(type = QueryCondition.Type.IN, propName = "storageId")
private List<String> storageIdList;
@QueryCondition
@ApiModelProperty("出入库类型")
private Integer type;
@ApiModelProperty("分组ID")
private String groupId;
@ApiModelProperty("CID数组")
private String[] cids;
@QueryCondition
@ApiModelProperty("来源名称")
private String sourceName;
@QueryCondition
@ApiModelProperty("出入库类型")
private String inOutType;
@QueryCondition
@ApiModelProperty("操作人")
private String operator;
}
package com.neotel.smfcore.core.system.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface IMaterialTraceDao extends IBaseDao {
}
package com.neotel.smfcore.core.system.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.core.system.service.dao.IMaterialTraceDao;
import com.neotel.smfcore.core.system.service.po.MaterialTrace;
import org.springframework.stereotype.Service;
@Service
public class MaterialTraceDaoImpl extends AbstractBaseDao implements IMaterialTraceDao {
@Override
public Class getEntityClass() {
return MaterialTrace.class;
}
}
package com.neotel.smfcore.core.system.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.core.system.service.po.MaterialTrace;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import java.util.List;
public interface IMaterialTraceManager extends IBaseManager<MaterialTrace> {
//List<MaterialTrace> dataLogs = materialTraceManager.findByQuery(query,pageable);
List<MaterialTrace> findByQuery(Query query, Pageable pageable);
}
package com.neotel.smfcore.core.system.service.manager.impl;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.system.service.dao.IMaterialTraceDao;
import com.neotel.smfcore.core.system.service.manager.IMaterialTraceManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.service.po.MaterialTrace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MaterialTraceManagerImpl implements IMaterialTraceManager {
@Autowired
private IMaterialTraceDao materialTraceDao;
@Override
public MaterialTrace get(String id) {
return null;
}
@Override
public MaterialTrace save(MaterialTrace object) throws ValidateException {
return materialTraceDao.save(object);
}
@Override
public void delete(MaterialTrace object) throws ValidateException {
}
@Override
public PageData<MaterialTrace> findByPage(Query query, Pageable pageable) {
int totalCount = materialTraceDao.countByQuery(query);
List<MaterialTrace> list = materialTraceDao.findByQuery(query, pageable);
return new PageData<MaterialTrace>(list, totalCount);
}
@Override
public List<MaterialTrace> findByQuery(Query query) {
return null;
}
@Override
public List<MaterialTrace> findByQuery(Query query, Pageable pageable) {
return materialTraceDao.findByQuery(query,pageable);
}
}
package com.neotel.smfcore.core.system.service.po;
import lombok.Data;
/**
* 物料追溯(字段和datalog一样,直接继承使用)
*/
@Data
public class MaterialTrace extends DataLog {
}
package com.neotel.smfcore.core.system.util;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.neotel.smfcore.core.system.bean.MSDAppendInfo;
import com.neotel.smfcore.core.system.service.manager.IMaterialTraceManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.service.po.MaterialTrace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Slf4j
@Service
public class MaterialTraceUtil {
@Autowired
private IMaterialTraceManager materialTraceManager;
//把task每个状态都拆分出来 重新保存一张表
public void onTaskStatusChange(DataLog task) {
try {
MaterialTrace materialTrace = dataLogToMaterialTrace(task);
materialTrace.setId("");
materialTrace.setCreateDate(new Date());
materialTrace.setUpdateDate(new Date());
materialTraceManager.save(materialTrace);
} catch (Exception e) {
e.printStackTrace();
}
}
private MaterialTrace dataLogToMaterialTrace(DataLog task) throws JsonProcessingException {
MaterialTrace materialTrace = new MaterialTrace();
materialTrace.setSingleOut(task.isSingleOut());
materialTrace.setStorageName(task.getStorageName());
materialTrace.setCid(task.getCid());
materialTrace.setStorageId(task.getStorageId());
materialTrace.setGroupId(task.getGroupId());
materialTrace.setSourceId(task.getSourceId());
materialTrace.setPosId(task.getPosId());
materialTrace.setPosName(task.getPosName());
materialTrace.setBarcode(task.getBarcode());
materialTrace.setW(task.getW());
materialTrace.setH(task.getH());
materialTrace.setCutReel(task.isCutReel());
materialTrace.setUrgentReel(task.isUrgentReel());
materialTrace.setLessSendReel(task.isLessSendReel());
materialTrace.setNgReel(task.isNgReel());
materialTrace.setPackageReel(task.isPackageReel());
materialTrace.setPartNumber(task.getPartNumber());
materialTrace.setNum(task.getNum());
materialTrace.setType(task.getType());
materialTrace.setStatus(task.getStatus());
materialTrace.setBatchId(task.getBatchId());
materialTrace.setBatchInfo(task.getBatchInfo());
materialTrace.setSourceType(task.getSourceType());
materialTrace.setSourceId(task.getSourceId());
materialTrace.setSourceName(task.getSourceName());
materialTrace.setSubSourceId(task.getSubSourceId());
materialTrace.setSubSourceInfo(task.getSubSourceInfo());
materialTrace.setCreator(task.getCreator());
materialTrace.setOperator(task.getOperator());
materialTrace.setRelationCodes(task.getRelationCodes());
materialTrace.setMemo(task.getMemo());
materialTrace.setMixTime(task.getMixTime());
materialTrace.setLightColor(task.getLightColor());
materialTrace.setExecuteTime(task.getExecuteTime());
materialTrace.setInStoreTime(task.getInStoreTime());
materialTrace.setPutInDate(task.getPutInDate());
materialTrace.setLocInfo(task.getLocInfo());
materialTrace.setInOutType(task.getInOutType());
materialTrace.setProviderNumber(task.getProviderNumber());
materialTrace.setMsdAppendInfo(task.getMsdAppendInfo());
materialTrace.setPriority(task.getPriority());
materialTrace.setLine(task.getLine());
materialTrace.setClosed(task.isClosed());
return materialTrace;
}
}
......@@ -56,6 +56,10 @@ public class TaskService {
@Autowired
protected SelfAuditUtil selfAuditUtil;
@Autowired
private MaterialTraceUtil materialTraceUtil;
@Autowired
private SmfApi smfApi;
......@@ -165,6 +169,7 @@ public class TaskService {
liteOrderCache.onTaskStatusChange(task);
smfApi.onTaskStatusChange(task);
selfAuditUtil.onTaskStatusChange(task);
materialTraceUtil.onTaskStatusChange(task);
}
/**
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!