|  | @ -16,7 +16,9 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.iot.device.IotDeviceQualityInspectionPlanVO;
 | 
	
		
			
				|  |  | import com.yihu.jw.rm.iot.IotRequestMapping;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import com.yihu.utils.network.HttpUtils;
 | 
	
		
			
				|  |  | import org.apache.commons.lang.StringUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.BeanPropertyRowMapper;
 | 
	
	
		
			
				|  | @ -53,6 +55,8 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private IotSystemDictDao iotSystemDictDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private final static String jobUrl = "http://localhost:10031/job/reStartById?taskId=data_device_quality_plan_job";
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 新增
 | 
	
		
			
				|  |  |      * @param iotDeviceQualityInspectionPlan
 | 
	
	
		
			
				|  | @ -237,35 +241,28 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> queryPage(String status, String orderNo, String startTime, String endTime, Integer page, Integer size){
 | 
	
		
			
				|  |  |         StringBuffer sql = new StringBuffer("SELECT c.* from iot_device_quality_inspection_plan c  WHERE c.del=1 ");
 | 
	
		
			
				|  |  |         StringBuffer sqlCount = new StringBuffer("SELECT COUNT(c.id) count from iot_device_quality_inspection_plan c WHERE c.del=1 ");
 | 
	
		
			
				|  |  |         StringBuffer sql = new StringBuffer("SELECT  c.* from iot_device_quality_inspection_plan c  WHERE c.del=1 ");
 | 
	
		
			
				|  |  |         List<Object> args = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(status)){
 | 
	
		
			
				|  |  |             sql.append(" and c.status=? ");
 | 
	
		
			
				|  |  |             sqlCount.append(" and c.status='").append(status).append("' ");
 | 
	
		
			
				|  |  |             args.add(status);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(orderNo)){
 | 
	
		
			
				|  |  |             sql.append("and c.order_no like'%").append(orderNo).append("%' ");
 | 
	
		
			
				|  |  |             sqlCount.append(" and c.order_no like'%").append(orderNo).append("%' ");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(startTime)){
 | 
	
		
			
				|  |  |             sql.append(" and c.plan_time>=? ");
 | 
	
		
			
				|  |  |             sqlCount.append(" and c.plan_time>='").append(startTime).append("' ");
 | 
	
		
			
				|  |  |             args.add(startTime);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(endTime)){
 | 
	
		
			
				|  |  |             sql.append(" and c.plan_time<=? ");
 | 
	
		
			
				|  |  |             sqlCount.append(" and c.plan_time<='").append(endTime).append("' ");
 | 
	
		
			
				|  |  |             args.add(endTime);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql.append(" GROUP BY c.order_no ORDER BY c.plan_time DESC limit ").append((page-1)*size).append(",").append(size);
 | 
	
		
			
				|  |  |         List<IotDeviceQualityInspectionPlanDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceQualityInspectionPlanDO.class));
 | 
	
		
			
				|  |  |         List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
 | 
	
		
			
				|  |  |         long count = Long.valueOf(countList.get(0).get("count").toString());
 | 
	
		
			
				|  |  |         long count = list.size();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //DO转VO
 | 
	
		
			
				|  |  |         List<IotDeviceQualityInspectionPlanVO> qualityInspectionPlanVOList = transforList(list);
 | 
	
	
		
			
				|  | @ -279,10 +276,47 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void remindTimePlan(String time) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         IotSystemDictDO qualityRemind= iotSystemDictDao.findByDictName("DEVICE_QUALITY_REMIND").get(0);
 | 
	
		
			
				|  |  |         qualityRemind.setTime(time);
 | 
	
		
			
				|  |  |         qualityRemind.setDel(1);
 | 
	
		
			
				|  |  |         iotSystemDictDao.save(qualityRemind);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询所有需要提醒的质检信息
 | 
	
		
			
				|  |  |      * @param time
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<IotDeviceQualityInspectionPlanDO>  findListAll(String time){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         StringBuffer sql = new StringBuffer("SELECT c.* FROM  iot_device_quality_inspection_plan c WHERE del=1");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Object> args = new ArrayList<>();
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(time)){
 | 
	
		
			
				|  |  |             sql.append("  and DATEDIFF(c.plan_time,CURRENT_TIMESTAMP)=?");
 | 
	
		
			
				|  |  |             args.add(time);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<IotDeviceQualityInspectionPlanDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceQualityInspectionPlanDO.class));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据订单编号查找所有计划时间
 | 
	
		
			
				|  |  |      * @param orderNo
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO>  findPlanTimeByOrderNo(String orderNo,Integer page,Integer size) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<IotDeviceQualityInspectionPlanDO> listOrderNo = iotDeviceQualityInspectionPlanDao.findByOrderNo(orderNo);
 | 
	
		
			
				|  |  |         List<IotDeviceQualityInspectionPlanVO> list = transforList(listOrderNo);
 | 
	
		
			
				|  |  |         long count = list.size();
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find_functions,list,page,size,count);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |