Merge branch 'master' of http://121.40.234.130:8899/root/lanzhouhailiang_one
This commit is contained in:
@@ -76,11 +76,19 @@
|
||||
case when plan.paper_tube_or_FRP = '1' then plan.paper_tube_description when plan.paper_tube_or_FRP = '2' then plan.FRP_description end AS paper_name,
|
||||
sub.box_weight,
|
||||
CASE
|
||||
WHEN DATEDIFF( NOW(), sub.date_of_production ) > '60'
|
||||
AND DATEDIFF( NOW(), sub.date_of_production ) <= '90' THEN '2'
|
||||
WHEN DATEDIFF( NOW(), sub.date_of_production ) <= '90' THEN '1'
|
||||
WHEN DATEDIFF( NOW(), sub.date_of_production ) > '90' THEN '3'
|
||||
WHEN SUBSTRING( sub.container_name, 1, 1 ) = 'B' THEN
|
||||
CASE
|
||||
WHEN DATEDIFF( NOW(), sub.date_of_production ) > '150' AND DATEDIFF( NOW(), sub.date_of_production ) <= '180' THEN '2'
|
||||
WHEN DATEDIFF( NOW(), sub.date_of_production ) <= '180' THEN '1'
|
||||
WHEN DATEDIFF( NOW(), sub.date_of_production ) > '180' THEN '3'
|
||||
END
|
||||
|
||||
WHEN SUBSTRING( sub.container_name, 1, 1 ) <> 'B' THEN
|
||||
CASE
|
||||
WHEN DATEDIFF( NOW(), sub.date_of_production ) > '60' AND DATEDIFF( NOW(), sub.date_of_production ) <= '90' THEN '2'
|
||||
WHEN DATEDIFF( NOW(), sub.date_of_production ) <= '90' THEN '1'
|
||||
WHEN DATEDIFF( NOW(), sub.date_of_production ) > '90' THEN '3'
|
||||
END
|
||||
END AS sub_type,
|
||||
DATEDIFF( NOW(), sub.date_of_production ) AS stock_age
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
JSONObject json = item.getJSONObject(i);
|
||||
lfart = json.getString("LFART");
|
||||
JSONObject jsonDtl = new JSONObject();
|
||||
if (StrUtil.equals(lfart, "ZLF")) {
|
||||
if (StrUtil.equals(lfart, "ZLF") || StrUtil.equals(lfart, "ZJS")) {
|
||||
// 生成出库单
|
||||
jsonMst.put("io_type", "1");
|
||||
jsonMst.put("buss_type", "1001");
|
||||
@@ -485,8 +485,7 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
box_rows.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 发货出库
|
||||
if (StrUtil.equals(lfart, "ZLF")) {
|
||||
jsonMst.put("tableData", tableData);
|
||||
// 调用出库新增并分配
|
||||
@@ -494,6 +493,17 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("iostorinv_id", iostorinv_id);
|
||||
}
|
||||
// 分拣出库
|
||||
if (StrUtil.equals(lfart, "ZJS")) {
|
||||
jsonMst.put("buss_type", "1011");
|
||||
jsonMst.put("bill_type", "1011");
|
||||
jsonMst.put("tableData", tableData);
|
||||
// 调用出库新增并分配
|
||||
String iostorinv_id = checkOutBillService.insertDtl2(jsonMst);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("iostorinv_id", iostorinv_id);
|
||||
}
|
||||
// 退货入库
|
||||
if (StrUtil.equals(lfart, "ZLR")) {
|
||||
jsonMst.put("tableData", box_rows);
|
||||
//创建退货入库单
|
||||
|
||||
@@ -104,11 +104,11 @@ public class AutoSaveIvtExcel {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
String nowStr = format.format(date) + "-";
|
||||
String path = properties.getPath().getPath() + type + File.separator + nowStr + "库存报表.xls";
|
||||
String path = properties.getPath().getPath() + type + File.separator + nowStr + "0库存报表.xls";
|
||||
FileOutputStream fileOut = new FileOutputStream(path);
|
||||
LocalStorage localStorage = new LocalStorage(
|
||||
nowStr + "库存报表.xls",
|
||||
nowStr + "库存报表",
|
||||
nowStr + "0库存报表.xls",
|
||||
nowStr + "0库存报表",
|
||||
"xls",
|
||||
path,
|
||||
type,
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.tools.domain.LocalStorage;
|
||||
import org.nl.modules.tools.repository.LocalStorageRepository;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AutoSaveIvtExcelTwo {
|
||||
|
||||
private final RedissonClient redissonClient;
|
||||
|
||||
private final FileProperties properties;
|
||||
|
||||
private final LocalStorageRepository localStorageRepository;
|
||||
|
||||
@SneakyThrows
|
||||
public void run() {
|
||||
RLock lock = redissonClient.getLock(this.getClass().getName());
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet sheet = workbook.createSheet("TestSheet");
|
||||
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
|
||||
//设置第一列
|
||||
row.createCell(0).setCellValue("仓库");
|
||||
row.createCell(1).setCellValue("库区");
|
||||
row.createCell(2).setCellValue("木箱码");
|
||||
row.createCell(3).setCellValue("物料名称");
|
||||
row.createCell(4).setCellValue("子卷号");
|
||||
row.createCell(5).setCellValue("客户名称");
|
||||
row.createCell(6).setCellValue("销售订单");
|
||||
row.createCell(7).setCellValue("业务员");
|
||||
row.createCell(8).setCellValue("入库时间");
|
||||
row.createCell(9).setCellValue("单箱装卷数");
|
||||
row.createCell(10).setCellValue("库龄");
|
||||
row.createCell(11).setCellValue("产品规格(幅宽)");
|
||||
row.createCell(12).setCellValue("净重");
|
||||
row.createCell(13).setCellValue("长度");
|
||||
row.createCell(14).setCellValue("物料标准厚度");
|
||||
row.createCell(15).setCellValue("管件类型");
|
||||
row.createCell(16).setCellValue("管件描述");
|
||||
|
||||
//查询库存明细
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "22");
|
||||
|
||||
JSONArray resultJSONArray = WQL.getWO("QST_STRUCTIVT001").addParamMap(map).process().getResultJSONArray(0);
|
||||
|
||||
for (int i = 0; i < resultJSONArray.size(); i++) {
|
||||
HSSFRow row_dtl = sheet.createRow(i+1);
|
||||
JSONObject dtl = resultJSONArray.getJSONObject(i);
|
||||
row_dtl.createCell(0).setCellValue(dtl.getString("stor_name"));
|
||||
row_dtl.createCell(1).setCellValue(dtl.getString("sect_name"));
|
||||
row_dtl.createCell(2).setCellValue(dtl.getString("package_box_sn"));
|
||||
row_dtl.createCell(3).setCellValue(dtl.getString("material_name"));
|
||||
row_dtl.createCell(4).setCellValue(dtl.getString("pcsn"));
|
||||
row_dtl.createCell(5).setCellValue(dtl.getString("customer_description"));
|
||||
row_dtl.createCell(6).setCellValue(dtl.getString("sale_order_name"));
|
||||
row_dtl.createCell(7).setCellValue(dtl.getString("sales_owner"));
|
||||
row_dtl.createCell(8).setCellValue(dtl.getString("instorage_time"));
|
||||
row_dtl.createCell(9).setCellValue(dtl.getString("quanlity_in_box"));
|
||||
row_dtl.createCell(10).setCellValue(dtl.getString("sid_day"));
|
||||
row_dtl.createCell(11).setCellValue(String.format("%.0f", dtl.getDoubleValue("width")));
|
||||
row_dtl.createCell(12).setCellValue(dtl.getString("net_weight"));
|
||||
row_dtl.createCell(13).setCellValue(dtl.getString("length"));
|
||||
row_dtl.createCell(14).setCellValue(dtl.getString("thickness_request"));
|
||||
row_dtl.createCell(15).setCellValue(dtl.getString("paper_type"));
|
||||
row_dtl.createCell(16).setCellValue(dtl.getString("paper_name"));
|
||||
}
|
||||
|
||||
|
||||
String type = FileUtil.getFileType("xls");
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
||||
String nowStr = format.format(date) + "-";
|
||||
String path = properties.getPath().getPath() + type + File.separator + nowStr + "8库存报表.xls";
|
||||
FileOutputStream fileOut = new FileOutputStream(path);
|
||||
LocalStorage localStorage = new LocalStorage(
|
||||
nowStr + "8库存报表.xls",
|
||||
nowStr + "8库存报表",
|
||||
"xls",
|
||||
path,
|
||||
type,
|
||||
"");
|
||||
localStorageRepository.save(localStorage);
|
||||
workbook.write(fileOut);
|
||||
|
||||
fileOut.close();
|
||||
} else {
|
||||
System.out.println("AutoQueryBillInfo" + DateUtil.now() + "被锁住!!!!");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -319,4 +319,13 @@ public interface CheckOutBillService {
|
||||
* @param request、
|
||||
*/
|
||||
void importExcel(MultipartFile file, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 更新分拣出库重量
|
||||
* @param whereJson {
|
||||
* dtl: 明细数据
|
||||
* tabledis: 分配明细集合
|
||||
* }
|
||||
*/
|
||||
void saveUpdate(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -320,4 +320,11 @@ public class CheckOutBillController {
|
||||
checkOutBillService.importExcel(file, request);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/saveUpdate")
|
||||
@Log("更新分拣出库重量")
|
||||
public ResponseEntity<Object> saveUpdate(@RequestBody JSONObject whereJson) {
|
||||
checkOutBillService.saveUpdate(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1241,6 +1241,72 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveUpdate(JSONObject whereJson) {
|
||||
// 分配明细表
|
||||
WQLObject disTab = WQLObject.getWQLObject("st_ivt_iostorinvdis");
|
||||
// 明细表
|
||||
WQLObject dtlTab = WQLObject.getWQLObject("st_ivt_iostorinvdtl");
|
||||
// 库存表
|
||||
WQLObject ivtTab = WQLObject.getWQLObject("st_ivt_structivt");
|
||||
|
||||
JSONObject jsonDtl = whereJson.getJSONObject("dtl");
|
||||
List<JSONObject> disArr = whereJson.getJSONArray("tabledis").toJavaList(JSONObject.class);
|
||||
|
||||
for (int i = 0; i < disArr.size(); i++) {
|
||||
JSONObject json = disArr.get(i);
|
||||
|
||||
// 输入数量不能为零
|
||||
if (json.getDoubleValue("plan_qty") == 0) {
|
||||
throw new BadRequestException("输入数量不能为0!");
|
||||
}
|
||||
|
||||
// 更新冻结库存
|
||||
JSONObject jsonIvt = ivtTab.query("pcsn = '" + json.getString("pcsn") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonIvt)) {
|
||||
throw new BadRequestException("库存不存在!"+json.getString("pcsn"));
|
||||
}
|
||||
|
||||
jsonIvt.put("frozen_qty", json.getDoubleValue("plan_qty"));
|
||||
// 冻结库存不能超过库存数量
|
||||
if (jsonIvt.getDoubleValue("frozen_qty") > jsonIvt.getDoubleValue("ivt_qty")) {
|
||||
throw new BadRequestException("输入数量不能大于库存数量! 当前库存数为:"+jsonIvt.getString("ivt_qty"));
|
||||
}
|
||||
|
||||
// 更新库存数
|
||||
double canuse_qty = NumberUtil.sub(jsonIvt.getDoubleValue("ivt_qty"), jsonIvt.getDoubleValue("frozen_qty"));
|
||||
jsonIvt.put("canuse_qty",canuse_qty);
|
||||
|
||||
ivtTab.update(jsonIvt);
|
||||
|
||||
// 更新分配明细
|
||||
json.put("real_qty", json.getDoubleValue("plan_qty"));
|
||||
disTab.update(json);
|
||||
}
|
||||
|
||||
// 更新明细
|
||||
double assign_qty = disArr.stream()
|
||||
.map(row -> row.getDoubleValue("plan_qty"))
|
||||
.reduce(Double::sum).orElse(0.00);
|
||||
// 已分配重量
|
||||
jsonDtl.put("assign_qty", assign_qty);
|
||||
|
||||
// 未分配重量/明细状态
|
||||
double unassign_qty = NumberUtil.sub(jsonDtl.getDoubleValue("plan_qty"), assign_qty);
|
||||
if (unassign_qty <= 0) {
|
||||
jsonDtl.put("unassign_qty", 0);
|
||||
jsonDtl.put("bill_status", "40");
|
||||
} else {
|
||||
jsonDtl.put("unassign_qty", unassign_qty);
|
||||
jsonDtl.put("bill_status", "30");
|
||||
}
|
||||
dtlTab.update(jsonDtl);
|
||||
|
||||
// 更新主表状态
|
||||
updateMststatus(jsonDtl.getString("iostorinv_id"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(JSONObject whereJson) {
|
||||
@@ -2472,8 +2538,15 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
||||
String iostorinv_id = whereJson.getString("iostorinv_id");
|
||||
//查询主表信息
|
||||
JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
||||
// 查询此分配明细下的所有相同箱号的分配明细
|
||||
JSONArray diss = wo_dis.query("box_no = '" + whereJson.getString("storagevehicle_code") + "' and iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0);
|
||||
// 查询此分配明细下的所有相同箱号的分配明细-- 如果为分拣出库则只需要更新当前子卷库存
|
||||
JSONArray diss;
|
||||
if (jo_mst.getString("bill_type").equals("1011")) {
|
||||
diss = wo_dis.query("pcsn = '" + whereJson.getString("pcsn") + "' and iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0);
|
||||
|
||||
} else {
|
||||
diss = wo_dis.query("box_no = '" + whereJson.getString("storagevehicle_code") + "' and iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0);
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < diss.size(); i++) {
|
||||
JSONObject dis = diss.getJSONObject(i);
|
||||
@@ -2544,18 +2617,28 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
||||
map.put("is_delete", "1");
|
||||
wo_Task.update(map, "task_id='" + dis.getString("task_id") + "'");
|
||||
}
|
||||
//解锁起点仓位点位
|
||||
JSONObject from_start = new JSONObject();
|
||||
from_start.put("struct_id", dis.getString("struct_id"));
|
||||
from_start.put("lock_type", "1");
|
||||
storPublicService.updateStructAndPoint2(from_start);
|
||||
//解锁终点仓位点位
|
||||
if (StrUtil.isNotEmpty(dis.getString("point_code"))) {
|
||||
JSONObject from_end = new JSONObject();
|
||||
from_end.put("point_code", dis.getString("point_code"));
|
||||
from_end.put("lock_type", "1");
|
||||
storPublicService.updateStructAndPoint2(from_end);
|
||||
//解锁起点仓位点位: 判断此仓位是否还有库存
|
||||
List<JSONObject> ivtList = WQLObject.getWQLObject("st_ivt_structivt")
|
||||
.query("struct_id = '" + dis.getString("struct_id") + "'")
|
||||
.getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
boolean is_zero = ivtList.stream()
|
||||
.allMatch(row -> row.getDoubleValue("frozen_qty") == 0);
|
||||
|
||||
if (is_zero) {
|
||||
JSONObject from_start = new JSONObject();
|
||||
from_start.put("struct_id", dis.getString("struct_id"));
|
||||
from_start.put("lock_type", "1");
|
||||
storPublicService.updateStructAndPoint2(from_start);
|
||||
//解锁终点仓位点位
|
||||
if (StrUtil.isNotEmpty(dis.getString("point_code"))) {
|
||||
JSONObject from_end = new JSONObject();
|
||||
from_end.put("point_code", dis.getString("point_code"));
|
||||
from_end.put("lock_type", "1");
|
||||
storPublicService.updateStructAndPoint2(from_end);
|
||||
}
|
||||
}
|
||||
|
||||
} else {//仓位载具扔有冻结数,需改任务类型为拣选出库
|
||||
//任务号不为空
|
||||
/* if (ObjectUtil.isNotEmpty(dis.getString("task_id"))) {
|
||||
|
||||
@@ -660,7 +660,7 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
|
||||
}
|
||||
|
||||
// 销售出库
|
||||
if (StrUtil.equals(bill_type, "1001")) {
|
||||
if (StrUtil.equals(bill_type, "1001") || StrUtil.equals(bill_type, "1011")) {
|
||||
// 1.回传sap
|
||||
JSONArray paramSapMstArr = new JSONArray();
|
||||
|
||||
@@ -1284,7 +1284,7 @@ public class InAndOutRetrunServiceImpl implements InAndOutReturnService {
|
||||
}
|
||||
|
||||
// 销售出库
|
||||
if (StrUtil.equals(bill_type, "1001")) {
|
||||
if (StrUtil.equals(bill_type, "1001") || StrUtil.equals(bill_type, "1011") ) {
|
||||
// 1.回传sap
|
||||
JSONArray paramSapMstArr = new JSONArray();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user