|
@@ -24,6 +24,7 @@ import com.fjhx.service.check.CheckInfoService;
|
|
|
import com.fjhx.service.check.CheckTagService;
|
|
|
import com.fjhx.service.stock.StockService;
|
|
|
import com.fjhx.service.water.WaterTagService;
|
|
|
+import com.fjhx.utils.UserClientUtil;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.utils.ThreadUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -66,15 +67,17 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
@Override
|
|
|
public synchronized void automaticCheck() {
|
|
|
|
|
|
+ // 发起标签扫描
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.put("instructions", "test");
|
|
|
data.put("type", 2);
|
|
|
data.put("flag", "automaticCheck");
|
|
|
-
|
|
|
WebSocketServer.sendInfo(WebSocketConstant.WEB_STOCK_PROGRAM, WebSocketConstant.OPERATING_UPPER_COMPUTER, data);
|
|
|
|
|
|
+ // 扫描10分钟
|
|
|
ThreadUtil.sleep(1000 * 60 * 10);
|
|
|
|
|
|
+ // 关闭扫描标签
|
|
|
data.clear();
|
|
|
data.put("type", 9);
|
|
|
WebSocketServer.sendInfo(WebSocketConstant.WEB_STOCK_PROGRAM, WebSocketConstant.OPERATING_UPPER_COMPUTER, data);
|
|
@@ -82,6 +85,7 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
// 获取在库标签
|
|
|
List<WaterTag> list = getInHouseWaterTag();
|
|
|
|
|
|
+ // 获取扫描到的去重标签
|
|
|
List<String> rfidList = RFID_LIST.stream().distinct().collect(Collectors.toList());
|
|
|
RFID_LIST.clear();
|
|
|
|
|
@@ -102,11 +106,13 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
public Page<Map<String, Object>> getPage(Condition condition) {
|
|
|
String keyword = condition.getKeyword();
|
|
|
Integer status = condition.getStatus();
|
|
|
+ Integer type = condition.getType();
|
|
|
|
|
|
QueryWrapper<Object> wrapper = Wrappers.query();
|
|
|
wrapper.and(ObjectUtil.isNotEmpty(keyword),
|
|
|
q -> q.like("m.name", keyword).or().like("m.code", keyword))
|
|
|
- .eq(ObjectUtil.isNotEmpty(status), "cd.complete_check", status);
|
|
|
+ .eq(ObjectUtil.isNotEmpty(status), "cd.complete_check", status)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(type), "ci.type", type);
|
|
|
|
|
|
return baseMapper.getPage(condition.getPage(), wrapper);
|
|
|
}
|
|
@@ -122,7 +128,7 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
List<CheckTag> checkTagList = checkDetailVo.getCheckTagList();
|
|
|
checkTagService.saveBatch(checkTagList);
|
|
|
|
|
|
- // 检测是否完成全部质检
|
|
|
+ // 检测是否完成全部盘点
|
|
|
synchronized (this) {
|
|
|
Long count = checkDetailService.count(q -> q
|
|
|
.eq(CheckDetail::getCheckId, checkDetailVo.getCheckId())
|
|
@@ -130,33 +136,201 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
|
|
|
// 盘点完成
|
|
|
if (count == 0) {
|
|
|
-
|
|
|
- Long errorCount = checkDetailService.count(q -> q
|
|
|
- .eq(CheckDetail::getCheckId, checkDetailVo.getCheckId())
|
|
|
- .eq(CheckDetail::getCheckResult, StatusConstant.NO));
|
|
|
-
|
|
|
update(q -> q
|
|
|
.eq(StorageBaseEntity::getId, checkDetailVo.getCheckId())
|
|
|
.set(CheckInfo::getStatus, 2)
|
|
|
- .set(CheckInfo::getPeopleCheckResult, errorCount == 0 ? 1 : 0)
|
|
|
+ .set(checkDetailVo.getCheckResult() == 0, CheckInfo::getPeopleCheckResult, 0)
|
|
|
.set(CheckInfo::getOperUserId, AuthUtil.getUserId())
|
|
|
.set(CheckInfo::getEndTime, new Date())
|
|
|
.set(StorageBaseEntity::getUpdateTime, new Date())
|
|
|
.set(StorageBaseEntity::getUpdateUser, AuthUtil.getUserId())
|
|
|
);
|
|
|
-
|
|
|
} else {
|
|
|
update(q -> q
|
|
|
.eq(StorageBaseEntity::getId, checkDetailVo.getCheckId())
|
|
|
.set(CheckInfo::getStatus, 1)
|
|
|
+ .set(checkDetailVo.getCheckResult() == 0, CheckInfo::getPeopleCheckResult, 0)
|
|
|
+ .set(CheckInfo::getOperUserId, AuthUtil.getUserId())
|
|
|
.set(StorageBaseEntity::getUpdateTime, new Date())
|
|
|
.set(StorageBaseEntity::getUpdateUser, AuthUtil.getUserId())
|
|
|
);
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> monthlyStatistics(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
|
|
|
- }
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query().between("ci.create_time", beginTime, endTime);
|
|
|
+
|
|
|
+ return baseMapper.monthlyStatistics(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long getCount(Condition condition) {
|
|
|
+ return count(q -> q.between(StorageBaseEntity::getCreateTime, condition.getBeginTime(), condition.getEndTime()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> houseCount(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+ Integer type = condition.getType();
|
|
|
+ Integer peopleCheckResult = condition.getInt("peopleCheckResult");
|
|
|
+
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query()
|
|
|
+ .between("ci.create_time", beginTime, endTime)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(type), "ci.type", type)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(peopleCheckResult), "ci.people_check_result", peopleCheckResult)
|
|
|
+ .groupBy("ci.stock_house_id");
|
|
|
+
|
|
|
+ return baseMapper.houseCount(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> typeCount(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+ Long houseId = condition.getLong("houseId");
|
|
|
+ Integer peopleCheckResult = condition.getInt("peopleCheckResult");
|
|
|
+
|
|
|
+ return getMap(Wrappers.<CheckInfo>query()
|
|
|
+ .select(
|
|
|
+ "ifnull(sum(if(type = 1, 1, 0)), 0) automaticCheckCount",
|
|
|
+ "ifnull(sum(if(type = 2, 1, 0)), 0) userCheckCount"
|
|
|
+ )
|
|
|
+ .lambda()
|
|
|
+ .between(StorageBaseEntity::getCreateTime, beginTime, endTime)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(peopleCheckResult), CheckInfo::getPeopleCheckResult, peopleCheckResult)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(houseId), CheckInfo::getStockHouseId, houseId)
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> peopleCheckResultCount(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+ Long houseId = condition.getLong("houseId");
|
|
|
+ Integer type = condition.getType();
|
|
|
+
|
|
|
+ return getMap(Wrappers.<CheckInfo>query()
|
|
|
+ .select(
|
|
|
+ "ifnull(sum(if(people_check_result = 1, 1, 0)), 0) normalCount",
|
|
|
+ "ifnull(sum(if(people_check_result = 0, 1, 0)), 0) errorCount"
|
|
|
+ )
|
|
|
+ .lambda()
|
|
|
+ .between(StorageBaseEntity::getCreateTime, beginTime, endTime)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(type), CheckInfo::getType, type)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(houseId), CheckInfo::getStockHouseId, houseId)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Map<String, Object>> webPage(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+ Integer type = condition.getType();
|
|
|
+ Integer peopleCheckResult = condition.getInt("peopleCheckResult");
|
|
|
+ Long houseId = condition.getLong("houseId");
|
|
|
+
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query()
|
|
|
+ .between("ci.create_time", beginTime, endTime)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(type), "ci.type", type)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(peopleCheckResult), "ci.people_check_result", peopleCheckResult)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(houseId), "ci.stock_house_id", houseId);
|
|
|
+
|
|
|
+ Page<Map<String, Object>> page = baseMapper.webPage(condition.getPage(), wrapper);
|
|
|
+ UserClientUtil.setUserName(page.getRecords(), "operUserId", "operUserName");
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> userCount(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = listMaps(Wrappers.<CheckInfo>query()
|
|
|
+ .select(
|
|
|
+ "oper_user_id",
|
|
|
+ "count(0) count"
|
|
|
+ )
|
|
|
+ .lambda()
|
|
|
+ .isNotNull(CheckInfo::getOperUserId)
|
|
|
+ .between(StorageBaseEntity::getCreateTime, beginTime, endTime)
|
|
|
+ .groupBy(CheckInfo::getOperUserId)
|
|
|
+ );
|
|
|
+ UserClientUtil.setUserName(list, "operUserId", "operUserName");
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> errorTagTechnologyTypeCount(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query()
|
|
|
+ .between("ci.create_time", beginTime, endTime)
|
|
|
+ .ne("ct.tag_status", 0)
|
|
|
+ .groupBy("m.technology_type")
|
|
|
+ .orderByAsc("m.technology_type");
|
|
|
+
|
|
|
+ return baseMapper.errorTagTechnologyTypeCount(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> errorTagPurposeCount(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+ Integer technologyType = condition.getInt("technologyType");
|
|
|
+
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query()
|
|
|
+ .between("ci.create_time", beginTime, endTime)
|
|
|
+ .ne("ct.tag_status", 0)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(technologyType), "m.technology_type", technologyType)
|
|
|
+ .groupBy("m.purpose");
|
|
|
+
|
|
|
+ return baseMapper.errorTagPurposeCount(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> errorTagHandleTypeCount(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+ Integer technologyType = condition.getInt("technologyType");
|
|
|
+ String purpose = condition.getStr("purpose");
|
|
|
+
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query()
|
|
|
+ .between("ci.create_time", beginTime, endTime)
|
|
|
+ .ne("ct.tag_status", 0)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(technologyType), "m.technology_type", technologyType)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(purpose), "m.purpose", purpose)
|
|
|
+ .groupBy("ct.handle_type");
|
|
|
+
|
|
|
+ return baseMapper.errorTagHandleTypeCount(wrapper);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Map<String, Object>> errorTagPage(Condition condition) {
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+ Integer technologyType = condition.getInt("technologyType");
|
|
|
+ String purpose = condition.getStr("purpose");
|
|
|
+ Integer handleType = condition.getInt("handleType");
|
|
|
+
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query()
|
|
|
+ .between("ci.create_time", beginTime, endTime)
|
|
|
+ .ne("ct.tag_status", 0)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(technologyType), "m.technology_type", technologyType)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(purpose), "m.purpose", purpose)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(handleType), "ct.handle_type", handleType);
|
|
|
+
|
|
|
+ Page<Map<String, Object>> page = baseMapper.errorTagPage(condition.getPage(), wrapper);
|
|
|
+
|
|
|
+ UserClientUtil.setUserName(page.getRecords(), "operUserId", "operUserName");
|
|
|
+ return page;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -189,7 +363,7 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
|
|
|
// 不在库存,但扫描到rfid
|
|
|
errorMaterialIdList.addAll(
|
|
|
- waterTagService.list(Wrappers.<WaterTag>lambdaQuery()
|
|
|
+ waterTagService.list(q -> q
|
|
|
.select(WaterTag::getMaterialId)
|
|
|
.in(WaterTag::getRfidCode, rfidList)
|
|
|
.eq(WaterTag::getUseStatus, StatusConstant.YES))
|
|
@@ -207,6 +381,7 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
checkInfo.setCheckResult(errorMaterialId.size() == 0 ? 1 : 0);
|
|
|
checkInfo.setType(1);
|
|
|
checkInfo.setStatus(0);
|
|
|
+ checkInfo.setPeopleCheckResult(1);
|
|
|
checkInfo.setStockHouseId(HouseConstant.GROUND_FLOOR_ID);
|
|
|
checkInfo.setBeginTime(new Date());
|
|
|
save(checkInfo);
|