package com.zy.asrs.controller;
|
|
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.core.annotations.ManagerAuth;
|
import com.core.common.BaseRes;
|
import com.core.common.Cools;
|
import com.core.common.DateUtils;
|
import com.core.common.R;
|
import com.sun.org.apache.bcel.internal.generic.NEW;
|
import com.zy.asrs.entity.LocNormal;
|
import com.zy.asrs.entity.LocNormalReport;
|
import com.zy.asrs.entity.param.LocNormalParam;
|
import com.zy.asrs.service.LocNormalReportService;
|
import com.zy.asrs.service.LocNormalService;
|
import com.zy.common.utils.excel.locNomal.LocNormalExcel;
|
import com.zy.common.utils.excel.locNomal.LocNormalExcelListener;
|
import com.zy.common.utils.excel.matcode.MatCodeExcel;
|
import com.zy.common.utils.excel.matcode.MatCodeExcelListener;
|
import com.zy.common.web.BaseController;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.io.IOException;
|
import java.text.SimpleDateFormat;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
|
import static jdk.nashorn.api.scripting.ScriptUtils.convert;
|
|
@RestController
|
public class LocNormalController extends BaseController {
|
@Autowired
|
private LocNormalService locNormalService;
|
@Autowired
|
private LocNormalReportService locNormalReportService;
|
|
@RequestMapping(value = "/locNomal/list/auth")
|
@ManagerAuth
|
public R list(@RequestParam(defaultValue = "1") Integer curr,
|
@RequestParam(defaultValue = "10") Integer limit,
|
@RequestParam(required = false) String orderByField,
|
@RequestParam(required = false) String orderByType,
|
@RequestParam(required = false) String condition,
|
@RequestParam Map<String, Object> param) {
|
excludeTrash(param);
|
EntityWrapper<LocNormal> wrapper = new EntityWrapper<>();
|
convert(param, wrapper);
|
allLike(LocNormal.class, param.keySet(), wrapper, condition);
|
if (!Cools.isEmpty(orderByField)) {
|
wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
|
}
|
if (Cools.isEmpty(param.get("state"))) {
|
wrapper.in("state", "1,2");
|
}
|
return R.ok(locNormalService.selectPage(new Page<>(curr, limit), wrapper));
|
}
|
|
private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) {
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
String val = String.valueOf(entry.getValue());
|
if (val.contains(RANGE_TIME_LINK)) {
|
String[] dates = val.split(RANGE_TIME_LINK);
|
wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
|
wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
|
} else {
|
wrapper.like(entry.getKey(), String.valueOf(entry.getValue()));
|
}
|
}
|
}
|
|
@RequestMapping(value = "/locNomal/add/auth")
|
@ManagerAuth
|
public R add(LocNormal locNormalList) {
|
// 插入创建信息
|
locNormalList.setModiUser(getUserId());
|
locNormalList.setModiTime(new Date());
|
locNormalList.setAppeUser(getUserId());
|
locNormalList.setAppeTime(new Date());
|
// 默认新增为已入库
|
locNormalList.setState("1");
|
locNormalService.insert(locNormalList);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/matnr/check/column/auth")
|
@ManagerAuth
|
public R query(@RequestBody JSONObject param) {
|
Wrapper<LocNormal> wrapper = new EntityWrapper<LocNormal>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
|
if (null != locNormalService.selectOne(wrapper)) {
|
return R.parse(BaseRes.REPEAT).add(getComment(LocNormal.class, String.valueOf(param.get("key"))));
|
}
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/locNormal/update/auth")
|
@ManagerAuth
|
public void updateLocNormal(LocNormal param) {
|
Long modiUser = getUserId();
|
Date modiTime = new Date();
|
locNormalService.updateLocNormal(param.getMatnr(), param.getAnfme(), modiUser, modiTime, param.getId());
|
}
|
|
@RequestMapping(value = "/locNormal/outLoc/auth")
|
@ManagerAuth
|
public void outLocNormal(LocNormal param) {
|
Long modiUser = getUserId();
|
Date modiTime = new Date();
|
locNormalService.outLocNormal(param.getMatnr(), modiUser, modiTime, param.getId());
|
}
|
|
@RequestMapping(value = "/locNormal/removeLoc/auth")
|
@ManagerAuth
|
public void removeLoc(LocNormal param) {
|
Long modiUser = getUserId();
|
Date modiTime = new Date();
|
locNormalService.removeLocNormal(param.getMatnr(), modiUser, modiTime, param.getId());
|
}
|
|
/* 导入 */
|
@RequestMapping(value = "/locNormal/import/auth")
|
@ManagerAuth(memo = "平仓管理导入")
|
@Transactional
|
public R locNormalImport(MultipartFile file) throws IOException, InterruptedException {
|
LocNormalExcelListener listener = new LocNormalExcelListener(getUserId());
|
EasyExcel.read(file.getInputStream(), LocNormalExcel.class, listener).sheet().doRead();
|
return R.ok("成功导入" + listener.getTotal() + "条物料信息");
|
}
|
|
/* 平仓入库 成品 */
|
@RequestMapping(value = "/locNormal/in")
|
@ManagerAuth(memo = "平仓入库")
|
@Transactional
|
public R locNormalIn(@RequestBody LocNormalParam param) {
|
Long userId = getUserId();
|
Date timeNow = new Date();
|
for (Integer i = 0; i < param.getNormalList().size(); i++) {
|
param.getNormalList().get(i).setAppeUser(userId);
|
param.getNormalList().get(i).setAppeTime(timeNow);
|
}
|
locNormalService.locNormalIn(param.getNormalList());
|
return R.ok();
|
}
|
|
/* 平仓入库-原材料 */
|
@RequestMapping(value = "/locNormal/in/source")
|
@ManagerAuth(memo = "平仓入库-原材料")
|
@Transactional
|
public R locNormalInSource(@RequestBody LocNormalParam param) {
|
Long userId = getUserId();
|
Date timeNow = new Date();
|
for (Integer i = 0; i < param.getNormalList().size(); i++) {
|
param.getNormalList().get(i).setAppeUser(userId);
|
param.getNormalList().get(i).setAppeTime(timeNow);
|
}
|
locNormalService.locNormalInSource(param.getNormalList());
|
return R.ok();
|
}
|
|
/* pda入库 */
|
@RequestMapping(value = "/locNormal/pda/in")
|
@ManagerAuth(memo = "平仓管理pda入库")
|
@Transactional
|
public R locNormalPdaIn(@RequestBody LocNormalParam param) {
|
Long userId = getUserId();
|
Date timeNow = new Date();
|
for (Integer i = 0; i < param.getNormalList().size(); i++) {
|
param.getNormalList().get(i).setAppeUser(userId);
|
param.getNormalList().get(i).setAppeTime(timeNow);
|
}
|
locNormalService.pdaLocNormalIn(param.getNormalList());
|
return R.ok();
|
}
|
|
/* pda出库查询 */
|
@RequestMapping(value = "/locNormal/pda/out/query")
|
@ManagerAuth(memo = "pda出库查询")
|
@Transactional
|
public R locNormalPdaOutQuery(String matnr, String warehouse, String billNo) {
|
List<LocNormal> list = new ArrayList<>();
|
list = locNormalService.pdaLocNormalQuery(matnr, warehouse, billNo);
|
return R.ok(list);
|
}
|
|
@RequestMapping(value = "/locNormal/pda/out")
|
@ManagerAuth(memo = "pda出库")
|
@Transactional
|
public R locNormalPdaOut(@RequestBody LocNormalParam param) {
|
Long userId = getUserId();
|
Date timeNow = new Date();
|
List<LocNormal> list = param.getNormalList();
|
for (Integer i = 0; i < list.size(); i++) {
|
list.get(i).setModiUser(userId);
|
list.get(i).setModiTime(timeNow);
|
}
|
locNormalService.pdaLocNormalOut(list);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/locNormal/pda/warehouseQuery")
|
@ManagerAuth(memo = "pda根据库区查询物料清单")
|
@Transactional
|
public R locNormalPdaWarehouseQuery(String warehouse, String matnr) {
|
List<LocNormal> list = locNormalService.pdaLocNormalWarehouseQuery(warehouse, matnr);
|
return R.ok(list);
|
}
|
|
@RequestMapping(value = "/locNormal/pda/move")
|
@ManagerAuth(memo = "pda移库")
|
@Transactional
|
public R LocNormalPdaMove(@RequestBody LocNormalParam param) {
|
Long userId = getUserId();
|
Date timeNow = new Date();
|
List<LocNormal> list = param.getNormalList();
|
for (Integer i = 0; i < list.size(); i++) {
|
list.get(i).setModiUser(userId);
|
list.get(i).setModiTime(timeNow);
|
}
|
locNormalService.pdaLocNormalMove(list);
|
return R.ok();
|
}
|
|
@RequestMapping(value = "/locNomal/getInListByDay")
|
@ManagerAuth(memo = "平仓日出入库查询")
|
public R getInListByDay(@RequestParam(defaultValue = "1") Integer curr,
|
@RequestParam(defaultValue = "10") Integer limit,
|
@RequestParam(required = false) String orderByField,
|
@RequestParam(required = false) String orderByType,
|
@RequestParam(required = false) String condition,
|
@RequestParam Map<String, Object> param) {
|
excludeTrash(param);
|
EntityWrapper<LocNormalReport> wrapper = new EntityWrapper<>();
|
List<String> orderList = new ArrayList<>();
|
orderList.add("time");
|
wrapper.eq("state", param.get("state").toString()).orderDesc(orderList);
|
String timeRange = "";
|
String time1 = "";
|
String time2 = "";
|
if (!Cools.isEmpty(param.get("query_date"))) {
|
timeRange = param.get("query_date").toString();
|
time1 = timeRange.substring(0, 19);
|
time2 = timeRange.substring(21, timeRange.length());
|
}
|
param.remove("query_date");
|
convert(param, wrapper);
|
if (time1 != "" && time2 != "") {
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
Date dateTime1 = new Date();
|
Date dateTime2 = new Date();
|
try {
|
dateTime1 = formatter.parse(time1);
|
dateTime2 = formatter.parse(time2);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
wrapper.ge("time", dateTime1).and().le("time", dateTime2);
|
}
|
allLike(LocNormalReport.class, param.keySet(), wrapper, condition);
|
return R.ok(locNormalReportService.selectPage(new Page<>(curr, limit), wrapper));
|
}
|
}
|