|  | @ -5,10 +5,12 @@ import com.yihu.iot.dao.device.IotDeviceDao;
 | 
	
		
			
				|  |  | import com.yihu.iot.dao.device.IotDeviceOrderDao;
 | 
	
		
			
				|  |  | import com.yihu.iot.dao.device.IotDeviceQualityInspectionPlanDao;
 | 
	
		
			
				|  |  | import com.yihu.iot.dao.device.IotOrderPurchaseDao;
 | 
	
		
			
				|  |  | import com.yihu.iot.dao.dict.IotSystemDictDao;
 | 
	
		
			
				|  |  | import com.yihu.iot.dao.message.IotMessageDao;
 | 
	
		
			
				|  |  | import com.yihu.iot.service.dict.IotSystemDictService;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.iot.device.IotDeviceQualityInspectionPlanDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.iot.device.IotOrderPurchaseDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.iot.message.IotMessageDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.iot.device.IotDeviceQualityInspectionPlanVO;
 | 
	
	
		
			
				|  | @ -48,6 +50,9 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private IotDeviceDao iotDeviceDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private IotSystemDictDao iotSystemDictDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 新增
 | 
	
		
			
				|  |  |      * @param iotDeviceQualityInspectionPlan
 | 
	
	
		
			
				|  | @ -56,7 +61,10 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public IotDeviceQualityInspectionPlanDO create(IotDeviceQualityInspectionPlanDO iotDeviceQualityInspectionPlan) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findById(iotDeviceQualityInspectionPlan.getPurchaseId());
 | 
	
		
			
				|  |  |         IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findByOrderNo(iotDeviceQualityInspectionPlan.getOrderNo());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         iotDeviceQualityInspectionPlan.setPurchaseId(purchaseDO.getId());
 | 
	
		
			
				|  |  |         iotDeviceQualityInspectionPlan.setDeviceId(purchaseDO.getProductId());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         iotDeviceQualityInspectionPlan.setOrderNo(purchaseDO.getOrderNo());
 | 
	
		
			
				|  |  |         iotDeviceQualityInspectionPlan.setDeviceId(purchaseDO.getProductId());
 | 
	
	
		
			
				|  | @ -225,23 +233,23 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
 | 
	
		
			
				|  |  |      * 分页查找
 | 
	
		
			
				|  |  |      * @param page
 | 
	
		
			
				|  |  |      * @param size
 | 
	
		
			
				|  |  |      * @param purcharseId
 | 
	
		
			
				|  |  |      * @param status
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> queryPage(String purcharseId, String orderNo, String startTime, String endTime, Integer page, Integer size){
 | 
	
		
			
				|  |  |     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 ");
 | 
	
		
			
				|  |  |         List<Object> args = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(purcharseId)){
 | 
	
		
			
				|  |  |             sql.append(" and c.purchase_id=? ");
 | 
	
		
			
				|  |  |             sqlCount.append(" and c.purchase_id='").append(purcharseId).append("' ");
 | 
	
		
			
				|  |  |             args.add(purcharseId);
 | 
	
		
			
				|  |  |         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=? ");
 | 
	
		
			
				|  |  |             sqlCount.append(" and c.order_no='").append(orderNo).append("' ");
 | 
	
		
			
				|  |  |             args.add(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>=? ");
 | 
	
	
		
			
				|  | @ -271,16 +279,10 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void remindTimePlan(String time) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         int remindTime = Integer.valueOf(time);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<IotDeviceQualityInspectionPlanDO> list = iotDeviceQualityInspectionPlanDao.findListAll();
 | 
	
		
			
				|  |  |         list.forEach(one->{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Date remind = DateUtil.getPreDays(one.getPlanTime(), -remindTime);
 | 
	
		
			
				|  |  |             one.setRemindTime(remind);
 | 
	
		
			
				|  |  |             iotDeviceQualityInspectionPlanDao.save(one);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |         IotSystemDictDO qualityRemind= iotSystemDictDao.findByDictName("DEVICE_QUALITY_REMIND").get(0);
 | 
	
		
			
				|  |  |         qualityRemind.setTime(time);
 | 
	
		
			
				|  |  |         qualityRemind.setDel(1);
 | 
	
		
			
				|  |  |         iotSystemDictDao.save(qualityRemind);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |