Commit 93cd73cd LN

查找出库增加导出功能。生产日期先出时需要尾料先出,然后根据生产日期。

1 个父辈 8188eac1
......@@ -31,6 +31,8 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.rest.bean.query.UserQueryCriteria;
import com.neotel.smfcore.security.service.po.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
......@@ -49,6 +51,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
......@@ -255,7 +259,44 @@ public class StoragePosController {
storagePosManager.deletePoss(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@ApiOperation("导出查找出库列表")
@GetMapping(value = "/find/download")
@PreAuthorize("@el.check('checkOut')")
public void download(HttpServletResponse response, StoragePosFindCriteria criteria) throws IOException {
if (criteria.getStorageId() != null && criteria.getStorageId().equals("0")) {
criteria.setStorageId(null);
}
Query query = QueryHelp.getQuery(criteria);
Criteria baseCriteria = Criteria.where("used").is(true);
int componentType = criteria.getType();
String name = "";
if (componentType != -1) {
int type = componentType;
if (componentType == 41) {//锡膏夹具
type = COMPONENT_TYPE.FIXTURE;
name = StorageConstants.PACKAGE_TYPE.SOLDER_FIXTURE.getCode();
} else if (componentType == 42) {//PCB夹具
type = COMPONENT_TYPE.FIXTURE;
name = StorageConstants.PACKAGE_TYPE.PCB_FIXTURE.getCode();
}
baseCriteria.and("barcode.type").is(type);
}
String expire = criteria.getExpire();
if (!Strings.isNullOrEmpty(expire)) {
if ("solder".equalsIgnoreCase(expire)) {
baseCriteria.and("barcode.expTime").lte(new Date());
} else if ("pcb".equalsIgnoreCase(expire)) {
baseCriteria.and("barcode.expireDate").lte(new Date());
}
}
query.addCriteria(baseCriteria);
List<StoragePos> storagePos = storagePosManager.findByQuery(query );
storagePosManager.download(storagePos, response);
}
@ApiOperation("查找出库列表")
@GetMapping("/find")
@PreAuthorize("@el.check('checkOut')")
......
......@@ -9,6 +9,8 @@ import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
......@@ -57,4 +59,6 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
StoragePos autoFindNextEmptyPos(Storage storage, Collection<String> excludePosIds,StoragePos currentPos);
public void updateBarcodeMsd(String pn,String msl,String thickness);
void download(List<StoragePos> storagePos, HttpServletResponse response) throws IOException;
}
......@@ -5,6 +5,8 @@ import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.PointUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.bean.PlateSizeBean;
......@@ -16,6 +18,7 @@ import com.neotel.smfcore.core.storage.service.dao.IStoragePosDao;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.security.service.po.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
......@@ -28,10 +31,11 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
@Slf4j
......@@ -241,7 +245,7 @@ public class StoragePosManagerImpl implements IStoragePosManager {
sort = Sort.by(Sort.Direction.ASC, "barcode.amount", "canCheckOutTime");
}else if(CHECKOUT_TYPE.PRODUCE_DATE.equals(checkoutType)){
//先生产先出
sort = Sort.by(Sort.Direction.ASC, "barcode.produceDate", "canCheckOutTime");
sort = Sort.by(Sort.Direction.ASC, "barcode.amount","barcode.produceDate", "canCheckOutTime");
}else{//效率优先
sort = Sort.by(Sort.Direction.ASC, "canCheckOutTime", "createDate");
}
......@@ -451,4 +455,30 @@ public class StoragePosManagerImpl implements IStoragePosManager {
storagePosDao.updateMulti(query, Update.update("barcode.thickness",thickness));
}
@Override
public void download(List<StoragePos> storagePos, HttpServletResponse response) throws IOException {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
List<Map<String, Object>> list = new ArrayList<>();
for (StoragePos pos : storagePos) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("条码编号", pos.getBarcode().getBarcode());
map.put("物料编号", pos.getBarcode().getPartNumber());
String proDate = pos.getBarcode().getProduceDate() == null ? "" : dateFormat.format(pos.getBarcode().getProduceDate());
map.put("生产日期", proDate);
map.put("过期时间", pos.getBarcode().getExpireDate());
map.put("库位号", pos.getPosName());
map.put("工单号", pos.getBarcode().getLockName());
map.put("数量", pos.getBarcode().getAmount());
String putInTime = (pos.getBarcode().getPutInTime() == -1) ? "" : dateFormat.format(new Date(pos.getBarcode().getPutInTime()));
if(ObjectUtil.isNotEmpty(putInTime)){
putInTime=dateFormat.format(pos.getBarcode().getPutInDate());
}
map.put("首次入库时间", putInTime);
map.put("入库时间", dateFormat.format(pos.getBarcode().getPutInDate()));
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!