From b7b3328fdfa45cf13d1943fa79d47f1b6bb43f01 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期三, 28 五月 2025 18:22:17 +0800 Subject: [PATCH] 添加定时任务用户 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java | 40 ++- rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java | 17 - rsf-server/src/main/java/com/vincent/rsf/server/api/service/MobileService.java | 1 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java | 2 rsf-server/src/main/java/com/vincent/rsf/server/api/utils/LocUtils.java | 260 +++++++++++++++++++++++++ rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java | 10 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 108 +++++++--- rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java | 14 + rsf-server/src/main/java/com/vincent/rsf/server/system/utils/SystemAuthUtils.java | 75 +++++++ rsf-server/src/main/java/com/vincent/rsf/server/common/config/ConfigProperties.java | 5 rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemController.java | 6 rsf-server/src/main/resources/application.yml | 3 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/LocItemService.java | 6 13 files changed, 464 insertions(+), 83 deletions(-) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/MobileService.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/MobileService.java index 5d45a84..a1169d0 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/MobileService.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/MobileService.java @@ -40,7 +40,6 @@ WaitPakin mergeItems(WaitPakinParam waitPakin, Long userId); - WaitPakin unBind(WaitPakinParam param); R inspect(String code, Long loginUserId); diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java index 85bf298..5c04328 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java @@ -331,7 +331,7 @@ // return locNo; // } @Override - public InTaskMsgDto getLocNo(TaskInParam param) throws Exception{ + public InTaskMsgDto getLocNo(TaskInParam param) throws Exception { String matnr = null; String batch = null; List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, param.getBarcode())); @@ -414,10 +414,10 @@ List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getMatnrCode, matnr)); for (LocItem locItem : locItems) { Loc loc1 = locService.getById(locItem.getLocId()); - if (LocUtils.isShallowLoc(slaveProperties, loc1.getCode())) { + if (LocUtils.isShallowLoc(loc1.getCode())) { continue; } - String shallowLocNo = LocUtils.getShallowLoc(slaveProperties, loc1.getCode()); + String shallowLocNo = LocUtils.getShallowLoc(loc1.getCode()); // 妫�娴嬬洰鏍囧簱浣嶆槸鍚︿负绌哄簱浣� Loc shallowLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLocNo)); if (shallowLoc != null && shallowLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { @@ -488,7 +488,7 @@ if (!LocUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { continue; } - String shallowLoc = LocUtils.getDeepLoc(slaveProperties, locMast1.getCode()); + String shallowLoc = LocUtils.getDeepLoc(locMast1.getCode()); if ((ioType == 1 && deviceBind.getBeSimilar().equals("1"))) { //鐩镐技鐗╂枡鎵撳紑锛屽垽鏂繁搴撲綅鏈夋病鏈夎揣锛屾病璐у氨鏀炬繁搴撲綅锛屾湁璐у氨涓嶆搷浣� Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>() @@ -529,7 +529,7 @@ continue; } if (deviceBind.getBeSimilar().equals("1")) { - String shallowLoc = LocUtils.getDeepLoc(slaveProperties, locMast1.getCode()); + String shallowLoc = LocUtils.getDeepLoc(locMast1.getCode()); Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>() .eq(Loc::getCode, shallowLoc) .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/utils/LocUtils.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/utils/LocUtils.java index b9668dc..811fbed 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/api/utils/LocUtils.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/utils/LocUtils.java @@ -10,6 +10,7 @@ import com.vincent.rsf.server.api.entity.dto.LocTypeDto; import com.vincent.rsf.server.manager.entity.*; import com.vincent.rsf.server.manager.enums.LocStsType; +import com.vincent.rsf.server.manager.enums.TaskStsType; import com.vincent.rsf.server.manager.enums.TaskType; import com.vincent.rsf.server.manager.service.*; import org.slf4j.Logger; @@ -45,11 +46,11 @@ /** * 鑾峰彇 娴呭簱浣嶅搴旂殑娣卞簱浣嶅彿 */ - public static String getDeepLoc(SlaveProperties slaveProperties, String shallowLoc) { + public static String getDeepLoc(String shallowLoc) { LocService locService = SpringUtils.getBean(LocService.class); Loc shaLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc)); int row = shaLoc.getRow()-1; - boolean contains = slaveProperties.getDoubleLocs().contains(row); + boolean contains = doubleLocs.contains(row); Loc deepLoc = null; if (contains) { deepLoc = locService.getOne(new LambdaQueryWrapper<Loc>() @@ -72,7 +73,7 @@ /** * 鑾峰彇 娣卞簱浣嶅搴旂殑娴呭簱浣嶅彿 */ - public static String getShallowLoc(SlaveProperties slaveProperties, String deepLoc) { + public static String getShallowLoc(String deepLoc) { LocService locService = SpringUtils.getBean(LocService.class); Loc depLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, deepLoc)); int row; @@ -81,7 +82,7 @@ } else { row = depLoc.getRow(); } - boolean contains = slaveProperties.getDoubleLocs().contains(row); + boolean contains = doubleLocs.contains(row); Loc shallowLoc = null; if (!contains) { shallowLoc = locService.getOne(new LambdaQueryWrapper<Loc>() @@ -104,10 +105,10 @@ /** * 鍒ゆ柇鏄惁涓烘祬搴撲綅 */ - public static boolean isShallowLoc(SlaveProperties slaveProperties, String locNo) { - if (slaveProperties.isDoubleDeep()) { + public static boolean isShallowLoc(String locNo) { + if (isDoubleDeep) { int row = getRow(locNo); - return !slaveProperties.getDoubleLocs().contains(row); + return !doubleLocs.contains(row); } else { return false; } @@ -213,8 +214,8 @@ } public static String getCrnLoc() { - SlaveProperties bean = SpringUtils.getBean(SlaveProperties.class); - System.out.println(bean.getDoubleLocs()); +// SlaveProperties bean = SpringUtils.getBean(SlaveProperties.class); + System.out.println(doubleLocs); return null; } @@ -233,4 +234,245 @@ return msgBuilder.toString(); } } + + /** + * 鑾峰彇鍫嗗灈鏈哄簱浣嶄俊鎭� + * @param deviceBind + * @param area + * @param sourceStaNo + * @param matnr + * @param batch + * @param locTypeDto + * @param times + * @param ioType 浣滀笟绫诲瀷锛�*蹇呬紶鍙傛暟锛� + * @return + */ + public static InTaskMsgDto getLocNoCrn(DeviceBind deviceBind, Long area, Integer sourceStaNo, String matnr, String batch, LocTypeDto locTypeDto, int times, Integer ioType) { + DeviceBindService deviceBindService = SpringUtils.getBean(DeviceBindService.class); + DeviceSiteService deviceSiteService = SpringUtils.getBean(DeviceSiteService.class); + LocService locService = SpringUtils.getBean(LocService.class); + LocItemService locItemService = SpringUtils.getBean(LocItemService.class); + + if (Cools.isEmpty(matnr)) { //鐗╂枡鍙� + matnr = ""; + } + if (Cools.isEmpty(batch)) { //鎵规 + batch = ""; + } + // 鍒濆鍖栧弬鏁� + int channel = 0; //鍫嗗灈鏈哄彿 + int nearRow = 0; //鏈�娴呭簱浣嶆帓 + int curRow = 0; //鏈�娣卞簱浣嶆帓 + int rowCount = 0; //杞杞 + Loc loc = null; // 鐩爣搴撲綅 + + InTaskMsgDto inTaskMsgDto = new InTaskMsgDto(); + + int sRow = deviceBind.getStartRow(); + int eRow = deviceBind.getEndRow(); + int deviceQty = deviceBind.getDeviceQty(); + + + // ===============>>>> 寮�濮嬫墽琛� + curRow = deviceBind.getCurrentRow(); + + //姝ょ▼搴忕敤浜庝紭鍖栧爢鍨涙満寮傚父鏃剁殑杩愯鏃堕棿 + for (int i = times; i <= deviceQty * 2; i++) { + int[] locNecessaryParameters = LocUtils.LocNecessaryParameters(deviceBind, curRow, deviceQty); + curRow = locNecessaryParameters[1]; + channel = locNecessaryParameters[2]; + rowCount = locNecessaryParameters[0]; + nearRow = locNecessaryParameters[3]; + break; + } + if (nearRow == 0) { + throw new CoolException("鏃犲彲鐢ㄥ爢鍨涙満"); + } + //鍏ュ簱闈犺繎鎽嗘斁 + if (ioType == 1 && deviceBind.getBeSimilar().equals("1") && !Cools.isEmpty(matnr)) { + if (nearRow != curRow) { + List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getMatnrCode, matnr)); + for (LocItem locItem : locItems) { + Loc loc1 = locService.getById(locItem.getLocId()); + if (LocUtils.isShallowLoc(loc1.getCode())) { + continue; + } + String shallowLocNo = LocUtils.getShallowLoc(loc1.getCode()); + // 妫�娴嬬洰鏍囧簱浣嶆槸鍚︿负绌哄簱浣� + Loc shallowLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLocNo)); + if (shallowLoc != null && shallowLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { + if (LocUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) { + loc = shallowLoc; + channel = shallowLoc.getChannel(); + break; + } + } + } + } + } + +// // 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭 //浜掗�氱増 +// if (ioType == 10 && deviceBind.getEmptySimilar().equals("1")) { +// List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() +// .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type", rowLastnoType.getType().longValue())); +// if (!locMasts.isEmpty()) { +// for (LocMast loc : locMasts) { +// if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) { +// continue; +// } +// String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo()); +// // 妫�娴嬬洰鏍囧簱浣嶆槸鍚︿负绌哄簱浣� +// LocMast shallowLoc = locMastService.selectById(shallowLocNo); +// if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { +// if (VersionUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) { +// if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) { +// locMast = shallowLoc; +// crnNo = locMast.getCrnNo(); +// break; +// } +// } +// } +// } +// } +// } + //鏌ユ壘璺緞 + DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() + .eq(DeviceSite::getType, ioType) + .eq(DeviceSite::getSite, sourceStaNo) + .eq(DeviceSite::getChannel, channel) + ); + if (Cools.isEmpty(deviceSite)) { + channel = 0; + } else { + inTaskMsgDto.setStaNo(Integer.parseInt(deviceSite.getDeviceSite())); + } + + //鏇存柊褰撳墠鎺� + deviceBind.setCurrentRow(curRow); + deviceBindService.updateById(deviceBind); + + // 寮�濮嬫煡鎵惧簱浣� ==============================>> + + // 1.鎸夎鍒欐煡鎵惧簱浣� + if (Cools.isEmpty(loc) && channel != 0) { + List<Loc> locMasts = null; + locMasts = locService.list(new LambdaQueryWrapper<Loc>() + .eq(Loc::getRow, nearRow) + .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) + .eq(Loc::getType, locTypeDto.getLocType1()) + .eq(Loc::getAreaId, area) + .orderByAsc(Loc::getLev) + .orderByAsc(Loc::getCol) + ); + for (Loc locMast1 : locMasts) { + if (!LocUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { + continue; + } + String shallowLoc = LocUtils.getDeepLoc(locMast1.getCode()); + if ((ioType == TaskStsType.GENERATE_IN.id && deviceBind.getBeSimilar().equals("1"))) { + //鐩镐技鐗╂枡鎵撳紑锛屽垽鏂繁搴撲綅鏈夋病鏈夎揣锛屾病璐у氨鏀炬繁搴撲綅锛屾湁璐у氨涓嶆搷浣� + Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getCode, shallowLoc) + .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) + .eq(Loc::getAreaId, area) + ); + if (!Cools.isEmpty(locMast2)) { + loc = locMast2; + break; + } + } else { + //鐩镐技鐗╂枡鍏抽棴锛屽垽鏂繁搴撲綅鏈夋病鏈夎揣锛屾湁璐у氨鏀炬祬搴撲綅锛屾棤璐у氨涓嶆搷浣� + Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getCode, shallowLoc) + .in(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type, LocStsType.LOC_STS_TYPE_F.type) + .eq(Loc::getAreaId, area) + ); + if (!Cools.isEmpty(locMast2)) { + loc = locMast1; + break; + } else { + locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getCode, shallowLoc) + .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) + .eq(Loc::getAreaId, area) + ); + if (!Cools.isEmpty(locMast2)) { + loc = locMast2; + break; + } + } + } + } + if (Cools.isEmpty(loc) && deviceBind.getBeSimilar().equals("1")) { + for (Loc locMast1 : locMasts) { + if (!LocUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { + continue; + } + if (deviceBind.getBeSimilar().equals("1")) { + String shallowLoc = LocUtils.getDeepLoc(locMast1.getCode()); + Loc locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getCode, shallowLoc) + .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) + .eq(Loc::getAreaId, area) + ); + if (!Cools.isEmpty(locMast2)) { + loc = locMast2; + break; + } else { + locMast2 = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getCode, shallowLoc) + .in(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type, LocStsType.LOC_STS_TYPE_D.type) + .eq(Loc::getAreaId, area) + ); + if (!Cools.isEmpty(locMast2)) { + loc = locMast1; + break; + } + } + } else { + if (!Cools.isEmpty(locMast1)) { + loc = locMast1; + break; + } + } + } + } + } + //鏌ヨ褰撳墠搴撲綅绫诲瀷绌哄簱浣� 灏忎簬5涓垯locmast = null + List<Loc> locTypeLocMasts = locService.list(new LambdaQueryWrapper<Loc>() + .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) + .eq(Loc::getChannel, channel) + .eq(Loc::getType, locTypeDto.getLocType1()) + .eq(Loc::getAreaId, area) + ); + if (null != locTypeLocMasts && locTypeLocMasts.size() <= 5) { + loc = null; + } + // 閫掑綊鏌ヨ + if (Cools.isEmpty(loc) || !loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { + // 褰撳墠宸烽亾鏃犵┖搴撲綅鏃讹紝閫掑綊璋冩暣鑷充笅涓�宸烽亾锛屾绱㈠叏閮ㄥ贩閬撴棤鏋滃悗锛岃烦鍑洪�掑綊 + if (times < rowCount * 2) { + times = times + 1; + return getLocNoCrn(deviceBind, area, sourceStaNo, matnr, batch, locTypeDto, times, ioType); + + } + // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣� + if (locTypeDto.getLocType1() < 3) { + int i = locTypeDto.getLocType1() + 1; + locTypeDto.setLocType1(i); + return getLocNoCrn(deviceBind, area, sourceStaNo, matnr, batch, locTypeDto, 0, ioType); + } + throw new CoolException("娌℃湁绌哄簱浣�"); + } + String locNo = loc.getCode(); + + // 杩斿洖dto + inTaskMsgDto.setDeviceNo(channel); + inTaskMsgDto.setSourceStaNo(sourceStaNo); +// inTaskMsgDto.setStaNo(); + inTaskMsgDto.setLocNo(locNo); + return inTaskMsgDto; + } + + } diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/config/ConfigProperties.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/config/ConfigProperties.java index d0443c4..6c1f406 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/common/config/ConfigProperties.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/config/ConfigProperties.java @@ -70,6 +70,11 @@ */ private String securityCode; + private String userName; + + private String password; + + public List<String> getSuperUserList() { return Arrays.stream(superUsername.split(",")).collect(Collectors.toList()); } diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemController.java index f0a1b5f..612bce4 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemController.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocItemController.java @@ -97,7 +97,7 @@ } param.setType(Constants.TASK_TYPE_OUT_STOCK); - return locItemService.generateTask(param); + return locItemService.generateTask(param, getLoginUserId()); } /** @@ -112,7 +112,7 @@ if (Objects.isNull(map)) { return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒"); } - return R.ok("浠诲姟鐢熸垚鎴愬姛").add(locItemService.genMoveTask(map)); + return R.ok("浠诲姟鐢熸垚鎴愬姛").add(locItemService.genMoveTask(map, getLoginUserId())); } /** @@ -129,7 +129,7 @@ } map.setType(Constants.TASK_TYPE_OUT_CHECK); - return R.ok("浠诲姟鐢熸垚鎴愬姛").add(locItemService.generateTask(map)); + return R.ok("浠诲姟鐢熸垚鎴愬姛").add(locItemService.generateTask(map, getLoginUserId())); } diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java index 7038d6b..f3fc609 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java @@ -9,6 +9,7 @@ import com.vincent.rsf.server.system.entity.DictData; import com.vincent.rsf.server.system.service.DictDataService; import lombok.experimental.Accessors; +import org.apache.commons.lang3.StringUtils; import org.springframework.format.annotation.DateTimeFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -31,6 +32,7 @@ import com.vincent.rsf.server.system.entity.User; import java.io.Serializable; import java.util.Date; +import java.util.stream.Collectors; @Data @Accessors(chain = true) @@ -259,6 +261,18 @@ return dictDatas.getValue() + "." + dictDatas.getLabel(); } + public String getWarehType$(){ + if (null == this.warehType){ return null; } + DictDataService dictDataService = SpringUtils.getBean(DictDataService.class); + DictData dictDatas = dictDataService.getOne(new LambdaQueryWrapper<DictData>() + .eq(DictData::getDictTypeCode, DictTypeCode.DICT_SYS_DEVICE_TYPE) + .eq(DictData::getValue, warehType)); + if (Objects.isNull(dictDatas)) { + return null; + } + return dictDatas.getLabel(); + } + public String getTaskType$() { if (Cools.isEmpty(this.taskType)) { return null; diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java index 4349860..18711a1 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java @@ -8,6 +8,9 @@ import com.vincent.rsf.server.system.constant.GlobalConfigCode; import com.vincent.rsf.server.system.entity.Config; import com.vincent.rsf.server.system.service.ConfigService; +import com.vincent.rsf.server.system.utils.SystemAuthUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -27,6 +30,8 @@ @Component public class TaskSchedules { + public static Logger logger = LoggerFactory.getLogger(TaskSchedules.class); + @Autowired private TaskService taskService; @Autowired @@ -35,18 +40,6 @@ private TaskLogService taskLogService; @Autowired private TaskItemLogService taskItemLogService; - @Autowired - private StockItemService stockItemService; - @Autowired - private PurchaseService purchaseService; - @Autowired - private AsnOrderService asnOrderService; - @Autowired - private AsnOrderItemService asnOrderItemService; - @Autowired - private StockService stockService; - @Autowired - private LocService locService; @Autowired private ConfigService configService; diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/LocItemService.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/LocItemService.java index ff4c683..2e24cfe 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/LocItemService.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/LocItemService.java @@ -6,12 +6,10 @@ import com.vincent.rsf.server.manager.entity.LocItem; import com.vincent.rsf.server.manager.entity.Task; -import java.util.Map; - public interface LocItemService extends IService<LocItem> { - R generateTask(LocToTaskParams map); + R generateTask(LocToTaskParams map, Long loginUserId); - Task genMoveTask(LocToTaskParams map); + Task genMoveTask(LocToTaskParams map, Long loginUserId); } diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java index cac3725..6101454 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java @@ -1,7 +1,5 @@ package com.vincent.rsf.server.manager.service.impl; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.vincent.rsf.framework.common.R; import com.vincent.rsf.framework.exception.CoolException; @@ -14,7 +12,6 @@ import com.vincent.rsf.server.manager.controller.params.LocToTaskParams; import com.vincent.rsf.server.manager.entity.*; import com.vincent.rsf.server.manager.enums.*; -import com.vincent.rsf.server.manager.enums.LocType; import com.vincent.rsf.server.manager.mapper.LocItemMapper; import com.vincent.rsf.server.manager.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -27,7 +24,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.lang.reflect.Array; import java.util.*; import java.util.stream.Collectors; @@ -55,12 +51,13 @@ * type: check 鐩樼偣, stock: 搴撳瓨鍑哄簱 * * @param map + * @param loginUserId * @return */ @Override @Synchronized @Transactional(rollbackFor = Exception.class) - public R generateTask(LocToTaskParams map) { + public R generateTask(LocToTaskParams map, Long loginUserId) { if (Objects.isNull(map.getSiteNo())) { throw new CoolException("绔欑偣涓嶈兘涓虹┖锛�"); } @@ -84,9 +81,9 @@ } Task moveTask = new Task(); - if (!LocUtils.isShallowLoc(slaveProperties, loc.getCode())) { + if (!LocUtils.isShallowLoc(loc.getCode())) { //鑾峰彇娣卞簱浣嶅搴旀祬搴撲綅 - String shallowLoc = LocUtils.getShallowLoc(slaveProperties, loc.getCode()); + String shallowLoc = LocUtils.getShallowLoc(loc.getCode()); Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc)); if (Objects.isNull(one)) { throw new CoolException("瀵瑰簲搴撲綅涓嶅瓨鍦紒锛�"); @@ -94,7 +91,7 @@ map.setOrgLoc(one.getCode()); //浼樺厛鐢熸垚绉诲簱浠诲姟 if (!one.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { - moveTask = genMoveTask(map); + moveTask = genMoveTask(map, loginUserId); } } @@ -103,6 +100,10 @@ .setTaskCode(ruleCode) .setParentId(moveTask.getId()) .setTargSite(siteNo) + .setUpdateBy(loginUserId) + .setCreateBy(loginUserId) + .setCreateTime(new Date()) + .setUpdateTime(new Date()) .setTaskStatus(TaskStsType.GENERATE_OUT.id) .setBarcode(loc.getBarcode()); @@ -125,7 +126,6 @@ Double useQty = Math.round((outQty + workQty) * 10000) / 10000.0; if (orgQty.compareTo(useQty) > 0) { //鎷f枡鍑哄簱 - task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type); DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() .eq(DeviceSite::getSite, siteNo) @@ -134,19 +134,21 @@ if (Objects.isNull(deviceSite)) { throw new CoolException("绔欑偣涓嶆敮鎸佹嫞鏂欏嚭搴擄紒锛�"); } + task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type).setWarehType(deviceSite.getDevice()); + } else { //鍏ㄦ澘鍑哄簱 - task.setTaskType(TaskType.TASK_TYPE_OUT.type); DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() .eq(DeviceSite::getChannel, loc.getChannel()) .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_OUT.type)); if (Objects.isNull(deviceSite)) { throw new CoolException("绔欑偣涓嶆敮鎸佸叏鏉垮嚭搴擄紒锛�"); } + task.setTaskType(TaskType.TASK_TYPE_OUT.type).setWarehType(deviceSite.getDevice()); + } } else if (map.getType().equals(Constants.TASK_TYPE_OUT_CHECK)) { //鐩樼偣鍑哄簱 - task.setTaskType(TaskType.TASK_TYPE_CHECK_OUT.type); DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() .eq(DeviceSite::getChannel, loc.getChannel()) .eq(DeviceSite::getSite, siteNo) @@ -154,6 +156,9 @@ if (Objects.isNull(deviceSite)) { throw new CoolException("褰撳墠绔欑偣涓嶆敮鎸佺洏鐐瑰嚭搴擄紒锛�"); } + + task.setTaskType(TaskType.TASK_TYPE_CHECK_OUT.type).setWarehType(deviceSite.getDevice()); + } if (!taskService.save(task)) { @@ -166,6 +171,10 @@ taskItem.setTaskId(task.getId()) .setAnfme(item.getOutQty()) .setBatch(item.getBatch()) + .setUpdateBy(loginUserId) + .setCreateBy(loginUserId) + .setCreateTime(new Date()) + .setUpdateTime(new Date()) .setOrderType(OrderType.ORDER_OUT.type) .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)); taskItems.add(taskItem); @@ -186,6 +195,8 @@ } else { item.setWorkQty(qty); } + item.setUpdateBy(loginUserId).setUpdateTime(new Date()); + if (!locItemService.updateById(item)) { throw new CoolException("搴撳瓨淇℃伅淇敼澶辫触锛侊紒"); } @@ -203,11 +214,12 @@ * 鐢熸垚绉诲簱浠诲姟 * * @param map + * @param loginUserId * @return */ @Override @Transactional(rollbackFor = Exception.class) - public Task genMoveTask(LocToTaskParams map) { + public Task genMoveTask(LocToTaskParams map, Long loginUserId) { if (Objects.isNull(map.getOrgLoc()) || StringUtils.isBlank(map.getOrgLoc())) { throw new CoolException("婧愬簱浣嶄笉鑳戒负绌猴紒"); } @@ -270,6 +282,8 @@ .setTaskCode(ruleCode) .setTaskType(TaskType.TASK_TYPE_LOC_MOVE.type) .setTargLoc(targetLoc.getCode()) + .setUpdateBy(loginUserId) + .setUpdateTime(new Date()) .setTaskStatus(TaskStsType.GENERATE_IN.id) .setBarcode(orgLoc.getBarcode()); @@ -286,6 +300,8 @@ taskItem.setTaskId(task.getId()) .setAnfme(item.getAnfme()) .setBatch(item.getBatch()) + .setUpdateBy(loginUserId) + .setUpdateTime(new Date()) .setOrderType(OrderType.ORDER_IN.type) .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER_IN.type)); taskItems.add(taskItem); diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java index c670bbc..71cce1a 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java @@ -13,7 +13,6 @@ import com.vincent.rsf.server.api.utils.LocUtils; import com.vincent.rsf.server.manager.controller.params.GenerateTaskParams; import com.vincent.rsf.server.manager.entity.*; -import com.vincent.rsf.server.manager.enums.LocType; import com.vincent.rsf.server.manager.mapper.TaskMapper; import com.vincent.rsf.server.manager.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -21,8 +20,11 @@ import com.vincent.rsf.server.system.constant.SerialRuleCode; import com.vincent.rsf.server.manager.enums.LocStsType; import com.vincent.rsf.server.system.utils.SerialRuleUtils; +import com.vincent.rsf.server.system.utils.SystemAuthUtils; import lombok.Synchronized; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -33,6 +35,8 @@ @Service("taskService") public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService { + + public static final Logger logger = LoggerFactory.getLogger(TaskServiceImpl.class); @Autowired private WaitPakinService waitPakinService; @@ -385,23 +389,24 @@ @Override @Transactional(rollbackFor = Exception.class) public void complateInTask(List<Task> tasks) throws Exception { + Long loginUserId = SystemAuthUtils.getLoginUserId(); for (Task task : tasks) { if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { //1.鍏ュ簱 - complateInstock(task); + complateInstock(task, loginUserId); } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { //53.鎷f枡鍐嶅叆搴� //57.鐩樼偣鍐嶅叆搴� - pickComplateInStock(task); + pickComplateInStock(task, loginUserId); } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { //绉诲簱 - moveInStock(task); + moveInStock(task, loginUserId); } } } @Transactional(rollbackFor = Exception.class) - public void moveInStock(Task task) { + public void moveInStock(Task task, Long loginUserId) { if (Objects.isNull(task)) { return; } @@ -430,7 +435,7 @@ //绉诲簱鏈夊彲鑳芥槸绌烘澘 try { //鏇存柊搴撲綅鏄庣粏 - saveLocItem(taskItems, task.getId()); + saveLocItem(taskItems, task.getId(), loginUserId); } catch (Exception e) { throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒"); } @@ -444,19 +449,26 @@ /**淇敼搴撲綅鐘舵�佷负F.鍦ㄥ簱*/ if (!locService.update(new LambdaUpdateWrapper<Loc>() .set(Loc::getBarcode, task.getBarcode()) - .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type) - .eq(Loc::getCode, task.getTargLoc()))) { + .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type) + .set(Loc::getUpdateBy, loginUserId) + .set(Loc::getUpdateTime, new Date()) + .eq(Loc::getCode, task.getTargLoc()))) { throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�"); } if (!locService.update(new LambdaUpdateWrapper<Loc>() .set(Loc::getBarcode, null) - .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type).eq(Loc::getCode, task.getOrgLoc()))) { + .set(Loc::getUpdateBy, loginUserId) + .set(Loc::getUpdateTime, new Date()) + .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) + .eq(Loc::getCode, task.getOrgLoc()))) { throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�"); } - - if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) { + if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()) + .set(Task::getUpdateBy, loginUserId) + .set(Task::getUpdateTime, new Date()) + .set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) { throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�"); } @@ -473,17 +485,18 @@ @Override @Transactional(rollbackFor = Exception.class) public void completeTask(List<Task> tasks) throws Exception { + Long loginUserId = SystemAuthUtils.getLoginUserId(); for (Task task : tasks) { //鍑哄簱浠诲姟 if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) { //鍏ㄦ墭鍑哄簱 - complateOutStock(task); + complateOutStock(task, loginUserId); } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) { //鎷f枡鍑哄簱 - complateOutStock(task); + complateOutStock(task, loginUserId); } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) { //鐩樼偣鍑哄簱 - complateOutStock(task); + complateOutStock(task, loginUserId); } } } @@ -492,9 +505,10 @@ * 鎷f枡鍐嶅叆搴� * * @param task + * @param loginUserId */ @Transactional(rollbackFor = Exception.class) - public void pickComplateInStock(Task task) throws Exception { + public void pickComplateInStock(Task task, Long loginUserId) throws Exception { if (Objects.isNull(task)) { return; } @@ -506,7 +520,9 @@ throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害锛屼笉鍙墽琛屽叆搴撴搷浣滐紒"); } - loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type).setBarcode(task.getBarcode()); + loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type) + .setBarcode(task.getBarcode()) + .setUpdateBy(loginUserId).setUpdateTime(new Date()); if (!locService.updateById(loc)) { throw new CoolException("搴撲綅淇℃伅鏇存柊澶辫触锛侊紒"); @@ -531,7 +547,7 @@ locWorking.setAnfme(taskItem.getAnfme()); } BeanUtils.copyProperties(locWorking, locItem); - locItem.setWorkQty(0.0).setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null); + locItem.setWorkQty(0.0).setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null).setUpdateBy(loginUserId).setUpdateTime(new Date()); items.add(locItem); } @@ -541,13 +557,13 @@ TaskItem taskItem = taskItems.stream().findFirst().get(); //淇濆瓨鍏ュ嚭搴撴祦姘� - saveStockItems(taskItems, task, null, null, taskItem.getWkType(), taskItem.getOrderType()); + saveStockItems(taskItems, task, null, null, taskItem.getWkType(), taskItem.getOrderType(), loginUserId); if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) { throw new CoolException("浣滀笟涓簱瀛樺垹闄ゅけ璐ワ紒锛�"); } - task.setTaskStatus(TaskStsType.UPDATED_IN.id).setUpdateTime(null); + task.setTaskStatus(TaskStsType.UPDATED_IN.id).setUpdateTime(new Date()).setUpdateBy(loginUserId); if (!taskService.updateById(task)) { throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�"); } @@ -577,7 +593,7 @@ .eq(WaitPakin::getBarcode, task.getBarcode()) ); if (null != waitPakin) { - waitPakin.setIoStatus(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)); + waitPakin.setIoStatus(PakinIOStatus.PAKIN_IO_STATUS_DONE.val); if (!waitPakinService.updateById(waitPakin)) { throw new CoolException("鏇存柊缁勬墭鐘舵�佸け璐ワ紒锛�"); } @@ -736,11 +752,10 @@ */ @Synchronized @Transactional(rollbackFor = Exception.class) - public void complateOutStock(Task task) throws Exception { + public void complateOutStock(Task task, Long loginUserId) throws Exception { if (Objects.isNull(task)) { throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒"); } - Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc())); if (Objects.isNull(loc)) { throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�"); @@ -763,7 +778,11 @@ for (LocItem item : locItems) { LocItemWorking working = new LocItemWorking(); BeanUtils.copyProperties(item, working); - working.setId(null).setTaskId(task.getId()).setLocItemId(item.getId()); + working.setId(null) + .setTaskId(task.getId()) + .setLocItemId(item.getId()) + .setUpdateBy(loginUserId) + .setUpdateTime(new Date()); workings.add(working); } @@ -775,7 +794,7 @@ //鏇存柊搴撲綅鏄庣粏 subtractLocItem(loc); } catch (Exception e) { - log.error("<UNK>", e); + logger.error("<UNK>", e); throw new CoolException(e.getMessage()); } @@ -794,14 +813,14 @@ throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�"); } try { - saveOutStockItem(maps.get(key), waveItem); + saveOutStockItem(maps.get(key), waveItem, loginUserId); } catch (Exception e) { throw new CoolException(e.getMessage()); } }); } else { try { - saveOutStockItem(taskItems, null); + saveOutStockItem(taskItems, null, loginUserId); } catch (Exception e) { throw new CoolException(e.getMessage()); } @@ -811,6 +830,8 @@ if (!locService.update(new LambdaUpdateWrapper<Loc>() .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) .set(Loc::getBarcode, null) + .set(Loc::getUpdateBy, loginUserId) + .set(Loc::getUpdateTime, new Date()) .eq(Loc::getId, loc.getId()))) { throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�"); } @@ -818,21 +839,23 @@ if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) { if (!this.update(new LambdaUpdateWrapper<Task>() .eq(Task::getId, task.getId()) + .set(Task::getUpdateBy, loginUserId) + .set(Task::getUpdateTime, new Date()) .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) { throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�"); } } else { if (!this.update(new LambdaUpdateWrapper<Task>() .eq(Task::getId, task.getId()) + .set(Task::getUpdateBy, loginUserId) + .set(Task::getUpdateTime, new Date()) .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) { throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�"); } - //鍏ㄦ澘鍑哄簱锛屽垹闄や复鏃跺簱瀛� if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) { throw new CoolException("涓存椂搴撳瓨娓呴櫎澶辫触锛侊紒"); } - } } @@ -844,7 +867,7 @@ * @version 1.0 */ @Transactional(rollbackFor = Exception.class) - public void saveOutStockItem(List<TaskItem> taskItems, WaveItem waveItem) throws Exception { + public void saveOutStockItem(List<TaskItem> taskItems, WaveItem waveItem, Long loginUserId) throws Exception { Stock stock = new Stock(); String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null); if (StringUtils.isBlank(ruleCode)) { @@ -852,6 +875,8 @@ } Double sum = taskItems.stream().mapToDouble(TaskItem::getAnfme).sum(); stock.setCode(ruleCode) + .setUpdateBy(loginUserId) + .setUpdateTime(new Date()) .setAnfme(sum); if (Objects.isNull(waveItem)) { stock.setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)) @@ -870,6 +895,8 @@ StockItem stockItem = new StockItem(); BeanUtils.copyProperties(item, stockItem); stockItem.setSourceItemId(item.getOrderItemId()) + .setUpdateBy(loginUserId) + .setUpdateTime(new Date()) .setStockCode(stock.getCode()) .setId(null) .setStockId(stock.getId()); @@ -901,7 +928,7 @@ * @version 1.0 */ @Transactional(rollbackFor = Exception.class) - public void complateInstock(Task task) { + public void complateInstock(Task task, Long loginUserId) { if (Objects.isNull(task)) { return; } @@ -921,7 +948,7 @@ } try { //鏇存柊搴撲綅鏄庣粏 - saveLocItem(taskItems, task.getId()); + saveLocItem(taskItems, task.getId(), loginUserId); } catch (Exception e) { throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒"); } @@ -936,10 +963,11 @@ List<TaskItem> items = orderMap.get(key); try { //淇濆瓨搴撳瓨鏄庣粏 - saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType()); + saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType(), loginUserId); //绉诲嚭鏀惰揣鍖哄簱瀛橈紝 淇敼缁勬墭鐘舵�� - removeReceiptStock(pakinItem); + removeReceiptStock(pakinItem, loginUserId); } catch (Exception e) { + logger.error("<UNK>", e); throw new CoolException(e.getMessage()); } }); @@ -954,13 +982,14 @@ /** * @param + * @param loginUserId * @return * @author Ryan * @description 绉婚櫎鏀惰揣鍖哄簱瀛� * @time 2025/4/30 16:32 */ @Transactional(rollbackFor = Exception.class) - public void removeReceiptStock(WaitPakinItem pakinItem) { + public void removeReceiptStock(WaitPakinItem pakinItem, Long loginUserId) { WarehouseAreasItem itemServiceOne = warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>() .eq(WarehouseAreasItem::getId, pakinItem.getSource())); if (Objects.isNull(itemServiceOne)) { @@ -972,6 +1001,7 @@ if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>() .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val) + .set(WaitPakin::getUpdateBy, loginUserId) .eq(WaitPakin::getId, pakinItem.getPakinId()))) { throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�"); } @@ -981,6 +1011,7 @@ throw new CoolException("鏀惰揣鍖虹墿鏂欏垹闄ゅけ璐ワ紒锛�"); } } else { + itemServiceOne.setUpdateBy(loginUserId).setUpdateTime(null); if (!warehouseAreasItemService.updateById(itemServiceOne)) { throw new CoolException("鏀惰揣鍖哄簱瀹屾垚鏁伴噺淇敼澶辫触锛侊紒"); } @@ -989,13 +1020,14 @@ /** * @param + * @param loginUserId * @return * @author Ryan * @description 鏇存柊搴撲綅鏄庣粏 * @time 2025/4/15 15:28 */ @Transactional(rollbackFor = Exception.class) - public void saveLocItem(List<TaskItem> items, Long taskId) throws Exception { + public void saveLocItem(List<TaskItem> items, Long taskId, Long loginUserId) throws Exception { Task task = this.getById(taskId); if (Objects.isNull(task)) { throw new CoolException("浠诲姟涓嶅瓨鍦�!!"); @@ -1008,6 +1040,7 @@ BeanUtils.copyProperties(taskItem, item); item.setLocCode(loc.getCode()).setId(null) .setLocId(loc.getId()) + .setUpdateBy(loginUserId) .setWkType(taskItem.getWkType()) .setType(taskItem.getOrderType()); locItems.add(item); @@ -1021,10 +1054,11 @@ * 鐢熸垚鍏ュ簱搴撳瓨鏄庣粏 * * @param items + * @param loginUserId * @return */ @Transactional(rollbackFor = Exception.class) - public void saveStockItems(List<TaskItem> items, Task task, Long id, String code, Short wkType, String type) throws + public void saveStockItems(List<TaskItem> items, Task task, Long id, String code, Short wkType, String type, Long loginUserId) throws Exception { Stock stock = new Stock(); String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null); @@ -1038,6 +1072,7 @@ .setAnfme(sum) .setWkType(wkType) .setBarcode(task.getBarcode()) + .setUpdateBy(loginUserId) .setType(type); if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type) || @@ -1061,6 +1096,7 @@ .setStockCode(stock.getCode()) .setBarcode(task.getBarcode()) .setSourceItemId(item.getOrderItemId()) + .setUpdateBy(loginUserId) .setId(null) .setStockId(stock.getId()); stockItems.add(stockItem); diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java index faa792f..988d27a 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/WaitPakinServiceImpl.java @@ -63,7 +63,7 @@ if (StringUtils.isBlank(waitPakin.getBarcode())) { throw new CoolException("鍙傛暟閿欒锛氭墭鐩樼爜涓虹┖锛侊紒"); } - List<Short> asList = Arrays.asList(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val), Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)); +// List<Short> asList = Arrays.asList(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val), Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)); WaitPakin pakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>() .eq(WaitPakin::getBarcode, waitPakin.getBarcode())); if (!Objects.isNull(pakin)) { diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/system/utils/SystemAuthUtils.java b/rsf-server/src/main/java/com/vincent/rsf/server/system/utils/SystemAuthUtils.java new file mode 100644 index 0000000..322bd24 --- /dev/null +++ b/rsf-server/src/main/java/com/vincent/rsf/server/system/utils/SystemAuthUtils.java @@ -0,0 +1,75 @@ +package com.vincent.rsf.server.system.utils; + +import com.vincent.rsf.common.enums.SystemModeType; +import com.vincent.rsf.framework.common.R; +import com.vincent.rsf.framework.common.SpringUtils; +import com.vincent.rsf.server.common.config.ConfigProperties; +import com.vincent.rsf.server.common.domain.BusinessRes; +import com.vincent.rsf.server.common.security.JwtSubject; +import com.vincent.rsf.server.common.utils.JwtUtil; +import com.vincent.rsf.server.system.entity.Tenant; +import com.vincent.rsf.server.system.entity.User; +import com.vincent.rsf.server.system.entity.UserLogin; +import com.vincent.rsf.server.system.service.TenantService; +import com.vincent.rsf.server.system.service.UserLoginService; +import com.vincent.rsf.server.system.service.UserService; +import org.checkerframework.checker.units.qual.C; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.PostMapping; + +import javax.annotation.PostConstruct; +import java.util.Objects; + +@Component +public class SystemAuthUtils { + + public static Logger logger = LoggerFactory.getLogger(SystemAuthUtils.class); + + private static String username; + + private static String password; + + private static String tokenKey; + + private static Long tokenExpireTime; + + private static SystemModeType systemMode; + + @Autowired + private ConfigProperties configProperties; + + @PostConstruct + public void init() { + username = configProperties.getUserName(); + password = configProperties.getPassword(); + } + + public static User getLoginUser() { + try { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication != null) { + Object object = authentication.getPrincipal(); + if (object instanceof User) { + return (User) object; + } + } else { + UserService userService = SpringUtils.getBean(UserService.class); + return userService.getByUsername(username, null); + } + } catch (Exception e) { + logger.error("<UNK>", e); + } + return null; + } + + public static Long getLoginUserId() { + User loginUser = getLoginUser(); + return loginUser == null ? null : loginUser.getId(); + } + +} diff --git a/rsf-server/src/main/resources/application.yml b/rsf-server/src/main/resources/application.yml index 547ae36..db51329 100644 --- a/rsf-server/src/main/resources/application.yml +++ b/rsf-server/src/main/resources/application.yml @@ -11,6 +11,8 @@ code-length: 6 code-time: 300 security-code: 951123 + username: super + password: 123456 eureka: client: @@ -37,6 +39,7 @@ super: pwd: xltys1995 + logging: file: path: logs/@pom.artifactId@ -- Gitblit v1.9.1