瀏覽代碼

设备管理经销商修改

lyhzzz 2 年之前
父節點
當前提交
f015198156

+ 1 - 0
src/main/java/com/fdkankan/manage/common/ResultCode.java

@@ -57,6 +57,7 @@ public enum ResultCode  {
     INCREMENT_TYPE_EMPTY(50040, "权益类型不存在!"),
     AGENT_NEW_EMPTY(50041, "代理商不存在!"),
     SS_NO_COPY(50042, "深时场景暂不支持复制!"),
+    AGENT_NOT_EMPTY(50043, "经销商名称已存在!"),
 
     ;
 

+ 10 - 0
src/main/java/com/fdkankan/manage/controller/AgentNewController.java

@@ -68,6 +68,10 @@ public class AgentNewController {
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         userService.checkUserName(param.getUserName());
+        AgentNew agentNew = agentNewService.getByName(param.getName().trim());
+        if(agentNew != null){
+            throw new BusinessException(ResultCode.AGENT_NOT_EMPTY);
+        }
         param.setSysUserId(Integer.valueOf((String)StpUtil.getLoginId()));
         agentNewService.save(param);
         return ResultData.ok();
@@ -77,6 +81,12 @@ public class AgentNewController {
         if(param.getId() == null || StringUtils.isBlank(param.getName())){
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
+        if(StringUtils.isNotBlank(param.getName())){
+            AgentNew agentNew = agentNewService.getByName(param.getName().trim());
+            if(agentNew != null && !agentNew.getId().equals(param.getId())){
+                throw new BusinessException(ResultCode.AGENT_NOT_EMPTY);
+            }
+        }
         LambdaUpdateWrapper<AgentNew> wrapper = new LambdaUpdateWrapper<>();
         wrapper.eq(AgentNew::getId,param.getId());
         wrapper.set(AgentNew::getName,param.getName());

+ 3 - 0
src/main/java/com/fdkankan/manage/entity/CameraDetail.java

@@ -147,5 +147,8 @@ public class CameraDetail implements Serializable {
     @TableField("last_request_time")
     private String lastRequestTime;
 
+    @TableField("agent_id")
+    private Integer agentId;
+
 
 }

+ 2 - 0
src/main/java/com/fdkankan/manage/service/IAgentNewService.java

@@ -27,4 +27,6 @@ public interface IAgentNewService extends IService<AgentNew> {
     Object logList(AgentNewLogParam param);
 
     void export(HttpServletRequest req, HttpServletResponse resp);
+
+    AgentNew getByName(String agentName);
 }

+ 11 - 0
src/main/java/com/fdkankan/manage/service/impl/AgentNewServiceImpl.java

@@ -104,6 +104,17 @@ public class AgentNewServiceImpl extends ServiceImpl<IAgentNewMapper, AgentNew>
     }
 
     @Override
+    public AgentNew getByName(String agentName) {
+        LambdaQueryWrapper<AgentNew> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(AgentNew::getName, agentName);
+        List<AgentNew> list = this.list(wrapper);
+        if(list == null || list.size() != 1) {
+            return null;
+        }
+        return list.get(0);
+    }
+
+    @Override
     public Object logList(AgentNewLogParam param) {
         CacheUtil.agentParam = param;
         return agentNewLogService.getVoList(param);

+ 3 - 0
src/main/java/com/fdkankan/manage/service/impl/CameraServiceImpl.java

@@ -293,6 +293,9 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
             if(cameraDetail == null){
                 throw new BusinessException(ResultCode.CAMERA_NOT_IN);
             }
+            if(param.getAgentId() != null){
+                cameraDetail.setAgentId(param.getAgentId());
+            }
             cameraDetail.setOrderSn(param.getOrderSn());
             cameraDetail.setOwn(param.getOutType());
             cameraDetail.setCompanyId(param.getCompanyId());

+ 13 - 0
src/main/java/com/fdkankan/manage/service/impl/ExcelServiceImpl.java

@@ -5,9 +5,11 @@ import com.alibaba.excel.ExcelWriter;
 import com.alibaba.excel.write.metadata.WriteSheet;
 import com.fdkankan.manage.common.ExcelErrorUtil;
 import com.fdkankan.manage.common.ResultCode;
+import com.fdkankan.manage.entity.AgentNew;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.constant.CameraOutTypeEnum;
 import com.fdkankan.manage.entity.Company;
+import com.fdkankan.manage.service.IAgentNewService;
 import com.fdkankan.manage.service.ICameraService;
 import com.fdkankan.manage.service.ICompanyService;
 import com.fdkankan.manage.service.IExcelService;
@@ -41,6 +43,8 @@ public class ExcelServiceImpl implements IExcelService {
     ICompanyService companyService;
     @Autowired
     ICameraService cameraService;
+    @Autowired
+    IAgentNewService agentNewService;
 
     public void commonExport(HttpServletRequest request, HttpServletResponse response,String name,List<?> result,ExcelWriter excelWriter) throws Exception {
         response.setContentType("application/vnd.ms-excel");
@@ -116,6 +120,7 @@ public class ExcelServiceImpl implements IExcelService {
                 String outTypeString = map.get(1);
                 String companyName = map.get(2);
                 String orderSn = map.get(3);
+                String agentName = map.get(2);
                 CameraOutTypeEnum outTypeEnum = CameraOutTypeEnum.getByMsg(outTypeString);
                 if(outTypeEnum == null || StringUtils.isBlank(snCode)){
                     errorIndex.add(index -3);
@@ -125,6 +130,14 @@ public class ExcelServiceImpl implements IExcelService {
                     int outType = outTypeEnum.getCode();
                     param.setOutType(outType);
                 }
+                if(StringUtils.isNotBlank(agentName)){
+                    AgentNew agentNew = agentNewService.getByName(agentName);
+                    if(agentNew == null){
+                        errorIndex.add(index -3);
+                    }else {
+                        param.setAgentId(agentNew.getId());
+                    }
+                }
                 param.setCompanyName(companyName);
                 param.setOrderSn(orderSn);
                 param.setSnCode(snCode);

+ 2 - 0
src/main/java/com/fdkankan/manage/vo/request/CameraInOutParam.java

@@ -11,4 +11,6 @@ public class CameraInOutParam {
     private String orderSn;         //订单号
     private String snCode;
     private String companyName;     //客户名
+
+    private Integer agentId;
 }

+ 2 - 0
src/main/java/com/fdkankan/manage/vo/request/CameraParam.java

@@ -21,6 +21,8 @@ public class CameraParam extends RequestBase {
     private String activatedStartTime;          //激活时间
     private String activatedEndTime;            //激活时间
 
+    private Integer agentId;
+
 
 
     public String getActivatedStartTime() {

+ 3 - 0
src/main/java/com/fdkankan/manage/vo/response/CameraDetailVo.java

@@ -19,5 +19,8 @@ public class CameraDetailVo {
 
     private String orderSn;
 
+    private Integer agentId;
+    private String agentName;
+
 
 }

+ 4 - 0
src/main/resources/mapper/manage/CameraMapper.xml

@@ -9,6 +9,7 @@
         left join t_camera_detail d on c.id = d.camera_id
         left join t_company co on d.company_id = co.id
         left join t_user u on d.user_id = u.id
+        left join t_agent_new an on d.agent_id = an.id
         where c.rec_status = 'A'
         <if test="param.userId !=null ">
             and d.user_id = #{param.userId}
@@ -37,6 +38,9 @@
         <if test="param.activatedEndTime !=null and param.activatedEndTime != '' ">
             and c.activated_time &lt;= #{param.activatedEndTime}
         </if>
+        <if test="param.agentId !=null  ">
+            and d.agent_id = #{param.agentId}
+        </if>
         order by c.activated_time desc
     </select>
     <select id="getByOutSnCodes" resultType="com.fdkankan.manage.entity.Camera">

二進制
src/main/resources/template/cameraOut.xlsx