|
|
|
|
|
package com.ruoyi.webapi.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
|
|
|
import com.ruoyi.manager.domain.*;
|
|
|
|
|
|
import com.ruoyi.manager.service.*;
|
|
|
|
|
|
import com.ruoyi.webapi.doman.APKVersion;
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
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;//货物实时绑定信息
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IRecordCargoBindingService recordCargoBindingService;
|
|
|
|
|
|
|
|
|
|
|
|
@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) {
|
|
|
|
|
|
int i = ledgerInstantBindingService.deleteLedgerInstantBindingByObjids(objids);
|
|
|
|
|
|
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("解绑成功");
|
|
|
|
|
|
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("库位没有维护");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 接货查询
|
|
|
|
|
|
@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);
|
|
|
|
|
|
if (list == null || list.isEmpty()) return AjaxResult.error("账号无绑定记录");
|
|
|
|
|
|
return AjaxResult.success(list);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IRecordDeliveryTaskService recordDeliveryTaskService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IRecordDeliveryTaskBaseketService recordDeliveryTaskBaseketService;
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/delivery/createTask")
|
|
|
|
|
|
public AjaxResult createDeliveryTask(String json,String user, List<MultipartFile> files) {
|
|
|
|
|
|
List<Long> ids = JSONArray.parseArray(json, Long.class);
|
|
|
|
|
|
// 生成任务编码
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IRecordDeliveryTaskImgService recordDeliveryTaskImgService;
|
|
|
|
|
|
//交货提交
|
|
|
|
|
|
@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("钢号或自编号已存在");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
baseBasketInfo.setUpdatedTime(new Date());
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
if (baseBasketInfo.getObjId() == null) {
|
|
|
|
|
|
i = baseBasketInfoService.insertBaseBasketInfo(baseBasketInfo);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通过资产编号查询资产
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/getBasketInfoBySearchCode")
|
|
|
|
|
|
public AjaxResult getBasketInfoBySearchCode(String searchCode) {
|
|
|
|
|
|
List<BaseBasketInfo> baseBasketInfo = baseBasketInfoService.selectBaseBasketInfoBySearchCode2(searchCode);
|
|
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 货物入筐-查询资产和资产使用情况
|
|
|
|
|
|
*
|
|
|
|
|
|
* @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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 货物绑定货框
|
|
|
|
|
|
@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);
|
|
|
|
|
|
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();
|
|
|
|
|
|
apkVersion.setCode(0);
|
|
|
|
|
|
apkVersion.setMsg("");
|
|
|
|
|
|
if (apkVersion == null) {
|
|
|
|
|
|
apkVersion = new APKVersion();
|
|
|
|
|
|
apkVersion.setUpdateStatus(0);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
apkVersion.setUpdateStatus(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
String s = JSONObject.toJSONString(apkVersion);
|
|
|
|
|
|
System.out.println("请求版本信息" + s);
|
|
|
|
|
|
return s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|