修改
This commit is contained in:
@@ -20,6 +20,7 @@ import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
@@ -31,6 +32,7 @@ import org.nl.modules.tools.service.LocalStorageService;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageDto;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageQueryCriteria;
|
||||
import org.nl.modules.tools.service.mapstruct.LocalStorageMapper;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -41,15 +43,12 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
@@ -59,20 +58,20 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
private final FileProperties properties;
|
||||
|
||||
@Override
|
||||
public Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable){
|
||||
Page<LocalStorage> page = localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
public Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable) {
|
||||
Page<LocalStorage> page = localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
return PageUtil.toPage(page.map(localStorageMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalStorageDto> queryAll(LocalStorageQueryCriteria criteria){
|
||||
return localStorageMapper.toDto(localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
public List<LocalStorageDto> queryAll(LocalStorageQueryCriteria criteria) {
|
||||
return localStorageMapper.toDto(localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalStorageDto findById(Long id){
|
||||
public LocalStorageDto findById(Long id) {
|
||||
LocalStorage localStorage = localStorageRepository.findById(id).orElseGet(LocalStorage::new);
|
||||
ValidationUtil.isNull(localStorage.getId(),"LocalStorage","id",id);
|
||||
ValidationUtil.isNull(localStorage.getId(), "LocalStorage", "id", id);
|
||||
return localStorageMapper.toDto(localStorage);
|
||||
}
|
||||
|
||||
@@ -82,8 +81,8 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
|
||||
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
|
||||
if(ObjectUtil.isNull(file)){
|
||||
File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
|
||||
if (ObjectUtil.isNull(file)) {
|
||||
throw new BadRequestException("上传失败");
|
||||
}
|
||||
try {
|
||||
@@ -97,7 +96,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
FileUtil.getSize(multipartFile.getSize())
|
||||
);
|
||||
return localStorageRepository.save(localStorage);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
FileUtil.del(file);
|
||||
throw e;
|
||||
}
|
||||
@@ -107,7 +106,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(LocalStorage resources) {
|
||||
LocalStorage localStorage = localStorageRepository.findById(resources.getId()).orElseGet(LocalStorage::new);
|
||||
ValidationUtil.isNull( localStorage.getId(),"LocalStorage","id",resources.getId());
|
||||
ValidationUtil.isNull(localStorage.getId(), "LocalStorage", "id", resources.getId());
|
||||
localStorage.copy(resources);
|
||||
localStorageRepository.save(localStorage);
|
||||
}
|
||||
@@ -126,7 +125,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
public void download(List<LocalStorageDto> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (LocalStorageDto localStorageDTO : queryAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", localStorageDTO.getRealName());
|
||||
map.put("备注名", localStorageDTO.getName());
|
||||
map.put("文件类型", localStorageDTO.getType());
|
||||
@@ -151,32 +150,129 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
List<Map<String, Object>> listMap = EasyExcel.read(path).sheet(1).doReadSync();
|
||||
List<Map<String, Object>> listMap = EasyExcel.read(path).sheet(0).doReadSync();
|
||||
// listMap.remove(0);
|
||||
for (int i = 0; i < listMap.size(); i++) {
|
||||
for (int i = 2; i < 86; i++) {
|
||||
Map<String, Object> map = listMap.get(i);
|
||||
String package_box_sn = String.valueOf(map.get(17));
|
||||
String container_name = String.valueOf(map.get(9));
|
||||
String sale_order = String.valueOf(map.get(15));
|
||||
String no = String.valueOf(map.get(16));
|
||||
String customer_name = String.valueOf(map.get(21));
|
||||
String customer_description = String.valueOf(map.get(22));
|
||||
String product_name = String.valueOf(map.get(2));
|
||||
String product_description = String.valueOf(map.get(3));
|
||||
String date_of_FG_inbound = String.valueOf(map.get(11));
|
||||
String width = String.valueOf(map.get(23));
|
||||
String thickness = String.valueOf(map.get(24));
|
||||
String net_weight = String.valueOf(map.get(4));
|
||||
String length = String.valueOf(map.get(26));
|
||||
String is_un_plan_production = String.valueOf(map.get(27));
|
||||
|
||||
if (StrUtil.isEmpty(package_box_sn)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的木箱唯一码为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(sale_order)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的销售订单及行号为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(customer_name)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的客户编号为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(customer_description)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的客户名称为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(product_name)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的产品编码为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(product_description)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的产品描述为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(container_name)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的子卷号为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(width)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的产品规格(幅宽)为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(net_weight)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的净重为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(length)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的长度为空!");
|
||||
}
|
||||
if (StrUtil.isEmpty(is_un_plan_production)) {
|
||||
throw new BadRequestException("第" + (i + 2) + "行的计划外分切的子卷为空!");
|
||||
}
|
||||
|
||||
String material_code = String.valueOf(map.get(5));
|
||||
if (StrUtil.isEmpty(material_code)){
|
||||
if (StrUtil.isEmpty(material_code)) {
|
||||
continue;
|
||||
}
|
||||
String material_name = String.valueOf(map.get(6));
|
||||
String unit_code = String.valueOf(map.get(7));
|
||||
JSONObject object = measureunitTab.query("unit_code = '" + unit_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(object)) throw new BadRequestException("空" + unit_code);
|
||||
JSONObject material = new JSONObject();
|
||||
material.put("material_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
material.put("material_code", material_code);
|
||||
material.put("material_name", material_name);
|
||||
material.put("base_unit_id", object.getString("measure_unit_id"));
|
||||
material.put("is_used", 1);
|
||||
material.put("is_delete", 0);
|
||||
material.put("create_id", currentUserId);
|
||||
material.put("create_name", nickName);
|
||||
material.put("create_time", now);
|
||||
material.put("update_optid", currentUserId);
|
||||
material.put("update_optname", nickName);
|
||||
material.put("update_time", now);
|
||||
materialbaseTab.insert(material);
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("workorder_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
jo.put("package_box_sn", package_box_sn);
|
||||
jo.put("sap_pcsn", container_name);
|
||||
// jo.put("box_weight", BoxWeight);
|
||||
jo.put("quality_guaran_period", "90");
|
||||
jo.put("sale_order_name", sale_order + "-" + no);
|
||||
jo.put("customer_name", customer_name);
|
||||
jo.put("customer_description", customer_description);
|
||||
jo.put("product_name", product_name);
|
||||
jo.put("product_description", product_description);
|
||||
jo.put("date_of_FG_inbound", date_of_FG_inbound);
|
||||
jo.put("container_name", container_name);
|
||||
jo.put("width", width);
|
||||
jo.put("thickness", thickness);
|
||||
jo.put("net_weight", net_weight);
|
||||
jo.put("length", length);
|
||||
jo.put("date_of_production", date_of_FG_inbound);
|
||||
jo.put("is_un_plan_production", is_un_plan_production);
|
||||
jo.put("status", "0");
|
||||
jo.put("create_id", "1");
|
||||
jo.put("create_name", "管理员");
|
||||
jo.put("create_time", DateUtil.now());
|
||||
WQLObject tab = WQLObject.getWQLObject("PDM_BI_SubPackageRelation");
|
||||
tab.insert(jo);
|
||||
}
|
||||
|
||||
JSONArray rows = WQL.getWO("ST_REGION_IN_01").addParam("flag", "3").process().getResultJSONArray(0);
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject row = rows.getJSONObject(i);
|
||||
String package_box_sn = row.getString("package_box_sn");
|
||||
double total_weight = 0;
|
||||
JSONArray box_rows = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '"+package_box_sn+"'").getResultJSONArray(0);
|
||||
//查询一个空的虚拟区货位
|
||||
JSONObject struct = WQL.getWO("PDA_ST_01").addParam("flag", "3").process().uniqueResult(0);
|
||||
for (int j = 0; j < box_rows.size(); j++) {
|
||||
JSONObject box_row = box_rows.getJSONObject(j);
|
||||
JSONObject ivt_jo = new JSONObject();
|
||||
//插入库存数据
|
||||
ivt_jo.put("stockrecord_id",IdUtil.getSnowflake(1,1).nextId());
|
||||
ivt_jo.put("struct_id",struct.getString("struct_id"));
|
||||
ivt_jo.put("struct_code",struct.getString("struct_code"));
|
||||
ivt_jo.put("struct_name",struct.getString("struct_name"));
|
||||
ivt_jo.put("region_id","");
|
||||
ivt_jo.put("quality_scode","01");
|
||||
ivt_jo.put("pcsn",box_row.getString("container_name"));
|
||||
ivt_jo.put("canuse_qty",box_row.getString("net_weight"));
|
||||
ivt_jo.put("frozen_qty",0);
|
||||
ivt_jo.put("ivt_qty",box_row.getString("net_weight"));
|
||||
ivt_jo.put("instorage_time",DateUtil.now());
|
||||
JSONObject mater = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '"+box_row.getString("product_name")+"'").uniqueResult(0);
|
||||
ivt_jo.put("material_id",mater.getString("material_id"));
|
||||
ivt_jo.put("qty_unit_id",mater.getString("base_unit_id"));
|
||||
WQLObject.getWQLObject("st_ivt_structivt").insert(ivt_jo);
|
||||
total_weight += box_row.getDoubleValue("net_weight");
|
||||
}
|
||||
|
||||
//更新总重量
|
||||
HashMap<String,String> sub_map = new HashMap<>();
|
||||
sub_map.put("box_weight",total_weight+"");
|
||||
sub_map.put("status","2");
|
||||
WQLObject.getWQLObject("pdm_bi_subpackagerelation").update(sub_map,"package_box_sn = '"+package_box_sn+"'");
|
||||
|
||||
//更新仓位字段
|
||||
struct.put("storagevehicle_code",package_box_sn);
|
||||
WQLObject.getWQLObject("st_ivt_structattr").update(struct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,14 +105,17 @@
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
*
|
||||
*
|
||||
FROM
|
||||
st_ivt_structattr
|
||||
st_ivt_structattr
|
||||
WHERE
|
||||
sect_code = 'XN01'
|
||||
AND lock_type = '1'
|
||||
AND is_delete = '0'
|
||||
AND IFNULL( storagevehicle_code, '' ) = ''
|
||||
sect_code = 'XN01'
|
||||
AND lock_type = '1'
|
||||
AND is_delete = '0'
|
||||
AND IFNULL( storagevehicle_code, '' ) = ''
|
||||
ORDER BY
|
||||
struct_code
|
||||
LIMIT 1
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -137,3 +137,13 @@
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT DISTINCT
|
||||
package_box_sn
|
||||
FROM
|
||||
pdm_bi_subpackagerelation
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
Reference in New Issue
Block a user