You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

347 lines
13 KiB
Java

5 months ago
package com.ruoyi.webapi.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.config.RuoYiConfig;
5 months ago
import com.ruoyi.common.core.domain.AjaxResult;
4 months ago
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
5 months ago
import com.ruoyi.manager.domain.*;
import com.ruoyi.manager.service.*;
import com.ruoyi.webapi.doman.APKVersion;
5 months ago
import com.ruoyi.webapi.doman.BindingSubmitBeen;
import com.ruoyi.webapi.doman.JoinSubmitBeen;
import com.ruoyi.webapi.service.ApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
5 months ago
import java.io.IOException;
5 months ago
import java.util.Date;
import java.util.List;
/**
* Created by wangh on 2020/7/17-15:18
*/
@RestController
@RequestMapping("/api")
public class ApiController {
@Autowired
ApiService service;
@Autowired
private IBaseManufacturerService baseManufacturerService;
@Autowired
private IBaseBasketInfoService baseBasketInfoService;
@Autowired
private IRecordBasketRepairService recordBasketRepairService;
@Autowired
private IRecordtRfidBindingService recordtRfidBindingService;
@Autowired
private ILedgerInstantBindingService ledgerInstantBindingService;//货物实时绑定信息
4 months ago
@Autowired
private IRecordCargoBindingService recordCargoBindingService;
5 months ago
@PostMapping("/findBindingList")
public AjaxResult findBindingList(String epc) {
List<String> codes = service.findBindingList(epc);
if (codes == null || codes.isEmpty()) return AjaxResult.error("没有运单绑定该资产");
return AjaxResult.success(codes);
}
@PostMapping("/deleteBindingList")
public AjaxResult deleteBindingList(String objids) {
4 months ago
int i = ledgerInstantBindingService.deleteLedgerInstantBindingByObjids(objids);
5 months ago
if (i > 0) return AjaxResult.success("全部解绑成功");
return AjaxResult.error();
}
@PostMapping("/deleteBindingItem")
public AjaxResult deleteBindingItem(Long ledgerId) {
// int i = service.deleteBindingItem(epc, code);
int i = ledgerInstantBindingService.deleteLedgerInstantBindingByObjid(ledgerId);
if (i == 1) return AjaxResult.success("解绑成功");
5 months ago
return AjaxResult.error();
}
@PostMapping("/deleteLocationCode")
public AjaxResult deleteLocationCode(String dbCode, String hkCode) {
int i = service.delectLocationInfoRemarkByDbCode(dbCode, hkCode);
if (i == 1) return AjaxResult.success();
return AjaxResult.error();
}
@PostMapping("/blueToothSubmit")
public AjaxResult blueToothSubmit(String locationCode, String hkCode) {
int i = service.blueToothSubmit(locationCode, hkCode);
if (i > 0) {
return AjaxResult.success();
}
return AjaxResult.error("库位没有维护");
}
4 months ago
// 接货查询
5 months ago
@PostMapping("/jion/select")
public AjaxResult jionSelect(String user) {
// List<LedgerInstantBinding> list = service.jionSelect(user);
LedgerInstantBinding query = new LedgerInstantBinding();
query.setCreateBy(user);
List<LedgerInstantBinding> list = ledgerInstantBindingService.selectList(query);
5 months ago
if (list == null || list.isEmpty()) return AjaxResult.error("账号无绑定记录");
return AjaxResult.success(list);
}
4 months ago
@Autowired
private IRecordDeliveryTaskService recordDeliveryTaskService;
@Autowired
private IRecordDeliveryTaskBaseketService recordDeliveryTaskBaseketService;
@PostMapping("/delivery/createTask")
4 months ago
public AjaxResult createDeliveryTask(String json,String user, List<MultipartFile> files) {
List<Long> ids = JSONArray.parseArray(json, Long.class);
4 months ago
// 生成任务编码
int taskNumber = recordDeliveryTaskService.countNowDateTaskNumber();
String taskCode="Task"+DateUtils.dateTime()+String.format("%03d",taskNumber);
// 插入任务
RecordDeliveryTask recordDeliveryTask=new RecordDeliveryTask();
recordDeliveryTask.setTaskCode(taskCode);
recordDeliveryTask.setCreateBy(user);
recordDeliveryTaskService.insertRecordDeliveryTask(recordDeliveryTask);
// 插入资产到任务表
recordDeliveryTaskBaseketService.insertRecordDeliveryTaskBaseket(taskCode,ids);
// 插入图片
String filePath = RuoYiConfig.getUploadPath()+"/task";
for (int i = 0; i < files.size(); i++) {
try {
String fileName = FileUploadUtils.upload(filePath, files.get(i));
RecordDeliveryTaskImg recordDeliveryTaskImg=new RecordDeliveryTaskImg();
recordDeliveryTaskImg.setTaskCode(taskCode);
recordDeliveryTaskImg.setImgPath(fileName);
recordDeliveryTaskImgService.insertRecordDeliveryTaskImg(recordDeliveryTaskImg);
} catch (IOException e) {
throw new RuntimeException(e);
}
4 months ago
}
5 months ago
4 months ago
return AjaxResult.success();
}
@Autowired
private IRecordDeliveryTaskImgService recordDeliveryTaskImgService;
5 months ago
//交货提交
@PostMapping("/join/jiaoSubmit")
public AjaxResult joinJiaoSubmit(@RequestBody JoinSubmitBeen been) {
int i = service.joinSelectByUser(been);
if (i == 0) {
return AjaxResult.success();
}
return AjaxResult.error();
}
//接货提交
@PostMapping("/join/shouSubmit")
public AjaxResult joinJieSubmit(@RequestBody JoinSubmitBeen been) {
int i = service.joinShouSubmit(been);
if (i >= been.getList().size()) {
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
*
*/
@PostMapping("/manufacturerList")
public AjaxResult manufacturerList() {
List<BaseManufacturer> list = baseManufacturerService.selectBaseManufacturerList(new BaseManufacturer());
if (list == null || list.isEmpty()) return AjaxResult.error("没有维护生产厂家");
return AjaxResult.success(list);
}
/**
*
*/
@PostMapping("/saveBasketInfo")
public AjaxResult saveBasketInfo(@RequestBody BaseBasketInfo baseBasketInfo) {
int tagCount = baseBasketInfoService.selectCountBasketByEpc(baseBasketInfo.getBasketEpc());
if (tagCount > 0) {
return AjaxResult.error("RFID标签1已绑定");
}
tagCount = baseBasketInfoService.selectCountBasketByEpc(baseBasketInfo.getBasketEpc2());
if (tagCount > 0) {
return AjaxResult.error("RFID标签2已绑定");
}
List<BaseBasketInfo> list = baseBasketInfoService.checkBasketInfoBySteelGradeAndSelfCode(baseBasketInfo);
if (list != null && !list.isEmpty()) {
return AjaxResult.error("钢号或自编号已存在");
}
5 months ago
baseBasketInfo.setUpdatedTime(new Date());
int i = 0;
5 months ago
if (baseBasketInfo.getObjId() == null) {
i = baseBasketInfoService.insertBaseBasketInfo(baseBasketInfo);
} else {
5 months ago
baseBasketInfo.setUpdatedBy(baseBasketInfo.getCreatedBy());
baseBasketInfo.setCreatedBy(null);
i = baseBasketInfoService.updateBaseBasketInfo(baseBasketInfo);
}
if (i > 0) return AjaxResult.success();
return AjaxResult.error();
}
/**
*
*/
@PostMapping("/saveRepairInfo")
public AjaxResult saveRepairInfo(@RequestBody RecordBasketRepair recordBasketRepair) {
int i = recordBasketRepairService.insertRecordBasketRepair(recordBasketRepair);
if (i > 0) return AjaxResult.success();
return AjaxResult.error();
}
/**
* RFID
*/
@PostMapping("/findBasketInfoByEpc")
public AjaxResult findBasketInfoByEpc(String epc) {
BaseBasketInfo baseBasketInfo = baseBasketInfoService.selectBaseBasketInfoByEpc(epc);
if (baseBasketInfo == null) return AjaxResult.error("没有维护该资产");
return AjaxResult.success(baseBasketInfo);
}
5 months ago
/**
*
*/
@GetMapping("/getBasketInfoBySearchCode")
public AjaxResult getBasketInfoBySearchCode(String searchCode) {
List<BaseBasketInfo> baseBasketInfo = baseBasketInfoService.selectBaseBasketInfoBySearchCode2(searchCode);
5 months ago
if (baseBasketInfo == null) return AjaxResult.error("没有维护该资产");
return AjaxResult.success(baseBasketInfo);
}
/**
*
*/
@PostMapping("/submitBindingRecord")
public AjaxResult submitBindingRecord(Long baseBasketId, String basketEpc, String basketEpc2, String localWeight, String createdBy, List<MultipartFile> files) {
int tagCount = baseBasketInfoService.selectCountBasketByEpc(basketEpc);
if (tagCount > 0) {
return AjaxResult.error("RFID标签1已绑定");
}
tagCount = baseBasketInfoService.selectCountBasketByEpc(basketEpc2);
if (tagCount > 0) {
return AjaxResult.error("RFID标签2已绑定");
}
// 验证钢号与自编号重复
String filePath = RuoYiConfig.getUploadPath();
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < files.size(); i++) {
String fileName = null;
try {
fileName = FileUploadUtils.upload(filePath, files.get(i));
} catch (IOException e) {
throw new RuntimeException(e);
}
// System.out.println("上传路径="+fileName);
stringBuilder.append(fileName);
if (i != files.size() - 1) {
stringBuilder.append(",");
}
}
// 新增绑定记录
RecordtRfidBinding recordtRfidBinding = new RecordtRfidBinding();
recordtRfidBinding.setBaseBasketId(baseBasketId);
recordtRfidBinding.setBasketEpc(basketEpc);
recordtRfidBinding.setBasketEpc2(basketEpc2);
recordtRfidBinding.setCreatedBy(createdBy);
recordtRfidBinding.setFilePath(stringBuilder.toString());
int i = recordtRfidBindingService.insertRecordtRfidBinding(recordtRfidBinding);
// 更新资产信息
BaseBasketInfo baseBasketInfo = new BaseBasketInfo();
baseBasketInfo.setBasketEpc(basketEpc);
baseBasketInfo.setBasketEpc2(basketEpc2);
baseBasketInfo.setUpdatedTime(new Date());
baseBasketInfo.setUpdatedBy(createdBy);
baseBasketInfo.setObjId(baseBasketId);
baseBasketInfo.setLocalWeight(Double.parseDouble(localWeight));
int i1 = baseBasketInfoService.updateBaseBasketInfo(baseBasketInfo);
if (i > 0) return AjaxResult.success();
return AjaxResult.error();
}
5 months ago
/**
* -使
*
* @param epc
* @return
*/
@PostMapping("/binding/findBasketByEpc")
public AjaxResult findBasketByEpc(String epc) {
BaseBasketInfo baseBasketInfo = baseBasketInfoService.selectBaseBasketInfoByEpc(epc);
if (baseBasketInfo == null) return AjaxResult.error("RFID查询失败没有维护该资产");
LedgerInstantBinding ledgerInstantBinding = new LedgerInstantBinding();
ledgerInstantBinding.setBasketId(baseBasketInfo.getObjId());
List<LedgerInstantBinding> ledgerInstantBindings = ledgerInstantBindingService.selectLedgerChildTablelist(ledgerInstantBinding);
baseBasketInfo.setLedgerInstantBindings(ledgerInstantBindings);
return AjaxResult.success(baseBasketInfo);
}
// 解绑货物和货框
@PostMapping("/unbindingCargo")
public AjaxResult unbindingCargo(Long basketId) {
int i = ledgerInstantBindingService.unbindingCargoDeleteLedger(basketId);
if (i > 0) return AjaxResult.success();
return AjaxResult.error();
}
4 months ago
// 货物绑定货框
@PostMapping("/bindingSubmit")
public AjaxResult bindingSubmit(@RequestBody BindingSubmitBeen submitBeen) {
List<String> watBills = submitBeen.getWatBills();
String user = submitBeen.getUser();
String epc1 = submitBeen.getEpc();
Long basketId = submitBeen.getBasketId();
watBills.forEach(code -> {
String epc = service.selectEpcByWaybill(code, basketId);
if (epc == null) {
int i = service.insertLedgerBinding(epc1, code, user, basketId);
4 months ago
RecordCargoBinding recordCargoBinding = new RecordCargoBinding();
recordCargoBinding.setBasketId(basketId);
recordCargoBinding.setCargoFrameEpc(epc1);
recordCargoBinding.setWaybillNumber(code);
recordCargoBinding.setCreateBy(user);
recordCargoBinding.setLocationInfo(submitBeen.getLocationInfo());
recordCargoBindingService.insertRecordCargoBinding(recordCargoBinding);
}
});
return AjaxResult.success();
}
@GetMapping("/getVersion")
public String getVersion() {
APKVersion apkVersion = service.getVersion();
5 months ago
apkVersion.setCode(0);
apkVersion.setMsg("");
if (apkVersion == null) {
apkVersion = new APKVersion();
5 months ago
apkVersion.setUpdateStatus(0);
} else {
5 months ago
apkVersion.setUpdateStatus(1);
}
String s = JSONObject.toJSONString(apkVersion);
System.out.println("请求版本信息" + s);
5 months ago
return s;
}
5 months ago
}