|
@@ -28,6 +28,7 @@ import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
|
|
|
import com.github.zuihou.utils.DateUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
@@ -53,6 +54,8 @@ public class OpsAppApi {
|
|
|
private MaterialService materialService;
|
|
|
@Autowired
|
|
|
private DoorRecordService doorRecordService;
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -67,7 +70,7 @@ public class OpsAppApi {
|
|
|
IPage<ProductionResource> page = params.buildPage();
|
|
|
LbqWrapper<ProductionResource> queryWrap = Wraps.lbQ();
|
|
|
ProductionResource productionResource = BeanUtil.toBean(params.getModel(), ProductionResource.class);
|
|
|
- queryWrap.eq(ProductionResource::getStatus,"1").orderByDesc(ProductionResource::getCreateTime);
|
|
|
+ queryWrap.eq(ProductionResource::getStatus, "1").orderByDesc(ProductionResource::getCreateTime);
|
|
|
IPage<ProductionResource> list = productionTenantResourceService.pageList(page, queryWrap);
|
|
|
return R.success(list);
|
|
|
}
|
|
@@ -83,7 +86,7 @@ public class OpsAppApi {
|
|
|
LbqWrapper<ProductionResource> queryWrap = Wraps.lbQ();
|
|
|
queryWrap.like(ProductionResource::getName, name).orderByDesc(ProductionResource::getCreateTime);
|
|
|
List<Long> orgIds = CommonUtil.getOrgIdsArr();
|
|
|
- if(orgIds.size()>0){
|
|
|
+ if (orgIds.size() > 0) {
|
|
|
queryWrap.in(ProductionResource::getOrgId, orgIds);
|
|
|
}
|
|
|
List<ProductionResource> list = productionTenantResourceService.list(queryWrap);
|
|
@@ -104,9 +107,9 @@ public class OpsAppApi {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
LbqWrapper<ProductionResource> queryWrap = Wraps.lbQ();
|
|
|
queryWrap.eq(ProductionResource::getId, equId);
|
|
|
- Page<ProductionResource> page = new Page<>(1L,1);
|
|
|
+ Page<ProductionResource> page = new Page<>(1L, 1);
|
|
|
IPage<ProductionResource> productionResourceList = productionTenantResourceService.pageList(page, queryWrap);
|
|
|
- return R.success(productionResourceList.getRecords().size()>0? productionResourceList.getRecords().get(0) : ProductionResource.builder().build());
|
|
|
+ return R.success(productionResourceList.getRecords().size() > 0 ? productionResourceList.getRecords().get(0) : ProductionResource.builder().build());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -121,22 +124,22 @@ public class OpsAppApi {
|
|
|
IPage<Order> page = params.buildPage();
|
|
|
QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
|
|
|
Order order = BeanUtil.toBean(params.getModel(), Order.class);
|
|
|
- if(params.getMap().containsKey("createTime_st")){
|
|
|
+ if (params.getMap().containsKey("createTime_st")) {
|
|
|
LocalDateTime startTime = DateUtils.getStartTime(params.getMap().get("createTime_st").toString());
|
|
|
orderQueryWrap.geHeader("create_time", startTime);
|
|
|
}
|
|
|
- if(params.getMap().containsKey("createTime_ed")){
|
|
|
+ if (params.getMap().containsKey("createTime_ed")) {
|
|
|
LocalDateTime endTime = DateUtils.getEndTime(params.getMap().get("createTime_ed").toString());
|
|
|
orderQueryWrap.leFooter("create_time", endTime);
|
|
|
}
|
|
|
- orderQueryWrap.eq(StringUtils.isNotEmpty(order.getOrderStatus()),"order_status",order.getOrderStatus()).eq("order_equ_id", order.getOrderEquId()).orderByDesc("create_time");
|
|
|
+ orderQueryWrap.eq(StringUtils.isNotEmpty(order.getOrderStatus()), "order_status", order.getOrderStatus()).eq("order_equ_id", order.getOrderEquId()).orderByDesc("create_time");
|
|
|
IPage<Order> list = orderService.pageList(page, orderQueryWrap);
|
|
|
|
|
|
orderQueryWrap.select("ifnull(sum(order_amount), 0.0) as orderSum");
|
|
|
Order sumOrder = orderService.getOne(orderQueryWrap);
|
|
|
- if(list.getRecords().size()>0){
|
|
|
+ if (list.getRecords().size() > 0) {
|
|
|
list.getRecords().add(0, sumOrder);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
list.setRecords(new ArrayList<Order>(Arrays.asList(sumOrder)));
|
|
|
}
|
|
|
return R.success(list);
|
|
@@ -153,9 +156,9 @@ public class OpsAppApi {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
QueryWrap<Order> queryWrap = new QueryWrap<>();
|
|
|
queryWrap.eq("id", id);
|
|
|
- Page<Order> page = new Page<Order>(1L,1);
|
|
|
+ Page<Order> page = new Page<Order>(1L, 1);
|
|
|
IPage<Order> orderList = orderService.pageList(page, queryWrap);
|
|
|
- return R.success(orderList.getRecords().size()>0? orderList.getRecords().get(0) : Order.builder().build());
|
|
|
+ return R.success(orderList.getRecords().size() > 0 ? orderList.getRecords().get(0) : Order.builder().build());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -168,14 +171,14 @@ public class OpsAppApi {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
QueryWrap<EquBarrel> equBarrelQueryWrap = new QueryWrap<>();
|
|
|
equBarrelQueryWrap.eq("equ_id", equId);
|
|
|
- if(StringUtils.isNotEmpty(barrelType)){
|
|
|
+ if (StringUtils.isNotEmpty(barrelType)) {
|
|
|
//equBarrelQueryWrap.in("barrel_type", new String[]{"4","5"});
|
|
|
equBarrelQueryWrap.gt("barrel_type", 3);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//equBarrelQueryWrap.in("barrel_type", new String[]{"1","2", "3"});
|
|
|
equBarrelQueryWrap.le("barrel_type", 3);
|
|
|
}
|
|
|
- Page<EquBarrel> page = new Page<>(1L,10);
|
|
|
+ Page<EquBarrel> page = new Page<>(1L, 10);
|
|
|
IPage<EquBarrel> list = equBarrelService.pageList(page, equBarrelQueryWrap);
|
|
|
return R.success(list);
|
|
|
}
|
|
@@ -187,14 +190,14 @@ public class OpsAppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/recordList")
|
|
|
- public R<IPage<EquRecord>> recordList(@RequestBody PageParams<EquRecord> params){
|
|
|
+ public R<IPage<EquRecord>> recordList(@RequestBody PageParams<EquRecord> params) {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
IPage<EquRecord> page = params.buildPage();
|
|
|
LbqWrapper<EquRecord> recordQueryWrap = Wraps.lbQ();
|
|
|
EquRecord equRecord = BeanUtil.toBean(params.getModel(), EquRecord.class);
|
|
|
- if(StringUtil.isNotEmpty(equRecord.getBarrelType())){
|
|
|
+ if (StringUtil.isNotEmpty(equRecord.getBarrelType())) {
|
|
|
recordQueryWrap.gt(EquRecord::getBarrelType, "3");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
recordQueryWrap.le(EquRecord::getBarrelType, "3");
|
|
|
}
|
|
|
recordQueryWrap.eq(EquRecord::getEquId, equRecord.getEquId()).orderByDesc(EquRecord::getCreateTime);
|
|
@@ -204,7 +207,7 @@ public class OpsAppApi {
|
|
|
|
|
|
|
|
|
@GetMapping("/equMaterialList")
|
|
|
- public R<List<Material>> equMaterialList(@RequestParam("mtType") String mtType){
|
|
|
+ public R<List<Material>> equMaterialList(@RequestParam("mtType") String mtType) {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
LbqWrapper<Material> materialQueryWrap = Wraps.lbQ();
|
|
|
materialQueryWrap.eq(Material::getMtType, mtType);
|
|
@@ -217,27 +220,26 @@ public class OpsAppApi {
|
|
|
|
|
|
/**
|
|
|
* 订单统计数据
|
|
|
- *
|
|
|
*/
|
|
|
@GetMapping("/orderStatistics")
|
|
|
public R<Map> statisticsList(@RequestParam("equId") Long equId) {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
QueryWrap<Order> orderStatisticWrap = new QueryWrap<>();
|
|
|
- if(equId!=null && equId.longValue()!=0) {
|
|
|
+ if (equId != null && equId.longValue() != 0) {
|
|
|
orderStatisticWrap.eq("id", equId).orderByDesc("create_time");
|
|
|
}
|
|
|
- Map<String, String> paramsMap = new HashMap<String,String>();
|
|
|
+ Map<String, String> paramsMap = new HashMap<String, String>();
|
|
|
String now = DateUtil.dateToString(new Date());
|
|
|
- String sevenAgo = DateUtil.dateToString(DateUtil.getBeforeDate(new Date(), 7));
|
|
|
- String nextDay = DateUtil.dateToString(DateUtil.getAddSecondsTime(new Date(), 60*60*24*1000));
|
|
|
+ String sevenAgo = DateUtil.dateToString(DateUtil.getBeforeDate(new Date(), 7));
|
|
|
+ String nextDay = DateUtil.dateToString(DateUtil.getAddSecondsTime(new Date(), 60 * 60 * 24 * 1000));
|
|
|
paramsMap.put("now", now);
|
|
|
paramsMap.put("sevenAgo", sevenAgo);
|
|
|
paramsMap.put("nextDay", nextDay);
|
|
|
- if(equId!=null && equId.longValue()!=0) {
|
|
|
+ if (equId != null && equId.longValue() != 0) {
|
|
|
paramsMap.put("id", equId.toString());
|
|
|
}
|
|
|
String orgIds = CommonUtil.getOrgIdsStr();
|
|
|
- if(StringUtils.isNotEmpty(orgIds)) {
|
|
|
+ if (StringUtils.isNotEmpty(orgIds)) {
|
|
|
paramsMap.put("orgIds", orgIds);
|
|
|
}
|
|
|
Map map = orderService.getStatisticMap(paramsMap);
|
|
@@ -245,6 +247,7 @@ public class OpsAppApi {
|
|
|
}
|
|
|
|
|
|
//
|
|
|
+
|
|
|
/**
|
|
|
* 换料接口
|
|
|
*
|
|
@@ -257,7 +260,7 @@ public class OpsAppApi {
|
|
|
updateWrapper.set(EquBarrel::getMtrId, equRecord.getReplaceMaterial()).set(EquBarrel::getMtrName, equRecord.getMtName()).set(EquBarrel::getMtrResidue, equRecord.getSpecs())
|
|
|
.set(StringUtil.isNotEmpty(equRecord.getDate()), EquBarrel::getExprTime, DateUtils.getStartTime(equRecord.getDate())).eq(EquBarrel::getId, equRecord.getMaterialId());
|
|
|
Boolean bool = equBarrelService.update(null, updateWrapper);
|
|
|
- if(bool){
|
|
|
+ if (bool) {
|
|
|
bool = equRecordService.save(equRecord);
|
|
|
}
|
|
|
return R.success(bool);
|
|
@@ -276,7 +279,7 @@ public class OpsAppApi {
|
|
|
updateWrapper.set(EquBarrel::getMtrResidue, equRecord.getSpecs()).set(EquBarrel::getExprTime, equRecord.getDate())
|
|
|
.eq(EquBarrel::getId, equRecord.getMaterialId());
|
|
|
Boolean bool = equBarrelService.update(null, updateWrapper);
|
|
|
- if(bool){
|
|
|
+ if (bool) {
|
|
|
bool = equRecordService.save(equRecord);
|
|
|
}
|
|
|
return R.success(bool);
|
|
@@ -284,7 +287,7 @@ public class OpsAppApi {
|
|
|
|
|
|
|
|
|
@PostMapping("/doorRecordList")
|
|
|
- public R<IPage<DoorRecord>> equDoorList(@RequestBody PageParams<DoorRecord> params){
|
|
|
+ public R<IPage<DoorRecord>> equDoorList(@RequestBody PageParams<DoorRecord> params) {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
IPage<DoorRecord> page = params.buildPage();
|
|
|
LbqWrapper<DoorRecord> doorQueryWrap = Wraps.lbQ();
|
|
@@ -296,11 +299,29 @@ public class OpsAppApi {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @GetMapping("/getEquRunInfo")
|
|
|
+ public R<Map<String, String>> getEquRunInfo(@RequestParam(name = "equId" ,required = true) String equId) {
|
|
|
+ BaseContextHandler.setTenant("0000");
|
|
|
+ HashMap<String, String> resultMap = new HashMap<>();
|
|
|
+ Boolean exist = redisTemplate.hasKey("equStatus" + equId);
|
|
|
+ if (exist) {
|
|
|
+ String status = (String) redisTemplate.opsForHash().get("equStatus" + equId, "status");
|
|
|
+ if (status.equals("2")) {
|
|
|
+ String errMsg = (String) redisTemplate.opsForHash().get("equStatus" + equId, "errMsg");
|
|
|
+
|
|
|
+ resultMap.put("errMsg", errMsg);
|
|
|
+ }
|
|
|
+ resultMap.put("equStatus", status);
|
|
|
+ } else {
|
|
|
+ resultMap.put("equStatus", "0");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ return R.success(resultMap);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
-// 操作记录接口
|
|
|
|
|
|
|
|
|
}
|