Commit 25b49329 by 高晓磊

地磅同步接口,增加生产线list返回值.并且在保存地磅记录时获取用户选择的生产线

parent b4c657de
......@@ -273,9 +273,10 @@ public class InventoryServiceImpl implements InventoryService {
if(item.getBigDecimal("amount")==null || item.getBigDecimal("amount").compareTo(BigDecimal.ZERO)<1){
continue;
}
KObject kObject = item.get("station");
StationDinasTypeRelation r = new StationDinasTypeRelation();
r.setStationId(item.get("station").getUuid("id"));
r.setStationName(item.get("station").getString("stationName"));
r.setStationId(kObject.getUuid("id"));
r.setStationName(kObject.getString("stationName"));
r.setDinasTypeId(item.get("dinasType").getUuid("id"));
r.setDinasTypeName(item.get("dinasType").getString("dinasTypeName"));
r.setAmount(item.getBigDecimal("amount"));
......@@ -284,6 +285,17 @@ public class InventoryServiceImpl implements InventoryService {
Map<String, Object> stringObjectMap = JsonUtil.jsonToMap(s, String.class, Object.class);
stringObjectMap.put("saleType",2);
stringObjectMap.put("transportType",2);
KObject productionLines = kObject.get("productionLines");
//生产线列表
ArrayList<HashMap<String,Object>> productionLine = new ArrayList<>();
List<KObject> kObjects = productionLines.toList();
for (KObject object : kObjects) {
HashMap<String, Object> stringObjectHashMap1 = new HashMap<>();
stringObjectHashMap1.put("name",object.getString("name"));
stringObjectHashMap1.put("id",object.getUuid("id"));
productionLine.add(stringObjectHashMap1);
}
stringObjectMap.put("productionLines",productionLine);
result.add(stringObjectMap);
}
return result;
......
......@@ -622,7 +622,19 @@ public class SalesPlanServiceImpl implements SalesPlanService {
//收货方名称
stringObjectHashMap.put("consignee", contract.get("purchaseSandUnit").getString("name"));
//供货方名称
stringObjectHashMap.put("supplier", saleTempDetail.get("master").get("station").getString("stationName"));
KObject kObject = saleTempDetail.get("master").get("station");
stringObjectHashMap.put("supplier", kObject.getString("stationName"));
//生产线列表
KObject productionLines = kObject.get("productionLines");
ArrayList<HashMap<String,Object>> productionLine = new ArrayList<>();
List<KObject> kObjects = productionLines.toList();
for (KObject object : kObjects) {
HashMap<String, Object> stringObjectHashMap1 = new HashMap<>();
stringObjectHashMap1.put("name",object.getString("name"));
stringObjectHashMap1.put("id",object.getUuid("id"));
productionLine.add(stringObjectHashMap1);
}
stringObjectHashMap.put("productionLines",productionLine);
//地址
stringObjectHashMap.put("shippingAddress", contract.getString("addrReceive"));
//合同id
......@@ -638,7 +650,11 @@ public class SalesPlanServiceImpl implements SalesPlanService {
//需用计划砂石id
stringObjectHashMap.put("needPlanDetailId", saleTempDetail.getUuid("id"));
//本周期已拉取量
stringObjectHashMap.put("effectiveSale", saleTempDetail.getBigDecimal("actualSaleAmount"));
BigDecimal actualSaleAmount = saleTempDetail.getBigDecimal("actualSaleAmount");
if(actualSaleAmount==null){
actualSaleAmount=BigDecimal.ZERO;
}
stringObjectHashMap.put("effectiveSale",actualSaleAmount );
//本周期分配量
stringObjectHashMap.put("planAmount", saleTempDetail.getBigDecimal("salesPlanAmount"));
stringObjectHashMap.put("salePlanId", saleTempDetail.get("master").getUuid("id"));
......@@ -727,8 +743,19 @@ public class SalesPlanServiceImpl implements SalesPlanService {
//收货方名称
stringObjectHashMap.put("consignee", a.get("purchaseSandUnit").getString("name"));
//供货方名称
stringObjectHashMap.put("supplier", a.get("station").getString("stationName"));
KObject kObject = a.get("station");
stringObjectHashMap.put("supplier", kObject.getString("stationName"));
KObject productionLines = kObject.get("productionLines");
//生产线列表
ArrayList<HashMap<String,Object>> productionLine = new ArrayList<>();
List<KObject> kObjects = productionLines.toList();
for (KObject object : kObjects) {
HashMap<String, Object> stringObjectHashMap1 = new HashMap<>();
stringObjectHashMap1.put("name",object.getString("name"));
stringObjectHashMap1.put("id",object.getUuid("id"));
productionLine.add(stringObjectHashMap1);
}
stringObjectHashMap.put("productionLines",productionLine);
});
//库存id
......
......@@ -104,8 +104,13 @@ public class SalesRecordServiceImpl implements SalesRecordService {
salesRecord.set(SalesRecordConstant.DEALTIME, salesRecordInfo.getGrossWeightTime());
salesRecord.set(SalesRecordConstant.DEALBILLCODE, salesRecordInfo.getDealBillCode());
salesRecord.set(SalesRecordConstant.CARINFO, salesRecordInfo.getCarNum());
salesRecord.set(SalesRecordConstant.PRICE, salesRecordInfo.getPrice());
Integer paymentSource = salesRecordInfo.getPaymentSource();
if(null!=salesRecordInfo.getProductionLineId()&&StringUtils.isNotBlank(salesRecordInfo.getProductionLineId())){
salesRecord.set(SalesRecordConstant.PRODUCTIONLINE, productionLineDao.findById(UUID.fromString(salesRecordInfo.getProductionLineId())));
}
if(paymentSource==0){
salesRecord.set(SalesRecordConstant.PAYMENTSOURCE,PayMentSourceEnum.Advance );
}else{
......
......@@ -90,6 +90,10 @@ public class SalesRecordInfo {
*/
private String planningCycleId;
/**
* 生产线id
*/
private String productionLineId;
/**
* saleType为1是需用计划id,saleType不为1时无用
*/
private String needPlanId;
......@@ -146,6 +150,14 @@ public class SalesRecordInfo {
*/
private Integer saleType;
public String getProductionLineId() {
return productionLineId;
}
public void setProductionLineId(String productionLineId) {
this.productionLineId = productionLineId;
}
public String getTransportTypeId() {
return transportTypeId;
}
......
......@@ -217,6 +217,18 @@ public class VehicleDispatchServiceImpl implements VehicleDispatchService {
stringObjectHashMap.put("effectiveSale", dispatch.getBigDecimal("actualTransportation"));
//本周期分配量
stringObjectHashMap.put("planAmount", dispatch.getBigDecimal("planAmount"));
KObject productionLines = station.get("productionLines");
//生产线列表
ArrayList<HashMap<String,Object>> productionLine = new ArrayList<>();
List<KObject> kObjects = productionLines.toList();
for (KObject object : kObjects) {
HashMap<String, Object> stringObjectHashMap1 = new HashMap<>();
stringObjectHashMap1.put("name",object.getString("name"));
stringObjectHashMap1.put("id",object.getUuid("id"));
productionLine.add(stringObjectHashMap1);
}
stringObjectHashMap.put("productionLines",productionLine);
if(dispatchType==DispatchTypeEnum.SALE_TEMP_PLAN.getValue()){
KObject salePlanTemp = salesPlanDao.loadTempDetail(sealDetailId);
//临时销售计划没有需用计划,这里值仅做填充
......
......@@ -7,16 +7,15 @@ import com.beecode.bap.attachment.exception.AttachmentDataUploadException;
import com.beecode.bap.attachment.service.AttachmentService;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.util.Base64;
import com.xyst.dinas.biz.service.StationService;
import com.xyst.dinas.sales.service.InventoryService;
import com.xyst.dinas.sales.service.SalesPlanService;
import com.xyst.dinas.sales.service.SalesRecordService;
import com.xyst.dinas.sales.web.info.SalesRecordInfo;
import com.xyst.dinas.transport.service.VehicleDispatchService;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -68,7 +67,7 @@ public class WeighbridgeSyncController {
return ResponseObj.error("传递的销售台账数据条数为0!请确认!");
} else {
HashMap<String, Object> stringObjectHashMap = salesRecordService.saveSalesRecordService(salesRecordList, station);
return ResponseObj.response((Integer) stringObjectHashMap.get("code"),stringObjectHashMap.get("message").toString(),stringObjectHashMap.get("id"));
return ResponseObj.error((Integer) stringObjectHashMap.get("code"),stringObjectHashMap.get("message").toString(),stringObjectHashMap.get("id"));
}
}
......@@ -115,43 +114,57 @@ public class WeighbridgeSyncController {
@RequestMapping(value = "weighbridgeSync/uploadFile", method = RequestMethod.POST)
public ResponseObj<UUID> upload(@RequestParam(name = "belongId", required = false) String belongId,
@RequestParam("files") MultipartFile[] files,
@RequestHeader(name = HttpHeaders.USER_AGENT, required = false) String userAgent,
@RequestParam (name = "weighbridgeCode") String weighbridgeCode ) {
public ResponseObj<UUID> upload(
@RequestParam String weighbridgeCode,
@RequestBody HashMap<String,Object> map) {
if (null == files || files.length < 1) {
Object files = map.get("files");
Object belongId = map.get("belongId");
if (files==null||StringUtils.isBlank(files.toString())) {
return ResponseObj.response(500, "文件不能为空",null);
}
//根据地磅id查询场站
if (StringUtils.isBlank(weighbridgeCode)) {
if (weighbridgeCode==null||StringUtils.isBlank(weighbridgeCode.toString())) {
return ResponseObj.response(500, "地磅唯一编码不能为空",null);
}
KObject station = stationService.getStationByWeighbridge(weighbridgeCode);
KObject station = stationService.getStationByWeighbridge(weighbridgeCode.toString());
if (station == null) {
return ResponseObj.response(500, "没有查询到地磅匹配的场站",null);
}
//根据查询地磅id
if (StringUtils.isBlank(belongId)) {
if (belongId==null||StringUtils.isBlank(belongId.toString())) {
return ResponseObj.response(500, "地磅记录不能为空",null);
}
checkFileUpload(files);
// checkFileUpload(files);
try {
for (MultipartFile file : files) {
File file1 = new File("");
Thumbnails.of(file.getInputStream())
.scale(0.9f)
.toFile(file1);
ArrayList<Map<String,Object>> files1 = (ArrayList) files;
for (Map<String, Object> stringObjectMap : files1) {
Object fileName = stringObjectMap.get("fileName");
Object fileData = stringObjectMap.get("fileData");
System.out.println(fileName);
File file1 = new File(getTmpdir(),fileName.toString());
if(!file1.exists()){
if(!file1.getParentFile().exists()){
boolean mkdirs = file1.getParentFile().mkdirs();
}
boolean newFile = file1.createNewFile();
}
String s1 = fileData.toString();
byte[] bytes = Base64.base64ToByteArray(s1);
OutputStream imageStream = new FileOutputStream(file1);
imageStream.write(bytes);
FileInputStream
fileInputStream = new FileInputStream(file1);
AttachmentInfo info = generateInfo(UUID.fromString(belongId), file.getOriginalFilename(), file1.length());
return ResponseObj.response(200,"保存成功", attachmentService.insert(info, fileInputStream));
AttachmentInfo info = generateInfo(UUID.fromString(belongId.toString()), fileName.toString(), Long.valueOf(bytes.length+""));
attachmentService.insert(info, fileInputStream);
file1.deleteOnExit();
}
return ResponseObj.response(200,"保存成功",UUID.randomUUID());
} catch (IOException e) {
throw new AttachmentDataUploadException("文件上传失败," + e.getMessage(), e);
}
return ResponseObj.response(500,"保存失败", null);
}
......@@ -166,7 +179,7 @@ public class WeighbridgeSyncController {
public Object getAllDinasType(@RequestParam String weighbridgeCode) {
//根据地磅id查询场站
if (StringUtils.isBlank(weighbridgeCode)) {
return ResponseObj.error(500, "地磅唯一编码不能为空");
return ResponseObj.error(500, "地磅唯一编码不能为空");
}
KObject station = stationService.getStationByWeighbridge(weighbridgeCode);
if (station == null) {
......@@ -193,10 +206,11 @@ public class WeighbridgeSyncController {
private AttachmentInfo generateInfo(UUID belongId, String fileName, Long fileSize) {
fileName += ".jpg";
AttachmentInfo attachmentInfo = new AttachmentInfo();
attachmentInfo.setBelongId(belongId);
attachmentInfo.setCategory("saleRecord");
attachmentInfo.setFileName(UUID.randomUUID() + "." + Utils.getFileType(Objects.requireNonNull(fileName)));
attachmentInfo.setFileName(fileName );
// macOS系统存在含‘\’文件名的文件所以分开写
attachmentInfo.setFileType(Utils.getFileType(Objects.requireNonNull(fileName)));
attachmentInfo.setSize(fileSize);
......@@ -217,4 +231,7 @@ public class WeighbridgeSyncController {
}
private String getTmpdir(){
return System.getProperty("java.io.tmpdir") + "/aaa";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment