QiuYuMiao преди 1 година
родител
ревизия
5339e55326

+ 12 - 4
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/cbgl/controller/ZnbZlLogController.java

@@ -2,18 +2,19 @@ package com.tofly.feesapi.cbgl.controller;
 
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.tofly.common.core.entity.ResultRespone;
+import com.tofly.feesapi.cbgl.entity.dto.ZnbFkFilter;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbZlLogFilter;
 import com.tofly.feesapi.cbgl.entity.vo.ZnbZlLogSelect;
 import com.tofly.feesapi.cbgl.service.IZnbZlLogService;
 import com.tofly.feesapi.common.entity.dto.PageDto;
 import com.tofly.feesapi.common.entity.vo.PageResult;
+import com.tofly.feesapi.security.model.CzyUserDetails;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
 
 /**
  * <p>
@@ -39,6 +40,13 @@ public class ZnbZlLogController {
         return ResultRespone.success(znbZlLogService.getPage(pageDto, filter));
     }
 
+    @ApiOperationSupport(order=2)
+    @ApiOperation(value = "智能表阀控")
+    @PostMapping
+    public  ResultRespone<Boolean> ZnbFk(@ModelAttribute ZnbFkFilter filter, @ApiIgnore @AuthenticationPrincipal CzyUserDetails czyUserDetails){
+        boolean result = znbZlLogService.ZnbFk(filter,czyUserDetails);
+        return result ? ResultRespone.success(true, "指令下发成功") : ResultRespone.failed(false, "指令下发失败");
+    }
 //    @ApiOperationSupport(order = 2)
 //    @GetMapping("/export")
 //    @ApiOperation(value = "导出智能表指令明细")

+ 17 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/cbgl/entity/dto/ZnbFkFilter.java

@@ -0,0 +1,17 @@
+package com.tofly.feesapi.cbgl.entity.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@ApiModel("用户阀控指令dto")
+public class ZnbFkFilter {
+
+    @ApiModelProperty(value = "指令(操作)类型编码 0-关阀 1-开阀",required = true)
+    private String zltype;
+    @ApiModelProperty(value = "操作用户编号",  required = true)
+    private List<String> yhbhs;
+}

+ 4 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/cbgl/service/IZnbZlLogService.java

@@ -3,10 +3,12 @@ package com.tofly.feesapi.cbgl.service;
 import com.tofly.feesapi.cbgl.entity.ZnbZlLog;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbCbLogFilter;
+import com.tofly.feesapi.cbgl.entity.dto.ZnbFkFilter;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbZlLogFilter;
 import com.tofly.feesapi.cbgl.entity.vo.ZnbZlLogSelect;
 import com.tofly.feesapi.common.entity.dto.PageDto;
 import com.tofly.feesapi.common.entity.vo.PageResult;
+import com.tofly.feesapi.security.model.CzyUserDetails;
 
 import java.util.List;
 
@@ -23,4 +25,6 @@ public interface IZnbZlLogService extends IService<ZnbZlLog> {
     PageResult<ZnbZlLogSelect> getPage(PageDto pageDto, ZnbZlLogFilter filter);
 
     List<ZnbZlLogSelect> getList(ZnbCbLogFilter filter);
+
+   boolean ZnbFk(ZnbFkFilter filter, CzyUserDetails czyUserDetails);
 }

+ 66 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/cbgl/service/impl/ZnbZlLogServiceImpl.java

@@ -1,7 +1,10 @@
 package com.tofly.feesapi.cbgl.service.impl;
 
+import com.tofly.feesapi.bjgl.entity.YhCbkxx;
+import com.tofly.feesapi.bjgl.service.YhCbkxxService;
 import com.tofly.feesapi.cbgl.entity.ZnbZlLog;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbCbLogFilter;
+import com.tofly.feesapi.cbgl.entity.dto.ZnbFkFilter;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbZlLogFilter;
 import com.tofly.feesapi.cbgl.entity.vo.ZnbZlLogSelect;
 import com.tofly.feesapi.cbgl.mapper.ZnbZlLogMapper;
@@ -9,9 +12,21 @@ import com.tofly.feesapi.cbgl.service.IZnbZlLogService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.tofly.feesapi.common.entity.dto.PageDto;
 import com.tofly.feesapi.common.entity.vo.PageResult;
+import com.tofly.feesapi.common.exception.FeesErrorCode;
+import com.tofly.feesapi.common.exception.FeesException;
+import com.tofly.feesapi.security.model.CzyUserDetails;
+import com.tofly.feesapi.yhgl.entity.YhKhjbxx;
+import com.tofly.feesapi.yhgl.service.YhKhjbxxService;
+import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
+import org.apache.commons.math3.analysis.function.Log;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.support.TransactionTemplate;
 
+import java.time.LocalDateTime;
 import java.util.List;
+import  java.util.UUID;
 
 /**
  * <p>
@@ -23,7 +38,14 @@ import java.util.List;
  */
 @Service
 public class ZnbZlLogServiceImpl extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> implements IZnbZlLogService {
+    @Autowired
+    private YhKhjbxxService khjbxxService;
 
+    @Autowired
+    private YhCbkxxService cbkxxService;
+
+    @Autowired
+    private TransactionTemplate transactionTemplate;
     @Override
     public PageResult<ZnbZlLogSelect> getPage(PageDto pageDto, ZnbZlLogFilter filter) {
         PageDto<ZnbZlLogSelect> page = this.baseMapper.getPage(pageDto, filter);
@@ -34,4 +56,48 @@ public class ZnbZlLogServiceImpl extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> i
     public List<ZnbZlLogSelect> getList(ZnbCbLogFilter filter) {
         return this.baseMapper.getList(filter);
     }
+
+    @Override
+    public boolean ZnbFk(ZnbFkFilter filter, CzyUserDetails czyUserDetails) {
+        List<String> yhbhs=filter.getYhbhs();
+
+        if(yhbhs.size()==0){throw new FeesException("未查询到相关操作用户",FeesErrorCode.BUSINESS_ERROR );}
+           List<YhKhjbxx> yhList=khjbxxService.lambdaQuery().in(YhKhjbxx::getYhbh,yhbhs).list();
+        if(yhList.isEmpty()){throw new FeesException("未查询到可操作的用户", FeesErrorCode.BUSINESS_ERROR);}
+
+        return fk(yhList,filter.getZltype(),czyUserDetails.getId())==1;
+    }
+
+    private int fk(List<YhKhjbxx> yhList, String zltype,Long czry) {
+        int rlt=transactionTemplate.execute(status->{
+            try{
+                String pch=UUID.randomUUID().toString();
+                for(YhKhjbxx khjbxx:yhList){
+                    List<YhCbkxx> cbkList=cbkxxService.lambdaQuery().in(YhCbkxx::getYhbh,khjbxx.getYhbh()).list();
+                    for(YhCbkxx cbk:cbkList){
+                        ZnbZlLog log=new ZnbZlLog();
+                      log.setYhbh(cbk.getYhbh());
+                      log.setCbkh(cbk.getCbkh());
+                      log.setCbkid(cbk.getCbkid());
+                      log.setPch(pch);
+                      log.setSccj(cbk.getSbsccj());
+                      log.setSsgs(khjbxx.getSsgs());
+                      log.setCzry(czry.toString());
+                      log.setCzsj(LocalDateTime.now());
+                      log.setClLock("0");
+                      log.setClCljg("0");
+                      log.setZltype("fk");
+                      log.setZlvalue(zltype);
+                      this.save(log);
+                    }
+                }
+                return 1;
+            }catch (Exception e) {
+                status.setRollbackOnly();
+                throw e;
+            }
+        });
+        return rlt;
+    }
+
 }